@@ -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, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ")) $j++; |
|
| 12 | + foreach ($output as $line) { |
|
| 13 | + if(strpos($line, dirname(__FILE__)."/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($globalVA) || !$globalVA) && (!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($globalVA) || !$globalVA) && (!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($globalVA) || !$globalVA) && (!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(); |
@@ -45,8 +51,11 @@ discard block |
||
| 45 | 51 | if (isset($globalGeoid) && $globalGeoid && $update_db->check_last_geoid_update()) { |
| 46 | 52 | echo "Check if new geoid version exist..."; |
| 47 | 53 | $error = $update_db->update_geoid_fam(); |
| 48 | - if ($error == '') $update_db->insert_last_geoid_update(); |
|
| 49 | - else echo $error; |
|
| 54 | + if ($error == '') { |
|
| 55 | + $update_db->insert_last_geoid_update(); |
|
| 56 | + } else { |
|
| 57 | + echo $error; |
|
| 58 | + } |
|
| 50 | 59 | } |
| 51 | 60 | if (isset($globalMarine) && $globalMarine && $update_db->check_last_marine_identity_update()) { |
| 52 | 61 | echo "Check if new marine identity version exist..."; |
@@ -64,7 +73,9 @@ discard block |
||
| 64 | 73 | //echo "Done"; |
| 65 | 74 | } |
| 66 | 75 | $update_db->insert_last_owner_update(); |
| 67 | - } elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n"; |
|
| 76 | + } elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
| 77 | + echo "Owner are only updated every 15 days.\n"; |
|
| 78 | + } |
|
| 68 | 79 | |
| 69 | 80 | if (isset($globalAccidents) && $globalAccidents && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
| 70 | 81 | require_once(dirname(__FILE__).'/../require/class.Accident.php'); |
@@ -73,7 +84,9 @@ discard block |
||
| 73 | 84 | if ($Accident->check_last_accidents_update()) { |
| 74 | 85 | $Accident->download_update(); |
| 75 | 86 | $Accident->insert_last_accidents_update(); |
| 76 | - } else echo "Accidents are updated once a day.\n"; |
|
| 87 | + } else { |
|
| 88 | + echo "Accidents are updated once a day.\n"; |
|
| 89 | + } |
|
| 77 | 90 | } |
| 78 | 91 | |
| 79 | 92 | } |
@@ -86,15 +99,19 @@ discard block |
||
| 86 | 99 | if ($METAR->check_last_update()) { |
| 87 | 100 | $METAR->addMETARCycle(); |
| 88 | 101 | $METAR->insert_last_update(); |
| 89 | - } else echo "METAR are only updated every 30 minutes.\n"; |
|
| 90 | -} |
|
| 102 | + } else { |
|
| 103 | + echo "METAR are only updated every 30 minutes.\n"; |
|
| 104 | + } |
|
| 105 | + } |
|
| 91 | 106 | |
| 92 | 107 | if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
| 93 | 108 | echo "Updating schedules..."; |
| 94 | 109 | //$update_db->update_oneworld(); |
| 95 | 110 | $update_db->update_skyteam(); |
| 96 | 111 | $update_db->insert_last_schedules_update(); |
| 97 | -} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n"; |
|
| 112 | +} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
| 113 | + echo "Schedules are only updated every 15 days.\n"; |
|
| 114 | +} |
|
| 98 | 115 | |
| 99 | 116 | if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) { |
| 100 | 117 | echo "Updating statistics and archive old data..."; |
@@ -22,11 +22,15 @@ discard block |
||
| 22 | 22 | require_once('require/class.Spotter.php'); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if (!isset($filter_name)) $filter_name = ''; |
|
| 25 | +if (!isset($filter_name)) { |
|
| 26 | + $filter_name = ''; |
|
| 27 | +} |
|
| 26 | 28 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 27 | 29 | if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) { |
| 28 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 29 | -} |
|
| 30 | + if (isset($globalFilter['airline'])) { |
|
| 31 | + $airline_icao = $globalFilter['airline'][0]; |
|
| 32 | + } |
|
| 33 | + } |
|
| 30 | 34 | if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') { |
| 31 | 35 | $Spotter = new Spotter(); |
| 32 | 36 | $airline_info = $Spotter->getAllAirlineInfo($airline_icao); |
@@ -61,7 +65,12 @@ discard block |
||
| 61 | 65 | <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script> |
| 62 | 66 | <div class="column"> |
| 63 | 67 | <div class="info"> |
| 64 | - <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1> |
|
| 68 | + <h1><?php if (isset($airline_name)) { |
|
| 69 | + echo _("Statistics for ").$airline_name; |
|
| 70 | +} else { |
|
| 71 | + echo _("Statistics"); |
|
| 72 | +} |
|
| 73 | +?></h1> |
|
| 65 | 74 | <?php |
| 66 | 75 | if ($type == 'aircraft') { |
| 67 | 76 | $last_update = $Stats->getLastStatsUpdate(); |
@@ -69,7 +78,9 @@ discard block |
||
| 69 | 78 | if (isset($last_update[0]['value'])) { |
| 70 | 79 | date_default_timezone_set('UTC'); |
| 71 | 80 | $lastupdate = strtotime($last_update[0]['value']); |
| 72 | - if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone); |
|
| 81 | + if (isset($globalTimezone) && $globalTimezone != '') { |
|
| 82 | + date_default_timezone_set($globalTimezone); |
|
| 83 | + } |
|
| 73 | 84 | print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>'; |
| 74 | 85 | } |
| 75 | 86 | } |
@@ -154,8 +165,11 @@ discard block |
||
| 154 | 165 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
| 155 | 166 | $aircraft_data = ''; |
| 156 | 167 | foreach($aircraft_array as $aircraft_item) { |
| 157 | - if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
| 158 | - else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
| 168 | + if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') { |
|
| 169 | + $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
| 170 | + } else { |
|
| 171 | + $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
|
| 172 | + } |
|
| 159 | 173 | } |
| 160 | 174 | $aircraft_data = substr($aircraft_data, 0, -1); |
| 161 | 175 | print 'var series = ['.$aircraft_data.'];'; |
@@ -172,11 +186,17 @@ discard block |
||
| 172 | 186 | <?php |
| 173 | 187 | if ($year != '' && $month != '') { |
| 174 | 188 | ?> |
| 175 | - <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 189 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 190 | + echo '/'.$airline_icao; |
|
| 191 | +} |
|
| 192 | +?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 176 | 193 | <?php |
| 177 | 194 | } else { |
| 178 | 195 | ?> |
| 179 | - <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 196 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 197 | + echo '/'.$airline_icao; |
|
| 198 | +} |
|
| 199 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 180 | 200 | <?php |
| 181 | 201 | } |
| 182 | 202 | ?> |
@@ -205,11 +225,15 @@ discard block |
||
| 205 | 225 | print '</script>'; |
| 206 | 226 | if ($year != '' && $month != '') { |
| 207 | 227 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
| 208 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
| 228 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 229 | + echo '/'.$airline_icao; |
|
| 230 | + } |
|
| 209 | 231 | print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
| 210 | 232 | } else { |
| 211 | 233 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
| 212 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
| 234 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 235 | + echo '/'.$airline_icao; |
|
| 236 | + } |
|
| 213 | 237 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
| 214 | 238 | } |
| 215 | 239 | print '</div>'; |
@@ -229,8 +253,9 @@ discard block |
||
| 229 | 253 | <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2> |
| 230 | 254 | <?php |
| 231 | 255 | $marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month); |
| 232 | - if (count($marine_array) == 0) print _("No data available"); |
|
| 233 | - else { |
|
| 256 | + if (count($marine_array) == 0) { |
|
| 257 | + print _("No data available"); |
|
| 258 | + } else { |
|
| 234 | 259 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
| 235 | 260 | $marine_data = ''; |
| 236 | 261 | foreach($marine_array as $marine_item) { |
@@ -274,8 +299,9 @@ discard block |
||
| 274 | 299 | <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2> |
| 275 | 300 | <?php |
| 276 | 301 | $tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month); |
| 277 | - if (count($tracker_array) == 0) print _("No data available"); |
|
| 278 | - else { |
|
| 302 | + if (count($tracker_array) == 0) { |
|
| 303 | + print _("No data available"); |
|
| 304 | + } else { |
|
| 279 | 305 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
| 280 | 306 | $tracker_data = ''; |
| 281 | 307 | foreach($tracker_array as $tracker_item) { |
@@ -319,8 +345,9 @@ discard block |
||
| 319 | 345 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
| 320 | 346 | <?php |
| 321 | 347 | $owner_array = $Satellite->countAllOwners(true); |
| 322 | - if (count($owner_array) == 0) print _("No data available"); |
|
| 323 | - else { |
|
| 348 | + if (count($owner_array) == 0) { |
|
| 349 | + print _("No data available"); |
|
| 350 | + } else { |
|
| 324 | 351 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
| 325 | 352 | $owner_data = ''; |
| 326 | 353 | foreach($owner_array as $owner_item) { |
@@ -339,7 +366,10 @@ discard block |
||
| 339 | 366 | ?> |
| 340 | 367 | <!-- |
| 341 | 368 | <div class="more"> |
| 342 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 369 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 370 | + echo '/'.$airline_icao; |
|
| 371 | +} |
|
| 372 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 343 | 373 | </div> |
| 344 | 374 | --> |
| 345 | 375 | </div> |
@@ -348,8 +378,9 @@ discard block |
||
| 348 | 378 | <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2> |
| 349 | 379 | <?php |
| 350 | 380 | $countries_array = $Satellite->countAllCountriesOwners(true); |
| 351 | - if (count($countries_array) == 0) print _("No data available"); |
|
| 352 | - else { |
|
| 381 | + if (count($countries_array) == 0) { |
|
| 382 | + print _("No data available"); |
|
| 383 | + } else { |
|
| 353 | 384 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
| 354 | 385 | $owner_data = ''; |
| 355 | 386 | foreach($countries_array as $owner_item) { |
@@ -368,7 +399,10 @@ discard block |
||
| 368 | 399 | ?> |
| 369 | 400 | <!-- |
| 370 | 401 | <div class="more"> |
| 371 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 402 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 403 | + echo '/'.$airline_icao; |
|
| 404 | +} |
|
| 405 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 372 | 406 | </div> |
| 373 | 407 | --> |
| 374 | 408 | </div> |
@@ -380,8 +414,9 @@ discard block |
||
| 380 | 414 | <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2> |
| 381 | 415 | <?php |
| 382 | 416 | $launch_site_array = $Satellite->countAllLaunchSite(true); |
| 383 | - if (count($launch_site_array) == 0) print _("No data available"); |
|
| 384 | - else { |
|
| 417 | + if (count($launch_site_array) == 0) { |
|
| 418 | + print _("No data available"); |
|
| 419 | + } else { |
|
| 385 | 420 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
| 386 | 421 | $launch_site_data = ''; |
| 387 | 422 | foreach($launch_site_array as $launch_site_item) { |
@@ -400,7 +435,10 @@ discard block |
||
| 400 | 435 | ?> |
| 401 | 436 | <!-- |
| 402 | 437 | <div class="more"> |
| 403 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 438 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 439 | + echo '/'.$airline_icao; |
|
| 440 | +} |
|
| 441 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 404 | 442 | </div> |
| 405 | 443 | --> |
| 406 | 444 | </div> |
@@ -423,8 +461,9 @@ discard block |
||
| 423 | 461 | <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2> |
| 424 | 462 | <?php |
| 425 | 463 | $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month); |
| 426 | - if (count($pilot_array) == 0) print _("No data available"); |
|
| 427 | - else { |
|
| 464 | + if (count($pilot_array) == 0) { |
|
| 465 | + print _("No data available"); |
|
| 466 | + } else { |
|
| 428 | 467 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
| 429 | 468 | $pilot_data = ''; |
| 430 | 469 | foreach($pilot_array as $pilot_item) { |
@@ -442,7 +481,9 @@ discard block |
||
| 442 | 481 | } |
| 443 | 482 | print '<div class="more">'; |
| 444 | 483 | print '<a href="'.$globalURL.'/statistics/pilot'; |
| 445 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
| 484 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 485 | + echo '/'.$airline_icao; |
|
| 486 | + } |
|
| 446 | 487 | print'" class="btn btn-default btn" role="button">'._("See full statistic").'»</a>'; |
| 447 | 488 | print '</div>'; |
| 448 | 489 | ?> |
@@ -458,8 +499,9 @@ discard block |
||
| 458 | 499 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
| 459 | 500 | <?php |
| 460 | 501 | $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month); |
| 461 | - if (count($owner_array) == 0) print _("No data available"); |
|
| 462 | - else { |
|
| 502 | + if (count($owner_array) == 0) { |
|
| 503 | + print _("No data available"); |
|
| 504 | + } else { |
|
| 463 | 505 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
| 464 | 506 | $owner_data = ''; |
| 465 | 507 | foreach($owner_array as $owner_item) { |
@@ -477,7 +519,10 @@ discard block |
||
| 477 | 519 | } |
| 478 | 520 | ?> |
| 479 | 521 | <div class="more"> |
| 480 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 522 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 523 | + echo '/'.$airline_icao; |
|
| 524 | +} |
|
| 525 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 481 | 526 | </div> |
| 482 | 527 | </div> |
| 483 | 528 | |
@@ -490,8 +535,9 @@ discard block |
||
| 490 | 535 | <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2> |
| 491 | 536 | <?php |
| 492 | 537 | //$flightover_array = $Stats->countAllFlightOverCountries(); |
| 493 | - if (count($flightover_array) == 0) print _("No data available"); |
|
| 494 | - else { |
|
| 538 | + if (count($flightover_array) == 0) { |
|
| 539 | + print _("No data available"); |
|
| 540 | + } else { |
|
| 495 | 541 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
| 496 | 542 | print 'var series = ['; |
| 497 | 543 | $flightover_data = ''; |
@@ -533,7 +579,10 @@ discard block |
||
| 533 | 579 | } |
| 534 | 580 | ?> |
| 535 | 581 | <div class="more"> |
| 536 | - <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 582 | + <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 583 | + echo '/'.$airline_icao; |
|
| 584 | +} |
|
| 585 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 537 | 586 | </div> |
| 538 | 587 | </div> |
| 539 | 588 | <?php |
@@ -551,8 +600,9 @@ discard block |
||
| 551 | 600 | <div class="col-md-6"> |
| 552 | 601 | <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2> |
| 553 | 602 | <?php |
| 554 | - if (count($flightover_array) == 0) print _("No data available"); |
|
| 555 | - else { |
|
| 603 | + if (count($flightover_array) == 0) { |
|
| 604 | + print _("No data available"); |
|
| 605 | + } else { |
|
| 556 | 606 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
| 557 | 607 | print 'var series = ['; |
| 558 | 608 | $flightover_data = ''; |
@@ -608,8 +658,9 @@ discard block |
||
| 608 | 658 | <div class="col-md-6"> |
| 609 | 659 | <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2> |
| 610 | 660 | <?php |
| 611 | - if (count($flightover_array) == 0) print _("No data available"); |
|
| 612 | - else { |
|
| 661 | + if (count($flightover_array) == 0) { |
|
| 662 | + print _("No data available"); |
|
| 663 | + } else { |
|
| 613 | 664 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
| 614 | 665 | print 'var series = ['; |
| 615 | 666 | $flightover_data = ''; |
@@ -715,7 +766,9 @@ discard block |
||
| 715 | 766 | });"; |
| 716 | 767 | print '</script>'; |
| 717 | 768 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; |
| 718 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
| 769 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 770 | + echo '/'.$airline_icao; |
|
| 771 | + } |
|
| 719 | 772 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
| 720 | 773 | } |
| 721 | 774 | ?> |
@@ -777,7 +830,9 @@ discard block |
||
| 777 | 830 | });"; |
| 778 | 831 | print '</script>'; |
| 779 | 832 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival'; |
| 780 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
| 833 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 834 | + echo '/'.$airline_icao; |
|
| 835 | + } |
|
| 781 | 836 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
| 782 | 837 | } |
| 783 | 838 | ?> |
@@ -796,8 +851,9 @@ discard block |
||
| 796 | 851 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
| 797 | 852 | <?php |
| 798 | 853 | $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
| 799 | - if (count($year_array) == 0) print _("No data available"); |
|
| 800 | - else { |
|
| 854 | + if (count($year_array) == 0) { |
|
| 855 | + print _("No data available"); |
|
| 856 | + } else { |
|
| 801 | 857 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
| 802 | 858 | $year_data = ''; |
| 803 | 859 | $year_cnt = ''; |
@@ -816,7 +872,10 @@ discard block |
||
| 816 | 872 | } |
| 817 | 873 | ?> |
| 818 | 874 | <div class="more"> |
| 819 | - <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 875 | + <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 876 | + echo '/'.$airline_icao; |
|
| 877 | +} |
|
| 878 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 820 | 879 | </div> |
| 821 | 880 | </div> |
| 822 | 881 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -824,8 +883,9 @@ discard block |
||
| 824 | 883 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
| 825 | 884 | <?php |
| 826 | 885 | $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
| 827 | - if (count($month_array) == 0) print _("No data available"); |
|
| 828 | - else { |
|
| 886 | + if (count($month_array) == 0) { |
|
| 887 | + print _("No data available"); |
|
| 888 | + } else { |
|
| 829 | 889 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
| 830 | 890 | $month_data = ''; |
| 831 | 891 | $month_cnt = ''; |
@@ -844,7 +904,10 @@ discard block |
||
| 844 | 904 | } |
| 845 | 905 | ?> |
| 846 | 906 | <div class="more"> |
| 847 | - <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 907 | + <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 908 | + echo '/'.$airline_icao; |
|
| 909 | +} |
|
| 910 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 848 | 911 | </div> |
| 849 | 912 | </div> |
| 850 | 913 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -853,8 +916,9 @@ discard block |
||
| 853 | 916 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
| 854 | 917 | <?php |
| 855 | 918 | $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
| 856 | - if (empty($date_array)) print _("No data available"); |
|
| 857 | - else { |
|
| 919 | + if (empty($date_array)) { |
|
| 920 | + print _("No data available"); |
|
| 921 | + } else { |
|
| 858 | 922 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
| 859 | 923 | $date_data = ''; |
| 860 | 924 | $date_cnt = ''; |
@@ -873,7 +937,10 @@ discard block |
||
| 873 | 937 | } |
| 874 | 938 | ?> |
| 875 | 939 | <div class="more"> |
| 876 | - <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 940 | + <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 941 | + echo '/'.$airline_icao; |
|
| 942 | +} |
|
| 943 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 877 | 944 | </div> |
| 878 | 945 | </div> |
| 879 | 946 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -881,8 +948,9 @@ discard block |
||
| 881 | 948 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
| 882 | 949 | <?php |
| 883 | 950 | $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
| 884 | - if (empty($hour_array)) print _("No data available"); |
|
| 885 | - else { |
|
| 951 | + if (empty($hour_array)) { |
|
| 952 | + print _("No data available"); |
|
| 953 | + } else { |
|
| 886 | 954 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
| 887 | 955 | $hour_data = ''; |
| 888 | 956 | $hour_cnt = ''; |
@@ -901,7 +969,10 @@ discard block |
||
| 901 | 969 | } |
| 902 | 970 | ?> |
| 903 | 971 | <div class="more"> |
| 904 | - <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 972 | + <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
| 973 | + echo '/'.$airline_icao; |
|
| 974 | +} |
|
| 975 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
| 905 | 976 | </div> |
| 906 | 977 | </div> |
| 907 | 978 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -921,8 +992,9 @@ discard block |
||
| 921 | 992 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
| 922 | 993 | <?php |
| 923 | 994 | $year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
| 924 | - if (count($year_array) == 0) print _("No data available"); |
|
| 925 | - else { |
|
| 995 | + if (count($year_array) == 0) { |
|
| 996 | + print _("No data available"); |
|
| 997 | + } else { |
|
| 926 | 998 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
| 927 | 999 | $year_data = ''; |
| 928 | 1000 | $year_cnt = ''; |
@@ -950,8 +1022,9 @@ discard block |
||
| 950 | 1022 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
| 951 | 1023 | <?php |
| 952 | 1024 | $month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name); |
| 953 | - if (count($month_array) == 0) print _("No data available"); |
|
| 954 | - else { |
|
| 1025 | + if (count($month_array) == 0) { |
|
| 1026 | + print _("No data available"); |
|
| 1027 | + } else { |
|
| 955 | 1028 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
| 956 | 1029 | $month_data = ''; |
| 957 | 1030 | $month_cnt = ''; |
@@ -979,8 +1052,9 @@ discard block |
||
| 979 | 1052 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
| 980 | 1053 | <?php |
| 981 | 1054 | $date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name); |
| 982 | - if (empty($date_array)) print _("No data available"); |
|
| 983 | - else { |
|
| 1055 | + if (empty($date_array)) { |
|
| 1056 | + print _("No data available"); |
|
| 1057 | + } else { |
|
| 984 | 1058 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
| 985 | 1059 | $date_data = ''; |
| 986 | 1060 | $date_cnt = ''; |
@@ -1007,8 +1081,9 @@ discard block |
||
| 1007 | 1081 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
| 1008 | 1082 | <?php |
| 1009 | 1083 | $hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name); |
| 1010 | - if (empty($hour_array)) print _("No data available"); |
|
| 1011 | - else { |
|
| 1084 | + if (empty($hour_array)) { |
|
| 1085 | + print _("No data available"); |
|
| 1086 | + } else { |
|
| 1012 | 1087 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
| 1013 | 1088 | $hour_data = ''; |
| 1014 | 1089 | $hour_cnt = ''; |
@@ -1047,8 +1122,9 @@ discard block |
||
| 1047 | 1122 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
| 1048 | 1123 | <?php |
| 1049 | 1124 | $year_array = $Tracker->countAllMonthsLastYear(true); |
| 1050 | - if (count($year_array) == 0) print _("No data available"); |
|
| 1051 | - else { |
|
| 1125 | + if (count($year_array) == 0) { |
|
| 1126 | + print _("No data available"); |
|
| 1127 | + } else { |
|
| 1052 | 1128 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
| 1053 | 1129 | $year_data = ''; |
| 1054 | 1130 | $year_cnt = ''; |
@@ -1076,8 +1152,9 @@ discard block |
||
| 1076 | 1152 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
| 1077 | 1153 | <?php |
| 1078 | 1154 | $month_array = $Tracker->countAllDatesLastMonth(); |
| 1079 | - if (count($month_array) == 0) print _("No data available"); |
|
| 1080 | - else { |
|
| 1155 | + if (count($month_array) == 0) { |
|
| 1156 | + print _("No data available"); |
|
| 1157 | + } else { |
|
| 1081 | 1158 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
| 1082 | 1159 | $month_data = ''; |
| 1083 | 1160 | $month_cnt = ''; |
@@ -1105,8 +1182,9 @@ discard block |
||
| 1105 | 1182 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
| 1106 | 1183 | <?php |
| 1107 | 1184 | $date_array = $Tracker->countAllDatesLast7Days(); |
| 1108 | - if (empty($date_array)) print _("No data available"); |
|
| 1109 | - else { |
|
| 1185 | + if (empty($date_array)) { |
|
| 1186 | + print _("No data available"); |
|
| 1187 | + } else { |
|
| 1110 | 1188 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
| 1111 | 1189 | $date_data = ''; |
| 1112 | 1190 | $date_cnt = ''; |
@@ -1133,8 +1211,9 @@ discard block |
||
| 1133 | 1211 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
| 1134 | 1212 | <?php |
| 1135 | 1213 | $hour_array = $Tracker->countAllHours('hour',true); |
| 1136 | - if (empty($hour_array)) print _("No data available"); |
|
| 1137 | - else { |
|
| 1214 | + if (empty($hour_array)) { |
|
| 1215 | + print _("No data available"); |
|
| 1216 | + } else { |
|
| 1138 | 1217 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
| 1139 | 1218 | $hour_data = ''; |
| 1140 | 1219 | $hour_cnt = ''; |
@@ -1173,8 +1252,9 @@ discard block |
||
| 1173 | 1252 | <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2> |
| 1174 | 1253 | <?php |
| 1175 | 1254 | $year_array = $Satellite->countAllMonthsLastYear(); |
| 1176 | - if (count($year_array) == 0) print _("No data available"); |
|
| 1177 | - else { |
|
| 1255 | + if (count($year_array) == 0) { |
|
| 1256 | + print _("No data available"); |
|
| 1257 | + } else { |
|
| 1178 | 1258 | print '<div id="chart21" class="chart" width="100%"></div><script>'; |
| 1179 | 1259 | $year_data = ''; |
| 1180 | 1260 | $year_cnt = ''; |
@@ -1204,8 +1284,9 @@ discard block |
||
| 1204 | 1284 | <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2> |
| 1205 | 1285 | <?php |
| 1206 | 1286 | $year_array = $Satellite->countAllYears(); |
| 1207 | - if (count($year_array) == 0) print _("No data available"); |
|
| 1208 | - else { |
|
| 1287 | + if (count($year_array) == 0) { |
|
| 1288 | + print _("No data available"); |
|
| 1289 | + } else { |
|
| 1209 | 1290 | print '<div id="chart22" class="chart" width="100%"></div><script>'; |
| 1210 | 1291 | $year_data = ''; |
| 1211 | 1292 | $year_cnt = ''; |
@@ -1247,8 +1328,9 @@ discard block |
||
| 1247 | 1328 | <h2><?php echo _("Fatalities by Years"); ?></h2> |
| 1248 | 1329 | <?php |
| 1249 | 1330 | $year_array = $Stats->countFatalitiesByYear(); |
| 1250 | - if (count($year_array) == 0) print _("No data available"); |
|
| 1251 | - else { |
|
| 1331 | + if (count($year_array) == 0) { |
|
| 1332 | + print _("No data available"); |
|
| 1333 | + } else { |
|
| 1252 | 1334 | print '<div id="chart32" class="chart" width="100%"></div><script>'; |
| 1253 | 1335 | $year_data = ''; |
| 1254 | 1336 | $year_cnt = ''; |
@@ -1277,8 +1359,9 @@ discard block |
||
| 1277 | 1359 | <h2><?php echo _("Fatalities last 12 Months"); ?></h2> |
| 1278 | 1360 | <?php |
| 1279 | 1361 | $year_array = $Stats->countFatalitiesLast12Months(); |
| 1280 | - if (count($year_array) == 0) print _("No data available"); |
|
| 1281 | - else { |
|
| 1362 | + if (count($year_array) == 0) { |
|
| 1363 | + print _("No data available"); |
|
| 1364 | + } else { |
|
| 1282 | 1365 | print '<div id="chart33" class="chart" width="100%"></div><script>'; |
| 1283 | 1366 | $year_data = ''; |
| 1284 | 1367 | $year_cnt = ''; |
@@ -1349,8 +1432,11 @@ discard block |
||
| 1349 | 1432 | $distance = $distance; |
| 1350 | 1433 | $unit = 'km'; |
| 1351 | 1434 | } |
| 1352 | - if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
| 1353 | - else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
| 1435 | + if (!isset($polar_data)) { |
|
| 1436 | + $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
| 1437 | + } else { |
|
| 1438 | + $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
| 1439 | + } |
|
| 1354 | 1440 | } |
| 1355 | 1441 | ?> |
| 1356 | 1442 | <div class="col-md-6"> |
@@ -1414,9 +1500,12 @@ discard block |
||
| 1414 | 1500 | foreach ($msg as $eachmsg) { |
| 1415 | 1501 | //$eachmsg = $msg[0]; |
| 1416 | 1502 | $data = $eachmsg['source_data']; |
| 1417 | - if ($data > 500) $max = (round(($data+100)/100))*100; |
|
| 1418 | - else $max = 500; |
|
| 1419 | -?> |
|
| 1503 | + if ($data > 500) { |
|
| 1504 | + $max = (round(($data+100)/100))*100; |
|
| 1505 | + } else { |
|
| 1506 | + $max = 500; |
|
| 1507 | + } |
|
| 1508 | + ?> |
|
| 1420 | 1509 | <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
| 1421 | 1510 | <script> |
| 1422 | 1511 | var g = new JustGage({ |
@@ -52,7 +52,9 @@ discard block |
||
| 52 | 52 | try { |
| 53 | 53 | $GeoidClass = new GeoidHeight(); |
| 54 | 54 | } catch(Exception $e) { |
| 55 | - if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
| 55 | + if ($globalDebug) { |
|
| 56 | + echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
| 57 | + } |
|
| 56 | 58 | $GeoidClass = FALSE; |
| 57 | 59 | } |
| 58 | 60 | } |
@@ -71,7 +73,9 @@ discard block |
||
| 71 | 73 | $dbc = $this->db; |
| 72 | 74 | $this->all_flights[$id]['schedule_check'] = true; |
| 73 | 75 | if ($globalSchedulesFetch) { |
| 74 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
| 76 | + if ($globalDebug) { |
|
| 77 | + echo 'Getting schedule info...'."\n"; |
|
| 78 | + } |
|
| 75 | 79 | $Spotter = new Spotter($dbc); |
| 76 | 80 | $Schedule = new Schedule($dbc); |
| 77 | 81 | $Translation = new Translation($dbc); |
@@ -82,7 +86,9 @@ discard block |
||
| 82 | 86 | if ($Schedule->checkSchedule($operator) == 0) { |
| 83 | 87 | $schedule = $Schedule->fetchSchedule($operator); |
| 84 | 88 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 89 | + if ($globalDebug) { |
|
| 90 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 91 | + } |
|
| 86 | 92 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
| 87 | 93 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
| 88 | 94 | // Should also check if route schedule = route from DB |
@@ -91,7 +97,9 @@ discard block |
||
| 91 | 97 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
| 92 | 98 | if (trim($airport_icao) != '') { |
| 93 | 99 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 94 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 100 | + if ($globalDebug) { |
|
| 101 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 102 | + } |
|
| 95 | 103 | } |
| 96 | 104 | } |
| 97 | 105 | } |
@@ -100,17 +108,25 @@ discard block |
||
| 100 | 108 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
| 101 | 109 | if (trim($airport_icao) != '') { |
| 102 | 110 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 103 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 111 | + if ($globalDebug) { |
|
| 112 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 113 | + } |
|
| 104 | 114 | } |
| 105 | 115 | } |
| 106 | 116 | } |
| 107 | 117 | $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
| 108 | 118 | } |
| 109 | - } else $scheduleexist = true; |
|
| 110 | - } else $scheduleexist = true; |
|
| 119 | + } else { |
|
| 120 | + $scheduleexist = true; |
|
| 121 | + } |
|
| 122 | + } else { |
|
| 123 | + $scheduleexist = true; |
|
| 124 | + } |
|
| 111 | 125 | // close connection, at least one way will work ? |
| 112 | 126 | if ($scheduleexist) { |
| 113 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
| 127 | + if ($globalDebug) { |
|
| 128 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
| 129 | + } |
|
| 114 | 130 | $sch = $Schedule->getSchedule($operator); |
| 115 | 131 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
| 116 | 132 | } |
@@ -132,14 +148,18 @@ discard block |
||
| 132 | 148 | |
| 133 | 149 | public function checkAll() { |
| 134 | 150 | global $globalDebug, $globalNoImport; |
| 135 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
| 151 | + if ($globalDebug) { |
|
| 152 | + echo "Update last seen flights data...\n"; |
|
| 153 | + } |
|
| 136 | 154 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 137 | 155 | foreach ($this->all_flights as $key => $flight) { |
| 138 | 156 | if (isset($this->all_flights[$key]['id'])) { |
| 139 | 157 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
| 140 | 158 | $Spotter = new Spotter($this->db); |
| 141 | 159 | $real_arrival = $this->arrival($key); |
| 142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 160 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) { |
|
| 161 | + $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 162 | + } |
|
| 143 | 163 | } |
| 144 | 164 | } |
| 145 | 165 | } |
@@ -147,24 +167,32 @@ discard block |
||
| 147 | 167 | |
| 148 | 168 | public function arrival($key) { |
| 149 | 169 | global $globalClosestMinDist, $globalDebug; |
| 150 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
| 170 | + if ($globalDebug) { |
|
| 171 | + echo 'Update arrival...'."\n"; |
|
| 172 | + } |
|
| 151 | 173 | $Spotter = new Spotter($this->db); |
| 152 | 174 | $airport_icao = ''; |
| 153 | 175 | $airport_time = ''; |
| 154 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 176 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
| 177 | + $globalClosestMinDist = 50; |
|
| 178 | + } |
|
| 155 | 179 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 156 | 180 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
| 157 | 181 | if (isset($closestAirports[0])) { |
| 158 | 182 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 159 | 183 | $airport_icao = $closestAirports[0]['icao']; |
| 160 | 184 | $airport_time = $this->all_flights[$key]['datetime']; |
| 161 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 185 | + if ($globalDebug) { |
|
| 186 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 187 | + } |
|
| 162 | 188 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
| 163 | 189 | foreach ($closestAirports as $airport) { |
| 164 | 190 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
| 165 | 191 | $airport_icao = $airport['icao']; |
| 166 | 192 | $airport_time = $this->all_flights[$key]['datetime']; |
| 167 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 193 | + if ($globalDebug) { |
|
| 194 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 195 | + } |
|
| 168 | 196 | break; |
| 169 | 197 | } |
| 170 | 198 | } |
@@ -172,14 +200,20 @@ discard block |
||
| 172 | 200 | $airport_icao = $closestAirports[0]['icao']; |
| 173 | 201 | $airport_time = $this->all_flights[$key]['datetime']; |
| 174 | 202 | } else { |
| 175 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 203 | + if ($globalDebug) { |
|
| 204 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 205 | + } |
|
| 176 | 206 | } |
| 177 | 207 | } else { |
| 178 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 208 | + if ($globalDebug) { |
|
| 209 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 210 | + } |
|
| 179 | 211 | } |
| 180 | 212 | |
| 181 | 213 | } else { |
| 182 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 214 | + if ($globalDebug) { |
|
| 215 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 216 | + } |
|
| 183 | 217 | } |
| 184 | 218 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
| 185 | 219 | } |
@@ -189,7 +223,9 @@ discard block |
||
| 189 | 223 | public function del() { |
| 190 | 224 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 191 | 225 | // Delete old infos |
| 192 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 226 | + if ($globalDebug) { |
|
| 227 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 228 | + } |
|
| 193 | 229 | foreach ($this->all_flights as $key => $flight) { |
| 194 | 230 | if (isset($flight['lastupdate'])) { |
| 195 | 231 | if ($flight['lastupdate'] < (time()-5900)) { |
@@ -203,13 +239,17 @@ discard block |
||
| 203 | 239 | global $globalDebug, $globalNoImport, $globalNoDB; |
| 204 | 240 | // Delete old infos |
| 205 | 241 | if (isset($this->all_flights[$key]['id'])) { |
| 206 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 242 | + if ($globalDebug) { |
|
| 243 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 244 | + } |
|
| 207 | 245 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 208 | 246 | $real_arrival = $this->arrival($key); |
| 209 | 247 | $Spotter = new Spotter($this->db); |
| 210 | 248 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 211 | 249 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
| 212 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 250 | + if ($globalDebug && $result != 'success') { |
|
| 251 | + echo '!!! ERROR : '.$result."\n"; |
|
| 252 | + } |
|
| 213 | 253 | } |
| 214 | 254 | } |
| 215 | 255 | } |
@@ -219,9 +259,13 @@ discard block |
||
| 219 | 259 | public function add($line) { |
| 220 | 260 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass; |
| 221 | 261 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 222 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 223 | - if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000; |
|
| 224 | -/* |
|
| 262 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 263 | + $globalCoordMinChange = '0.02'; |
|
| 264 | + } |
|
| 265 | + if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') { |
|
| 266 | + $globalAircraftMaxUpdate = 3000; |
|
| 267 | + } |
|
| 268 | + /* |
|
| 225 | 269 | $Spotter = new Spotter(); |
| 226 | 270 | $dbc = $Spotter->db; |
| 227 | 271 | $SpotterLive = new SpotterLive($dbc); |
@@ -243,19 +287,28 @@ discard block |
||
| 243 | 287 | // SBS format is CSV format |
| 244 | 288 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
| 245 | 289 | //print_r($line); |
| 246 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
| 290 | + if (isset($line['hex'])) { |
|
| 291 | + $line['hex'] = strtoupper($line['hex']); |
|
| 292 | + } |
|
| 247 | 293 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
| 248 | 294 | |
| 249 | 295 | // Increment message number |
| 250 | 296 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
| 251 | 297 | $current_date = date('Y-m-d'); |
| 252 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
| 253 | - else $source = ''; |
|
| 254 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 298 | + if (isset($line['source_name'])) { |
|
| 299 | + $source = $line['source_name']; |
|
| 300 | + } else { |
|
| 301 | + $source = ''; |
|
| 302 | + } |
|
| 303 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 304 | + $source = $line['format_source']; |
|
| 305 | + } |
|
| 255 | 306 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 256 | 307 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 257 | 308 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 258 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 309 | + } else { |
|
| 310 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 311 | + } |
|
| 259 | 312 | } |
| 260 | 313 | |
| 261 | 314 | /* |
@@ -271,23 +324,38 @@ discard block |
||
| 271 | 324 | //$this->db = $dbc; |
| 272 | 325 | |
| 273 | 326 | //$hex = trim($line['hex']); |
| 274 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 275 | - else $id = trim($line['id']); |
|
| 327 | + if (!isset($line['id'])) { |
|
| 328 | + $id = trim($line['hex']); |
|
| 329 | + } else { |
|
| 330 | + $id = trim($line['id']); |
|
| 331 | + } |
|
| 276 | 332 | |
| 277 | 333 | if (!isset($this->all_flights[$id])) { |
| 278 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
| 334 | + if ($globalDebug) { |
|
| 335 | + echo 'New flight...'."\n"; |
|
| 336 | + } |
|
| 279 | 337 | $this->all_flights[$id] = array(); |
| 280 | 338 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 281 | 339 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
| 282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 340 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
| 341 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 342 | + } |
|
| 283 | 343 | if (!isset($line['id'])) { |
| 284 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 285 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
| 344 | + if (!isset($globalDaemon)) { |
|
| 345 | + $globalDaemon = TRUE; |
|
| 346 | + } |
|
| 347 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
| 286 | 348 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 287 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 349 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 350 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 351 | + } |
|
| 288 | 352 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 290 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 353 | + } else { |
|
| 354 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 355 | + } |
|
| 356 | + if ($globalAllFlights !== FALSE) { |
|
| 357 | + $dataFound = true; |
|
| 358 | + } |
|
| 291 | 359 | } |
| 292 | 360 | if (isset($line['source_type']) && $line['source_type'] != '') { |
| 293 | 361 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -309,12 +377,20 @@ discard block |
||
| 309 | 377 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 310 | 378 | } |
| 311 | 379 | $Spotter->db = null; |
| 312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 380 | + if ($globalDebugTimeElapsed) { |
|
| 381 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 382 | + } |
|
| 383 | + if ($aircraft_icao != '') { |
|
| 384 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 385 | + } |
|
| 314 | 386 | } |
| 315 | 387 | } |
| 316 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 317 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 388 | + if ($globalAllFlights !== FALSE) { |
|
| 389 | + $dataFound = true; |
|
| 390 | + } |
|
| 391 | + if ($globalDebug) { |
|
| 392 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 393 | + } |
|
| 318 | 394 | } |
| 319 | 395 | if (isset($line['id']) && !isset($line['hex'])) { |
| 320 | 396 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
@@ -322,7 +398,9 @@ discard block |
||
| 322 | 398 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 323 | 399 | $icao = $line['aircraft_icao']; |
| 324 | 400 | $Spotter = new Spotter($this->db); |
| 325 | - if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
| 401 | + if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
| 402 | + $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
| 403 | + } |
|
| 326 | 404 | $Spotter->db = null; |
| 327 | 405 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
| 328 | 406 | } |
@@ -332,15 +410,24 @@ discard block |
||
| 332 | 410 | $Spotter = new Spotter($this->db); |
| 333 | 411 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 334 | 412 | $Spotter->db = null; |
| 335 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 413 | + if ($aircraft_icao != '') { |
|
| 414 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 415 | + } |
|
| 336 | 416 | } |
| 337 | 417 | } |
| 338 | 418 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
| 339 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
| 340 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
| 341 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
| 342 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
| 343 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 419 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
| 420 | + $aircraft_icao = 'GLID'; |
|
| 421 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
| 422 | + $aircraft_icao = 'UHEL'; |
|
| 423 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
| 424 | + $aircraft_icao = 'TOWPLANE'; |
|
| 425 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
| 426 | + $aircraft_icao = 'POWAIRC'; |
|
| 427 | + } |
|
| 428 | + if (isset($aircraft_icao)) { |
|
| 429 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 430 | + } |
|
| 344 | 431 | } |
| 345 | 432 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
| 346 | 433 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -350,8 +437,11 @@ discard block |
||
| 350 | 437 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 351 | 438 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 352 | 439 | } else { |
| 353 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 354 | - elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 440 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 441 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 442 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 443 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 444 | + } |
|
| 355 | 445 | /* |
| 356 | 446 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
| 357 | 447 | print_r($this->all_flights[$id]); |
@@ -360,16 +450,22 @@ discard block |
||
| 360 | 450 | return ''; |
| 361 | 451 | } |
| 362 | 452 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
| 363 | - if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
|
| 453 | + if ($globalDebug) { |
|
| 454 | + echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
|
| 455 | + } |
|
| 364 | 456 | return ''; |
| 365 | 457 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
| 366 | - if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
|
| 458 | + if ($globalDebug) { |
|
| 459 | + echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n"; |
|
| 460 | + } |
|
| 367 | 461 | return ''; |
| 368 | 462 | } elseif (!isset($line['datetime'])) { |
| 369 | 463 | date_default_timezone_set('UTC'); |
| 370 | 464 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 371 | 465 | } else { |
| 372 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 466 | + if ($globalDebug) { |
|
| 467 | + echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
| 468 | + } |
|
| 373 | 469 | return ''; |
| 374 | 470 | } |
| 375 | 471 | |
@@ -390,30 +486,48 @@ discard block |
||
| 390 | 486 | |
| 391 | 487 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
| 392 | 488 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 393 | - if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
| 489 | + if ($globalDebug) { |
|
| 490 | + echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
| 491 | + } |
|
| 394 | 492 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 395 | 493 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 396 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 397 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 398 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 494 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 495 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 496 | + } elseif (isset($line['id'])) { |
|
| 497 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 498 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 499 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 500 | + } |
|
| 399 | 501 | } else { |
| 400 | 502 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
| 401 | 503 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 402 | 504 | $timeelapsed = microtime(true); |
| 403 | 505 | $Spotter = new Spotter($this->db); |
| 404 | 506 | $fromsource = NULL; |
| 405 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 406 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 407 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
| 408 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
| 409 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
| 507 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
| 508 | + $fromsource = $globalAirlinesSource; |
|
| 509 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
| 510 | + $fromsource = 'vatsim'; |
|
| 511 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
| 512 | + $fromsource = 'ivao'; |
|
| 513 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
| 514 | + $fromsource = 'vatsim'; |
|
| 515 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
| 516 | + $fromsource = 'ivao'; |
|
| 517 | + } |
|
| 410 | 518 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
| 411 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 519 | + if ($globalDebug && $result != 'success') { |
|
| 520 | + echo '!!! ERROR : '.$result."\n"; |
|
| 521 | + } |
|
| 412 | 522 | $Spotter->db = null; |
| 413 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 523 | + if ($globalDebugTimeElapsed) { |
|
| 524 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 525 | + } |
|
| 414 | 526 | } |
| 415 | 527 | } |
| 416 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 528 | + } else { |
|
| 529 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 530 | + } |
|
| 417 | 531 | |
| 418 | 532 | /* |
| 419 | 533 | if (!isset($line['id'])) { |
@@ -423,7 +537,9 @@ discard block |
||
| 423 | 537 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 424 | 538 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 425 | 539 | */ |
| 426 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 540 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 541 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 542 | + } |
|
| 427 | 543 | |
| 428 | 544 | //$putinarchive = true; |
| 429 | 545 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -441,7 +557,9 @@ discard block |
||
| 441 | 557 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 442 | 558 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 443 | 559 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
| 444 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 560 | + if ($globalDebugTimeElapsed) { |
|
| 561 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 562 | + } |
|
| 445 | 563 | } |
| 446 | 564 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 447 | 565 | $timeelapsed = microtime(true); |
@@ -455,7 +573,9 @@ discard block |
||
| 455 | 573 | $Translation->db = null; |
| 456 | 574 | } |
| 457 | 575 | $Spotter->db = null; |
| 458 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 576 | + if ($globalDebugTimeElapsed) { |
|
| 577 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 578 | + } |
|
| 459 | 579 | } |
| 460 | 580 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 461 | 581 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -464,9 +584,13 @@ discard block |
||
| 464 | 584 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
| 465 | 585 | } |
| 466 | 586 | } |
| 467 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
| 587 | + if (!isset($globalFork)) { |
|
| 588 | + $globalFork = TRUE; |
|
| 589 | + } |
|
| 468 | 590 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 469 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 591 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
| 592 | + $this->get_Schedule($id,trim($line['ident'])); |
|
| 593 | + } |
|
| 470 | 594 | } |
| 471 | 595 | } |
| 472 | 596 | } |
@@ -484,9 +608,13 @@ discard block |
||
| 484 | 608 | $speed = $speed*3.6; |
| 485 | 609 | if ($speed < 1000) { |
| 486 | 610 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
| 487 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 611 | + if ($globalDebug) { |
|
| 612 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 613 | + } |
|
| 488 | 614 | } else { |
| 489 | - if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 615 | + if ($globalDebug) { |
|
| 616 | + echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
| 617 | + } |
|
| 490 | 618 | } |
| 491 | 619 | } |
| 492 | 620 | } |
@@ -495,13 +623,21 @@ discard block |
||
| 495 | 623 | |
| 496 | 624 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 497 | 625 | if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
| 498 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 626 | + if ($globalDebug) { |
|
| 627 | + echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
| 628 | + } |
|
| 499 | 629 | return false; |
| 500 | 630 | } |
| 501 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 502 | - else unset($timediff); |
|
| 503 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 504 | - else unset($timediff_archive); |
|
| 631 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
| 632 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 633 | + } else { |
|
| 634 | + unset($timediff); |
|
| 635 | + } |
|
| 636 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) { |
|
| 637 | + $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
| 638 | + } else { |
|
| 639 | + unset($timediff_archive); |
|
| 640 | + } |
|
| 505 | 641 | if ($this->tmd > 5 |
| 506 | 642 | || (isset($line['format_source']) |
| 507 | 643 | && $line['format_source'] == 'airwhere' |
@@ -537,16 +673,25 @@ discard block |
||
| 537 | 673 | $this->all_flights[$id]['putinarchive'] = true; |
| 538 | 674 | $this->tmd = 0; |
| 539 | 675 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 540 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 676 | + if ($globalDebug) { |
|
| 677 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 678 | + } |
|
| 541 | 679 | $timeelapsed = microtime(true); |
| 542 | 680 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 543 | 681 | $Spotter = new Spotter($this->db); |
| 544 | 682 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 545 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 546 | - else $this->all_flights[$id]['over_country'] = ''; |
|
| 683 | + if (!empty($all_country)) { |
|
| 684 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 685 | + } else { |
|
| 686 | + $this->all_flights[$id]['over_country'] = ''; |
|
| 687 | + } |
|
| 547 | 688 | $Spotter->db = null; |
| 548 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 549 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
| 689 | + if ($globalDebugTimeElapsed) { |
|
| 690 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 691 | + } |
|
| 692 | + if ($globalDebug) { |
|
| 693 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
| 694 | + } |
|
| 550 | 695 | } |
| 551 | 696 | } |
| 552 | 697 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
@@ -592,7 +737,9 @@ discard block |
||
| 592 | 737 | */ |
| 593 | 738 | } |
| 594 | 739 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 595 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 740 | + if ($line['longitude'] > 180) { |
|
| 741 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 742 | + } |
|
| 596 | 743 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
| 597 | 744 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
| 598 | 745 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -629,7 +776,9 @@ discard block |
||
| 629 | 776 | } |
| 630 | 777 | } |
| 631 | 778 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 632 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 779 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
| 780 | + $dataFound = true; |
|
| 781 | + } |
|
| 633 | 782 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
| 634 | 783 | } |
| 635 | 784 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -651,35 +800,53 @@ discard block |
||
| 651 | 800 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 652 | 801 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 653 | 802 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 654 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 655 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 656 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 803 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 804 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 805 | + } elseif (isset($line['id'])) { |
|
| 806 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 807 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 808 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 809 | + } |
|
| 810 | + } |
|
| 811 | + if ($line['ground'] != 1) { |
|
| 812 | + $line['ground'] = 0; |
|
| 657 | 813 | } |
| 658 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 659 | 814 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
| 660 | 815 | //$dataFound = true; |
| 661 | 816 | } |
| 662 | 817 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 663 | 818 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
| 664 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 819 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
| 820 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 821 | + } |
|
| 665 | 822 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
| 666 | 823 | $highlight = ''; |
| 667 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 668 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 669 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 824 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 825 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 826 | + } |
|
| 827 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 828 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 829 | + } |
|
| 830 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 831 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 832 | + } |
|
| 670 | 833 | if ($highlight != '') { |
| 671 | 834 | $timeelapsed = microtime(true); |
| 672 | 835 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 673 | 836 | $Spotter = new Spotter($this->db); |
| 674 | 837 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
| 675 | 838 | $Spotter->db = null; |
| 676 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 839 | + if ($globalDebugTimeElapsed) { |
|
| 840 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 841 | + } |
|
| 677 | 842 | } |
| 678 | 843 | //$putinarchive = true; |
| 679 | 844 | //$highlight = ''; |
| 680 | 845 | } |
| 681 | 846 | |
| 682 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 847 | + } else { |
|
| 848 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 849 | + } |
|
| 683 | 850 | //$dataFound = true; |
| 684 | 851 | } |
| 685 | 852 | |
@@ -692,19 +859,27 @@ discard block |
||
| 692 | 859 | } |
| 693 | 860 | } |
| 694 | 861 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 695 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 862 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
| 863 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 864 | + } |
|
| 696 | 865 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 697 | 866 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 698 | 867 | //$dataFound = true; |
| 699 | 868 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
| 700 | 869 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
| 701 | 870 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
| 702 | - if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
| 871 | + if ($globalDebug) { |
|
| 872 | + echo '--- Reset because of altitude'."\n"; |
|
| 873 | + } |
|
| 703 | 874 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 704 | 875 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 705 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 706 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 707 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 876 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
| 877 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 878 | + } elseif (isset($line['id'])) { |
|
| 879 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 880 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 881 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 882 | + } |
|
| 708 | 883 | } |
| 709 | 884 | } |
| 710 | 885 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
@@ -715,22 +890,32 @@ discard block |
||
| 715 | 890 | } |
| 716 | 891 | |
| 717 | 892 | if (isset($line['heading']) && $line['heading'] != '') { |
| 718 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 893 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
| 894 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 895 | + } |
|
| 719 | 896 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
| 720 | 897 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
| 721 | 898 | //$dataFound = true; |
| 722 | 899 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 723 | 900 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
| 724 | 901 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
| 725 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 726 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
| 902 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
| 903 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 904 | + } |
|
| 905 | + if ($globalDebug) { |
|
| 906 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
| 907 | + } |
|
| 727 | 908 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 728 | 909 | // If not enough messages and ACARS set heading to 0 |
| 729 | 910 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
| 730 | 911 | } |
| 731 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 732 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 733 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
| 912 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
| 913 | + $dataFound = false; |
|
| 914 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
| 915 | + $dataFound = false; |
|
| 916 | + } elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) { |
|
| 917 | + $dataFound = false; |
|
| 918 | + } |
|
| 734 | 919 | |
| 735 | 920 | // print_r($this->all_flights[$id]); |
| 736 | 921 | //gets the callsign from the last hour |
@@ -747,23 +932,38 @@ discard block |
||
| 747 | 932 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
| 748 | 933 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
| 749 | 934 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 750 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 935 | + if ($globalDebug) { |
|
| 936 | + echo "Check if aircraft is already in DB..."; |
|
| 937 | + } |
|
| 751 | 938 | $timeelapsed = microtime(true); |
| 752 | 939 | $SpotterLive = new SpotterLive($this->db); |
| 753 | 940 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
| 754 | 941 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 755 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 942 | + if ($globalDebugTimeElapsed) { |
|
| 943 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 944 | + } |
|
| 756 | 945 | } elseif (isset($line['id'])) { |
| 757 | 946 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 758 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 947 | + if ($globalDebugTimeElapsed) { |
|
| 948 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 949 | + } |
|
| 759 | 950 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 760 | 951 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 761 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 762 | - } else $recent_ident = ''; |
|
| 952 | + if ($globalDebugTimeElapsed) { |
|
| 953 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 954 | + } |
|
| 955 | + } else { |
|
| 956 | + $recent_ident = ''; |
|
| 957 | + } |
|
| 763 | 958 | $SpotterLive->db=null; |
| 764 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 765 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 766 | - } else $recent_ident = ''; |
|
| 959 | + if ($globalDebug && $recent_ident == '') { |
|
| 960 | + echo " Not in DB.\n"; |
|
| 961 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 962 | + echo " Already in DB.\n"; |
|
| 963 | + } |
|
| 964 | + } else { |
|
| 965 | + $recent_ident = ''; |
|
| 966 | + } |
|
| 767 | 967 | } else { |
| 768 | 968 | $recent_ident = ''; |
| 769 | 969 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -771,7 +971,9 @@ discard block |
||
| 771 | 971 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 772 | 972 | if($recent_ident == "") |
| 773 | 973 | { |
| 774 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 974 | + if ($globalDebug) { |
|
| 975 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 976 | + } |
|
| 775 | 977 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 776 | 978 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 777 | 979 | //adds the spotter data for the archive |
@@ -815,31 +1017,49 @@ discard block |
||
| 815 | 1017 | |
| 816 | 1018 | if (!$ignoreImport) { |
| 817 | 1019 | $highlight = ''; |
| 818 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 819 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 820 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 821 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1020 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 1021 | + $highlight = 'Squawk 7500 : Hijack'; |
|
| 1022 | + } |
|
| 1023 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 1024 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 1025 | + } |
|
| 1026 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 1027 | + $highlight = 'Squawk 7700 : Emergency'; |
|
| 1028 | + } |
|
| 1029 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 1030 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1031 | + } |
|
| 822 | 1032 | $timeelapsed = microtime(true); |
| 823 | 1033 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 824 | 1034 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 825 | 1035 | $Spotter = new Spotter($this->db); |
| 826 | 1036 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
| 827 | 1037 | $Spotter->db = null; |
| 828 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 1038 | + if ($globalDebug && isset($result)) { |
|
| 1039 | + echo $result."\n"; |
|
| 1040 | + } |
|
| 829 | 1041 | } |
| 830 | 1042 | } |
| 831 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1043 | + if ($globalDebugTimeElapsed) { |
|
| 1044 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1045 | + } |
|
| 832 | 1046 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 833 | 1047 | |
| 834 | 1048 | // Add source stat in DB |
| 835 | 1049 | $Stats = new Stats($this->db); |
| 836 | 1050 | if (!empty($this->stats)) { |
| 837 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 1051 | + if ($globalDebug) { |
|
| 1052 | + echo 'Add source stats : '; |
|
| 1053 | + } |
|
| 838 | 1054 | foreach($this->stats as $date => $data) { |
| 839 | 1055 | foreach($data as $source => $sourced) { |
| 840 | 1056 | //print_r($sourced); |
| 841 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 842 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 1057 | + if (isset($sourced['polar'])) { |
|
| 1058 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 1059 | + } |
|
| 1060 | + if (isset($sourced['hist'])) { |
|
| 1061 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 1062 | + } |
|
| 843 | 1063 | if (isset($sourced['msg'])) { |
| 844 | 1064 | if (time() - $sourced['msg']['date'] > 10) { |
| 845 | 1065 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -852,13 +1072,17 @@ discard block |
||
| 852 | 1072 | unset($this->stats[$date]); |
| 853 | 1073 | } |
| 854 | 1074 | } |
| 855 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 1075 | + if ($globalDebug) { |
|
| 1076 | + echo 'Done'."\n"; |
|
| 1077 | + } |
|
| 856 | 1078 | |
| 857 | 1079 | } |
| 858 | 1080 | $Stats->db = null; |
| 859 | 1081 | } |
| 860 | 1082 | $this->del(); |
| 861 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
| 1083 | + } elseif ($globalDebug) { |
|
| 1084 | + echo 'Ignore data'."\n"; |
|
| 1085 | + } |
|
| 862 | 1086 | //$ignoreImport = false; |
| 863 | 1087 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 864 | 1088 | //print_r($this->all_flights[$id]); |
@@ -875,7 +1099,9 @@ discard block |
||
| 875 | 1099 | */ |
| 876 | 1100 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 877 | 1101 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 878 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 1102 | + if ($globalDebug) { |
|
| 1103 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 1104 | + } |
|
| 879 | 1105 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 880 | 1106 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 881 | 1107 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -884,7 +1110,9 @@ discard block |
||
| 884 | 1110 | $SpotterLive->db=null; |
| 885 | 1111 | } |
| 886 | 1112 | } |
| 887 | - if ($globalDebug) echo " Done\n"; |
|
| 1113 | + if ($globalDebug) { |
|
| 1114 | + echo " Done\n"; |
|
| 1115 | + } |
|
| 888 | 1116 | $this->last_delete = time(); |
| 889 | 1117 | } |
| 890 | 1118 | } else { |
@@ -911,11 +1139,17 @@ discard block |
||
| 911 | 1139 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
| 912 | 1140 | if ($globalDebug) { |
| 913 | 1141 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
| 914 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 915 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
| 1142 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 1143 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 1144 | + } else { |
|
| 1145 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
| 1146 | + } |
|
| 916 | 1147 | } else { |
| 917 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 918 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
| 1148 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 1149 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 1150 | + } else { |
|
| 1151 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
| 1152 | + } |
|
| 919 | 1153 | } |
| 920 | 1154 | } |
| 921 | 1155 | $ignoreImport = false; |
@@ -961,22 +1195,30 @@ discard block |
||
| 961 | 1195 | |
| 962 | 1196 | if (!$ignoreImport) { |
| 963 | 1197 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 964 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1198 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 1199 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 1200 | + } |
|
| 965 | 1201 | $timeelapsed = microtime(true); |
| 966 | 1202 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
| 967 | 1203 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 968 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 1204 | + if ($globalDebug) { |
|
| 1205 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 1206 | + } |
|
| 969 | 1207 | $SpotterLive = new SpotterLive($this->db); |
| 970 | 1208 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 971 | 1209 | $SpotterLive->db = null; |
| 972 | - if ($globalDebug) echo $result."\n"; |
|
| 1210 | + if ($globalDebug) { |
|
| 1211 | + echo $result."\n"; |
|
| 1212 | + } |
|
| 973 | 1213 | } |
| 974 | 1214 | } |
| 975 | 1215 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
| 976 | 1216 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 977 | 1217 | } |
| 978 | 1218 | $this->all_flights[$id]['putinarchive'] = false; |
| 979 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1219 | + if ($globalDebugTimeElapsed) { |
|
| 1220 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1221 | + } |
|
| 980 | 1222 | |
| 981 | 1223 | // Put statistics in $this->stats variable |
| 982 | 1224 | //if ($line['format_source'] != 'aprs') { |
@@ -984,7 +1226,9 @@ discard block |
||
| 984 | 1226 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
| 985 | 1227 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 986 | 1228 | $source = $this->all_flights[$id]['source_name']; |
| 987 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
| 1229 | + if ($source == '') { |
|
| 1230 | + $source = $this->all_flights[$id]['format_source']; |
|
| 1231 | + } |
|
| 988 | 1232 | if (!isset($this->source_location[$source])) { |
| 989 | 1233 | $Location = new Source($this->db); |
| 990 | 1234 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -1005,7 +1249,9 @@ discard block |
||
| 1005 | 1249 | $stats_heading = round($stats_heading/22.5); |
| 1006 | 1250 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
| 1007 | 1251 | $current_date = date('Y-m-d'); |
| 1008 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 1252 | + if ($stats_heading == 16) { |
|
| 1253 | + $stats_heading = 0; |
|
| 1254 | + } |
|
| 1009 | 1255 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 1010 | 1256 | for ($i=0;$i<=15;$i++) { |
| 1011 | 1257 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -1023,7 +1269,9 @@ discard block |
||
| 1023 | 1269 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 1024 | 1270 | end($this->stats[$current_date][$source]['hist']); |
| 1025 | 1271 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 1026 | - } else $mini = 0; |
|
| 1272 | + } else { |
|
| 1273 | + $mini = 0; |
|
| 1274 | + } |
|
| 1027 | 1275 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 1028 | 1276 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 1029 | 1277 | } |
@@ -1035,19 +1283,27 @@ discard block |
||
| 1035 | 1283 | } |
| 1036 | 1284 | |
| 1037 | 1285 | $this->all_flights[$id]['lastupdate'] = time(); |
| 1038 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
| 1286 | + if ($this->all_flights[$id]['putinarchive']) { |
|
| 1287 | + $send = true; |
|
| 1288 | + } |
|
| 1039 | 1289 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 1040 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1290 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 1291 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1292 | + } |
|
| 1041 | 1293 | //$this->del(); |
| 1042 | 1294 | |
| 1043 | 1295 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 1044 | 1296 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
| 1045 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1297 | + if ($globalDebug) { |
|
| 1298 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1299 | + } |
|
| 1046 | 1300 | $SpotterLive = new SpotterLive($this->db); |
| 1047 | 1301 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 1048 | 1302 | $SpotterLive->db = null; |
| 1049 | 1303 | //SpotterLive->deleteLiveSpotterData(); |
| 1050 | - if ($globalDebug) echo " Done\n"; |
|
| 1304 | + if ($globalDebug) { |
|
| 1305 | + echo " Done\n"; |
|
| 1306 | + } |
|
| 1051 | 1307 | $this->last_delete_hourly = time(); |
| 1052 | 1308 | } else { |
| 1053 | 1309 | $this->del(); |
@@ -1059,7 +1315,9 @@ discard block |
||
| 1059 | 1315 | //$ignoreImport = false; |
| 1060 | 1316 | } |
| 1061 | 1317 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 1062 | - if ($send) return $this->all_flights[$id]; |
|
| 1318 | + if ($send) { |
|
| 1319 | + return $this->all_flights[$id]; |
|
| 1320 | + } |
|
| 1063 | 1321 | } |
| 1064 | 1322 | } |
| 1065 | 1323 | } |
@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | public function __construct($dbc = null) { |
| 9 | 9 | $Connection = new Connection($dbc); |
| 10 | 10 | $this->db = $Connection->db(); |
| 11 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 11 | + if ($this->db === null) { |
|
| 12 | + die('Error: No DB connection.'); |
|
| 13 | + } |
|
| 12 | 14 | } |
| 13 | 15 | |
| 14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
| 30 | 32 | if (isset($filter[0]['source'])) { |
| 31 | 33 | $filters = array_merge($filters,$filter); |
| 32 | 34 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 35 | + if (is_array($globalFilter)) { |
|
| 36 | + $filter = array_merge($filter,$globalFilter); |
|
| 37 | + } |
|
| 34 | 38 | $filter_query_join = ''; |
| 35 | 39 | $filter_query_where = ''; |
| 36 | 40 | foreach($filters as $flt) { |
@@ -119,8 +123,11 @@ discard block |
||
| 119 | 123 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 120 | 124 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 121 | 125 | } |
| 122 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 123 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 126 | + if ($filter_query_where == '' && $where) { |
|
| 127 | + $filter_query_where = ' WHERE'; |
|
| 128 | + } elseif ($filter_query_where != '' && $and) { |
|
| 129 | + $filter_query_where .= ' AND'; |
|
| 130 | + } |
|
| 124 | 131 | if ($filter_query_where != '') { |
| 125 | 132 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 126 | 133 | } |
@@ -161,9 +168,13 @@ discard block |
||
| 161 | 168 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
| 162 | 169 | } |
| 163 | 170 | } |
| 164 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
| 171 | + if ($orderby_query == '') { |
|
| 172 | + $orderby_query = ' ORDER BY date DESC'; |
|
| 173 | + } |
|
| 165 | 174 | |
| 166 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 175 | + if (!isset($globalLiveInterval)) { |
|
| 176 | + $globalLiveInterval = '200'; |
|
| 177 | + } |
|
| 167 | 178 | if ($globalDBdriver == 'mysql') { |
| 168 | 179 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
| 169 | 180 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -186,7 +197,9 @@ discard block |
||
| 186 | 197 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 187 | 198 | date_default_timezone_set('UTC'); |
| 188 | 199 | $filter_query = $this->getFilter($filter,true,true); |
| 189 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 200 | + if (!isset($globalLiveInterval)) { |
|
| 201 | + $globalLiveInterval = '200'; |
|
| 202 | + } |
|
| 190 | 203 | if ($globalDBdriver == 'mysql') { |
| 191 | 204 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 192 | 205 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -229,7 +242,9 @@ discard block |
||
| 229 | 242 | |
| 230 | 243 | $filter_query = $this->getFilter($filter,true,true); |
| 231 | 244 | |
| 232 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 245 | + if (!isset($globalLiveInterval)) { |
|
| 246 | + $globalLiveInterval = '200'; |
|
| 247 | + } |
|
| 233 | 248 | if ($globalDBdriver == 'mysql') { |
| 234 | 249 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 235 | 250 | /* |
@@ -297,7 +312,9 @@ discard block |
||
| 297 | 312 | global $globalDBdriver, $globalLiveInterval; |
| 298 | 313 | $filter_query = $this->getFilter($filter,true,true); |
| 299 | 314 | |
| 300 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 315 | + if (!isset($globalLiveInterval)) { |
|
| 316 | + $globalLiveInterval = '200'; |
|
| 317 | + } |
|
| 301 | 318 | if ($globalDBdriver == 'mysql') { |
| 302 | 319 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
| 303 | 320 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -327,7 +344,9 @@ discard block |
||
| 327 | 344 | { |
| 328 | 345 | global $globalDBdriver, $globalLiveInterval; |
| 329 | 346 | $Spotter = new Spotter($this->db); |
| 330 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 347 | + if (!isset($globalLiveInterval)) { |
|
| 348 | + $globalLiveInterval = '200'; |
|
| 349 | + } |
|
| 331 | 350 | $filter_query = $this->getFilter($filter); |
| 332 | 351 | |
| 333 | 352 | if (is_array($coord)) { |
@@ -335,7 +354,9 @@ discard block |
||
| 335 | 354 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 336 | 355 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 337 | 356 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 338 | - } else return array(); |
|
| 357 | + } else { |
|
| 358 | + return array(); |
|
| 359 | + } |
|
| 339 | 360 | if ($globalDBdriver == 'mysql') { |
| 340 | 361 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
| 341 | 362 | } else { |
@@ -356,7 +377,9 @@ discard block |
||
| 356 | 377 | { |
| 357 | 378 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 358 | 379 | $Spotter = new Spotter($this->db); |
| 359 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 380 | + if (!isset($globalLiveInterval)) { |
|
| 381 | + $globalLiveInterval = '200'; |
|
| 382 | + } |
|
| 360 | 383 | $filter_query = $this->getFilter($filter,true,true); |
| 361 | 384 | |
| 362 | 385 | if (is_array($coord)) { |
@@ -364,7 +387,9 @@ discard block |
||
| 364 | 387 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 365 | 388 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 366 | 389 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 367 | - } else return array(); |
|
| 390 | + } else { |
|
| 391 | + return array(); |
|
| 392 | + } |
|
| 368 | 393 | if ($globalDBdriver == 'mysql') { |
| 369 | 394 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 370 | 395 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -591,11 +616,15 @@ discard block |
||
| 591 | 616 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
| 592 | 617 | if ($globalDBdriver == 'mysql') { |
| 593 | 618 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 594 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 619 | + if ($liveinterval) { |
|
| 620 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 621 | + } |
|
| 595 | 622 | $query .= ' ORDER BY date'; |
| 596 | 623 | } else { |
| 597 | 624 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 598 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 625 | + if ($liveinterval) { |
|
| 626 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 627 | + } |
|
| 599 | 628 | $query .= ' ORDER BY date'; |
| 600 | 629 | } |
| 601 | 630 | |
@@ -690,7 +719,9 @@ discard block |
||
| 690 | 719 | $i++; |
| 691 | 720 | $j++; |
| 692 | 721 | if ($j == 30) { |
| 693 | - if ($globalDebug) echo "."; |
|
| 722 | + if ($globalDebug) { |
|
| 723 | + echo "."; |
|
| 724 | + } |
|
| 694 | 725 | try { |
| 695 | 726 | |
| 696 | 727 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -997,7 +1028,9 @@ discard block |
||
| 997 | 1028 | { |
| 998 | 1029 | return false; |
| 999 | 1030 | } |
| 1000 | - } else return ''; |
|
| 1031 | + } else { |
|
| 1032 | + return ''; |
|
| 1033 | + } |
|
| 1001 | 1034 | |
| 1002 | 1035 | if ($longitude != '') |
| 1003 | 1036 | { |
@@ -1005,7 +1038,9 @@ discard block |
||
| 1005 | 1038 | { |
| 1006 | 1039 | return false; |
| 1007 | 1040 | } |
| 1008 | - } else return ''; |
|
| 1041 | + } else { |
|
| 1042 | + return ''; |
|
| 1043 | + } |
|
| 1009 | 1044 | |
| 1010 | 1045 | if ($waypoints != '') |
| 1011 | 1046 | { |
@@ -1021,14 +1056,18 @@ discard block |
||
| 1021 | 1056 | { |
| 1022 | 1057 | return false; |
| 1023 | 1058 | } |
| 1024 | - } else $altitude = 0; |
|
| 1059 | + } else { |
|
| 1060 | + $altitude = 0; |
|
| 1061 | + } |
|
| 1025 | 1062 | if ($altitude_real != '') |
| 1026 | 1063 | { |
| 1027 | 1064 | if (!is_numeric($altitude_real)) |
| 1028 | 1065 | { |
| 1029 | 1066 | return false; |
| 1030 | 1067 | } |
| 1031 | - } else $altitude_real = 0; |
|
| 1068 | + } else { |
|
| 1069 | + $altitude_real = 0; |
|
| 1070 | + } |
|
| 1032 | 1071 | |
| 1033 | 1072 | if ($heading != '') |
| 1034 | 1073 | { |
@@ -1036,7 +1075,9 @@ discard block |
||
| 1036 | 1075 | { |
| 1037 | 1076 | return false; |
| 1038 | 1077 | } |
| 1039 | - } else $heading = 0; |
|
| 1078 | + } else { |
|
| 1079 | + $heading = 0; |
|
| 1080 | + } |
|
| 1040 | 1081 | |
| 1041 | 1082 | if ($groundspeed != '') |
| 1042 | 1083 | { |
@@ -1044,9 +1085,13 @@ discard block |
||
| 1044 | 1085 | { |
| 1045 | 1086 | return false; |
| 1046 | 1087 | } |
| 1047 | - } else $groundspeed = 0; |
|
| 1088 | + } else { |
|
| 1089 | + $groundspeed = 0; |
|
| 1090 | + } |
|
| 1048 | 1091 | date_default_timezone_set('UTC'); |
| 1049 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 1092 | + if ($date == '') { |
|
| 1093 | + $date = date("Y-m-d H:i:s", time()); |
|
| 1094 | + } |
|
| 1050 | 1095 | |
| 1051 | 1096 | |
| 1052 | 1097 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1091,14 +1136,24 @@ discard block |
||
| 1091 | 1136 | $arrival_airport_country = ''; |
| 1092 | 1137 | |
| 1093 | 1138 | |
| 1094 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1095 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1096 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1097 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1139 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
| 1140 | + $squawk = NULL; |
|
| 1141 | + } |
|
| 1142 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
| 1143 | + $verticalrate = NULL; |
|
| 1144 | + } |
|
| 1145 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 1146 | + $groundspeed = 0; |
|
| 1147 | + } |
|
| 1148 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1149 | + $heading = 0; |
|
| 1150 | + } |
|
| 1098 | 1151 | |
| 1099 | 1152 | $query = ''; |
| 1100 | 1153 | if ($globalArchive) { |
| 1101 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 1154 | + if ($globalDebug) { |
|
| 1155 | + echo '-- Delete previous data -- '; |
|
| 1156 | + } |
|
| 1102 | 1157 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
| 1103 | 1158 | } |
| 1104 | 1159 | |
@@ -1115,10 +1170,14 @@ discard block |
||
| 1115 | 1170 | return "error : ".$e->getMessage(); |
| 1116 | 1171 | } |
| 1117 | 1172 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1118 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1173 | + if ($globalDebug) { |
|
| 1174 | + echo '(Add to SBS archive : '; |
|
| 1175 | + } |
|
| 1119 | 1176 | $SpotterArchive = new SpotterArchive($this->db); |
| 1120 | 1177 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
| 1121 | - if ($globalDebug) echo $result.')'; |
|
| 1178 | + if ($globalDebug) { |
|
| 1179 | + echo $result.')'; |
|
| 1180 | + } |
|
| 1122 | 1181 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1123 | 1182 | echo '(Not adding to archive)'; |
| 1124 | 1183 | } elseif ($globalDebug && $noarchive === true) { |
@@ -12,7 +12,9 @@ discard block |
||
| 12 | 12 | public function __construct($dbc = null) { |
| 13 | 13 | $Connection = new Connection($dbc); |
| 14 | 14 | $this->db = $Connection->db(); |
| 15 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 15 | + if ($this->db === null) { |
|
| 16 | + die('Error: No DB connection.'); |
|
| 17 | + } |
|
| 16 | 18 | } |
| 17 | 19 | |
| 18 | 20 | public function get_tle($name) { |
@@ -24,8 +26,11 @@ discard block |
||
| 24 | 26 | echo $e->getMessage(); |
| 25 | 27 | } |
| 26 | 28 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 27 | - if (isset($result[0])) return $result[0]; |
|
| 28 | - else return array(); |
|
| 29 | + if (isset($result[0])) { |
|
| 30 | + return $result[0]; |
|
| 31 | + } else { |
|
| 32 | + return array(); |
|
| 33 | + } |
|
| 29 | 34 | } |
| 30 | 35 | public function get_tle_types() { |
| 31 | 36 | $query = 'SELECT DISTINCT tle_type FROM tle ORDER BY tle_type'; |
@@ -36,8 +41,11 @@ discard block |
||
| 36 | 41 | echo $e->getMessage(); |
| 37 | 42 | } |
| 38 | 43 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 39 | - if (isset($result[0])) return $result; |
|
| 40 | - else return array(); |
|
| 44 | + if (isset($result[0])) { |
|
| 45 | + return $result; |
|
| 46 | + } else { |
|
| 47 | + return array(); |
|
| 48 | + } |
|
| 41 | 49 | } |
| 42 | 50 | public function get_tle_names() { |
| 43 | 51 | $query = 'SELECT DISTINCT tle_name, tle_type FROM tle'; |
@@ -48,8 +56,11 @@ discard block |
||
| 48 | 56 | echo $e->getMessage(); |
| 49 | 57 | } |
| 50 | 58 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 51 | - if (isset($result[0])) return $result; |
|
| 52 | - else return array(); |
|
| 59 | + if (isset($result[0])) { |
|
| 60 | + return $result; |
|
| 61 | + } else { |
|
| 62 | + return array(); |
|
| 63 | + } |
|
| 53 | 64 | } |
| 54 | 65 | public function get_tle_names_type($type) { |
| 55 | 66 | $query = 'SELECT tle_name, tle_type FROM tle WHERE tle_type = :type ORDER BY tle_name'; |
@@ -60,8 +71,11 @@ discard block |
||
| 60 | 71 | echo $e->getMessage(); |
| 61 | 72 | } |
| 62 | 73 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 63 | - if (isset($result[0])) return $result; |
|
| 64 | - else return array(); |
|
| 74 | + if (isset($result[0])) { |
|
| 75 | + return $result; |
|
| 76 | + } else { |
|
| 77 | + return array(); |
|
| 78 | + } |
|
| 65 | 79 | } |
| 66 | 80 | |
| 67 | 81 | public function position_all($timestamp_begin = '',$timestamp_end = '',$second = 10) { |
@@ -95,7 +109,9 @@ discard block |
||
| 95 | 109 | $sat = new Predict_Sat($tle); |
| 96 | 110 | $predict = new Predict(); |
| 97 | 111 | //if ($timestamp == '') $now = Predict_Time::get_current_daynum(); |
| 98 | - if ($timestamp_begin == '') $timestamp_begin = time(); |
|
| 112 | + if ($timestamp_begin == '') { |
|
| 113 | + $timestamp_begin = time(); |
|
| 114 | + } |
|
| 99 | 115 | if ($timestamp_end == '') { |
| 100 | 116 | $now = Predict_Time::unix2daynum($timestamp_begin); |
| 101 | 117 | $predict->predict_calc($sat,$qth,$now); |
@@ -120,8 +136,11 @@ discard block |
||
| 120 | 136 | echo $e->getMessage(); |
| 121 | 137 | } |
| 122 | 138 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 123 | - if (isset($result[0])) return $result[0]; |
|
| 124 | - else return array(); |
|
| 139 | + if (isset($result[0])) { |
|
| 140 | + return $result[0]; |
|
| 141 | + } else { |
|
| 142 | + return array(); |
|
| 143 | + } |
|
| 125 | 144 | } |
| 126 | 145 | |
| 127 | 146 | /** |
@@ -139,7 +158,9 @@ discard block |
||
| 139 | 158 | FROM satellite".$filter_query." satellite.launch_site <> '' AND satellite.launch_site IS NOT NULL"; |
| 140 | 159 | $query_values = array(); |
| 141 | 160 | $query .= " GROUP BY satellite.launch_site ORDER BY launch_site_count DESC"; |
| 142 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 161 | + if ($limit) { |
|
| 162 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 163 | + } |
|
| 143 | 164 | $sth = $this->db->prepare($query); |
| 144 | 165 | $sth->execute($query_values); |
| 145 | 166 | $launch_site_array = array(); |
@@ -168,7 +189,9 @@ discard block |
||
| 168 | 189 | FROM satellite".$filter_query." satellite.owner <> '' AND satellite.owner IS NOT NULL"; |
| 169 | 190 | $query_values = array(); |
| 170 | 191 | $query .= " GROUP BY satellite.owner ORDER BY owner_count DESC"; |
| 171 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 192 | + if ($limit) { |
|
| 193 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 194 | + } |
|
| 172 | 195 | $sth = $this->db->prepare($query); |
| 173 | 196 | $sth->execute($query_values); |
| 174 | 197 | $owner_array = array(); |
@@ -197,7 +220,9 @@ discard block |
||
| 197 | 220 | FROM satellite".$filter_query." satellite.country_owner <> '' AND satellite.country_owner IS NOT NULL"; |
| 198 | 221 | $query_values = array(); |
| 199 | 222 | $query .= " GROUP BY satellite.country_owner ORDER BY country_count DESC"; |
| 200 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
| 223 | + if ($limit) { |
|
| 224 | + $query .= " LIMIT 10 OFFSET 0"; |
|
| 225 | + } |
|
| 201 | 226 | $sth = $this->db->prepare($query); |
| 202 | 227 | $sth->execute($query_values); |
| 203 | 228 | $owner_array = array(); |
@@ -224,20 +249,26 @@ discard block |
||
| 224 | 249 | date_default_timezone_set($globalTimezone); |
| 225 | 250 | $datetime = new DateTime(); |
| 226 | 251 | $offset = $datetime->format('P'); |
| 227 | - } else $offset = '+00:00'; |
|
| 252 | + } else { |
|
| 253 | + $offset = '+00:00'; |
|
| 254 | + } |
|
| 228 | 255 | //$filter_query = $this->getFilter($filters,true,true); |
| 229 | 256 | $filter_query = ' WHERE'; |
| 230 | 257 | if ($globalDBdriver == 'mysql') { |
| 231 | 258 | $query = "SELECT MONTH(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS year_name, count(*) as date_count |
| 232 | 259 | FROM satellite".$filter_query." satellite.launch_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
| 233 | - if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 260 | + if ($sincedate != '') { |
|
| 261 | + $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 262 | + } |
|
| 234 | 263 | $query .= " GROUP BY year_name, month_name |
| 235 | 264 | ORDER BY year_name, month_name ASC"; |
| 236 | 265 | $query_data = array(':offset' => $offset); |
| 237 | 266 | } else { |
| 238 | 267 | $query = "SELECT EXTRACT(MONTH FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS month_name, EXTRACT(YEAR FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count |
| 239 | 268 | FROM satellite".$filter_query." satellite.launch_date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 YEARS'"; |
| 240 | - if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 269 | + if ($sincedate != '') { |
|
| 270 | + $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 271 | + } |
|
| 241 | 272 | $query .= " GROUP BY year_name, month_name |
| 242 | 273 | ORDER BY year_name, month_name ASC"; |
| 243 | 274 | $query_data = array(':offset' => $offset); |
@@ -269,20 +300,26 @@ discard block |
||
| 269 | 300 | date_default_timezone_set($globalTimezone); |
| 270 | 301 | $datetime = new DateTime(); |
| 271 | 302 | $offset = $datetime->format('P'); |
| 272 | - } else $offset = '+00:00'; |
|
| 303 | + } else { |
|
| 304 | + $offset = '+00:00'; |
|
| 305 | + } |
|
| 273 | 306 | //$filter_query = $this->getFilter($filters,true,true); |
| 274 | 307 | $filter_query = ' WHERE'; |
| 275 | 308 | if ($globalDBdriver == 'mysql') { |
| 276 | 309 | $query = "SELECT YEAR(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS year_name, count(*) as date_count |
| 277 | 310 | FROM satellite".$filter_query." satellite.launch_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 YEAR)"; |
| 278 | - if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 311 | + if ($sincedate != '') { |
|
| 312 | + $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 313 | + } |
|
| 279 | 314 | $query .= " GROUP BY year_name |
| 280 | 315 | ORDER BY year_name ASC"; |
| 281 | 316 | $query_data = array(':offset' => $offset); |
| 282 | 317 | } else { |
| 283 | 318 | $query = "SELECT EXTRACT(YEAR FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count |
| 284 | 319 | FROM satellite".$filter_query." satellite.launch_date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '10 YEARS'"; |
| 285 | - if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 320 | + if ($sincedate != '') { |
|
| 321 | + $query .= " AND satellite.launch_date > '".$sincedate."'"; |
|
| 322 | + } |
|
| 286 | 323 | $query .= " GROUP BY year_name |
| 287 | 324 | ORDER BY year_name ASC"; |
| 288 | 325 | $query_data = array(':offset' => $offset); |
@@ -6,7 +6,9 @@ discard block |
||
| 6 | 6 | public function __construct($dbc = null) { |
| 7 | 7 | $Connection = new Connection($dbc); |
| 8 | 8 | $this->db = $Connection->db; |
| 9 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 9 | + if ($this->db === null) { |
|
| 10 | + die('Error: No DB connection.'); |
|
| 11 | + } |
|
| 10 | 12 | } |
| 11 | 13 | |
| 12 | 14 | /** |
@@ -27,7 +29,9 @@ discard block |
||
| 27 | 29 | if (isset($filter[0]['source'])) { |
| 28 | 30 | $filters = array_merge($filters,$filter); |
| 29 | 31 | } |
| 30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 31 | 35 | $filter_query_join = ''; |
| 32 | 36 | $filter_query_where = ''; |
| 33 | 37 | foreach($filters as $flt) { |
@@ -114,8 +118,11 @@ discard block |
||
| 114 | 118 | } |
| 115 | 119 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
| 116 | 120 | } |
| 117 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 118 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 121 | + if ($filter_query_where == '' && $where) { |
|
| 122 | + $filter_query_where = ' WHERE'; |
|
| 123 | + } elseif ($filter_query_where != '' && $and) { |
|
| 124 | + $filter_query_where .= ' AND'; |
|
| 125 | + } |
|
| 119 | 126 | if ($filter_query_where != '') { |
| 120 | 127 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 121 | 128 | } |
@@ -129,10 +136,17 @@ discard block |
||
| 129 | 136 | if ($over_country == '') { |
| 130 | 137 | $Spotter = new Spotter($this->db); |
| 131 | 138 | $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 132 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 133 | - else $country = ''; |
|
| 134 | - } else $country = $over_country; |
|
| 135 | - if ($airline_type === NULL) $airline_type =''; |
|
| 139 | + if (!empty($data_country)) { |
|
| 140 | + $country = $data_country['iso2']; |
|
| 141 | + } else { |
|
| 142 | + $country = ''; |
|
| 143 | + } |
|
| 144 | + } else { |
|
| 145 | + $country = $over_country; |
|
| 146 | + } |
|
| 147 | + if ($airline_type === NULL) { |
|
| 148 | + $airline_type =''; |
|
| 149 | + } |
|
| 136 | 150 | |
| 137 | 151 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 138 | 152 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
@@ -639,7 +653,9 @@ discard block |
||
| 639 | 653 | $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 640 | 654 | $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
| 641 | 655 | $translate = $Translation->ident2icao($q_item); |
| 642 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 656 | + if ($translate != $q_item) { |
|
| 657 | + $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 658 | + } |
|
| 643 | 659 | $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
| 644 | 660 | $additional_query .= ")"; |
| 645 | 661 | } |
@@ -857,7 +873,9 @@ discard block |
||
| 857 | 873 | date_default_timezone_set($globalTimezone); |
| 858 | 874 | $datetime = new DateTime(); |
| 859 | 875 | $offset = $datetime->format('P'); |
| 860 | - } else $offset = '+00:00'; |
|
| 876 | + } else { |
|
| 877 | + $offset = '+00:00'; |
|
| 878 | + } |
|
| 861 | 879 | |
| 862 | 880 | |
| 863 | 881 | if ($date_array[1] != "") |
@@ -1133,9 +1151,13 @@ discard block |
||
| 1133 | 1151 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1134 | 1152 | } |
| 1135 | 1153 | } |
| 1136 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1154 | + if ($sincedate != '') { |
|
| 1155 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1156 | + } |
|
| 1137 | 1157 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1138 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1158 | + if ($limit) { |
|
| 1159 | + $query .= " LIMIT 0,10"; |
|
| 1160 | + } |
|
| 1139 | 1161 | |
| 1140 | 1162 | |
| 1141 | 1163 | $sth = $this->db->prepare($query); |
@@ -1179,9 +1201,13 @@ discard block |
||
| 1179 | 1201 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1180 | 1202 | } |
| 1181 | 1203 | } |
| 1182 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1204 | + if ($sincedate != '') { |
|
| 1205 | + $query .= "AND s.date > '".$sincedate."' "; |
|
| 1206 | + } |
|
| 1183 | 1207 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1184 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1208 | + if ($limit) { |
|
| 1209 | + $query .= " LIMIT 0,10"; |
|
| 1210 | + } |
|
| 1185 | 1211 | |
| 1186 | 1212 | |
| 1187 | 1213 | $sth = $this->db->prepare($query); |
@@ -7,7 +7,9 @@ discard block |
||
| 7 | 7 | public function __construct($dbc = null) { |
| 8 | 8 | $Connection = new Connection($dbc); |
| 9 | 9 | $this->db = $Connection->db; |
| 10 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 10 | + if ($this->db === null) { |
|
| 11 | + die('Error: No DB connection.'); |
|
| 12 | + } |
|
| 11 | 13 | } |
| 12 | 14 | |
| 13 | 15 | /** |
@@ -20,20 +22,27 @@ discard block |
||
| 20 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 21 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 22 | 24 | foreach($globalStatsFilters[$globalFilterName] as $source) { |
| 23 | - if (isset($source['source'])) $filter['source'][] = $source['source']; |
|
| 25 | + if (isset($source['source'])) { |
|
| 26 | + $filter['source'][] = $source['source']; |
|
| 27 | + } |
|
| 24 | 28 | } |
| 25 | 29 | } else { |
| 26 | 30 | $filter = $globalStatsFilters[$globalFilterName]; |
| 27 | 31 | } |
| 28 | 32 | } |
| 29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 33 | + if (is_array($globalFilter)) { |
|
| 34 | + $filter = array_merge($filter,$globalFilter); |
|
| 35 | + } |
|
| 30 | 36 | $filter_query_join = ''; |
| 31 | 37 | $filter_query_where = ''; |
| 32 | 38 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 33 | 39 | $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
| 34 | 40 | } |
| 35 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 36 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 41 | + if ($filter_query_where == '' && $where) { |
|
| 42 | + $filter_query_where = ' WHERE'; |
|
| 43 | + } elseif ($filter_query_where != '' && $and) { |
|
| 44 | + $filter_query_where .= ' AND'; |
|
| 45 | + } |
|
| 37 | 46 | $filter_query = $filter_query_join.$filter_query_where; |
| 38 | 47 | return $filter_query; |
| 39 | 48 | } |
@@ -90,7 +99,9 @@ discard block |
||
| 90 | 99 | $info = str_replace('^','<br />',$info); |
| 91 | 100 | $info = str_replace('&sect;','',$info); |
| 92 | 101 | $info = str_replace('"','',$info); |
| 93 | - if ($type == '') $type = NULL; |
|
| 102 | + if ($type == '') { |
|
| 103 | + $type = NULL; |
|
| 104 | + } |
|
| 94 | 105 | $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)"; |
| 95 | 106 | $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); |
| 96 | 107 | try { |
@@ -106,7 +117,9 @@ discard block |
||
| 106 | 117 | $info = str_replace('^','<br />',$info); |
| 107 | 118 | $info = str_replace('&sect;','',$info); |
| 108 | 119 | $info = str_replace('"','',$info); |
| 109 | - if ($type == '') $type = NULL; |
|
| 120 | + if ($type == '') { |
|
| 121 | + $type = NULL; |
|
| 122 | + } |
|
| 110 | 123 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
| 111 | 124 | $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); |
| 112 | 125 | try { |
@@ -6,7 +6,9 @@ discard block |
||
| 6 | 6 | public function __construct($dbc = null) { |
| 7 | 7 | $Connection = new Connection($dbc); |
| 8 | 8 | $this->db = $Connection->db; |
| 9 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 9 | + if ($this->db === null) { |
|
| 10 | + die('Error: No DB connection.'); |
|
| 11 | + } |
|
| 10 | 12 | } |
| 11 | 13 | |
| 12 | 14 | /** |
@@ -27,7 +29,9 @@ discard block |
||
| 27 | 29 | if (isset($filter[0]['source'])) { |
| 28 | 30 | $filters = array_merge($filters,$filter); |
| 29 | 31 | } |
| 30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 32 | + if (is_array($globalFilter)) { |
|
| 33 | + $filter = array_merge($filter,$globalFilter); |
|
| 34 | + } |
|
| 31 | 35 | $filter_query_join = ''; |
| 32 | 36 | $filter_query_where = ''; |
| 33 | 37 | foreach($filters as $flt) { |
@@ -73,8 +77,11 @@ discard block |
||
| 73 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 74 | 78 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 75 | 79 | } |
| 76 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 77 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 80 | + if ($filter_query_where == '' && $where) { |
|
| 81 | + $filter_query_where = ' WHERE'; |
|
| 82 | + } elseif ($filter_query_where != '' && $and) { |
|
| 83 | + $filter_query_where .= ' AND'; |
|
| 84 | + } |
|
| 78 | 85 | if ($filter_query_where != '') { |
| 79 | 86 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 80 | 87 | } |
@@ -88,9 +95,14 @@ discard block |
||
| 88 | 95 | if ($over_country == '') { |
| 89 | 96 | $Marine = new Marine($this->db); |
| 90 | 97 | $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 91 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 92 | - else $country = ''; |
|
| 93 | - } else $country = $over_country; |
|
| 98 | + if (!empty($data_country)) { |
|
| 99 | + $country = $data_country['iso2']; |
|
| 100 | + } else { |
|
| 101 | + $country = ''; |
|
| 102 | + } |
|
| 103 | + } else { |
|
| 104 | + $country = $over_country; |
|
| 105 | + } |
|
| 94 | 106 | |
| 95 | 107 | //$country = $over_country; |
| 96 | 108 | // Route is not added in marine_archive |
@@ -593,7 +605,9 @@ discard block |
||
| 593 | 605 | $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 594 | 606 | $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
| 595 | 607 | $translate = $Translation->ident2icao($q_item); |
| 596 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
| 608 | + if ($translate != $q_item) { |
|
| 609 | + $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
| 610 | + } |
|
| 597 | 611 | $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
| 598 | 612 | $additional_query .= ")"; |
| 599 | 613 | } |
@@ -811,7 +825,9 @@ discard block |
||
| 811 | 825 | date_default_timezone_set($globalTimezone); |
| 812 | 826 | $datetime = new DateTime(); |
| 813 | 827 | $offset = $datetime->format('P'); |
| 814 | - } else $offset = '+00:00'; |
|
| 828 | + } else { |
|
| 829 | + $offset = '+00:00'; |
|
| 830 | + } |
|
| 815 | 831 | |
| 816 | 832 | |
| 817 | 833 | if ($date_array[1] != "") |
@@ -1087,9 +1103,13 @@ discard block |
||
| 1087 | 1103 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1088 | 1104 | } |
| 1089 | 1105 | } |
| 1090 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 1106 | + if ($sincedate != '') { |
|
| 1107 | + $query .= "AND date > '".$sincedate."' "; |
|
| 1108 | + } |
|
| 1091 | 1109 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1092 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1110 | + if ($limit) { |
|
| 1111 | + $query .= " LIMIT 0,10"; |
|
| 1112 | + } |
|
| 1093 | 1113 | |
| 1094 | 1114 | |
| 1095 | 1115 | $sth = $this->db->prepare($query); |
@@ -1133,9 +1153,13 @@ discard block |
||
| 1133 | 1153 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 1134 | 1154 | } |
| 1135 | 1155 | } |
| 1136 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
| 1156 | + if ($sincedate != '') { |
|
| 1157 | + $query .= "AND s.date > '".$sincedate."' "; |
|
| 1158 | + } |
|
| 1137 | 1159 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 1138 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 1160 | + if ($limit) { |
|
| 1161 | + $query .= " LIMIT 0,10"; |
|
| 1162 | + } |
|
| 1139 | 1163 | |
| 1140 | 1164 | |
| 1141 | 1165 | $sth = $this->db->prepare($query); |
@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | public function __construct($dbc = null) { |
| 9 | 9 | $Connection = new Connection($dbc); |
| 10 | 10 | $this->db = $Connection->db(); |
| 11 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 11 | + if ($this->db === null) { |
|
| 12 | + die('Error: No DB connection.'); |
|
| 13 | + } |
|
| 12 | 14 | } |
| 13 | 15 | |
| 14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
| 30 | 32 | if (isset($filter[0]['source'])) { |
| 31 | 33 | $filters = array_merge($filters,$filter); |
| 32 | 34 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 35 | + if (is_array($globalFilter)) { |
|
| 36 | + $filter = array_merge($filter,$globalFilter); |
|
| 37 | + } |
|
| 34 | 38 | $filter_query_join = ''; |
| 35 | 39 | $filter_query_where = ''; |
| 36 | 40 | foreach($filters as $flt) { |
@@ -77,8 +81,11 @@ discard block |
||
| 77 | 81 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 78 | 82 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 79 | 83 | } |
| 80 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 81 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 84 | + if ($filter_query_where == '' && $where) { |
|
| 85 | + $filter_query_where = ' WHERE'; |
|
| 86 | + } elseif ($filter_query_where != '' && $and) { |
|
| 87 | + $filter_query_where .= ' AND'; |
|
| 88 | + } |
|
| 82 | 89 | if ($filter_query_where != '') { |
| 83 | 90 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 84 | 91 | } |
@@ -120,7 +127,9 @@ discard block |
||
| 120 | 127 | } |
| 121 | 128 | } |
| 122 | 129 | |
| 123 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 130 | + if (!isset($globalLiveInterval)) { |
|
| 131 | + $globalLiveInterval = '200'; |
|
| 132 | + } |
|
| 124 | 133 | if ($globalDBdriver == 'mysql') { |
| 125 | 134 | //$query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate"; |
| 126 | 135 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -145,7 +154,9 @@ discard block |
||
| 145 | 154 | |
| 146 | 155 | $filter_query = $this->getFilter($filter,true,true); |
| 147 | 156 | |
| 148 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 157 | + if (!isset($globalLiveInterval)) { |
|
| 158 | + $globalLiveInterval = '200'; |
|
| 159 | + } |
|
| 149 | 160 | if ($globalDBdriver == 'mysql') { |
| 150 | 161 | $query = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 151 | 162 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0"; |
@@ -183,7 +194,9 @@ discard block |
||
| 183 | 194 | |
| 184 | 195 | $filter_query = $this->getFilter($filter,true,true); |
| 185 | 196 | |
| 186 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 197 | + if (!isset($globalLiveInterval)) { |
|
| 198 | + $globalLiveInterval = '200'; |
|
| 199 | + } |
|
| 187 | 200 | if ($globalDBdriver == 'mysql') { |
| 188 | 201 | if (isset($globalArchive) && $globalArchive) { |
| 189 | 202 | $query = "SELECT * FROM ( |
@@ -241,7 +254,9 @@ discard block |
||
| 241 | 254 | global $globalDBdriver, $globalLiveInterval; |
| 242 | 255 | $filter_query = $this->getFilter($filter,true,true); |
| 243 | 256 | |
| 244 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 257 | + if (!isset($globalLiveInterval)) { |
|
| 258 | + $globalLiveInterval = '200'; |
|
| 259 | + } |
|
| 245 | 260 | if ($globalDBdriver == 'mysql') { |
| 246 | 261 | $query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
| 247 | 262 | } else { |
@@ -269,7 +284,9 @@ discard block |
||
| 269 | 284 | { |
| 270 | 285 | global $globalDBdriver, $globalLiveInterval; |
| 271 | 286 | $Spotter = new Spotter($this->db); |
| 272 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 287 | + if (!isset($globalLiveInterval)) { |
|
| 288 | + $globalLiveInterval = '200'; |
|
| 289 | + } |
|
| 273 | 290 | $filter_query = $this->getFilter($filter); |
| 274 | 291 | |
| 275 | 292 | if (is_array($coord)) { |
@@ -277,7 +294,9 @@ discard block |
||
| 277 | 294 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 278 | 295 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 279 | 296 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 280 | - } else return array(); |
|
| 297 | + } else { |
|
| 298 | + return array(); |
|
| 299 | + } |
|
| 281 | 300 | if ($globalDBdriver == 'mysql') { |
| 282 | 301 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
| 283 | 302 | } else { |
@@ -297,7 +316,9 @@ discard block |
||
| 297 | 316 | { |
| 298 | 317 | global $globalDBdriver, $globalLiveInterval; |
| 299 | 318 | $Spotter = new Spotter($this->db); |
| 300 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 319 | + if (!isset($globalLiveInterval)) { |
|
| 320 | + $globalLiveInterval = '200'; |
|
| 321 | + } |
|
| 301 | 322 | $filter_query = $this->getFilter($filter); |
| 302 | 323 | |
| 303 | 324 | if (is_array($coord)) { |
@@ -305,7 +326,9 @@ discard block |
||
| 305 | 326 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 306 | 327 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 307 | 328 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 308 | - } else return array(); |
|
| 329 | + } else { |
|
| 330 | + return array(); |
|
| 331 | + } |
|
| 309 | 332 | if ($globalDBdriver == 'mysql') { |
| 310 | 333 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
| 311 | 334 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
@@ -498,11 +521,15 @@ discard block |
||
| 498 | 521 | //$query = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date'; |
| 499 | 522 | if ($globalDBdriver == 'mysql') { |
| 500 | 523 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 501 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 524 | + if ($liveinterval) { |
|
| 525 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 526 | + } |
|
| 502 | 527 | $query .= ' ORDER BY date'; |
| 503 | 528 | } else { |
| 504 | 529 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
| 505 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 530 | + if ($liveinterval) { |
|
| 531 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 532 | + } |
|
| 506 | 533 | $query .= ' ORDER BY date'; |
| 507 | 534 | } |
| 508 | 535 | |
@@ -597,7 +624,9 @@ discard block |
||
| 597 | 624 | $i++; |
| 598 | 625 | $j++; |
| 599 | 626 | if ($j == 30) { |
| 600 | - if ($globalDebug) echo "."; |
|
| 627 | + if ($globalDebug) { |
|
| 628 | + echo "."; |
|
| 629 | + } |
|
| 601 | 630 | try { |
| 602 | 631 | |
| 603 | 632 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -844,7 +873,9 @@ discard block |
||
| 844 | 873 | { |
| 845 | 874 | return false; |
| 846 | 875 | } |
| 847 | - } else return ''; |
|
| 876 | + } else { |
|
| 877 | + return ''; |
|
| 878 | + } |
|
| 848 | 879 | |
| 849 | 880 | if ($longitude != '') |
| 850 | 881 | { |
@@ -852,7 +883,9 @@ discard block |
||
| 852 | 883 | { |
| 853 | 884 | return false; |
| 854 | 885 | } |
| 855 | - } else return ''; |
|
| 886 | + } else { |
|
| 887 | + return ''; |
|
| 888 | + } |
|
| 856 | 889 | |
| 857 | 890 | if ($altitude != '') |
| 858 | 891 | { |
@@ -860,7 +893,9 @@ discard block |
||
| 860 | 893 | { |
| 861 | 894 | return false; |
| 862 | 895 | } |
| 863 | - } else $altitude = 0; |
|
| 896 | + } else { |
|
| 897 | + $altitude = 0; |
|
| 898 | + } |
|
| 864 | 899 | |
| 865 | 900 | if ($heading != '') |
| 866 | 901 | { |
@@ -868,7 +903,9 @@ discard block |
||
| 868 | 903 | { |
| 869 | 904 | return false; |
| 870 | 905 | } |
| 871 | - } else $heading = 0; |
|
| 906 | + } else { |
|
| 907 | + $heading = 0; |
|
| 908 | + } |
|
| 872 | 909 | |
| 873 | 910 | if ($groundspeed != '') |
| 874 | 911 | { |
@@ -876,9 +913,13 @@ discard block |
||
| 876 | 913 | { |
| 877 | 914 | return false; |
| 878 | 915 | } |
| 879 | - } else $groundspeed = 0; |
|
| 916 | + } else { |
|
| 917 | + $groundspeed = 0; |
|
| 918 | + } |
|
| 880 | 919 | date_default_timezone_set('UTC'); |
| 881 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 920 | + if ($date == '') { |
|
| 921 | + $date = date("Y-m-d H:i:s", time()); |
|
| 922 | + } |
|
| 882 | 923 | |
| 883 | 924 | |
| 884 | 925 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
@@ -894,12 +935,18 @@ discard block |
||
| 894 | 935 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
| 895 | 936 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
| 896 | 937 | |
| 897 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 898 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 938 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 939 | + $groundspeed = 0; |
|
| 940 | + } |
|
| 941 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 942 | + $heading = 0; |
|
| 943 | + } |
|
| 899 | 944 | |
| 900 | 945 | $query = ''; |
| 901 | 946 | if ($globalArchive) { |
| 902 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 947 | + if ($globalDebug) { |
|
| 948 | + echo '-- Delete previous data -- '; |
|
| 949 | + } |
|
| 903 | 950 | $query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;'; |
| 904 | 951 | } |
| 905 | 952 | $query .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
@@ -918,10 +965,14 @@ discard block |
||
| 918 | 965 | echo 'noarchive : '.$noarchive."\n"; |
| 919 | 966 | */ |
| 920 | 967 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 921 | - if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
| 968 | + if ($globalDebug) { |
|
| 969 | + echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
| 970 | + } |
|
| 922 | 971 | $TrackerArchive = new TrackerArchive($this->db); |
| 923 | 972 | $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
| 924 | - if ($globalDebug) echo $result.')'; |
|
| 973 | + if ($globalDebug) { |
|
| 974 | + echo $result.')'; |
|
| 975 | + } |
|
| 925 | 976 | } |
| 926 | 977 | |
| 927 | 978 | return "success"; |