@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | if (!isset($filter_name)) $filter_name = ''; |
22 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
22 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
23 | 23 | if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) { |
24 | 24 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
25 | 25 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | $title = _("Statistics"); |
35 | 35 | } |
36 | 36 | |
37 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
38 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
37 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
38 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
39 | 39 | |
40 | 40 | require_once('header.php'); |
41 | 41 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | date_default_timezone_set('UTC'); |
63 | 63 | $lastupdate = strtotime($last_update[0]['value']); |
64 | 64 | if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone); |
65 | - print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>'; |
|
65 | + print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>'; |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | ?> |
@@ -74,30 +74,30 @@ discard block |
||
74 | 74 | <?php |
75 | 75 | if ($type == 'aircraft') { |
76 | 76 | ?> |
77 | - <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span> |
|
78 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
79 | - <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span> |
|
80 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
77 | + <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span> |
|
78 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
79 | + <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span> |
|
80 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
81 | 81 | <?php |
82 | - if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) { |
|
82 | + if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) { |
|
83 | 83 | ?> |
84 | - <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span> |
|
85 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
84 | + <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span> |
|
85 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
86 | 86 | <?php |
87 | 87 | } else { |
88 | 88 | ?> |
89 | - <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span> |
|
90 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
89 | + <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span> |
|
90 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
91 | 91 | <?php |
92 | 92 | } |
93 | 93 | ?> |
94 | - <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span> |
|
95 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
94 | + <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span> |
|
95 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
96 | 96 | <?php |
97 | 97 | if ($airline_icao == '') { |
98 | 98 | ?> |
99 | - <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span> |
|
100 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
99 | + <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span> |
|
100 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
101 | 101 | <?php |
102 | 102 | } |
103 | 103 | ?> |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) { |
106 | 106 | if ($airline_icao == '' || $airline_icao == 'all') { |
107 | 107 | ?> |
108 | - <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span> |
|
109 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
108 | + <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span> |
|
109 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
110 | 110 | <?php |
111 | 111 | } |
112 | 112 | } |
@@ -114,22 +114,22 @@ discard block |
||
114 | 114 | <?php |
115 | 115 | } elseif ($type == 'marine') { |
116 | 116 | ?> |
117 | - <span><span class="badge"><?php print number_format($Marine->countOverallMarine($filter_name,$year,$month)); ?></span> <?php echo _("Vessels"); ?></span> |
|
118 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
119 | - <span><span class="badge"><?php print number_format($Marine->countOverallMarineTypes($filter_name,$year,$month)); ?></span> <?php echo _("Types"); ?></span> |
|
120 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
117 | + <span><span class="badge"><?php print number_format($Marine->countOverallMarine($filter_name, $year, $month)); ?></span> <?php echo _("Vessels"); ?></span> |
|
118 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
119 | + <span><span class="badge"><?php print number_format($Marine->countOverallMarineTypes($filter_name, $year, $month)); ?></span> <?php echo _("Types"); ?></span> |
|
120 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
121 | 121 | <?php |
122 | 122 | } elseif ($type == 'tracker') { |
123 | 123 | ?> |
124 | - <span><span class="badge"><?php print number_format($Tracker->countOverallTracker($filter_name,$year,$month)); ?></span> <?php echo _("Trackers"); ?></span> |
|
125 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
126 | - <span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes($filter_name,$year,$month)); ?></span> <?php echo _("Types"); ?></span> |
|
127 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
124 | + <span><span class="badge"><?php print number_format($Tracker->countOverallTracker($filter_name, $year, $month)); ?></span> <?php echo _("Trackers"); ?></span> |
|
125 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
126 | + <span><span class="badge"><?php print number_format($Tracker->countOverallTrackerTypes($filter_name, $year, $month)); ?></span> <?php echo _("Types"); ?></span> |
|
127 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
128 | 128 | <?php |
129 | 129 | } |
130 | 130 | ?> |
131 | 131 | </p> |
132 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
132 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
133 | 133 | <div class="specific-stats"> |
134 | 134 | <?php |
135 | 135 | if ($type == 'aircraft') { |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | <div class="col-md-6"> |
139 | 139 | <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2> |
140 | 140 | <?php |
141 | - $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month); |
|
141 | + $aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month); |
|
142 | 142 | if (count($aircraft_array) == 0) print _("No data available"); |
143 | 143 | else { |
144 | 144 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
145 | 145 | $aircraft_data = ''; |
146 | - foreach($aircraft_array as $aircraft_item) |
|
146 | + foreach ($aircraft_array as $aircraft_item) |
|
147 | 147 | { |
148 | 148 | $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
149 | 149 | } |
@@ -172,17 +172,17 @@ discard block |
||
172 | 172 | ?> |
173 | 173 | </div> |
174 | 174 | </div> |
175 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
175 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
176 | 176 | <?php |
177 | 177 | // echo $airline_icao; |
178 | 178 | if ($airline_icao == '' || $airline_icao == 'all') { |
179 | - $airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month); |
|
179 | + $airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month); |
|
180 | 180 | if (count($airline_array) > 0) { |
181 | 181 | print '<div class="col-md-6">'; |
182 | 182 | print '<h2>'._("Top 10 Most Common Airline").'</h2>'; |
183 | 183 | print '<div id="chart2" class="chart" width="100%"></div><script>'; |
184 | 184 | $airline_data = ''; |
185 | - foreach($airline_array as $airline_item) |
|
185 | + foreach ($airline_array as $airline_item) |
|
186 | 186 | { |
187 | 187 | $airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],'; |
188 | 188 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | } |
209 | 209 | ?> |
210 | 210 | </div> |
211 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
211 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
212 | 212 | <?php |
213 | 213 | } |
214 | 214 | ?> |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | else { |
228 | 228 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
229 | 229 | $marine_data = ''; |
230 | - foreach($marine_array as $marine_item) |
|
230 | + foreach ($marine_array as $marine_item) |
|
231 | 231 | { |
232 | 232 | $marine_data .= '["'.$marine_item['marine_type'].'",'.$marine_item['marine_type_count'].'],'; |
233 | 233 | } |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | ?> |
259 | 259 | </div> |
260 | 260 | </div> |
261 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
261 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
262 | 262 | <!-- </div>--> |
263 | 263 | <?php |
264 | 264 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | else { |
276 | 276 | print '<div id="chart1" class="chart" width="100%"></div><script>'; |
277 | 277 | $tracker_data = ''; |
278 | - foreach($tracker_array as $tracker_item) |
|
278 | + foreach ($tracker_array as $tracker_item) |
|
279 | 279 | { |
280 | 280 | $tracker_data .= '["'.$tracker_item['tracker_type'].'",'.$tracker_item['tracker_type_count'].'],'; |
281 | 281 | } |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | ?> |
307 | 307 | </div> |
308 | 308 | </div> |
309 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
309 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
310 | 310 | <!-- </div>--> |
311 | 311 | <?php |
312 | 312 | } |
@@ -316,8 +316,8 @@ discard block |
||
316 | 316 | ?> |
317 | 317 | <div class="row column"> |
318 | 318 | <?php |
319 | - $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month); |
|
320 | - if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) { |
|
319 | + $flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month); |
|
320 | + if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) { |
|
321 | 321 | if (empty($flightover_array)) { |
322 | 322 | print '<div class="col-md-12">'; |
323 | 323 | } else { |
@@ -326,12 +326,12 @@ discard block |
||
326 | 326 | ?> |
327 | 327 | <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2> |
328 | 328 | <?php |
329 | - $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month); |
|
329 | + $pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month); |
|
330 | 330 | if (count($pilot_array) == 0) print _("No data available"); |
331 | 331 | else { |
332 | 332 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
333 | 333 | $pilot_data = ''; |
334 | - foreach($pilot_array as $pilot_item) |
|
334 | + foreach ($pilot_array as $pilot_item) |
|
335 | 335 | { |
336 | 336 | $pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],'; |
337 | 337 | } |
@@ -353,19 +353,19 @@ discard block |
||
353 | 353 | ?> |
354 | 354 | </div> |
355 | 355 | |
356 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
356 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
357 | 357 | <?php |
358 | 358 | } else { |
359 | 359 | ?> |
360 | 360 | <div class="col-md-6"> |
361 | 361 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
362 | 362 | <?php |
363 | - $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month); |
|
363 | + $owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month); |
|
364 | 364 | if (count($owner_array) == 0) print _("No data available"); |
365 | 365 | else { |
366 | 366 | print '<div id="chart7" class="chart" width="100%"></div><script>'; |
367 | 367 | $owner_data = ''; |
368 | - foreach($owner_array as $owner_item) |
|
368 | + foreach ($owner_array as $owner_item) |
|
369 | 369 | { |
370 | 370 | $owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],'; |
371 | 371 | } |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | </div> |
386 | 386 | </div> |
387 | 387 | |
388 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
388 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
389 | 389 | <?php |
390 | 390 | } |
391 | 391 | if (!empty($flightover_array)) { |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
400 | 400 | print 'var series = ['; |
401 | 401 | $flightover_data = ''; |
402 | - foreach($flightover_array as $flightover_item) |
|
402 | + foreach ($flightover_array as $flightover_item) |
|
403 | 403 | { |
404 | 404 | $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],'; |
405 | 405 | } |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | } |
446 | 446 | ?> |
447 | 447 | </div> |
448 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
448 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
449 | 449 | |
450 | 450 | |
451 | 451 | </div> |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
466 | 466 | print 'var series = ['; |
467 | 467 | $flightover_data = ''; |
468 | - foreach($flightover_array as $flightover_item) |
|
468 | + foreach ($flightover_array as $flightover_item) |
|
469 | 469 | { |
470 | 470 | $flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],'; |
471 | 471 | } |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | print '<div id="chart10" class="chart" width="100%"></div><script>'; |
526 | 526 | print 'var series = ['; |
527 | 527 | $flightover_data = ''; |
528 | - foreach($flightover_array as $flightover_item) |
|
528 | + foreach ($flightover_array as $flightover_item) |
|
529 | 529 | { |
530 | 530 | $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],'; |
531 | 531 | } |
@@ -578,14 +578,14 @@ discard block |
||
578 | 578 | <div class="row column"> |
579 | 579 | <div class="col-md-6"> |
580 | 580 | <?php |
581 | - $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month); |
|
581 | + $airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month); |
|
582 | 582 | if (count($airport_airport_array) > 0) { |
583 | 583 | print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>'; |
584 | 584 | print '<div id="chart3" class="chart" width="100%"></div><script>'; |
585 | 585 | print "\n"; |
586 | 586 | print 'var series = ['; |
587 | 587 | $airport_data = ''; |
588 | - foreach($airport_airport_array as $airport_item) |
|
588 | + foreach ($airport_airport_array as $airport_item) |
|
589 | 589 | { |
590 | 590 | $airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],'; |
591 | 591 | } |
@@ -636,18 +636,18 @@ discard block |
||
636 | 636 | } |
637 | 637 | ?> |
638 | 638 | </div> |
639 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
639 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
640 | 640 | |
641 | 641 | <div class="col-md-6"> |
642 | 642 | <?php |
643 | - $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month); |
|
643 | + $airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month); |
|
644 | 644 | if (count($airport_airport_array2) > 0) { |
645 | 645 | print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>'; |
646 | 646 | print '<div id="chart4" class="chart" width="100%"></div><script>'; |
647 | 647 | print "\n"; |
648 | 648 | print 'var series = ['; |
649 | 649 | $airport_data = ''; |
650 | - foreach($airport_airport_array2 as $airport_item) |
|
650 | + foreach ($airport_airport_array2 as $airport_item) |
|
651 | 651 | { |
652 | 652 | $airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],'; |
653 | 653 | } |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | ?> |
700 | 700 | </div> |
701 | 701 | </div> |
702 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
702 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
703 | 703 | <?php |
704 | 704 | } |
705 | 705 | ?> |
@@ -713,19 +713,19 @@ discard block |
||
713 | 713 | <div class="col-md-6"> |
714 | 714 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
715 | 715 | <?php |
716 | - $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
|
716 | + $year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name); |
|
717 | 717 | if (count($year_array) == 0) print _("No data available"); |
718 | 718 | else { |
719 | 719 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
720 | 720 | $year_data = ''; |
721 | 721 | $year_cnt = ''; |
722 | - foreach($year_array as $year_item) |
|
722 | + foreach ($year_array as $year_item) |
|
723 | 723 | { |
724 | 724 | $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",'; |
725 | 725 | $year_cnt .= $year_item['date_count'].','; |
726 | 726 | } |
727 | 727 | $year_data = "['x',".substr($year_data, 0, -1)."]"; |
728 | - $year_cnt = "['flights',".substr($year_cnt,0,-1)."]"; |
|
728 | + $year_cnt = "['flights',".substr($year_cnt, 0, -1)."]"; |
|
729 | 729 | print 'c3.generate({ |
730 | 730 | bindto: "#chart8", |
731 | 731 | data: { x: "x", |
@@ -738,23 +738,23 @@ discard block |
||
738 | 738 | <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> |
739 | 739 | </div> |
740 | 740 | </div> |
741 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
741 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
742 | 742 | <div class="col-md-6"> |
743 | 743 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
744 | 744 | <?php |
745 | - $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
|
745 | + $month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name); |
|
746 | 746 | if (count($month_array) == 0) print _("No data available"); |
747 | 747 | else { |
748 | 748 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
749 | 749 | $month_data = ''; |
750 | 750 | $month_cnt = ''; |
751 | - foreach($month_array as $month_item) |
|
751 | + foreach ($month_array as $month_item) |
|
752 | 752 | { |
753 | 753 | $month_data .= '"'.$month_item['date_name'].'",'; |
754 | 754 | $month_cnt .= $month_item['date_count'].','; |
755 | 755 | } |
756 | 756 | $month_data = "['x',".substr($month_data, 0, -1)."]"; |
757 | - $month_cnt = "['flights',".substr($month_cnt,0,-1)."]"; |
|
757 | + $month_cnt = "['flights',".substr($month_cnt, 0, -1)."]"; |
|
758 | 758 | print 'c3.generate({ |
759 | 759 | bindto: "#chart9", |
760 | 760 | data: { x: "x", |
@@ -767,24 +767,24 @@ discard block |
||
767 | 767 | <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> |
768 | 768 | </div> |
769 | 769 | </div> |
770 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
770 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
771 | 771 | |
772 | 772 | <div class="col-md-6"> |
773 | 773 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
774 | 774 | <?php |
775 | - $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
|
775 | + $date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name); |
|
776 | 776 | if (empty($date_array)) print _("No data available"); |
777 | 777 | else { |
778 | 778 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
779 | 779 | $date_data = ''; |
780 | 780 | $date_cnt = ''; |
781 | - foreach($date_array as $date_item) |
|
781 | + foreach ($date_array as $date_item) |
|
782 | 782 | { |
783 | 783 | $date_data .= '"'.$date_item['date_name'].'",'; |
784 | 784 | $date_cnt .= $date_item['date_count'].','; |
785 | 785 | } |
786 | 786 | $date_data = "['x',".substr($date_data, 0, -1)."]"; |
787 | - $date_cnt = "['flights',".substr($date_cnt,0,-1)."]"; |
|
787 | + $date_cnt = "['flights',".substr($date_cnt, 0, -1)."]"; |
|
788 | 788 | print 'c3.generate({ |
789 | 789 | bindto: "#chart5", |
790 | 790 | data: { x: "x", |
@@ -797,23 +797,23 @@ discard block |
||
797 | 797 | <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> |
798 | 798 | </div> |
799 | 799 | </div> |
800 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
800 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
801 | 801 | <div class="col-md-6"> |
802 | 802 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
803 | 803 | <?php |
804 | - $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
|
804 | + $hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name); |
|
805 | 805 | if (empty($hour_array)) print _("No data available"); |
806 | 806 | else { |
807 | 807 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
808 | 808 | $hour_data = ''; |
809 | 809 | $hour_cnt = ''; |
810 | - foreach($hour_array as $hour_item) |
|
810 | + foreach ($hour_array as $hour_item) |
|
811 | 811 | { |
812 | 812 | $hour_data .= '"'.$hour_item['hour_name'].':00",'; |
813 | 813 | $hour_cnt .= $hour_item['hour_count'].','; |
814 | 814 | } |
815 | 815 | $hour_data = "[".substr($hour_data, 0, -1)."]"; |
816 | - $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]"; |
|
816 | + $hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]"; |
|
817 | 817 | print 'c3.generate({ |
818 | 818 | bindto: "#chart6", |
819 | 819 | data: { |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | <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> |
827 | 827 | </div> |
828 | 828 | </div> |
829 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
829 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
830 | 830 | </div> |
831 | 831 | <?php |
832 | 832 | } |
@@ -844,19 +844,19 @@ discard block |
||
844 | 844 | <div class="col-md-6"> |
845 | 845 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
846 | 846 | <?php |
847 | - $year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
|
847 | + $year_array = $Marine->countAllMonthsLastYear(true, $airline_icao, $filter_name); |
|
848 | 848 | if (count($year_array) == 0) print _("No data available"); |
849 | 849 | else { |
850 | 850 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
851 | 851 | $year_data = ''; |
852 | 852 | $year_cnt = ''; |
853 | - foreach($year_array as $year_item) |
|
853 | + foreach ($year_array as $year_item) |
|
854 | 854 | { |
855 | 855 | $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",'; |
856 | 856 | $year_cnt .= $year_item['date_count'].','; |
857 | 857 | } |
858 | 858 | $year_data = "['x',".substr($year_data, 0, -1)."]"; |
859 | - $year_cnt = "['vessels',".substr($year_cnt,0,-1)."]"; |
|
859 | + $year_cnt = "['vessels',".substr($year_cnt, 0, -1)."]"; |
|
860 | 860 | print 'c3.generate({ |
861 | 861 | bindto: "#chart8", |
862 | 862 | data: { x: "x", |
@@ -870,23 +870,23 @@ discard block |
||
870 | 870 | </div> |
871 | 871 | </div> |
872 | 872 | |
873 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
873 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
874 | 874 | <div class="col-md-6"> |
875 | 875 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
876 | 876 | <?php |
877 | - $month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name); |
|
877 | + $month_array = $Marine->countAllDatesLastMonth($airline_icao, $filter_name); |
|
878 | 878 | if (count($month_array) == 0) print _("No data available"); |
879 | 879 | else { |
880 | 880 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
881 | 881 | $month_data = ''; |
882 | 882 | $month_cnt = ''; |
883 | - foreach($month_array as $month_item) |
|
883 | + foreach ($month_array as $month_item) |
|
884 | 884 | { |
885 | 885 | $month_data .= '"'.$month_item['date_name'].'",'; |
886 | 886 | $month_cnt .= $month_item['date_count'].','; |
887 | 887 | } |
888 | 888 | $month_data = "['x',".substr($month_data, 0, -1)."]"; |
889 | - $month_cnt = "['vessels',".substr($month_cnt,0,-1)."]"; |
|
889 | + $month_cnt = "['vessels',".substr($month_cnt, 0, -1)."]"; |
|
890 | 890 | print 'c3.generate({ |
891 | 891 | bindto: "#chart9", |
892 | 892 | data: { x: "x", |
@@ -899,24 +899,24 @@ discard block |
||
899 | 899 | <a href="<?php print $globalURL; ?>/marine/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
900 | 900 | </div> |
901 | 901 | </div> |
902 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
902 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
903 | 903 | |
904 | 904 | <div class="col-md-6"> |
905 | 905 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
906 | 906 | <?php |
907 | - $date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name); |
|
907 | + $date_array = $Marine->countAllDatesLast7Days($airline_icao, $filter_name); |
|
908 | 908 | if (empty($date_array)) print _("No data available"); |
909 | 909 | else { |
910 | 910 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
911 | 911 | $date_data = ''; |
912 | 912 | $date_cnt = ''; |
913 | - foreach($date_array as $date_item) |
|
913 | + foreach ($date_array as $date_item) |
|
914 | 914 | { |
915 | 915 | $date_data .= '"'.$date_item['date_name'].'",'; |
916 | 916 | $date_cnt .= $date_item['date_count'].','; |
917 | 917 | } |
918 | 918 | $date_data = "['x',".substr($date_data, 0, -1)."]"; |
919 | - $date_cnt = "['vessels',".substr($date_cnt,0,-1)."]"; |
|
919 | + $date_cnt = "['vessels',".substr($date_cnt, 0, -1)."]"; |
|
920 | 920 | print 'c3.generate({ |
921 | 921 | bindto: "#chart5", |
922 | 922 | data: { x: "x", |
@@ -929,23 +929,23 @@ discard block |
||
929 | 929 | <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
930 | 930 | </div> |
931 | 931 | </div> |
932 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
932 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
933 | 933 | <div class="col-md-6"> |
934 | 934 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
935 | 935 | <?php |
936 | - $hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name); |
|
936 | + $hour_array = $Marine->countAllHours('hour', true, $airline_icao, $filter_name); |
|
937 | 937 | if (empty($hour_array)) print _("No data available"); |
938 | 938 | else { |
939 | 939 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
940 | 940 | $hour_data = ''; |
941 | 941 | $hour_cnt = ''; |
942 | - foreach($hour_array as $hour_item) |
|
942 | + foreach ($hour_array as $hour_item) |
|
943 | 943 | { |
944 | 944 | $hour_data .= '"'.$hour_item['hour_name'].':00",'; |
945 | 945 | $hour_cnt .= $hour_item['hour_count'].','; |
946 | 946 | } |
947 | 947 | $hour_data = "[".substr($hour_data, 0, -1)."]"; |
948 | - $hour_cnt = "['vessels',".substr($hour_cnt,0,-1)."]"; |
|
948 | + $hour_cnt = "['vessels',".substr($hour_cnt, 0, -1)."]"; |
|
949 | 949 | print 'c3.generate({ |
950 | 950 | bindto: "#chart6", |
951 | 951 | data: { |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | <a href="<?php print $globalURL; ?>/marine/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
959 | 959 | </div> |
960 | 960 | </div> |
961 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
961 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
962 | 962 | </div> |
963 | 963 | <?php |
964 | 964 | } |
@@ -982,13 +982,13 @@ discard block |
||
982 | 982 | print '<div id="chart8" class="chart" width="100%"></div><script>'; |
983 | 983 | $year_data = ''; |
984 | 984 | $year_cnt = ''; |
985 | - foreach($year_array as $year_item) |
|
985 | + foreach ($year_array as $year_item) |
|
986 | 986 | { |
987 | 987 | $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",'; |
988 | 988 | $year_cnt .= $year_item['date_count'].','; |
989 | 989 | } |
990 | 990 | $year_data = "['x',".substr($year_data, 0, -1)."]"; |
991 | - $year_cnt = "['trackers',".substr($year_cnt,0,-1)."]"; |
|
991 | + $year_cnt = "['trackers',".substr($year_cnt, 0, -1)."]"; |
|
992 | 992 | print 'c3.generate({ |
993 | 993 | bindto: "#chart8", |
994 | 994 | data: { x: "x", |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | </div> |
1003 | 1003 | </div> |
1004 | 1004 | |
1005 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
1005 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
1006 | 1006 | <div class="col-md-6"> |
1007 | 1007 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
1008 | 1008 | <?php |
@@ -1012,13 +1012,13 @@ discard block |
||
1012 | 1012 | print '<div id="chart9" class="chart" width="100%"></div><script>'; |
1013 | 1013 | $month_data = ''; |
1014 | 1014 | $month_cnt = ''; |
1015 | - foreach($month_array as $month_item) |
|
1015 | + foreach ($month_array as $month_item) |
|
1016 | 1016 | { |
1017 | 1017 | $month_data .= '"'.$month_item['date_name'].'",'; |
1018 | 1018 | $month_cnt .= $month_item['date_count'].','; |
1019 | 1019 | } |
1020 | 1020 | $month_data = "['x',".substr($month_data, 0, -1)."]"; |
1021 | - $month_cnt = "['trackers',".substr($month_cnt,0,-1)."]"; |
|
1021 | + $month_cnt = "['trackers',".substr($month_cnt, 0, -1)."]"; |
|
1022 | 1022 | print 'c3.generate({ |
1023 | 1023 | bindto: "#chart9", |
1024 | 1024 | data: { x: "x", |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | <a href="<?php print $globalURL; ?>/tracker/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
1032 | 1032 | </div> |
1033 | 1033 | </div> |
1034 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
1034 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
1035 | 1035 | |
1036 | 1036 | <div class="col-md-6"> |
1037 | 1037 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
@@ -1042,13 +1042,13 @@ discard block |
||
1042 | 1042 | print '<div id="chart5" class="chart" width="100%"></div><script>'; |
1043 | 1043 | $date_data = ''; |
1044 | 1044 | $date_cnt = ''; |
1045 | - foreach($date_array as $date_item) |
|
1045 | + foreach ($date_array as $date_item) |
|
1046 | 1046 | { |
1047 | 1047 | $date_data .= '"'.$date_item['date_name'].'",'; |
1048 | 1048 | $date_cnt .= $date_item['date_count'].','; |
1049 | 1049 | } |
1050 | 1050 | $date_data = "['x',".substr($date_data, 0, -1)."]"; |
1051 | - $date_cnt = "['trackers',".substr($date_cnt,0,-1)."]"; |
|
1051 | + $date_cnt = "['trackers',".substr($date_cnt, 0, -1)."]"; |
|
1052 | 1052 | print 'c3.generate({ |
1053 | 1053 | bindto: "#chart5", |
1054 | 1054 | data: { x: "x", |
@@ -1061,23 +1061,23 @@ discard block |
||
1061 | 1061 | <a href="<?php print $globalURL; ?>/marine/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
1062 | 1062 | </div> |
1063 | 1063 | </div> |
1064 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
1064 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
1065 | 1065 | <div class="col-md-6"> |
1066 | 1066 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
1067 | 1067 | <?php |
1068 | - $hour_array = $Tracker->countAllHours('hour',true); |
|
1068 | + $hour_array = $Tracker->countAllHours('hour', true); |
|
1069 | 1069 | if (empty($hour_array)) print _("No data available"); |
1070 | 1070 | else { |
1071 | 1071 | print '<div id="chart6" class="chart" width="100%"></div><script>'; |
1072 | 1072 | $hour_data = ''; |
1073 | 1073 | $hour_cnt = ''; |
1074 | - foreach($hour_array as $hour_item) |
|
1074 | + foreach ($hour_array as $hour_item) |
|
1075 | 1075 | { |
1076 | 1076 | $hour_data .= '"'.$hour_item['hour_name'].':00",'; |
1077 | 1077 | $hour_cnt .= $hour_item['hour_count'].','; |
1078 | 1078 | } |
1079 | 1079 | $hour_data = "[".substr($hour_data, 0, -1)."]"; |
1080 | - $hour_cnt = "['trackers',".substr($hour_cnt,0,-1)."]"; |
|
1080 | + $hour_cnt = "['trackers',".substr($hour_cnt, 0, -1)."]"; |
|
1081 | 1081 | print 'c3.generate({ |
1082 | 1082 | bindto: "#chart6", |
1083 | 1083 | data: { |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | <a href="<?php print $globalURL; ?>/tracker/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
1091 | 1091 | </div> |
1092 | 1092 | </div> |
1093 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
1093 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
1094 | 1094 | </div> |
1095 | 1095 | <?php |
1096 | 1096 | } |
@@ -1114,13 +1114,13 @@ discard block |
||
1114 | 1114 | print '<div id="chart32" class="chart" width="100%"></div><script>'; |
1115 | 1115 | $year_data = ''; |
1116 | 1116 | $year_cnt = ''; |
1117 | - foreach($year_array as $year_item) |
|
1117 | + foreach ($year_array as $year_item) |
|
1118 | 1118 | { |
1119 | 1119 | $year_data .= '"'.$year_item['year'].'-01-01",'; |
1120 | 1120 | $year_cnt .= $year_item['count'].','; |
1121 | 1121 | } |
1122 | 1122 | $year_data = "['x',".substr($year_data, 0, -1)."]"; |
1123 | - $year_cnt = "['flights',".substr($year_cnt,0,-1)."]"; |
|
1123 | + $year_cnt = "['flights',".substr($year_cnt, 0, -1)."]"; |
|
1124 | 1124 | print 'c3.generate({ |
1125 | 1125 | bindto: "#chart32", |
1126 | 1126 | data: { x: "x", |
@@ -1133,7 +1133,7 @@ discard block |
||
1133 | 1133 | <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
1134 | 1134 | </div> |
1135 | 1135 | </div> |
1136 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
1136 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
1137 | 1137 | |
1138 | 1138 | <div class="row column"> |
1139 | 1139 | <div class="col-md-6"> |
@@ -1145,13 +1145,13 @@ discard block |
||
1145 | 1145 | print '<div id="chart33" class="chart" width="100%"></div><script>'; |
1146 | 1146 | $year_data = ''; |
1147 | 1147 | $year_cnt = ''; |
1148 | - foreach($year_array as $year_item) |
|
1148 | + foreach ($year_array as $year_item) |
|
1149 | 1149 | { |
1150 | 1150 | $year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",'; |
1151 | 1151 | $year_cnt .= $year_item['count'].','; |
1152 | 1152 | } |
1153 | 1153 | $year_data = "['x',".substr($year_data, 0, -1)."]"; |
1154 | - $year_cnt = "['flights',".substr($year_cnt,0,-1)."]"; |
|
1154 | + $year_cnt = "['flights',".substr($year_cnt, 0, -1)."]"; |
|
1155 | 1155 | print 'c3.generate({ |
1156 | 1156 | bindto: "#chart33", |
1157 | 1157 | data: { x: "x", |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
1165 | 1165 | </div> |
1166 | 1166 | </div> |
1167 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
1167 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
1168 | 1168 | <br/> |
1169 | 1169 | <?php |
1170 | 1170 | } |
@@ -1182,9 +1182,9 @@ discard block |
||
1182 | 1182 | <?php |
1183 | 1183 | //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar'); |
1184 | 1184 | if ($year == '' && $month == '') { |
1185 | - $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d')); |
|
1185 | + $polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d')); |
|
1186 | 1186 | } else { |
1187 | - $polar = $Stats->getStatsSource('polar',$year,$month); |
|
1187 | + $polar = $Stats->getStatsSource('polar', $year, $month); |
|
1188 | 1188 | } |
1189 | 1189 | if (!empty($polar)) { |
1190 | 1190 | print '<h2>'._("Coverage pattern").'</h2>'; |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | unset($polar_data); |
1193 | 1193 | $Spotter = new Spotter(); |
1194 | 1194 | $data = json_decode($eachpolar['source_data']); |
1195 | - foreach($data as $value => $key) { |
|
1195 | + foreach ($data as $value => $key) { |
|
1196 | 1196 | $direction = $Spotter->parseDirection(($value*22.5)); |
1197 | 1197 | $distance = $key; |
1198 | 1198 | $unit = 'km'; |
@@ -1212,7 +1212,7 @@ discard block |
||
1212 | 1212 | ?> |
1213 | 1213 | <div class="col-md-6"> |
1214 | 1214 | <h4><?php print $eachpolar['source_name']; ?></h4> |
1215 | - <div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div> |
|
1215 | + <div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div> |
|
1216 | 1216 | <script> |
1217 | 1217 | (function() { |
1218 | 1218 | var margin = {top: 100, right: 100, bottom: 100, left: 100}, |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | color: color, |
1237 | 1237 | unit: '<?php echo $unit; ?>' |
1238 | 1238 | }; |
1239 | - RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions); |
|
1239 | + RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions); |
|
1240 | 1240 | })(); |
1241 | 1241 | </script> |
1242 | 1242 | </div> |
@@ -1250,22 +1250,22 @@ discard block |
||
1250 | 1250 | <?php |
1251 | 1251 | //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg'); |
1252 | 1252 | if ($year == '' && $month == '') { |
1253 | - $msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d')); |
|
1253 | + $msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d')); |
|
1254 | 1254 | } else { |
1255 | - $msg = $Stats->getStatsSource('msg',$year,$month); |
|
1255 | + $msg = $Stats->getStatsSource('msg', $year, $month); |
|
1256 | 1256 | } |
1257 | 1257 | if (!empty($msg)) { |
1258 | 1258 | print '<h2>'._("Messages received").'</h2>'; |
1259 | 1259 | foreach ($msg as $eachmsg) { |
1260 | 1260 | //$eachmsg = $msg[0]; |
1261 | 1261 | $data = $eachmsg['source_data']; |
1262 | - if ($data > 500) $max = (round(($data+100)/100))*100; |
|
1262 | + if ($data > 500) $max = (round(($data + 100)/100))*100; |
|
1263 | 1263 | else $max = 500; |
1264 | 1264 | ?> |
1265 | - <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
|
1265 | + <div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
|
1266 | 1266 | <script> |
1267 | 1267 | var g = new JustGage({ |
1268 | - id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>", |
|
1268 | + id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>", |
|
1269 | 1269 | value: <?php echo $data; ?>, |
1270 | 1270 | min: 0, |
1271 | 1271 | max: <?php print $max; ?>, |
@@ -1286,9 +1286,9 @@ discard block |
||
1286 | 1286 | <?php |
1287 | 1287 | //$hist = $Stats->getStatsSource(date('Y-m-d'),'hist'); |
1288 | 1288 | if ($year == '' && $month == '') { |
1289 | - $hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d')); |
|
1289 | + $hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d')); |
|
1290 | 1290 | } else { |
1291 | - $hist = $Stats->getStatsSource('hist',$year,$month); |
|
1291 | + $hist = $Stats->getStatsSource('hist', $year, $month); |
|
1292 | 1292 | } |
1293 | 1293 | foreach ($hist as $hists) { |
1294 | 1294 | //$hist_data = ''; |
@@ -1297,7 +1297,7 @@ discard block |
||
1297 | 1297 | $source = $hists['source_name']; |
1298 | 1298 | $hist_array = json_decode($hists['source_data']); |
1299 | 1299 | $unit = 'km'; |
1300 | - foreach($hist_array as $distance => $nb) |
|
1300 | + foreach ($hist_array as $distance => $nb) |
|
1301 | 1301 | { |
1302 | 1302 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
1303 | 1303 | $distance = round($distance*0.539957); |
@@ -1318,18 +1318,18 @@ discard block |
||
1318 | 1318 | $nb_data = "['flights',".substr($nb_data, 0, -1)."]"; |
1319 | 1319 | ?> |
1320 | 1320 | <div class="col-md-6"> |
1321 | - <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2> |
|
1321 | + <h2><?php echo sprintf(_("Flights Distance for %s"), $source); ?></h2> |
|
1322 | 1322 | <?php |
1323 | - print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>'; |
|
1323 | + print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div><script>'; |
|
1324 | 1324 | print 'c3.generate({ |
1325 | - bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'", |
|
1325 | + bindto: "#charthist-'.str_replace(' ', '_', strtolower($source)).'", |
|
1326 | 1326 | data: { x: "x", |
1327 | 1327 | columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}}, |
1328 | 1328 | axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});'; |
1329 | 1329 | print '</script>'; |
1330 | 1330 | ?> |
1331 | 1331 | </div> |
1332 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
1332 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
1333 | 1333 | <?php |
1334 | 1334 | } |
1335 | 1335 | ?> |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | require_once(dirname(__FILE__).'/class.Image.php'); |
5 | 5 | $global_query = "SELECT tracker_output.* FROM tracker_output"; |
6 | 6 | |
7 | -class Tracker{ |
|
7 | +class Tracker { |
|
8 | 8 | public $db; |
9 | 9 | |
10 | 10 | public function __construct($dbc = null) { |
@@ -18,33 +18,33 @@ discard block |
||
18 | 18 | * @return Array the SQL part |
19 | 19 | */ |
20 | 20 | |
21 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
21 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
22 | 22 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
23 | 23 | $filters = array(); |
24 | 24 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
25 | 25 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
26 | 26 | $filters = $globalStatsFilters[$globalFilterName]; |
27 | 27 | } else { |
28 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
28 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | if (isset($filter[0]['source'])) { |
32 | - $filters = array_merge($filters,$filter); |
|
32 | + $filters = array_merge($filters, $filter); |
|
33 | 33 | } |
34 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
34 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
35 | 35 | $filter_query_join = ''; |
36 | 36 | $filter_query_where = ''; |
37 | - foreach($filters as $flt) { |
|
37 | + foreach ($filters as $flt) { |
|
38 | 38 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
39 | 39 | if (isset($flt['source'])) { |
40 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
41 | 41 | } else { |
42 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
42 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.famtrackid = tracker_output.famtrackid"; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
46 | 46 | if (isset($filter['source']) && !empty($filter['source'])) { |
47 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
47 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
48 | 48 | } |
49 | 49 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
50 | 50 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
74 | 74 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
75 | 75 | if ($filter_query_where != '') { |
76 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
76 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
77 | 77 | } |
78 | 78 | $filter_query = $filter_query_join.$filter_query_where; |
79 | 79 | return $filter_query; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @return Array the spotter information |
89 | 89 | * |
90 | 90 | */ |
91 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
91 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
92 | 92 | { |
93 | 93 | date_default_timezone_set('UTC'); |
94 | 94 | if (!is_string($query)) |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | $sth = $this->db->prepare($query.$limitQuery); |
109 | 109 | $sth->execute($params); |
110 | 110 | } catch (PDOException $e) { |
111 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
111 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
112 | 112 | exit(); |
113 | 113 | } |
114 | 114 | |
115 | 115 | $num_rows = 0; |
116 | 116 | $spotter_array = array(); |
117 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
117 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
118 | 118 | { |
119 | 119 | $num_rows++; |
120 | 120 | $temp_array = array(); |
@@ -170,17 +170,17 @@ discard block |
||
170 | 170 | { |
171 | 171 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
172 | 172 | } else { |
173 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
173 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
174 | 174 | } |
175 | 175 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
176 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
177 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
176 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
177 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
178 | 178 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
179 | 179 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
180 | 180 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
181 | 181 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
182 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
183 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
182 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
183 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
184 | 184 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
185 | 185 | } |
186 | 186 | } |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | { |
218 | 218 | $limit_array = explode(",", $limit); |
219 | 219 | |
220 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
221 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
220 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
221 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
222 | 222 | |
223 | 223 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
224 | 224 | { |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | $orderby_query = " ORDER BY tracker_output.date DESC"; |
236 | 236 | } |
237 | 237 | |
238 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
238 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
239 | 239 | |
240 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
240 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
241 | 241 | |
242 | 242 | return $spotter_array; |
243 | 243 | } |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | if ($id == '') return array(); |
257 | 257 | $additional_query = "tracker_output.famtrackid = :id"; |
258 | 258 | $query_values = array(':id' => $id); |
259 | - $query = $global_query." WHERE ".$additional_query." "; |
|
260 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
259 | + $query = $global_query." WHERE ".$additional_query." "; |
|
260 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
261 | 261 | return $spotter_array; |
262 | 262 | } |
263 | 263 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $query_values = array(); |
277 | 277 | $limit_query = ''; |
278 | 278 | $additional_query = ''; |
279 | - $filter_query = $this->getFilter($filter,true,true); |
|
279 | + $filter_query = $this->getFilter($filter, true, true); |
|
280 | 280 | if ($ident != "") |
281 | 281 | { |
282 | 282 | if (!is_string($ident)) |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | { |
293 | 293 | $limit_array = explode(",", $limit); |
294 | 294 | |
295 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
296 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
295 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
296 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
297 | 297 | |
298 | 298 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
299 | 299 | { |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | return $spotter_array; |
318 | 318 | } |
319 | 319 | |
320 | - public function getTrackerDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
320 | + public function getTrackerDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
321 | 321 | { |
322 | 322 | global $global_query, $globalTimezone, $globalDBdriver; |
323 | 323 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | $limit_query = ''; |
326 | 326 | $additional_query = ''; |
327 | 327 | |
328 | - $filter_query = $this->getFilter($filter,true,true); |
|
328 | + $filter_query = $this->getFilter($filter, true, true); |
|
329 | 329 | |
330 | 330 | if ($date != "") |
331 | 331 | { |
@@ -351,8 +351,8 @@ discard block |
||
351 | 351 | { |
352 | 352 | $limit_array = explode(",", $limit); |
353 | 353 | |
354 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
355 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
354 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
355 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
356 | 356 | |
357 | 357 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
358 | 358 | { |
@@ -383,11 +383,11 @@ discard block |
||
383 | 383 | * @return Array list of source name |
384 | 384 | * |
385 | 385 | */ |
386 | - public function getAllSourceName($type = '',$filters = array()) |
|
386 | + public function getAllSourceName($type = '', $filters = array()) |
|
387 | 387 | { |
388 | - $filter_query = $this->getFilter($filters,true,true); |
|
388 | + $filter_query = $this->getFilter($filters, true, true); |
|
389 | 389 | $query_values = array(); |
390 | - $query = "SELECT DISTINCT tracker_output.source_name |
|
390 | + $query = "SELECT DISTINCT tracker_output.source_name |
|
391 | 391 | FROM tracker_output".$filter_query." tracker_output.source_name <> ''"; |
392 | 392 | if ($type != '') { |
393 | 393 | $query_values = array(':type' => $type); |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | $source_array = array(); |
403 | 403 | $temp_array = array(); |
404 | 404 | |
405 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
405 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
406 | 406 | { |
407 | 407 | $temp_array['source_name'] = $row['source_name']; |
408 | 408 | $source_array[] = $temp_array; |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function getAllIdents($filters = array()) |
421 | 421 | { |
422 | - $filter_query = $this->getFilter($filters,true,true); |
|
423 | - $query = "SELECT DISTINCT tracker_output.ident |
|
422 | + $filter_query = $this->getFilter($filters, true, true); |
|
423 | + $query = "SELECT DISTINCT tracker_output.ident |
|
424 | 424 | FROM tracker_output".$filter_query." tracker_output.ident <> '' |
425 | 425 | ORDER BY tracker_output.date ASC LIMIT 700 OFFSET 0"; |
426 | 426 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $ident_array = array(); |
431 | 431 | $temp_array = array(); |
432 | 432 | |
433 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
433 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
434 | 434 | { |
435 | 435 | $temp_array['ident'] = $row['ident']; |
436 | 436 | $ident_array[] = $temp_array; |
@@ -455,12 +455,12 @@ discard block |
||
455 | 455 | } else $offset = '+00:00'; |
456 | 456 | |
457 | 457 | if ($globalDBdriver == 'mysql') { |
458 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
|
458 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
|
459 | 459 | FROM tracker_output |
460 | 460 | WHERE tracker_output.date <> '' |
461 | 461 | ORDER BY tracker_output.date ASC LIMIT 0,200"; |
462 | 462 | } else { |
463 | - $query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
463 | + $query = "SELECT DISTINCT to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
464 | 464 | FROM tracker_output |
465 | 465 | WHERE tracker_output.date <> '' |
466 | 466 | ORDER BY tracker_output.date ASC LIMIT 0,200"; |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | $date_array = array(); |
473 | 473 | $temp_array = array(); |
474 | 474 | |
475 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
475 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
476 | 476 | { |
477 | 477 | $temp_array['date'] = $row['date']; |
478 | 478 | |
@@ -491,11 +491,11 @@ discard block |
||
491 | 491 | * @return String success or false |
492 | 492 | * |
493 | 493 | */ |
494 | - public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL) |
|
494 | + public function updateIdentTrackerData($famtrackid = '', $ident = '', $fromsource = NULL) |
|
495 | 495 | { |
496 | 496 | |
497 | 497 | $query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid'; |
498 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident); |
|
498 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident); |
|
499 | 499 | |
500 | 500 | try { |
501 | 501 | $sth = $this->db->prepare($query); |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '') |
520 | 520 | { |
521 | 521 | $query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid'; |
522 | - $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
522 | + $query_values = array(':famtrackid' => $famtrackid, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
523 | 523 | |
524 | 524 | try { |
525 | 525 | $sth = $this->db->prepare($query); |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | * @param String $verticalrate vertival rate of flight |
560 | 560 | * @return String success or false |
561 | 561 | */ |
562 | - public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '') |
|
562 | + public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '', $format_source = '', $source_name = '') |
|
563 | 563 | { |
564 | 564 | global $globalURL; |
565 | 565 | |
@@ -627,21 +627,21 @@ discard block |
||
627 | 627 | } |
628 | 628 | |
629 | 629 | |
630 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
630 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
631 | 631 | { |
632 | 632 | $date = date("Y-m-d H:i:s", time()); |
633 | 633 | } |
634 | 634 | |
635 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
636 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
637 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
638 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
639 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
640 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
641 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
642 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
643 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
644 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
635 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
636 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
637 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
638 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
639 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
640 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
641 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
642 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
643 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
644 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
645 | 645 | |
646 | 646 | if ($latitude == '' && $longitude == '') { |
647 | 647 | $latitude = 0; |
@@ -649,10 +649,10 @@ discard block |
||
649 | 649 | } |
650 | 650 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
651 | 651 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
652 | - $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
652 | + $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
|
653 | 653 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
654 | 654 | |
655 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type); |
|
655 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':comment' => $comment, ':type' => $type); |
|
656 | 656 | |
657 | 657 | try { |
658 | 658 | |
@@ -678,13 +678,13 @@ discard block |
||
678 | 678 | { |
679 | 679 | global $globalDBdriver, $globalTimezone; |
680 | 680 | if ($globalDBdriver == 'mysql') { |
681 | - $query = "SELECT tracker_output.ident FROM tracker_output |
|
681 | + $query = "SELECT tracker_output.ident FROM tracker_output |
|
682 | 682 | WHERE tracker_output.ident = :ident |
683 | 683 | AND tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
684 | 684 | AND tracker_output.date < UTC_TIMESTAMP()"; |
685 | 685 | $query_data = array(':ident' => $ident); |
686 | 686 | } else { |
687 | - $query = "SELECT tracker_output.ident FROM tracker_output |
|
687 | + $query = "SELECT tracker_output.ident FROM tracker_output |
|
688 | 688 | WHERE tracker_output.ident = :ident |
689 | 689 | AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
690 | 690 | AND tracker_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -693,8 +693,8 @@ discard block |
||
693 | 693 | |
694 | 694 | $sth = $this->db->prepare($query); |
695 | 695 | $sth->execute($query_data); |
696 | - $ident_result=''; |
|
697 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
696 | + $ident_result = ''; |
|
697 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
698 | 698 | { |
699 | 699 | $ident_result = $row['ident']; |
700 | 700 | } |
@@ -720,8 +720,8 @@ discard block |
||
720 | 720 | return false; |
721 | 721 | } else { |
722 | 722 | $q_array = explode(" ", $q); |
723 | - foreach ($q_array as $q_item){ |
|
724 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
723 | + foreach ($q_array as $q_item) { |
|
724 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
725 | 725 | $additional_query .= " AND ("; |
726 | 726 | $additional_query .= "(tracker_output.ident like '%".$q_item."%')"; |
727 | 727 | $additional_query .= ")"; |
@@ -729,11 +729,11 @@ discard block |
||
729 | 729 | } |
730 | 730 | } |
731 | 731 | if ($globalDBdriver == 'mysql') { |
732 | - $query = "SELECT tracker_output.* FROM tracker_output |
|
732 | + $query = "SELECT tracker_output.* FROM tracker_output |
|
733 | 733 | WHERE tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
734 | 734 | AND tracker_output.date < UTC_TIMESTAMP()"; |
735 | 735 | } else { |
736 | - $query = "SELECT tracker_output.* FROM tracker_output |
|
736 | + $query = "SELECT tracker_output.* FROM tracker_output |
|
737 | 737 | WHERE tracker_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
738 | 738 | AND tracker_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
739 | 739 | } |
@@ -752,16 +752,16 @@ discard block |
||
752 | 752 | * |
753 | 753 | */ |
754 | 754 | |
755 | - public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
755 | + public function countAllTrackerOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
756 | 756 | { |
757 | 757 | global $globalDBdriver, $globalArchive; |
758 | 758 | //$filter_query = $this->getFilter($filters,true,true); |
759 | - $Connection= new Connection($this->db); |
|
759 | + $Connection = new Connection($this->db); |
|
760 | 760 | if (!$Connection->tableExists('countries')) return array(); |
761 | 761 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
762 | 762 | require_once('class.TrackerLive.php'); |
763 | 763 | $TrackerLive = new TrackerLive(); |
764 | - $filter_query = $TrackerLive->getFilter($filters,true,true); |
|
764 | + $filter_query = $TrackerLive->getFilter($filters, true, true); |
|
765 | 765 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
766 | 766 | if ($olderthanmonths > 0) { |
767 | 767 | if ($globalDBdriver == 'mysql') { |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | } else { |
782 | 782 | require_once('class.TrackerArchive.php'); |
783 | 783 | $TrackerArchive = new TrackerArchive(); |
784 | - $filter_query = $TrackerArchive->getFilter($filters,true,true); |
|
784 | + $filter_query = $TrackerArchive->getFilter($filters, true, true); |
|
785 | 785 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
786 | 786 | if ($olderthanmonths > 0) { |
787 | 787 | if ($globalDBdriver == 'mysql') { |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | $flight_array = array(); |
810 | 810 | $temp_array = array(); |
811 | 811 | |
812 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
812 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
813 | 813 | { |
814 | 814 | $temp_array['flight_count'] = $row['nb']; |
815 | 815 | $temp_array['flight_country'] = $row['name']; |
@@ -826,11 +826,11 @@ discard block |
||
826 | 826 | * @return Array the callsign list |
827 | 827 | * |
828 | 828 | */ |
829 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
829 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
830 | 830 | { |
831 | 831 | global $globalDBdriver; |
832 | - $filter_query = $this->getFilter($filters,true,true); |
|
833 | - $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
832 | + $filter_query = $this->getFilter($filters, true, true); |
|
833 | + $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
|
834 | 834 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
835 | 835 | if ($olderthanmonths > 0) { |
836 | 836 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -844,28 +844,28 @@ discard block |
||
844 | 844 | if ($year != '') { |
845 | 845 | if ($globalDBdriver == 'mysql') { |
846 | 846 | $query .= " AND YEAR(tracker_output.date) = :year"; |
847 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
847 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
848 | 848 | } else { |
849 | 849 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
850 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
850 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
851 | 851 | } |
852 | 852 | } |
853 | 853 | if ($month != '') { |
854 | 854 | if ($globalDBdriver == 'mysql') { |
855 | 855 | $query .= " AND MONTH(tracker_output.date) = :month"; |
856 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
856 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
857 | 857 | } else { |
858 | 858 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
859 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
859 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | if ($day != '') { |
863 | 863 | if ($globalDBdriver == 'mysql') { |
864 | 864 | $query .= " AND DAY(tracker_output.date) = :day"; |
865 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
865 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
866 | 866 | } else { |
867 | 867 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
868 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
868 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
869 | 869 | } |
870 | 870 | } |
871 | 871 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | $callsign_array = array(); |
878 | 878 | $temp_array = array(); |
879 | 879 | |
880 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
880 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
881 | 881 | { |
882 | 882 | $temp_array['callsign_icao'] = $row['ident']; |
883 | 883 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | $date_array = array(); |
930 | 930 | $temp_array = array(); |
931 | 931 | |
932 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
932 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
933 | 933 | { |
934 | 934 | $temp_array['date_name'] = $row['date_name']; |
935 | 935 | $temp_array['date_count'] = $row['date_count']; |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | $datetime = new DateTime(); |
956 | 956 | $offset = $datetime->format('P'); |
957 | 957 | } else $offset = '+00:00'; |
958 | - $filter_query = $this->getFilter($filters,true,true); |
|
958 | + $filter_query = $this->getFilter($filters, true, true); |
|
959 | 959 | if ($globalDBdriver == 'mysql') { |
960 | 960 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
961 | 961 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | $date_array = array(); |
977 | 977 | $temp_array = array(); |
978 | 978 | |
979 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
979 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
980 | 980 | { |
981 | 981 | $temp_array['date_name'] = $row['date_name']; |
982 | 982 | $temp_array['date_count'] = $row['date_count']; |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | $datetime = new DateTime(); |
1002 | 1002 | $offset = $datetime->format('P'); |
1003 | 1003 | } else $offset = '+00:00'; |
1004 | - $filter_query = $this->getFilter($filters,true,true); |
|
1004 | + $filter_query = $this->getFilter($filters, true, true); |
|
1005 | 1005 | if ($globalDBdriver == 'mysql') { |
1006 | 1006 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1007 | 1007 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | $date_array = array(); |
1023 | 1023 | $temp_array = array(); |
1024 | 1024 | |
1025 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1025 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1026 | 1026 | { |
1027 | 1027 | $temp_array['date_name'] = $row['date_name']; |
1028 | 1028 | $temp_array['date_count'] = $row['date_count']; |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | $date_array = array(); |
1070 | 1070 | $temp_array = array(); |
1071 | 1071 | |
1072 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1072 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1073 | 1073 | { |
1074 | 1074 | $temp_array['month_name'] = $row['month_name']; |
1075 | 1075 | $temp_array['year_name'] = $row['year_name']; |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | $datetime = new DateTime(); |
1099 | 1099 | $offset = $datetime->format('P'); |
1100 | 1100 | } else $offset = '+00:00'; |
1101 | - $filter_query = $this->getFilter($filters,true,true); |
|
1101 | + $filter_query = $this->getFilter($filters, true, true); |
|
1102 | 1102 | if ($globalDBdriver == 'mysql') { |
1103 | 1103 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
1104 | 1104 | FROM tracker_output".$filter_query." tracker_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | $date_array = array(); |
1120 | 1120 | $temp_array = array(); |
1121 | 1121 | |
1122 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1122 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1123 | 1123 | { |
1124 | 1124 | $temp_array['year_name'] = $row['year_name']; |
1125 | 1125 | $temp_array['month_name'] = $row['month_name']; |
@@ -1139,7 +1139,7 @@ discard block |
||
1139 | 1139 | * @return Array the hour list |
1140 | 1140 | * |
1141 | 1141 | */ |
1142 | - public function countAllHours($orderby,$filters = array()) |
|
1142 | + public function countAllHours($orderby, $filters = array()) |
|
1143 | 1143 | { |
1144 | 1144 | global $globalTimezone, $globalDBdriver; |
1145 | 1145 | if ($globalTimezone != '') { |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | $hour_array = array(); |
1188 | 1188 | $temp_array = array(); |
1189 | 1189 | |
1190 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1190 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1191 | 1191 | { |
1192 | 1192 | $temp_array['hour_name'] = $row['hour_name']; |
1193 | 1193 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1209,8 +1209,8 @@ discard block |
||
1209 | 1209 | public function countAllHoursByDate($date, $filters = array()) |
1210 | 1210 | { |
1211 | 1211 | global $globalTimezone, $globalDBdriver; |
1212 | - $filter_query = $this->getFilter($filters,true,true); |
|
1213 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1212 | + $filter_query = $this->getFilter($filters, true, true); |
|
1213 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1214 | 1214 | if ($globalTimezone != '') { |
1215 | 1215 | date_default_timezone_set($globalTimezone); |
1216 | 1216 | $datetime = new DateTime($date); |
@@ -1218,12 +1218,12 @@ discard block |
||
1218 | 1218 | } else $offset = '+00:00'; |
1219 | 1219 | |
1220 | 1220 | if ($globalDBdriver == 'mysql') { |
1221 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1221 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1222 | 1222 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = :date |
1223 | 1223 | GROUP BY hour_name |
1224 | 1224 | ORDER BY hour_name ASC"; |
1225 | 1225 | } else { |
1226 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1226 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1227 | 1227 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1228 | 1228 | GROUP BY hour_name |
1229 | 1229 | ORDER BY hour_name ASC"; |
@@ -1235,7 +1235,7 @@ discard block |
||
1235 | 1235 | $hour_array = array(); |
1236 | 1236 | $temp_array = array(); |
1237 | 1237 | |
1238 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1238 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1239 | 1239 | { |
1240 | 1240 | $temp_array['hour_name'] = $row['hour_name']; |
1241 | 1241 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1257,8 +1257,8 @@ discard block |
||
1257 | 1257 | public function countAllHoursByIdent($ident, $filters = array()) |
1258 | 1258 | { |
1259 | 1259 | global $globalTimezone, $globalDBdriver; |
1260 | - $filter_query = $this->getFilter($filters,true,true); |
|
1261 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1260 | + $filter_query = $this->getFilter($filters, true, true); |
|
1261 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1262 | 1262 | if ($globalTimezone != '') { |
1263 | 1263 | date_default_timezone_set($globalTimezone); |
1264 | 1264 | $datetime = new DateTime(); |
@@ -1266,12 +1266,12 @@ discard block |
||
1266 | 1266 | } else $offset = '+00:00'; |
1267 | 1267 | |
1268 | 1268 | if ($globalDBdriver == 'mysql') { |
1269 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1269 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1270 | 1270 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
1271 | 1271 | GROUP BY hour_name |
1272 | 1272 | ORDER BY hour_name ASC"; |
1273 | 1273 | } else { |
1274 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1274 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1275 | 1275 | FROM tracker_output".$filter_query." tracker_output.ident = :ident |
1276 | 1276 | GROUP BY hour_name |
1277 | 1277 | ORDER BY hour_name ASC"; |
@@ -1279,12 +1279,12 @@ discard block |
||
1279 | 1279 | |
1280 | 1280 | |
1281 | 1281 | $sth = $this->db->prepare($query); |
1282 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1282 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1283 | 1283 | |
1284 | 1284 | $hour_array = array(); |
1285 | 1285 | $temp_array = array(); |
1286 | 1286 | |
1287 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1287 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1288 | 1288 | { |
1289 | 1289 | $temp_array['hour_name'] = $row['hour_name']; |
1290 | 1290 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1303,33 +1303,33 @@ discard block |
||
1303 | 1303 | * @return Integer the number of trackers |
1304 | 1304 | * |
1305 | 1305 | */ |
1306 | - public function countOverallTracker($filters = array(),$year = '',$month = '') |
|
1306 | + public function countOverallTracker($filters = array(), $year = '', $month = '') |
|
1307 | 1307 | { |
1308 | 1308 | global $globalDBdriver; |
1309 | 1309 | //$queryi = "SELECT COUNT(tracker_output.tracker_id) AS flight_count FROM tracker_output"; |
1310 | - $queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output"; |
|
1310 | + $queryi = "SELECT COUNT(DISTINCT tracker_output.ident) AS tracker_count FROM tracker_output"; |
|
1311 | 1311 | $query_values = array(); |
1312 | 1312 | $query = ''; |
1313 | 1313 | if ($year != '') { |
1314 | 1314 | if ($globalDBdriver == 'mysql') { |
1315 | 1315 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1316 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1316 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1317 | 1317 | } else { |
1318 | 1318 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1319 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1319 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1320 | 1320 | } |
1321 | 1321 | } |
1322 | 1322 | if ($month != '') { |
1323 | 1323 | if ($globalDBdriver == 'mysql') { |
1324 | 1324 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1325 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1325 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1326 | 1326 | } else { |
1327 | 1327 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1328 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1328 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1329 | 1329 | } |
1330 | 1330 | } |
1331 | 1331 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1332 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1332 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1333 | 1333 | |
1334 | 1334 | $sth = $this->db->prepare($queryi); |
1335 | 1335 | $sth->execute($query_values); |
@@ -1342,32 +1342,32 @@ discard block |
||
1342 | 1342 | * @return Integer the number of flights |
1343 | 1343 | * |
1344 | 1344 | */ |
1345 | - public function countOverallTrackerTypes($filters = array(),$year = '',$month = '') |
|
1345 | + public function countOverallTrackerTypes($filters = array(), $year = '', $month = '') |
|
1346 | 1346 | { |
1347 | 1347 | global $globalDBdriver; |
1348 | - $queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output"; |
|
1348 | + $queryi = "SELECT COUNT(DISTINCT tracker_output.type) AS tracker_count FROM tracker_output"; |
|
1349 | 1349 | $query_values = array(); |
1350 | 1350 | $query = ''; |
1351 | 1351 | if ($year != '') { |
1352 | 1352 | if ($globalDBdriver == 'mysql') { |
1353 | 1353 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1354 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1354 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1355 | 1355 | } else { |
1356 | 1356 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1357 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1357 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1358 | 1358 | } |
1359 | 1359 | } |
1360 | 1360 | if ($month != '') { |
1361 | 1361 | if ($globalDBdriver == 'mysql') { |
1362 | 1362 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1363 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1363 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1364 | 1364 | } else { |
1365 | 1365 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1366 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1366 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1367 | 1367 | } |
1368 | 1368 | } |
1369 | 1369 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1370 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1370 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1371 | 1371 | |
1372 | 1372 | $sth = $this->db->prepare($queryi); |
1373 | 1373 | $sth->execute($query_values); |
@@ -1384,7 +1384,7 @@ discard block |
||
1384 | 1384 | public function countAllHoursFromToday($filters = array()) |
1385 | 1385 | { |
1386 | 1386 | global $globalTimezone, $globalDBdriver; |
1387 | - $filter_query = $this->getFilter($filters,true,true); |
|
1387 | + $filter_query = $this->getFilter($filters, true, true); |
|
1388 | 1388 | if ($globalTimezone != '') { |
1389 | 1389 | date_default_timezone_set($globalTimezone); |
1390 | 1390 | $datetime = new DateTime(); |
@@ -1392,12 +1392,12 @@ discard block |
||
1392 | 1392 | } else $offset = '+00:00'; |
1393 | 1393 | |
1394 | 1394 | if ($globalDBdriver == 'mysql') { |
1395 | - $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1395 | + $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1396 | 1396 | FROM tracker_output".$filter_query." DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) = CURDATE() |
1397 | 1397 | GROUP BY hour_name |
1398 | 1398 | ORDER BY hour_name ASC"; |
1399 | 1399 | } else { |
1400 | - $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1400 | + $query = "SELECT EXTRACT(HOUR FROM tracker_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1401 | 1401 | FROM tracker_output".$filter_query." to_char(tracker_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1402 | 1402 | GROUP BY hour_name |
1403 | 1403 | ORDER BY hour_name ASC"; |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | $hour_array = array(); |
1410 | 1410 | $temp_array = array(); |
1411 | 1411 | |
1412 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1412 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1413 | 1413 | { |
1414 | 1414 | $temp_array['hour_name'] = $row['hour_name']; |
1415 | 1415 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1428,9 +1428,9 @@ discard block |
||
1428 | 1428 | */ |
1429 | 1429 | public function getTrackerIDBasedOnFamTrackID($famtrackid) |
1430 | 1430 | { |
1431 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
1431 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
1432 | 1432 | |
1433 | - $query = "SELECT tracker_output.tracker_id |
|
1433 | + $query = "SELECT tracker_output.tracker_id |
|
1434 | 1434 | FROM tracker_output |
1435 | 1435 | WHERE tracker_output.famtrackid = '".$famtrackid."'"; |
1436 | 1436 | |
@@ -1438,7 +1438,7 @@ discard block |
||
1438 | 1438 | $sth = $this->db->prepare($query); |
1439 | 1439 | $sth->execute(); |
1440 | 1440 | |
1441 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1441 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1442 | 1442 | { |
1443 | 1443 | return $row['tracker_id']; |
1444 | 1444 | } |
@@ -1463,23 +1463,23 @@ discard block |
||
1463 | 1463 | } |
1464 | 1464 | |
1465 | 1465 | $current_date = date("Y-m-d H:i:s"); |
1466 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1466 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1467 | 1467 | |
1468 | 1468 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1469 | 1469 | |
1470 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1470 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1471 | 1471 | $years = $time_array['years']; |
1472 | 1472 | |
1473 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1473 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1474 | 1474 | $months = $time_array['months']; |
1475 | 1475 | |
1476 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1476 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1477 | 1477 | $days = $time_array['days']; |
1478 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1478 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1479 | 1479 | $hours = $time_array['hours']; |
1480 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1480 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1481 | 1481 | $minutes = $time_array['minutes']; |
1482 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1482 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1483 | 1483 | |
1484 | 1484 | return $time_array; |
1485 | 1485 | } |
@@ -1502,63 +1502,63 @@ discard block |
||
1502 | 1502 | $temp_array['direction_degree'] = $direction; |
1503 | 1503 | $temp_array['direction_shortname'] = "N"; |
1504 | 1504 | $temp_array['direction_fullname'] = "North"; |
1505 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1505 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1506 | 1506 | $temp_array['direction_degree'] = $direction; |
1507 | 1507 | $temp_array['direction_shortname'] = "NNE"; |
1508 | 1508 | $temp_array['direction_fullname'] = "North-Northeast"; |
1509 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1509 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1510 | 1510 | $temp_array['direction_degree'] = $direction; |
1511 | 1511 | $temp_array['direction_shortname'] = "NE"; |
1512 | 1512 | $temp_array['direction_fullname'] = "Northeast"; |
1513 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1513 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1514 | 1514 | $temp_array['direction_degree'] = $direction; |
1515 | 1515 | $temp_array['direction_shortname'] = "ENE"; |
1516 | 1516 | $temp_array['direction_fullname'] = "East-Northeast"; |
1517 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1517 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1518 | 1518 | $temp_array['direction_degree'] = $direction; |
1519 | 1519 | $temp_array['direction_shortname'] = "E"; |
1520 | 1520 | $temp_array['direction_fullname'] = "East"; |
1521 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1521 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1522 | 1522 | $temp_array['direction_degree'] = $direction; |
1523 | 1523 | $temp_array['direction_shortname'] = "ESE"; |
1524 | 1524 | $temp_array['direction_fullname'] = "East-Southeast"; |
1525 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1525 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1526 | 1526 | $temp_array['direction_degree'] = $direction; |
1527 | 1527 | $temp_array['direction_shortname'] = "SE"; |
1528 | 1528 | $temp_array['direction_fullname'] = "Southeast"; |
1529 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1529 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1530 | 1530 | $temp_array['direction_degree'] = $direction; |
1531 | 1531 | $temp_array['direction_shortname'] = "SSE"; |
1532 | 1532 | $temp_array['direction_fullname'] = "South-Southeast"; |
1533 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1533 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1534 | 1534 | $temp_array['direction_degree'] = $direction; |
1535 | 1535 | $temp_array['direction_shortname'] = "S"; |
1536 | 1536 | $temp_array['direction_fullname'] = "South"; |
1537 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1537 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1538 | 1538 | $temp_array['direction_degree'] = $direction; |
1539 | 1539 | $temp_array['direction_shortname'] = "SSW"; |
1540 | 1540 | $temp_array['direction_fullname'] = "South-Southwest"; |
1541 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1541 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1542 | 1542 | $temp_array['direction_degree'] = $direction; |
1543 | 1543 | $temp_array['direction_shortname'] = "SW"; |
1544 | 1544 | $temp_array['direction_fullname'] = "Southwest"; |
1545 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1545 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1546 | 1546 | $temp_array['direction_degree'] = $direction; |
1547 | 1547 | $temp_array['direction_shortname'] = "WSW"; |
1548 | 1548 | $temp_array['direction_fullname'] = "West-Southwest"; |
1549 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1549 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1550 | 1550 | $temp_array['direction_degree'] = $direction; |
1551 | 1551 | $temp_array['direction_shortname'] = "W"; |
1552 | 1552 | $temp_array['direction_fullname'] = "West"; |
1553 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1553 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1554 | 1554 | $temp_array['direction_degree'] = $direction; |
1555 | 1555 | $temp_array['direction_shortname'] = "WNW"; |
1556 | 1556 | $temp_array['direction_fullname'] = "West-Northwest"; |
1557 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1557 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1558 | 1558 | $temp_array['direction_degree'] = $direction; |
1559 | 1559 | $temp_array['direction_shortname'] = "NW"; |
1560 | 1560 | $temp_array['direction_fullname'] = "Northwest"; |
1561 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1561 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1562 | 1562 | $temp_array['direction_degree'] = $direction; |
1563 | 1563 | $temp_array['direction_shortname'] = "NNW"; |
1564 | 1564 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1575,11 +1575,11 @@ discard block |
||
1575 | 1575 | * @param Float $longitude longitute of the flight |
1576 | 1576 | * @return String the countrie |
1577 | 1577 | */ |
1578 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1578 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1579 | 1579 | { |
1580 | 1580 | global $globalDBdriver, $globalDebug; |
1581 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1582 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1581 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1582 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1583 | 1583 | |
1584 | 1584 | $Connection = new Connection($this->db); |
1585 | 1585 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1619,7 +1619,7 @@ discard block |
||
1619 | 1619 | public function getCountryFromISO2($iso2) |
1620 | 1620 | { |
1621 | 1621 | global $globalDBdriver, $globalDebug; |
1622 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1622 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1623 | 1623 | |
1624 | 1624 | $Connection = new Connection($this->db); |
1625 | 1625 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1648,11 +1648,11 @@ discard block |
||
1648 | 1648 | * @return Array the vessel type list |
1649 | 1649 | * |
1650 | 1650 | */ |
1651 | - public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
1651 | + public function countAllTrackerTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1652 | 1652 | { |
1653 | 1653 | global $globalDBdriver; |
1654 | - $filter_query = $this->getFilter($filters,true,true); |
|
1655 | - $query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count |
|
1654 | + $filter_query = $this->getFilter($filters, true, true); |
|
1655 | + $query = "SELECT tracker_output.type AS tracker_type, COUNT(tracker_output.type) AS tracker_type_count |
|
1656 | 1656 | FROM tracker_output ".$filter_query." tracker_output.type <> ''"; |
1657 | 1657 | if ($olderthanmonths > 0) { |
1658 | 1658 | if ($globalDBdriver == 'mysql') { |
@@ -1672,28 +1672,28 @@ discard block |
||
1672 | 1672 | if ($year != '') { |
1673 | 1673 | if ($globalDBdriver == 'mysql') { |
1674 | 1674 | $query .= " AND YEAR(tracker_output.date) = :year"; |
1675 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1675 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1676 | 1676 | } else { |
1677 | 1677 | $query .= " AND EXTRACT(YEAR FROM tracker_output.date) = :year"; |
1678 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1678 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1679 | 1679 | } |
1680 | 1680 | } |
1681 | 1681 | if ($month != '') { |
1682 | 1682 | if ($globalDBdriver == 'mysql') { |
1683 | 1683 | $query .= " AND MONTH(tracker_output.date) = :month"; |
1684 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1684 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1685 | 1685 | } else { |
1686 | 1686 | $query .= " AND EXTRACT(MONTH FROM tracker_output.date) = :month"; |
1687 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1687 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1688 | 1688 | } |
1689 | 1689 | } |
1690 | 1690 | if ($day != '') { |
1691 | 1691 | if ($globalDBdriver == 'mysql') { |
1692 | 1692 | $query .= " AND DAY(tracker_output.date) = :day"; |
1693 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1693 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1694 | 1694 | } else { |
1695 | 1695 | $query .= " AND EXTRACT(DAY FROM tracker_output.date) = :day"; |
1696 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1696 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1697 | 1697 | } |
1698 | 1698 | } |
1699 | 1699 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
@@ -1702,7 +1702,7 @@ discard block |
||
1702 | 1702 | $sth->execute($query_values); |
1703 | 1703 | $tracker_array = array(); |
1704 | 1704 | $temp_array = array(); |
1705 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1705 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1706 | 1706 | { |
1707 | 1707 | $temp_array['tracker_type'] = $row['tracker_type']; |
1708 | 1708 | $temp_array['tracker_type_count'] = $row['tracker_type_count']; |
@@ -1737,7 +1737,7 @@ discard block |
||
1737 | 1737 | |
1738 | 1738 | $bitly_data = json_decode($bitly_data); |
1739 | 1739 | $bitly_url = ''; |
1740 | - if ($bitly_data->status_txt = "OK"){ |
|
1740 | + if ($bitly_data->status_txt = "OK") { |
|
1741 | 1741 | $bitly_url = $bitly_data->data->url; |
1742 | 1742 | } |
1743 | 1743 | |
@@ -1747,7 +1747,7 @@ discard block |
||
1747 | 1747 | |
1748 | 1748 | public function getOrderBy() |
1749 | 1749 | { |
1750 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
1750 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
1751 | 1751 | |
1752 | 1752 | return $orderby; |
1753 | 1753 |
@@ -8,20 +8,20 @@ discard block |
||
8 | 8 | require_once(dirname(__FILE__).'/class.Stats.php'); |
9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
10 | 10 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
11 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
11 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | class SpotterImport { |
15 | - private $all_flights = array(); |
|
16 | - private $last_delete_hourly = 0; |
|
17 | - private $last_delete = 0; |
|
18 | - private $stats = array(); |
|
19 | - private $tmd = 0; |
|
20 | - private $source_location = array(); |
|
21 | - public $db = null; |
|
22 | - public $nb = 0; |
|
23 | - |
|
24 | - public function __construct($dbc = null) { |
|
15 | + private $all_flights = array(); |
|
16 | + private $last_delete_hourly = 0; |
|
17 | + private $last_delete = 0; |
|
18 | + private $stats = array(); |
|
19 | + private $tmd = 0; |
|
20 | + private $source_location = array(); |
|
21 | + public $db = null; |
|
22 | + public $nb = 0; |
|
23 | + |
|
24 | + public function __construct($dbc = null) { |
|
25 | 25 | global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB; |
26 | 26 | if (!(isset($globalNoDB) && $globalNoDB)) { |
27 | 27 | $Connection = new Connection($dbc); |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | $currentdate = date('Y-m-d'); |
34 | 34 | $sourcestat = $Stats->getStatsSource($currentdate); |
35 | 35 | if (!empty($sourcestat)) { |
36 | - foreach($sourcestat as $srcst) { |
|
37 | - $type = $srcst['stats_type']; |
|
36 | + foreach($sourcestat as $srcst) { |
|
37 | + $type = $srcst['stats_type']; |
|
38 | 38 | if ($type == 'polar' || $type == 'hist') { |
39 | - $source = $srcst['source_name']; |
|
40 | - $data = $srcst['source_data']; |
|
41 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
42 | - } |
|
43 | - } |
|
39 | + $source = $srcst['source_name']; |
|
40 | + $data = $srcst['source_data']; |
|
41 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
42 | + } |
|
43 | + } |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | //$APRSSpotter->connect(); |
49 | 49 | } |
50 | 50 | |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | - public function get_Schedule($id,$ident) { |
|
53 | + public function get_Schedule($id,$ident) { |
|
54 | 54 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
55 | 55 | // Get schedule here, so it's done only one time |
56 | 56 | |
@@ -70,42 +70,42 @@ discard block |
||
70 | 70 | $operator = $Spotter->getOperator($ident); |
71 | 71 | $scheduleexist = false; |
72 | 72 | if ($Schedule->checkSchedule($operator) == 0) { |
73 | - $operator = $Translation->checkTranslation($ident); |
|
74 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
73 | + $operator = $Translation->checkTranslation($ident); |
|
74 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
75 | 75 | $schedule = $Schedule->fetchSchedule($operator); |
76 | 76 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
77 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
78 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
79 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
80 | - // Should also check if route schedule = route from DB |
|
81 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
77 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
78 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
79 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
80 | + // Should also check if route schedule = route from DB |
|
81 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
82 | 82 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
83 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
84 | - if (trim($airport_icao) != '') { |
|
83 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
84 | + if (trim($airport_icao) != '') { |
|
85 | 85 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
86 | 86 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
87 | - } |
|
87 | + } |
|
88 | + } |
|
88 | 89 | } |
89 | - } |
|
90 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
90 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
91 | 91 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
92 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
93 | - if (trim($airport_icao) != '') { |
|
92 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
93 | + if (trim($airport_icao) != '') { |
|
94 | 94 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
95 | 95 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
96 | - } |
|
96 | + } |
|
97 | 97 | } |
98 | - } |
|
99 | - $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']); |
|
98 | + } |
|
99 | + $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']); |
|
100 | 100 | } |
101 | - } else $scheduleexist = true; |
|
101 | + } else $scheduleexist = true; |
|
102 | 102 | } else $scheduleexist = true; |
103 | 103 | // close connection, at least one way will work ? |
104 | - if ($scheduleexist) { |
|
104 | + if ($scheduleexist) { |
|
105 | 105 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
106 | - $sch = $Schedule->getSchedule($operator); |
|
106 | + $sch = $Schedule->getSchedule($operator); |
|
107 | 107 | $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'])); |
108 | - } |
|
108 | + } |
|
109 | 109 | $Spotter->db = null; |
110 | 110 | $Schedule->db = null; |
111 | 111 | $Translation->db = null; |
@@ -120,96 +120,96 @@ discard block |
||
120 | 120 | } |
121 | 121 | */ |
122 | 122 | } |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | - public function checkAll() { |
|
125 | + public function checkAll() { |
|
126 | 126 | global $globalDebug, $globalNoImport; |
127 | 127 | if ($globalDebug) echo "Update last seen flights data...\n"; |
128 | 128 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
129 | - foreach ($this->all_flights as $key => $flight) { |
|
129 | + foreach ($this->all_flights as $key => $flight) { |
|
130 | 130 | if (isset($this->all_flights[$key]['id'])) { |
131 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
132 | - $Spotter = new Spotter($this->db); |
|
133 | - $real_arrival = $this->arrival($key); |
|
134 | - if (isset($this->all_flights[$key]['altitude'])) $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']); |
|
135 | - } |
|
136 | - } |
|
131 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
132 | + $Spotter = new Spotter($this->db); |
|
133 | + $real_arrival = $this->arrival($key); |
|
134 | + if (isset($this->all_flights[$key]['altitude'])) $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']); |
|
135 | + } |
|
136 | + } |
|
137 | + } |
|
137 | 138 | } |
138 | - } |
|
139 | 139 | |
140 | - public function arrival($key) { |
|
140 | + public function arrival($key) { |
|
141 | 141 | global $globalClosestMinDist, $globalDebug; |
142 | 142 | if ($globalDebug) echo 'Update arrival...'."\n"; |
143 | 143 | $Spotter = new Spotter($this->db); |
144 | - $airport_icao = ''; |
|
145 | - $airport_time = ''; |
|
146 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
144 | + $airport_icao = ''; |
|
145 | + $airport_time = ''; |
|
146 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
147 | 147 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
148 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
149 | - if (isset($closestAirports[0])) { |
|
150 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
151 | - $airport_icao = $closestAirports[0]['icao']; |
|
152 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
153 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
154 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
155 | - foreach ($closestAirports as $airport) { |
|
156 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
157 | - $airport_icao = $airport['icao']; |
|
158 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
159 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
160 | - break; |
|
161 | - } |
|
162 | - } |
|
163 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
164 | - $airport_icao = $closestAirports[0]['icao']; |
|
165 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
166 | - } else { |
|
167 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
168 | - } |
|
169 | - } else { |
|
170 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
171 | - } |
|
172 | - |
|
173 | - } else { |
|
174 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
175 | - } |
|
176 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - |
|
181 | - public function del() { |
|
148 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
149 | + if (isset($closestAirports[0])) { |
|
150 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
151 | + $airport_icao = $closestAirports[0]['icao']; |
|
152 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
153 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
154 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
155 | + foreach ($closestAirports as $airport) { |
|
156 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
157 | + $airport_icao = $airport['icao']; |
|
158 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
159 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
160 | + break; |
|
161 | + } |
|
162 | + } |
|
163 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
164 | + $airport_icao = $closestAirports[0]['icao']; |
|
165 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
166 | + } else { |
|
167 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
168 | + } |
|
169 | + } else { |
|
170 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
171 | + } |
|
172 | + |
|
173 | + } else { |
|
174 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
175 | + } |
|
176 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + |
|
181 | + public function del() { |
|
182 | 182 | global $globalDebug, $globalNoImport, $globalNoDB; |
183 | 183 | // Delete old infos |
184 | 184 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
185 | 185 | foreach ($this->all_flights as $key => $flight) { |
186 | - if (isset($flight['lastupdate'])) { |
|
187 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
188 | - if (isset($this->all_flights[$key]['id'])) { |
|
189 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
186 | + if (isset($flight['lastupdate'])) { |
|
187 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
188 | + if (isset($this->all_flights[$key]['id'])) { |
|
189 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
190 | 190 | /* |
191 | 191 | $SpotterLive = new SpotterLive(); |
192 | 192 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
193 | 193 | $SpotterLive->db = null; |
194 | 194 | */ |
195 | 195 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
196 | - $real_arrival = $this->arrival($key); |
|
197 | - $Spotter = new Spotter($this->db); |
|
198 | - if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
196 | + $real_arrival = $this->arrival($key); |
|
197 | + $Spotter = new Spotter($this->db); |
|
198 | + if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
199 | 199 | $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']); |
200 | 200 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
201 | - } |
|
201 | + } |
|
202 | 202 | // Put in archive |
203 | 203 | // $Spotter->db = null; |
204 | 204 | } |
205 | - } |
|
206 | - unset($this->all_flights[$key]); |
|
207 | - } |
|
208 | - } |
|
209 | - } |
|
210 | - } |
|
205 | + } |
|
206 | + unset($this->all_flights[$key]); |
|
207 | + } |
|
208 | + } |
|
209 | + } |
|
210 | + } |
|
211 | 211 | |
212 | - public function add($line) { |
|
212 | + public function add($line) { |
|
213 | 213 | 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; |
214 | 214 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
215 | 215 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
@@ -234,18 +234,18 @@ discard block |
||
234 | 234 | |
235 | 235 | // SBS format is CSV format |
236 | 236 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
237 | - //print_r($line); |
|
238 | - 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)) { |
|
237 | + //print_r($line); |
|
238 | + 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)) { |
|
239 | 239 | |
240 | 240 | // Increment message number |
241 | 241 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
242 | - $current_date = date('Y-m-d'); |
|
243 | - $source = $line['source_name']; |
|
244 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
245 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
246 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
247 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
248 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
242 | + $current_date = date('Y-m-d'); |
|
243 | + $source = $line['source_name']; |
|
244 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
245 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
246 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
247 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
248 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /* |
@@ -261,49 +261,49 @@ discard block |
||
261 | 261 | //$this->db = $dbc; |
262 | 262 | |
263 | 263 | //$hex = trim($line['hex']); |
264 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
265 | - else $id = trim($line['id']); |
|
264 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
265 | + else $id = trim($line['id']); |
|
266 | 266 | |
267 | 267 | if (!isset($this->all_flights[$id])) { |
268 | - $this->all_flights[$id] = array(); |
|
269 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
270 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', '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' => '')); |
|
271 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
272 | - if (!isset($line['id'])) { |
|
268 | + $this->all_flights[$id] = array(); |
|
269 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
270 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', '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' => '')); |
|
271 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
272 | + if (!isset($line['id'])) { |
|
273 | 273 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
274 | 274 | // 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'))); |
275 | 275 | // 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'))); |
276 | 276 | 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'))); |
277 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
278 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
279 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
277 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
278 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
279 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
280 | 280 | } |
281 | 281 | if (isset($line['source_type']) && $line['source_type'] != '') { |
282 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
282 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | //print_r($this->all_flights); |
286 | 286 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
287 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
288 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
287 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
288 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
289 | 289 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
290 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
291 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
290 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
291 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
292 | 292 | $timeelapsed = microtime(true); |
293 | 293 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
294 | - $Spotter = new Spotter($this->db); |
|
295 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
294 | + $Spotter = new Spotter($this->db); |
|
295 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
296 | 296 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
297 | - } else { |
|
297 | + } else { |
|
298 | 298 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
299 | - } |
|
300 | - $Spotter->db = null; |
|
301 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
302 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
299 | + } |
|
300 | + $Spotter->db = null; |
|
301 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
302 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
303 | 303 | } |
304 | - } |
|
305 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
306 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
304 | + } |
|
305 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
306 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
307 | 307 | } |
308 | 308 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
309 | 309 | $icao = $line['aircraft_icao']; |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | } |
334 | 334 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
335 | 335 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
336 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
336 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
337 | 337 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
338 | - } else { |
|
338 | + } else { |
|
339 | 339 | 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"; |
340 | 340 | 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"; |
341 | 341 | /* |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | print_r($line); |
345 | 345 | */ |
346 | 346 | return ''; |
347 | - } |
|
347 | + } |
|
348 | 348 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
349 | 349 | if ($globalDebug) echo "!!! Date is too old ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
350 | 350 | return ''; |
@@ -360,36 +360,36 @@ discard block |
||
360 | 360 | } |
361 | 361 | |
362 | 362 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
363 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
363 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
364 | 364 | } |
365 | 365 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
366 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
366 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
367 | 367 | } |
368 | 368 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
369 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
369 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
370 | 370 | } |
371 | 371 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
372 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
372 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
376 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
377 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
376 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
377 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
378 | 378 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
379 | - $timeelapsed = microtime(true); |
|
380 | - $Spotter = new Spotter($this->db); |
|
381 | - $fromsource = NULL; |
|
382 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
383 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
384 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
385 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
386 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
387 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
388 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
389 | - $Spotter->db = null; |
|
390 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
391 | - } |
|
392 | - } |
|
379 | + $timeelapsed = microtime(true); |
|
380 | + $Spotter = new Spotter($this->db); |
|
381 | + $fromsource = NULL; |
|
382 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
383 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
384 | + elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
385 | + elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
386 | + elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
387 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
388 | + if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
389 | + $Spotter->db = null; |
|
390 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
391 | + } |
|
392 | + } |
|
393 | 393 | |
394 | 394 | /* |
395 | 395 | if (!isset($line['id'])) { |
@@ -399,104 +399,104 @@ discard block |
||
399 | 399 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
400 | 400 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
401 | 401 | */ |
402 | - 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'])); |
|
402 | + 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'])); |
|
403 | 403 | |
404 | - //$putinarchive = true; |
|
405 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
404 | + //$putinarchive = true; |
|
405 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
406 | 406 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
407 | - } |
|
408 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
407 | + } |
|
408 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
409 | 409 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
410 | - } |
|
411 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
412 | - $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' => '')); |
|
413 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
410 | + } |
|
411 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
412 | + $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' => '')); |
|
413 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
414 | 414 | $timeelapsed = microtime(true); |
415 | 415 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
416 | 416 | $Spotter = new Spotter($this->db); |
417 | 417 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
418 | 418 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
419 | - $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' => '')); |
|
419 | + $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' => '')); |
|
420 | 420 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
421 | - } |
|
422 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
421 | + } |
|
422 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
423 | 423 | $timeelapsed = microtime(true); |
424 | 424 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
425 | - $Spotter = new Spotter($this->db); |
|
426 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
427 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
425 | + $Spotter = new Spotter($this->db); |
|
426 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
427 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
428 | 428 | $Translation = new Translation($this->db); |
429 | 429 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
430 | 430 | $route = $Spotter->getRouteInfo($ident); |
431 | 431 | $Translation->db = null; |
432 | - } |
|
433 | - $Spotter->db = null; |
|
434 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
435 | - } |
|
432 | + } |
|
433 | + $Spotter->db = null; |
|
434 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
435 | + } |
|
436 | 436 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
437 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
438 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
437 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
438 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
439 | 439 | // $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'])); |
440 | - $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'])); |
|
441 | - } |
|
440 | + $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'])); |
|
441 | + } |
|
442 | 442 | } |
443 | 443 | if (!isset($globalFork)) $globalFork = TRUE; |
444 | 444 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
445 | 445 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
446 | 446 | } |
447 | - } |
|
447 | + } |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | if (isset($line['speed']) && $line['speed'] != '') { |
451 | 451 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
452 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
453 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
454 | - //$dataFound = true; |
|
452 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
453 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
454 | + //$dataFound = true; |
|
455 | 455 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
456 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
457 | - if ($distance > 1000 && $distance < 10000) { |
|
458 | - // use datetime |
|
456 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
457 | + if ($distance > 1000 && $distance < 10000) { |
|
458 | + // use datetime |
|
459 | 459 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
460 | 460 | $speed = $speed*3.6; |
461 | 461 | if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
462 | 462 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
463 | - } |
|
463 | + } |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | |
467 | 467 | |
468 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude']) && !is_int($line['latitude']) && !is_int($line['longitude'])) { |
|
469 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
470 | - else unset($timediff); |
|
471 | - if ($this->tmd > 5 || (isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
468 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude']) && !is_int($line['latitude']) && !is_int($line['longitude'])) { |
|
469 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
470 | + else unset($timediff); |
|
471 | + if ($this->tmd > 5 || (isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
472 | 472 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
473 | - if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
473 | + if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
474 | 474 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
475 | 475 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
476 | 476 | $this->all_flights[$id]['putinarchive'] = true; |
477 | 477 | $this->tmd = 0; |
478 | 478 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
479 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
480 | - $timeelapsed = microtime(true); |
|
481 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
479 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
480 | + $timeelapsed = microtime(true); |
|
481 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
482 | 482 | $Spotter = new Spotter($this->db); |
483 | 483 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
484 | 484 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
485 | 485 | $Spotter->db = null; |
486 | 486 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
487 | 487 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
488 | - } |
|
488 | + } |
|
489 | + } |
|
489 | 490 | } |
490 | - } |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
494 | - //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
494 | + //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
495 | 495 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
496 | 496 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
497 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
498 | - $dataFound = true; |
|
499 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
497 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
498 | + $dataFound = true; |
|
499 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
500 | 500 | } |
501 | 501 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
502 | 502 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -507,20 +507,20 @@ discard block |
||
507 | 507 | //$putinarchive = true; |
508 | 508 | } |
509 | 509 | */ |
510 | - /* |
|
510 | + /* |
|
511 | 511 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
512 | 512 | if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n"; |
513 | 513 | } |
514 | 514 | */ |
515 | 515 | } |
516 | 516 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
517 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
518 | - //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) { |
|
517 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
518 | + //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) { |
|
519 | 519 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
520 | 520 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
521 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
522 | - $dataFound = true; |
|
523 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
521 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
522 | + $dataFound = true; |
|
523 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
524 | 524 | } |
525 | 525 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
526 | 526 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -538,95 +538,95 @@ discard block |
||
538 | 538 | */ |
539 | 539 | } |
540 | 540 | |
541 | - } else if ($globalDebug && $timediff > 30) { |
|
541 | + } else if ($globalDebug && $timediff > 30) { |
|
542 | 542 | $this->tmd = $this->tmd + 1; |
543 | 543 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
544 | 544 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
545 | 545 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
546 | 546 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
547 | - } |
|
547 | + } |
|
548 | 548 | } |
549 | 549 | if (isset($line['last_update']) && $line['last_update'] != '') { |
550 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
551 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
550 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
551 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
552 | 552 | } |
553 | 553 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
554 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
555 | - //$dataFound = true; |
|
554 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
555 | + //$dataFound = true; |
|
556 | 556 | } |
557 | 557 | if (isset($line['format_source']) && $line['format_source'] != '') { |
558 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
558 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
559 | 559 | } |
560 | 560 | if (isset($line['source_name']) && $line['source_name'] != '') { |
561 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
561 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
562 | 562 | } |
563 | 563 | if (isset($line['emergency']) && $line['emergency'] != '') { |
564 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
565 | - //$dataFound = true; |
|
564 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
565 | + //$dataFound = true; |
|
566 | 566 | } |
567 | 567 | if (isset($line['ground']) && $line['ground'] != '') { |
568 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
568 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
569 | 569 | // Here we force archive of flight because after ground it's a new one (or should be) |
570 | 570 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
571 | 571 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
572 | 572 | 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'].'-'.date('YmdGi'))); |
573 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
573 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
574 | 574 | 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'])); |
575 | - } |
|
576 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
577 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
578 | - //$dataFound = true; |
|
575 | + } |
|
576 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
577 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
578 | + //$dataFound = true; |
|
579 | 579 | } |
580 | 580 | if (isset($line['squawk']) && $line['squawk'] != '') { |
581 | - 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'])) { |
|
582 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
583 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
584 | - $highlight = ''; |
|
585 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
586 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
587 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
588 | - if ($highlight != '') { |
|
581 | + 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'])) { |
|
582 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
583 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
584 | + $highlight = ''; |
|
585 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
586 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
587 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
588 | + if ($highlight != '') { |
|
589 | 589 | $timeelapsed = microtime(true); |
590 | 590 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
591 | - $Spotter = new Spotter($this->db); |
|
592 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
593 | - $Spotter->db = null; |
|
594 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
591 | + $Spotter = new Spotter($this->db); |
|
592 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
593 | + $Spotter->db = null; |
|
594 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
595 | 595 | } |
596 | 596 | //$putinarchive = true; |
597 | 597 | //$highlight = ''; |
598 | - } |
|
598 | + } |
|
599 | 599 | |
600 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
601 | - //$dataFound = true; |
|
600 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
601 | + //$dataFound = true; |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | if (isset($line['altitude']) && $line['altitude'] != '') { |
605 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
605 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
606 | 606 | 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; |
607 | 607 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
608 | 608 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
609 | 609 | //$dataFound = true; |
610 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
610 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
614 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
614 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | if (isset($line['heading']) && $line['heading'] != '') { |
618 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
619 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
620 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
621 | - //$dataFound = true; |
|
618 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
619 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
620 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
621 | + //$dataFound = true; |
|
622 | 622 | } 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']) { |
623 | - $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']); |
|
624 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
625 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
626 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
623 | + $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']); |
|
624 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
625 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
626 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
627 | 627 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
628 | - // If not enough messages and ACARS set heading to 0 |
|
629 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
628 | + // If not enough messages and ACARS set heading to 0 |
|
629 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
630 | 630 | } |
631 | 631 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
632 | 632 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -637,125 +637,125 @@ discard block |
||
637 | 637 | //if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
638 | 638 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
639 | 639 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
640 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
641 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
642 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
643 | - //print_r($this->all_flights); |
|
644 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
645 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
646 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
640 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
641 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
642 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
643 | + //print_r($this->all_flights); |
|
644 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
645 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
646 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
647 | 647 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
648 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
649 | - $timeelapsed = microtime(true); |
|
650 | - $SpotterLive = new SpotterLive($this->db); |
|
651 | - 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')) { |
|
648 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
649 | + $timeelapsed = microtime(true); |
|
650 | + $SpotterLive = new SpotterLive($this->db); |
|
651 | + 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')) { |
|
652 | 652 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
653 | 653 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
654 | - } elseif (isset($line['id'])) { |
|
654 | + } elseif (isset($line['id'])) { |
|
655 | 655 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
656 | 656 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
657 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
657 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
658 | 658 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
659 | 659 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
660 | - } else $recent_ident = ''; |
|
661 | - $SpotterLive->db=null; |
|
662 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
663 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
660 | + } else $recent_ident = ''; |
|
661 | + $SpotterLive->db=null; |
|
662 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
663 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
664 | 664 | } else $recent_ident = ''; |
665 | - } else { |
|
665 | + } else { |
|
666 | 666 | $recent_ident = ''; |
667 | 667 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
668 | - } |
|
669 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
670 | - if($recent_ident == "") |
|
671 | - { |
|
668 | + } |
|
669 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
670 | + if($recent_ident == "") |
|
671 | + { |
|
672 | 672 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
673 | 673 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
674 | 674 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
675 | 675 | //adds the spotter data for the archive |
676 | 676 | $ignoreImport = false; |
677 | 677 | foreach($globalAirportIgnore as $airportIgnore) { |
678 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
678 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
679 | 679 | $ignoreImport = true; |
680 | - } |
|
680 | + } |
|
681 | 681 | } |
682 | 682 | if (count($globalAirportAccept) > 0) { |
683 | - $ignoreImport = true; |
|
684 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
683 | + $ignoreImport = true; |
|
684 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
685 | 685 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
686 | - $ignoreImport = false; |
|
686 | + $ignoreImport = false; |
|
687 | + } |
|
687 | 688 | } |
688 | - } |
|
689 | 689 | } |
690 | 690 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
691 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
691 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
692 | 692 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
693 | - $ignoreImport = true; |
|
693 | + $ignoreImport = true; |
|
694 | + } |
|
694 | 695 | } |
695 | - } |
|
696 | 696 | } |
697 | 697 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
698 | - $ignoreImport = true; |
|
699 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
698 | + $ignoreImport = true; |
|
699 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
700 | 700 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
701 | - $ignoreImport = false; |
|
701 | + $ignoreImport = false; |
|
702 | + } |
|
702 | 703 | } |
703 | - } |
|
704 | 704 | } |
705 | 705 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
706 | - $ignoreImport = true; |
|
707 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
706 | + $ignoreImport = true; |
|
707 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
708 | 708 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
709 | - $ignoreImport = false; |
|
709 | + $ignoreImport = false; |
|
710 | + } |
|
710 | 711 | } |
711 | - } |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | if (!$ignoreImport) { |
715 | - $highlight = ''; |
|
716 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
717 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
718 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
719 | - 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'))); |
|
720 | - $timeelapsed = microtime(true); |
|
721 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
715 | + $highlight = ''; |
|
716 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
717 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
718 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
719 | + 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'))); |
|
720 | + $timeelapsed = microtime(true); |
|
721 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
722 | 722 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
723 | - $Spotter = new Spotter($this->db); |
|
724 | - $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']); |
|
725 | - $Spotter->db = null; |
|
726 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
723 | + $Spotter = new Spotter($this->db); |
|
724 | + $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']); |
|
725 | + $Spotter->db = null; |
|
726 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
727 | + } |
|
727 | 728 | } |
728 | - } |
|
729 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
730 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
729 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
730 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
731 | 731 | |
732 | - // Add source stat in DB |
|
733 | - $Stats = new Stats($this->db); |
|
734 | - if (!empty($this->stats)) { |
|
732 | + // Add source stat in DB |
|
733 | + $Stats = new Stats($this->db); |
|
734 | + if (!empty($this->stats)) { |
|
735 | 735 | if ($globalDebug) echo 'Add source stats : '; |
736 | - foreach($this->stats as $date => $data) { |
|
737 | - foreach($data as $source => $sourced) { |
|
738 | - //print_r($sourced); |
|
739 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
740 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
741 | - if (isset($sourced['msg'])) { |
|
742 | - if (time() - $sourced['msg']['date'] > 10) { |
|
743 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
744 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
745 | - unset($this->stats[$date][$source]['msg']); |
|
746 | - } |
|
747 | - } |
|
748 | - } |
|
749 | - if ($date != date('Y-m-d')) { |
|
750 | - unset($this->stats[$date]); |
|
751 | - } |
|
752 | - } |
|
753 | - if ($globalDebug) echo 'Done'."\n"; |
|
754 | - |
|
755 | - } |
|
756 | - $Stats->db = null; |
|
757 | - } |
|
758 | - $this->del(); |
|
736 | + foreach($this->stats as $date => $data) { |
|
737 | + foreach($data as $source => $sourced) { |
|
738 | + //print_r($sourced); |
|
739 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
740 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
741 | + if (isset($sourced['msg'])) { |
|
742 | + if (time() - $sourced['msg']['date'] > 10) { |
|
743 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
744 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
745 | + unset($this->stats[$date][$source]['msg']); |
|
746 | + } |
|
747 | + } |
|
748 | + } |
|
749 | + if ($date != date('Y-m-d')) { |
|
750 | + unset($this->stats[$date]); |
|
751 | + } |
|
752 | + } |
|
753 | + if ($globalDebug) echo 'Done'."\n"; |
|
754 | + |
|
755 | + } |
|
756 | + $Stats->db = null; |
|
757 | + } |
|
758 | + $this->del(); |
|
759 | 759 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
760 | 760 | //$ignoreImport = false; |
761 | 761 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -773,41 +773,41 @@ discard block |
||
773 | 773 | */ |
774 | 774 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
775 | 775 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
776 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
777 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
778 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
776 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
777 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
778 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
779 | 779 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
780 | - $SpotterLive = new SpotterLive($this->db); |
|
781 | - $SpotterLive->deleteLiveSpotterData(); |
|
782 | - $SpotterLive->db=null; |
|
780 | + $SpotterLive = new SpotterLive($this->db); |
|
781 | + $SpotterLive->deleteLiveSpotterData(); |
|
782 | + $SpotterLive->db=null; |
|
783 | + } |
|
783 | 784 | } |
784 | - } |
|
785 | - if ($globalDebug) echo " Done\n"; |
|
786 | - $this->last_delete = time(); |
|
785 | + if ($globalDebug) echo " Done\n"; |
|
786 | + $this->last_delete = time(); |
|
787 | 787 | } |
788 | - } else { |
|
788 | + } else { |
|
789 | 789 | 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'] === 'famaprs')) { |
790 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
791 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
790 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
791 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
792 | 792 | } |
793 | 793 | if (isset($globalDaemon) && !$globalDaemon) { |
794 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
794 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
795 | 795 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
796 | - $Spotter = new Spotter($this->db); |
|
797 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
798 | - $Spotter->db = null; |
|
796 | + $Spotter = new Spotter($this->db); |
|
797 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
798 | + $Spotter->db = null; |
|
799 | + } |
|
799 | 800 | } |
800 | - } |
|
801 | 801 | } |
802 | 802 | |
803 | - } |
|
803 | + } |
|
804 | + } |
|
804 | 805 | } |
805 | - } |
|
806 | - //adds the spotter LIVE data |
|
807 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
808 | - //echo "\nAdd in Live !! \n"; |
|
809 | - //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"; |
|
810 | - if ($globalDebug) { |
|
806 | + //adds the spotter LIVE data |
|
807 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
808 | + //echo "\nAdd in Live !! \n"; |
|
809 | + //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"; |
|
810 | + if ($globalDebug) { |
|
811 | 811 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
812 | 812 | 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"; |
813 | 813 | 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"; |
@@ -815,60 +815,60 @@ discard block |
||
815 | 815 | 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"; |
816 | 816 | 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"; |
817 | 817 | } |
818 | - } |
|
819 | - $ignoreImport = false; |
|
820 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
821 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
818 | + } |
|
819 | + $ignoreImport = false; |
|
820 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
821 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
822 | 822 | |
823 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
824 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
825 | - $ignoreImport = true; |
|
823 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
824 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
825 | + $ignoreImport = true; |
|
826 | 826 | } |
827 | - } |
|
828 | - if (count($globalAirportAccept) > 0) { |
|
829 | - $ignoreImport = true; |
|
830 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
831 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
827 | + } |
|
828 | + if (count($globalAirportAccept) > 0) { |
|
829 | + $ignoreImport = true; |
|
830 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
831 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
832 | 832 | $ignoreImport = false; |
833 | - } |
|
833 | + } |
|
834 | + } |
|
834 | 835 | } |
835 | - } |
|
836 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
836 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
837 | 837 | foreach($globalAirlineIgnore as $airlineIgnore) { |
838 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
838 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
839 | 839 | $ignoreImport = true; |
840 | - } |
|
840 | + } |
|
841 | 841 | } |
842 | - } |
|
843 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
842 | + } |
|
843 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
844 | 844 | $ignoreImport = true; |
845 | 845 | foreach($globalAirlineAccept as $airlineAccept) { |
846 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
846 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
847 | 847 | $ignoreImport = false; |
848 | - } |
|
848 | + } |
|
849 | + } |
|
849 | 850 | } |
850 | - } |
|
851 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
851 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
852 | 852 | $ignoreImport = true; |
853 | 853 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
854 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
855 | - $ignoreImport = false; |
|
856 | - } |
|
854 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
855 | + $ignoreImport = false; |
|
856 | + } |
|
857 | + } |
|
857 | 858 | } |
858 | - } |
|
859 | 859 | |
860 | - if (!$ignoreImport) { |
|
860 | + if (!$ignoreImport) { |
|
861 | 861 | 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'])) { |
862 | 862 | 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'))); |
863 | 863 | $timeelapsed = microtime(true); |
864 | 864 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
865 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
865 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
866 | 866 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
867 | 867 | $SpotterLive = new SpotterLive($this->db); |
868 | 868 | $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']); |
869 | 869 | $SpotterLive->db = null; |
870 | 870 | if ($globalDebug) echo $result."\n"; |
871 | - } |
|
871 | + } |
|
872 | 872 | } |
873 | 873 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
874 | 874 | $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']); |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | //if ($line['format_source'] != 'aprs') { |
881 | 881 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
882 | 882 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
883 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
883 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
884 | 884 | $source = $this->all_flights[$id]['source_name']; |
885 | 885 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
886 | 886 | if (!isset($this->source_location[$source])) { |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | if ($stats_heading == 16) $stats_heading = 0; |
907 | 907 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
908 | 908 | for ($i=0;$i<=15;$i++) { |
909 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
909 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
910 | 910 | } |
911 | 911 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
912 | 912 | } else { |
@@ -919,17 +919,17 @@ discard block |
||
919 | 919 | //var_dump($this->stats); |
920 | 920 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
921 | 921 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
922 | - end($this->stats[$current_date][$source]['hist']); |
|
923 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
922 | + end($this->stats[$current_date][$source]['hist']); |
|
923 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
924 | 924 | } else $mini = 0; |
925 | 925 | for ($i=$mini;$i<=$distance;$i+=10) { |
926 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
926 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
927 | 927 | } |
928 | 928 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
929 | 929 | } else { |
930 | 930 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
931 | 931 | } |
932 | - } |
|
932 | + } |
|
933 | 933 | } |
934 | 934 | |
935 | 935 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | //$this->del(); |
940 | 940 | |
941 | 941 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
942 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
942 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
943 | 943 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
944 | 944 | $SpotterLive = new SpotterLive($this->db); |
945 | 945 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -947,19 +947,19 @@ discard block |
||
947 | 947 | //SpotterLive->deleteLiveSpotterData(); |
948 | 948 | if ($globalDebug) echo " Done\n"; |
949 | 949 | $this->last_delete_hourly = time(); |
950 | - } else { |
|
950 | + } else { |
|
951 | 951 | $this->del(); |
952 | 952 | $this->last_delete_hourly = time(); |
953 | - } |
|
953 | + } |
|
954 | 954 | } |
955 | 955 | |
956 | - } |
|
957 | - //$ignoreImport = false; |
|
956 | + } |
|
957 | + //$ignoreImport = false; |
|
958 | 958 | } |
959 | 959 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
960 | 960 | if ($send) return $this->all_flights[$id]; |
961 | - } |
|
961 | + } |
|
962 | + } |
|
962 | 963 | } |
963 | - } |
|
964 | 964 | } |
965 | 965 | ?> |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | $currentdate = date('Y-m-d'); |
34 | 34 | $sourcestat = $Stats->getStatsSource($currentdate); |
35 | 35 | if (!empty($sourcestat)) { |
36 | - foreach($sourcestat as $srcst) { |
|
36 | + foreach ($sourcestat as $srcst) { |
|
37 | 37 | $type = $srcst['stats_type']; |
38 | 38 | if ($type == 'polar' || $type == 'hist') { |
39 | 39 | $source = $srcst['source_name']; |
40 | 40 | $data = $srcst['source_data']; |
41 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
41 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | } |
52 | 52 | |
53 | - public function get_Schedule($id,$ident) { |
|
53 | + public function get_Schedule($id, $ident) { |
|
54 | 54 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
55 | 55 | // Get schedule here, so it's done only one time |
56 | 56 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | $schedule = $Schedule->fetchSchedule($operator); |
76 | 76 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
77 | 77 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
78 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
79 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
78 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
79 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
80 | 80 | // Should also check if route schedule = route from DB |
81 | 81 | if ($schedule['DepartureAirportIATA'] != '') { |
82 | 82 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |
99 | - $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']); |
|
99 | + $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']); |
|
100 | 100 | } |
101 | 101 | } else $scheduleexist = true; |
102 | 102 | } else $scheduleexist = true; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | if ($scheduleexist) { |
105 | 105 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
106 | 106 | $sch = $Schedule->getSchedule($operator); |
107 | - $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'])); |
|
107 | + $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'])); |
|
108 | 108 | } |
109 | 109 | $Spotter->db = null; |
110 | 110 | $Schedule->db = null; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
132 | 132 | $Spotter = new Spotter($this->db); |
133 | 133 | $real_arrival = $this->arrival($key); |
134 | - if (isset($this->all_flights[$key]['altitude'])) $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']); |
|
134 | + if (isset($this->all_flights[$key]['altitude'])) $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']); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $airport_time = ''; |
146 | 146 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
147 | 147 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
148 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
148 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
149 | 149 | if (isset($closestAirports[0])) { |
150 | 150 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
151 | 151 | $airport_icao = $closestAirports[0]['icao']; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | break; |
161 | 161 | } |
162 | 162 | } |
163 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
163 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
164 | 164 | $airport_icao = $closestAirports[0]['icao']; |
165 | 165 | $airport_time = $this->all_flights[$key]['datetime']; |
166 | 166 | } else { |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } else { |
174 | 174 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
175 | 175 | } |
176 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
176 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
185 | 185 | foreach ($this->all_flights as $key => $flight) { |
186 | 186 | if (isset($flight['lastupdate'])) { |
187 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
187 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
188 | 188 | if (isset($this->all_flights[$key]['id'])) { |
189 | 189 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
190 | 190 | /* |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $real_arrival = $this->arrival($key); |
197 | 197 | $Spotter = new Spotter($this->db); |
198 | 198 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
199 | - $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']); |
|
199 | + $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']); |
|
200 | 200 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
201 | 201 | } |
202 | 202 | // Put in archive |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $send = false; |
234 | 234 | |
235 | 235 | // SBS format is CSV format |
236 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
236 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
237 | 237 | //print_r($line); |
238 | 238 | 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)) { |
239 | 239 | |
@@ -266,25 +266,25 @@ discard block |
||
266 | 266 | |
267 | 267 | if (!isset($this->all_flights[$id])) { |
268 | 268 | $this->all_flights[$id] = array(); |
269 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
270 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', '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' => '')); |
|
271 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
269 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
270 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', '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' => '')); |
|
271 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
272 | 272 | if (!isset($line['id'])) { |
273 | 273 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
274 | 274 | // 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'))); |
275 | 275 | // 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'))); |
276 | - 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'))); |
|
276 | + 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'))); |
|
277 | 277 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
278 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
278 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
279 | 279 | if ($globalAllFlights !== FALSE) $dataFound = true; |
280 | 280 | } |
281 | 281 | if (isset($line['source_type']) && $line['source_type'] != '') { |
282 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
282 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | //print_r($this->all_flights); |
286 | 286 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
287 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
287 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
288 | 288 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
289 | 289 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
290 | 290 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -293,13 +293,13 @@ discard block |
||
293 | 293 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
294 | 294 | $Spotter = new Spotter($this->db); |
295 | 295 | if (isset($this->all_flights[$id]['source_type'])) { |
296 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
296 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
297 | 297 | } else { |
298 | 298 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
299 | 299 | } |
300 | 300 | $Spotter->db = null; |
301 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
302 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
301 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
302 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | if ($globalAllFlights !== FALSE) $dataFound = true; |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $Spotter = new Spotter($this->db); |
311 | 311 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
312 | 312 | $Spotter->db = null; |
313 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
313 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
314 | 314 | } |
315 | 315 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
316 | 316 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | $Spotter = new Spotter($this->db); |
319 | 319 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
320 | 320 | $Spotter->db = null; |
321 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
321 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -326,15 +326,15 @@ discard block |
||
326 | 326 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
327 | 327 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
328 | 328 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
329 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
329 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
330 | 330 | } |
331 | 331 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
332 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
332 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
333 | 333 | } |
334 | 334 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
335 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
335 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
336 | 336 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
337 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
337 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
338 | 338 | } else { |
339 | 339 | 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"; |
340 | 340 | 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"; |
@@ -345,35 +345,35 @@ discard block |
||
345 | 345 | */ |
346 | 346 | return ''; |
347 | 347 | } |
348 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
348 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
349 | 349 | if ($globalDebug) echo "!!! Date is too old ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
350 | 350 | return ''; |
351 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
351 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
352 | 352 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
353 | 353 | return ''; |
354 | 354 | } elseif (!isset($line['datetime'])) { |
355 | 355 | date_default_timezone_set('UTC'); |
356 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
356 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
357 | 357 | } else { |
358 | 358 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
359 | 359 | return ''; |
360 | 360 | } |
361 | 361 | |
362 | 362 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
363 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
363 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
364 | 364 | } |
365 | 365 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
366 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
366 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
367 | 367 | } |
368 | 368 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
369 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
369 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
370 | 370 | } |
371 | 371 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
372 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
372 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
376 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
376 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
377 | 377 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
378 | 378 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
379 | 379 | $timeelapsed = microtime(true); |
@@ -384,10 +384,10 @@ discard block |
||
384 | 384 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
385 | 385 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
386 | 386 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
387 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
387 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
388 | 388 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
389 | 389 | $Spotter->db = null; |
390 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
390 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
@@ -399,25 +399,25 @@ discard block |
||
399 | 399 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
400 | 400 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
401 | 401 | */ |
402 | - 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'])); |
|
402 | + 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'])); |
|
403 | 403 | |
404 | 404 | //$putinarchive = true; |
405 | 405 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
406 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
406 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
407 | 407 | } |
408 | 408 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
409 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
409 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
410 | 410 | } |
411 | 411 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
412 | - $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' => '')); |
|
412 | + $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' => '')); |
|
413 | 413 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
414 | 414 | $timeelapsed = microtime(true); |
415 | 415 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
416 | 416 | $Spotter = new Spotter($this->db); |
417 | 417 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
418 | 418 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
419 | - $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' => '')); |
|
420 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
419 | + $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' => '')); |
|
420 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
421 | 421 | } |
422 | 422 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
423 | 423 | $timeelapsed = microtime(true); |
@@ -431,34 +431,34 @@ discard block |
||
431 | 431 | $Translation->db = null; |
432 | 432 | } |
433 | 433 | $Spotter->db = null; |
434 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
434 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
435 | 435 | } |
436 | 436 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
437 | 437 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
438 | 438 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
439 | 439 | // $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'])); |
440 | - $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'])); |
|
440 | + $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'])); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | if (!isset($globalFork)) $globalFork = TRUE; |
444 | 444 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
445 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
445 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
446 | 446 | } |
447 | 447 | } |
448 | 448 | } |
449 | 449 | |
450 | 450 | if (isset($line['speed']) && $line['speed'] != '') { |
451 | 451 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
452 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
453 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
452 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
453 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
454 | 454 | //$dataFound = true; |
455 | 455 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
456 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
456 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
457 | 457 | if ($distance > 1000 && $distance < 10000) { |
458 | 458 | // use datetime |
459 | 459 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
460 | 460 | $speed = $speed*3.6; |
461 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
461 | + if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
462 | 462 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
463 | 463 | } |
464 | 464 | } |
@@ -466,11 +466,11 @@ discard block |
||
466 | 466 | |
467 | 467 | |
468 | 468 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude']) && !is_int($line['latitude']) && !is_int($line['longitude'])) { |
469 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
469 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
470 | 470 | else unset($timediff); |
471 | - if ($this->tmd > 5 || (isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
471 | + if ($this->tmd > 5 || (isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) { |
|
472 | 472 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
473 | - if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
473 | + if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
474 | 474 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
475 | 475 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
476 | 476 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -480,10 +480,10 @@ discard block |
||
480 | 480 | $timeelapsed = microtime(true); |
481 | 481 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
482 | 482 | $Spotter = new Spotter($this->db); |
483 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
483 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
484 | 484 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
485 | 485 | $Spotter->db = null; |
486 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
486 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
487 | 487 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
488 | 488 | } |
489 | 489 | } |
@@ -493,13 +493,13 @@ discard block |
||
493 | 493 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
494 | 494 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
495 | 495 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
496 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
496 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
497 | 497 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
498 | 498 | $dataFound = true; |
499 | 499 | $this->all_flights[$id]['time_last_coord'] = time(); |
500 | 500 | } |
501 | 501 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
502 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
502 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
503 | 503 | /* |
504 | 504 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
505 | 505 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -517,13 +517,13 @@ discard block |
||
517 | 517 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
518 | 518 | //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) { |
519 | 519 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
520 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
520 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
521 | 521 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
522 | 522 | $dataFound = true; |
523 | 523 | $this->all_flights[$id]['time_last_coord'] = time(); |
524 | 524 | } |
525 | 525 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
526 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
526 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
527 | 527 | /* |
528 | 528 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
529 | 529 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -541,46 +541,46 @@ discard block |
||
541 | 541 | } else if ($globalDebug && $timediff > 30) { |
542 | 542 | $this->tmd = $this->tmd + 1; |
543 | 543 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
544 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
545 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
544 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
545 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
546 | 546 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
547 | 547 | } |
548 | 548 | } |
549 | 549 | if (isset($line['last_update']) && $line['last_update'] != '') { |
550 | 550 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
551 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
551 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
552 | 552 | } |
553 | 553 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
554 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
554 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
555 | 555 | //$dataFound = true; |
556 | 556 | } |
557 | 557 | if (isset($line['format_source']) && $line['format_source'] != '') { |
558 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
558 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
559 | 559 | } |
560 | 560 | if (isset($line['source_name']) && $line['source_name'] != '') { |
561 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
561 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
562 | 562 | } |
563 | 563 | if (isset($line['emergency']) && $line['emergency'] != '') { |
564 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
564 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
565 | 565 | //$dataFound = true; |
566 | 566 | } |
567 | 567 | if (isset($line['ground']) && $line['ground'] != '') { |
568 | 568 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
569 | 569 | // Here we force archive of flight because after ground it's a new one (or should be) |
570 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
571 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
572 | - 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'].'-'.date('YmdGi'))); |
|
573 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
574 | - 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'])); |
|
570 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
571 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
572 | + 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'].'-'.date('YmdGi'))); |
|
573 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
574 | + 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'])); |
|
575 | 575 | } |
576 | 576 | if ($line['ground'] != 1) $line['ground'] = 0; |
577 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
577 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
578 | 578 | //$dataFound = true; |
579 | 579 | } |
580 | 580 | if (isset($line['squawk']) && $line['squawk'] != '') { |
581 | 581 | 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'])) { |
582 | 582 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
583 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
583 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
584 | 584 | $highlight = ''; |
585 | 585 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
586 | 586 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -589,47 +589,47 @@ discard block |
||
589 | 589 | $timeelapsed = microtime(true); |
590 | 590 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
591 | 591 | $Spotter = new Spotter($this->db); |
592 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
592 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
593 | 593 | $Spotter->db = null; |
594 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
594 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
595 | 595 | } |
596 | 596 | //$putinarchive = true; |
597 | 597 | //$highlight = ''; |
598 | 598 | } |
599 | 599 | |
600 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
600 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
601 | 601 | //$dataFound = true; |
602 | 602 | } |
603 | 603 | |
604 | 604 | if (isset($line['altitude']) && $line['altitude'] != '') { |
605 | 605 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
606 | - 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; |
|
607 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
608 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
606 | + 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; |
|
607 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
608 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
609 | 609 | //$dataFound = true; |
610 | 610 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
611 | 611 | } |
612 | 612 | |
613 | 613 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
614 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
614 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | if (isset($line['heading']) && $line['heading'] != '') { |
618 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
619 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
620 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
618 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
619 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
620 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
621 | 621 | //$dataFound = true; |
622 | 622 | } 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']) { |
623 | - $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']); |
|
624 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
625 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
623 | + $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']); |
|
624 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
625 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
626 | 626 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
627 | 627 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
628 | 628 | // If not enough messages and ACARS set heading to 0 |
629 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
629 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
630 | 630 | } |
631 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
632 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
631 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
632 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
633 | 633 | |
634 | 634 | // print_r($this->all_flights[$id]); |
635 | 635 | //gets the callsign from the last hour |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
640 | 640 | $this->all_flights[$id]['lastupdate'] = time(); |
641 | 641 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
642 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
642 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
643 | 643 | //print_r($this->all_flights); |
644 | 644 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
645 | 645 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -650,61 +650,61 @@ discard block |
||
650 | 650 | $SpotterLive = new SpotterLive($this->db); |
651 | 651 | 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')) { |
652 | 652 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
653 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
653 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
654 | 654 | } elseif (isset($line['id'])) { |
655 | 655 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
656 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
656 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
657 | 657 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
658 | 658 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
659 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
659 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
660 | 660 | } else $recent_ident = ''; |
661 | - $SpotterLive->db=null; |
|
661 | + $SpotterLive->db = null; |
|
662 | 662 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
663 | 663 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
664 | 664 | } else $recent_ident = ''; |
665 | 665 | } else { |
666 | 666 | $recent_ident = ''; |
667 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
667 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
668 | 668 | } |
669 | 669 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
670 | - if($recent_ident == "") |
|
670 | + if ($recent_ident == "") |
|
671 | 671 | { |
672 | 672 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
673 | 673 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
674 | 674 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
675 | 675 | //adds the spotter data for the archive |
676 | 676 | $ignoreImport = false; |
677 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
677 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
678 | 678 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
679 | 679 | $ignoreImport = true; |
680 | 680 | } |
681 | 681 | } |
682 | 682 | if (count($globalAirportAccept) > 0) { |
683 | 683 | $ignoreImport = true; |
684 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
684 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
685 | 685 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
686 | 686 | $ignoreImport = false; |
687 | 687 | } |
688 | 688 | } |
689 | 689 | } |
690 | 690 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
691 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
692 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
691 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
692 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
693 | 693 | $ignoreImport = true; |
694 | 694 | } |
695 | 695 | } |
696 | 696 | } |
697 | 697 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
698 | 698 | $ignoreImport = true; |
699 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
700 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
699 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
700 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
701 | 701 | $ignoreImport = false; |
702 | 702 | } |
703 | 703 | } |
704 | 704 | } |
705 | 705 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
706 | 706 | $ignoreImport = true; |
707 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
707 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
708 | 708 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
709 | 709 | $ignoreImport = false; |
710 | 710 | } |
@@ -716,32 +716,32 @@ discard block |
||
716 | 716 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
717 | 717 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
718 | 718 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
719 | - 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'))); |
|
719 | + 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'))); |
|
720 | 720 | $timeelapsed = microtime(true); |
721 | 721 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
722 | 722 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
723 | 723 | $Spotter = new Spotter($this->db); |
724 | - $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']); |
|
724 | + $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']); |
|
725 | 725 | $Spotter->db = null; |
726 | 726 | if ($globalDebug && isset($result)) echo $result."\n"; |
727 | 727 | } |
728 | 728 | } |
729 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
729 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
730 | 730 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
731 | 731 | |
732 | 732 | // Add source stat in DB |
733 | 733 | $Stats = new Stats($this->db); |
734 | 734 | if (!empty($this->stats)) { |
735 | 735 | if ($globalDebug) echo 'Add source stats : '; |
736 | - foreach($this->stats as $date => $data) { |
|
737 | - foreach($data as $source => $sourced) { |
|
736 | + foreach ($this->stats as $date => $data) { |
|
737 | + foreach ($data as $source => $sourced) { |
|
738 | 738 | //print_r($sourced); |
739 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
740 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
739 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
740 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
741 | 741 | if (isset($sourced['msg'])) { |
742 | 742 | if (time() - $sourced['msg']['date'] > 10) { |
743 | 743 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
744 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
744 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
745 | 745 | unset($this->stats[$date][$source]['msg']); |
746 | 746 | } |
747 | 747 | } |
@@ -779,14 +779,14 @@ discard block |
||
779 | 779 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
780 | 780 | $SpotterLive = new SpotterLive($this->db); |
781 | 781 | $SpotterLive->deleteLiveSpotterData(); |
782 | - $SpotterLive->db=null; |
|
782 | + $SpotterLive->db = null; |
|
783 | 783 | } |
784 | 784 | } |
785 | 785 | if ($globalDebug) echo " Done\n"; |
786 | 786 | $this->last_delete = time(); |
787 | 787 | } |
788 | 788 | } else { |
789 | - 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'] === 'famaprs')) { |
|
789 | + 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'] === 'famaprs')) { |
|
790 | 790 | $this->all_flights[$id]['id'] = $recent_ident; |
791 | 791 | $this->all_flights[$id]['addedSpotter'] = 1; |
792 | 792 | } |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
795 | 795 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
796 | 796 | $Spotter = new Spotter($this->db); |
797 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
797 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
798 | 798 | $Spotter->db = null; |
799 | 799 | } |
800 | 800 | } |
@@ -820,37 +820,37 @@ discard block |
||
820 | 820 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
821 | 821 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
822 | 822 | |
823 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
823 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
824 | 824 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
825 | 825 | $ignoreImport = true; |
826 | 826 | } |
827 | 827 | } |
828 | 828 | if (count($globalAirportAccept) > 0) { |
829 | 829 | $ignoreImport = true; |
830 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
830 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
831 | 831 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
832 | 832 | $ignoreImport = false; |
833 | 833 | } |
834 | 834 | } |
835 | 835 | } |
836 | 836 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
837 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
838 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
837 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
838 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
839 | 839 | $ignoreImport = true; |
840 | 840 | } |
841 | 841 | } |
842 | 842 | } |
843 | 843 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
844 | 844 | $ignoreImport = true; |
845 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
846 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
845 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
846 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
847 | 847 | $ignoreImport = false; |
848 | 848 | } |
849 | 849 | } |
850 | 850 | } |
851 | 851 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
852 | 852 | $ignoreImport = true; |
853 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
853 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
854 | 854 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
855 | 855 | $ignoreImport = false; |
856 | 856 | } |
@@ -858,23 +858,23 @@ discard block |
||
858 | 858 | } |
859 | 859 | |
860 | 860 | if (!$ignoreImport) { |
861 | - 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'])) { |
|
862 | - 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'))); |
|
861 | + 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'])) { |
|
862 | + 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'))); |
|
863 | 863 | $timeelapsed = microtime(true); |
864 | 864 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
865 | 865 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
866 | 866 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
867 | 867 | $SpotterLive = new SpotterLive($this->db); |
868 | - $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']); |
|
868 | + $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']); |
|
869 | 869 | $SpotterLive->db = null; |
870 | 870 | if ($globalDebug) echo $result."\n"; |
871 | 871 | } |
872 | 872 | } |
873 | 873 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
874 | - $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']); |
|
874 | + $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']); |
|
875 | 875 | } |
876 | 876 | $this->all_flights[$id]['putinarchive'] = false; |
877 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
877 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
878 | 878 | |
879 | 879 | // Put statistics in $this->stats variable |
880 | 880 | //if ($line['format_source'] != 'aprs') { |
@@ -893,19 +893,19 @@ discard block |
||
893 | 893 | $latitude = $globalCenterLatitude; |
894 | 894 | $longitude = $globalCenterLongitude; |
895 | 895 | } |
896 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
896 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
897 | 897 | } else { |
898 | 898 | $latitude = $this->source_location[$source]['latitude']; |
899 | 899 | $longitude = $this->source_location[$source]['longitude']; |
900 | 900 | } |
901 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
901 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
902 | 902 | //$stats_heading = $stats_heading%22.5; |
903 | 903 | $stats_heading = round($stats_heading/22.5); |
904 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
904 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
905 | 905 | $current_date = date('Y-m-d'); |
906 | 906 | if ($stats_heading == 16) $stats_heading = 0; |
907 | 907 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
908 | - for ($i=0;$i<=15;$i++) { |
|
908 | + for ($i = 0; $i <= 15; $i++) { |
|
909 | 909 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
910 | 910 | } |
911 | 911 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -920,9 +920,9 @@ discard block |
||
920 | 920 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
921 | 921 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
922 | 922 | end($this->stats[$current_date][$source]['hist']); |
923 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
923 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
924 | 924 | } else $mini = 0; |
925 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
925 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
926 | 926 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
927 | 927 | } |
928 | 928 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | $this->all_flights[$id]['lastupdate'] = time(); |
936 | 936 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
937 | 937 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
938 | - } 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"; |
|
938 | + } 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"; |
|
939 | 939 | //$this->del(); |
940 | 940 | |
941 | 941 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
3 | 3 | $global_query = "SELECT marine_output.* FROM marine_output"; |
4 | 4 | |
5 | -class Marine{ |
|
5 | +class Marine { |
|
6 | 6 | public $db; |
7 | 7 | |
8 | 8 | public function __construct($dbc = null) { |
@@ -16,33 +16,33 @@ discard block |
||
16 | 16 | * @return Array the SQL part |
17 | 17 | */ |
18 | 18 | |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($filter[0]['source'])) { |
30 | - $filters = array_merge($filters,$filter); |
|
30 | + $filters = array_merge($filters, $filter); |
|
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
33 | 33 | $filter_query_join = ''; |
34 | 34 | $filter_query_where = ''; |
35 | - foreach($filters as $flt) { |
|
35 | + foreach ($filters as $flt) { |
|
36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
37 | 37 | if (isset($flt['source'])) { |
38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
39 | 39 | } else { |
40 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
46 | 46 | } |
47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
72 | 72 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
73 | 73 | if ($filter_query_where != '') { |
74 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
74 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
75 | 75 | } |
76 | 76 | $filter_query = $filter_query_join.$filter_query_where; |
77 | 77 | return $filter_query; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return Array the spotter information |
87 | 87 | * |
88 | 88 | */ |
89 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
89 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
90 | 90 | { |
91 | 91 | date_default_timezone_set('UTC'); |
92 | 92 | if (!is_string($query)) |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | $sth = $this->db->prepare($query.$limitQuery); |
107 | 107 | $sth->execute($params); |
108 | 108 | } catch (PDOException $e) { |
109 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
109 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
110 | 110 | exit(); |
111 | 111 | } |
112 | 112 | |
113 | 113 | $num_rows = 0; |
114 | 114 | $spotter_array = array(); |
115 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
115 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
116 | 116 | { |
117 | 117 | $num_rows++; |
118 | 118 | $temp_array = array(); |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | } |
145 | 145 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
146 | 146 | |
147 | - if($temp_array['mmsi'] != "") |
|
147 | + if ($temp_array['mmsi'] != "") |
|
148 | 148 | { |
149 | 149 | $Image = new Image($this->db); |
150 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
150 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
151 | 151 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
152 | 152 | unset($Image); |
153 | 153 | if (count($image_array) > 0) { |
@@ -183,17 +183,17 @@ discard block |
||
183 | 183 | { |
184 | 184 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
185 | 185 | } else { |
186 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
186 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
187 | 187 | } |
188 | 188 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
189 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
190 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
189 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
190 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
191 | 191 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
192 | 192 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
193 | 193 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
194 | 194 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
195 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
196 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
195 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
196 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
197 | 197 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
198 | 198 | } |
199 | 199 | } |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | if ($limit != "") |
227 | 227 | { |
228 | 228 | $limit_array = explode(",", $limit); |
229 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
230 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
229 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
230 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
231 | 231 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
232 | 232 | { |
233 | 233 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | } else { |
242 | 242 | $orderby_query = " ORDER BY marine_output.date DESC"; |
243 | 243 | } |
244 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
245 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
244 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
245 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
246 | 246 | return $spotter_array; |
247 | 247 | } |
248 | 248 | |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | if ($id == '') return array(); |
261 | 261 | $additional_query = "marine_output.fammarine_id = :id"; |
262 | 262 | $query_values = array(':id' => $id); |
263 | - $query = $global_query." WHERE ".$additional_query." "; |
|
264 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
263 | + $query = $global_query." WHERE ".$additional_query." "; |
|
264 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
265 | 265 | return $spotter_array; |
266 | 266 | } |
267 | 267 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $query_values = array(); |
281 | 281 | $limit_query = ''; |
282 | 282 | $additional_query = ''; |
283 | - $filter_query = $this->getFilter($filter,true,true); |
|
283 | + $filter_query = $this->getFilter($filter, true, true); |
|
284 | 284 | if ($ident != "") |
285 | 285 | { |
286 | 286 | if (!is_string($ident)) |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | { |
297 | 297 | $limit_array = explode(",", $limit); |
298 | 298 | |
299 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
300 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
299 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
300 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
301 | 301 | |
302 | 302 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
303 | 303 | { |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | return $spotter_array; |
322 | 322 | } |
323 | 323 | |
324 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
324 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
325 | 325 | { |
326 | 326 | global $global_query, $globalTimezone, $globalDBdriver; |
327 | 327 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $limit_query = ''; |
330 | 330 | $additional_query = ''; |
331 | 331 | |
332 | - $filter_query = $this->getFilter($filter,true,true); |
|
332 | + $filter_query = $this->getFilter($filter, true, true); |
|
333 | 333 | |
334 | 334 | if ($date != "") |
335 | 335 | { |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | { |
356 | 356 | $limit_array = explode(",", $limit); |
357 | 357 | |
358 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
359 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
358 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
359 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
360 | 360 | |
361 | 361 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
362 | 362 | { |
@@ -387,11 +387,11 @@ discard block |
||
387 | 387 | * @return Array list of source name |
388 | 388 | * |
389 | 389 | */ |
390 | - public function getAllSourceName($type = '',$filters = array()) |
|
390 | + public function getAllSourceName($type = '', $filters = array()) |
|
391 | 391 | { |
392 | - $filter_query = $this->getFilter($filters,true,true); |
|
392 | + $filter_query = $this->getFilter($filters, true, true); |
|
393 | 393 | $query_values = array(); |
394 | - $query = "SELECT DISTINCT marine_output.source_name |
|
394 | + $query = "SELECT DISTINCT marine_output.source_name |
|
395 | 395 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
396 | 396 | if ($type != '') { |
397 | 397 | $query_values = array(':type' => $type); |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | $source_array = array(); |
407 | 407 | $temp_array = array(); |
408 | 408 | |
409 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
409 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
410 | 410 | { |
411 | 411 | $temp_array['source_name'] = $row['source_name']; |
412 | 412 | $source_array[] = $temp_array; |
@@ -423,8 +423,8 @@ discard block |
||
423 | 423 | */ |
424 | 424 | public function getAllIdents($filters = array()) |
425 | 425 | { |
426 | - $filter_query = $this->getFilter($filters,true,true); |
|
427 | - $query = "SELECT DISTINCT marine_output.ident |
|
426 | + $filter_query = $this->getFilter($filters, true, true); |
|
427 | + $query = "SELECT DISTINCT marine_output.ident |
|
428 | 428 | FROM marine_output".$filter_query." marine_output.ident <> '' |
429 | 429 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
430 | 430 | |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | $ident_array = array(); |
435 | 435 | $temp_array = array(); |
436 | 436 | |
437 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
437 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
438 | 438 | { |
439 | 439 | $temp_array['ident'] = $row['ident']; |
440 | 440 | $ident_array[] = $temp_array; |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | */ |
452 | 452 | public function getIdentity($mmsi) |
453 | 453 | { |
454 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
454 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
455 | 455 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
456 | 456 | $sth = $this->db->prepare($query); |
457 | 457 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -476,12 +476,12 @@ discard block |
||
476 | 476 | } else $offset = '+00:00'; |
477 | 477 | |
478 | 478 | if ($globalDBdriver == 'mysql') { |
479 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
479 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
480 | 480 | FROM marine_output |
481 | 481 | WHERE marine_output.date <> '' |
482 | 482 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
483 | 483 | } else { |
484 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
484 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
485 | 485 | FROM marine_output |
486 | 486 | WHERE marine_output.date <> '' |
487 | 487 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | $date_array = array(); |
494 | 494 | $temp_array = array(); |
495 | 495 | |
496 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
496 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
497 | 497 | { |
498 | 498 | $temp_array['date'] = $row['date']; |
499 | 499 | |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | * @return String success or false |
513 | 513 | * |
514 | 514 | */ |
515 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
515 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
516 | 516 | { |
517 | 517 | |
518 | 518 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
519 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
519 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
520 | 520 | |
521 | 521 | try { |
522 | 522 | $sth = $this->db->prepare($query); |
@@ -538,11 +538,11 @@ discard block |
||
538 | 538 | * @return String success or false |
539 | 539 | * |
540 | 540 | */ |
541 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
541 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
542 | 542 | { |
543 | 543 | |
544 | 544 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
545 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
545 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
546 | 546 | |
547 | 547 | try { |
548 | 548 | $sth = $this->db->prepare($query); |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
566 | 566 | { |
567 | 567 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
568 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
568 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
569 | 569 | |
570 | 570 | try { |
571 | 571 | $sth = $this->db->prepare($query); |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | * @param String $verticalrate vertival rate of flight |
604 | 604 | * @return String success or false |
605 | 605 | */ |
606 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
|
606 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '') |
|
607 | 607 | { |
608 | 608 | global $globalURL, $globalMarineImageFetch; |
609 | 609 | |
@@ -670,31 +670,31 @@ discard block |
||
670 | 670 | } |
671 | 671 | |
672 | 672 | |
673 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
673 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
674 | 674 | { |
675 | 675 | $date = date("Y-m-d H:i:s", time()); |
676 | 676 | } |
677 | 677 | |
678 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
679 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
680 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
681 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
682 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
683 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
684 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
685 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
686 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
687 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
688 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
689 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
690 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
691 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
678 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
679 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
680 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
681 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
682 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
683 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
684 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
685 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
686 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
687 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
688 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
689 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
690 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
691 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
692 | 692 | |
693 | 693 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
694 | 694 | $Image = new Image($this->db); |
695 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
695 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
696 | 696 | if (!isset($image_array[0]['mmsi'])) { |
697 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
697 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
698 | 698 | } |
699 | 699 | unset($Image); |
700 | 700 | } |
@@ -706,10 +706,10 @@ discard block |
||
706 | 706 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
707 | 707 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
708 | 708 | if ($arrival_date == '') $arrival_date = NULL; |
709 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
709 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
710 | 710 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
711 | 711 | |
712 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
712 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
713 | 713 | try { |
714 | 714 | |
715 | 715 | $sth = $this->db->prepare($query); |
@@ -734,13 +734,13 @@ discard block |
||
734 | 734 | { |
735 | 735 | global $globalDBdriver, $globalTimezone; |
736 | 736 | if ($globalDBdriver == 'mysql') { |
737 | - $query = "SELECT marine_output.ident FROM marine_output |
|
737 | + $query = "SELECT marine_output.ident FROM marine_output |
|
738 | 738 | WHERE marine_output.ident = :ident |
739 | 739 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
740 | 740 | AND marine_output.date < UTC_TIMESTAMP()"; |
741 | 741 | $query_data = array(':ident' => $ident); |
742 | 742 | } else { |
743 | - $query = "SELECT marine_output.ident FROM marine_output |
|
743 | + $query = "SELECT marine_output.ident FROM marine_output |
|
744 | 744 | WHERE marine_output.ident = :ident |
745 | 745 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
746 | 746 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | |
750 | 750 | $sth = $this->db->prepare($query); |
751 | 751 | $sth->execute($query_data); |
752 | - $ident_result=''; |
|
753 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
752 | + $ident_result = ''; |
|
753 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
754 | 754 | { |
755 | 755 | $ident_result = $row['ident']; |
756 | 756 | } |
@@ -776,8 +776,8 @@ discard block |
||
776 | 776 | return false; |
777 | 777 | } else { |
778 | 778 | $q_array = explode(" ", $q); |
779 | - foreach ($q_array as $q_item){ |
|
780 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
779 | + foreach ($q_array as $q_item) { |
|
780 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
781 | 781 | $additional_query .= " AND ("; |
782 | 782 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
783 | 783 | $additional_query .= ")"; |
@@ -785,11 +785,11 @@ discard block |
||
785 | 785 | } |
786 | 786 | } |
787 | 787 | if ($globalDBdriver == 'mysql') { |
788 | - $query = "SELECT marine_output.* FROM marine_output |
|
788 | + $query = "SELECT marine_output.* FROM marine_output |
|
789 | 789 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
790 | 790 | AND marine_output.date < UTC_TIMESTAMP()"; |
791 | 791 | } else { |
792 | - $query = "SELECT marine_output.* FROM marine_output |
|
792 | + $query = "SELECT marine_output.* FROM marine_output |
|
793 | 793 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
794 | 794 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
795 | 795 | } |
@@ -808,16 +808,16 @@ discard block |
||
808 | 808 | * |
809 | 809 | */ |
810 | 810 | |
811 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
811 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
812 | 812 | { |
813 | 813 | global $globalDBdriver, $globalArchive; |
814 | 814 | //$filter_query = $this->getFilter($filters,true,true); |
815 | - $Connection= new Connection($this->db); |
|
815 | + $Connection = new Connection($this->db); |
|
816 | 816 | if (!$Connection->tableExists('countries')) return array(); |
817 | 817 | require_once('class.SpotterLive.php'); |
818 | 818 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
819 | 819 | $MarineLive = new MarineLive(); |
820 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
820 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
821 | 821 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
822 | 822 | if ($olderthanmonths > 0) { |
823 | 823 | if ($globalDBdriver == 'mysql') { |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | } else { |
838 | 838 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
839 | 839 | $MarineArchive = new MarineArchive(); |
840 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
840 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
841 | 841 | $filter_query .= " over_country <> ''"; |
842 | 842 | if ($olderthanmonths > 0) { |
843 | 843 | if ($globalDBdriver == 'mysql') { |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | $flight_array = array(); |
866 | 866 | $temp_array = array(); |
867 | 867 | |
868 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
868 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
869 | 869 | { |
870 | 870 | $temp_array['marine_count'] = $row['nb']; |
871 | 871 | $temp_array['marine_country'] = $row['name']; |
@@ -884,11 +884,11 @@ discard block |
||
884 | 884 | * @return Array the callsign list |
885 | 885 | * |
886 | 886 | */ |
887 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
887 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
888 | 888 | { |
889 | 889 | global $globalDBdriver; |
890 | - $filter_query = $this->getFilter($filters,true,true); |
|
891 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
890 | + $filter_query = $this->getFilter($filters, true, true); |
|
891 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
892 | 892 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
893 | 893 | if ($olderthanmonths > 0) { |
894 | 894 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -902,28 +902,28 @@ discard block |
||
902 | 902 | if ($year != '') { |
903 | 903 | if ($globalDBdriver == 'mysql') { |
904 | 904 | $query .= " AND YEAR(marine_output.date) = :year"; |
905 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
905 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
906 | 906 | } else { |
907 | 907 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
908 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
908 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
909 | 909 | } |
910 | 910 | } |
911 | 911 | if ($month != '') { |
912 | 912 | if ($globalDBdriver == 'mysql') { |
913 | 913 | $query .= " AND MONTH(marine_output.date) = :month"; |
914 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
914 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
915 | 915 | } else { |
916 | 916 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
917 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
917 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
918 | 918 | } |
919 | 919 | } |
920 | 920 | if ($day != '') { |
921 | 921 | if ($globalDBdriver == 'mysql') { |
922 | 922 | $query .= " AND DAY(marine_output.date) = :day"; |
923 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
923 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
924 | 924 | } else { |
925 | 925 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
926 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
926 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
927 | 927 | } |
928 | 928 | } |
929 | 929 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | $callsign_array = array(); |
936 | 936 | $temp_array = array(); |
937 | 937 | |
938 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
938 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
939 | 939 | { |
940 | 940 | $temp_array['callsign_icao'] = $row['ident']; |
941 | 941 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -987,7 +987,7 @@ discard block |
||
987 | 987 | $date_array = array(); |
988 | 988 | $temp_array = array(); |
989 | 989 | |
990 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
990 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
991 | 991 | { |
992 | 992 | $temp_array['date_name'] = $row['date_name']; |
993 | 993 | $temp_array['date_count'] = $row['date_count']; |
@@ -1013,7 +1013,7 @@ discard block |
||
1013 | 1013 | $datetime = new DateTime(); |
1014 | 1014 | $offset = $datetime->format('P'); |
1015 | 1015 | } else $offset = '+00:00'; |
1016 | - $filter_query = $this->getFilter($filters,true,true); |
|
1016 | + $filter_query = $this->getFilter($filters, true, true); |
|
1017 | 1017 | if ($globalDBdriver == 'mysql') { |
1018 | 1018 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1019 | 1019 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | $date_array = array(); |
1035 | 1035 | $temp_array = array(); |
1036 | 1036 | |
1037 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1037 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1038 | 1038 | { |
1039 | 1039 | $temp_array['date_name'] = $row['date_name']; |
1040 | 1040 | $temp_array['date_count'] = $row['date_count']; |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | $datetime = new DateTime(); |
1060 | 1060 | $offset = $datetime->format('P'); |
1061 | 1061 | } else $offset = '+00:00'; |
1062 | - $filter_query = $this->getFilter($filters,true,true); |
|
1062 | + $filter_query = $this->getFilter($filters, true, true); |
|
1063 | 1063 | if ($globalDBdriver == 'mysql') { |
1064 | 1064 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1065 | 1065 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | $date_array = array(); |
1081 | 1081 | $temp_array = array(); |
1082 | 1082 | |
1083 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1083 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1084 | 1084 | { |
1085 | 1085 | $temp_array['date_name'] = $row['date_name']; |
1086 | 1086 | $temp_array['date_count'] = $row['date_count']; |
@@ -1127,7 +1127,7 @@ discard block |
||
1127 | 1127 | $date_array = array(); |
1128 | 1128 | $temp_array = array(); |
1129 | 1129 | |
1130 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1130 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1131 | 1131 | { |
1132 | 1132 | $temp_array['month_name'] = $row['month_name']; |
1133 | 1133 | $temp_array['year_name'] = $row['year_name']; |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | $datetime = new DateTime(); |
1157 | 1157 | $offset = $datetime->format('P'); |
1158 | 1158 | } else $offset = '+00:00'; |
1159 | - $filter_query = $this->getFilter($filters,true,true); |
|
1159 | + $filter_query = $this->getFilter($filters, true, true); |
|
1160 | 1160 | if ($globalDBdriver == 'mysql') { |
1161 | 1161 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
1162 | 1162 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1177,7 +1177,7 @@ discard block |
||
1177 | 1177 | $date_array = array(); |
1178 | 1178 | $temp_array = array(); |
1179 | 1179 | |
1180 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1180 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1181 | 1181 | { |
1182 | 1182 | $temp_array['year_name'] = $row['year_name']; |
1183 | 1183 | $temp_array['month_name'] = $row['month_name']; |
@@ -1197,7 +1197,7 @@ discard block |
||
1197 | 1197 | * @return Array the hour list |
1198 | 1198 | * |
1199 | 1199 | */ |
1200 | - public function countAllHours($orderby,$filters = array()) |
|
1200 | + public function countAllHours($orderby, $filters = array()) |
|
1201 | 1201 | { |
1202 | 1202 | global $globalTimezone, $globalDBdriver; |
1203 | 1203 | if ($globalTimezone != '') { |
@@ -1245,7 +1245,7 @@ discard block |
||
1245 | 1245 | $hour_array = array(); |
1246 | 1246 | $temp_array = array(); |
1247 | 1247 | |
1248 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1248 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1249 | 1249 | { |
1250 | 1250 | $temp_array['hour_name'] = $row['hour_name']; |
1251 | 1251 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1267,8 +1267,8 @@ discard block |
||
1267 | 1267 | public function countAllHoursByDate($date, $filters = array()) |
1268 | 1268 | { |
1269 | 1269 | global $globalTimezone, $globalDBdriver; |
1270 | - $filter_query = $this->getFilter($filters,true,true); |
|
1271 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1270 | + $filter_query = $this->getFilter($filters, true, true); |
|
1271 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1272 | 1272 | if ($globalTimezone != '') { |
1273 | 1273 | date_default_timezone_set($globalTimezone); |
1274 | 1274 | $datetime = new DateTime($date); |
@@ -1276,12 +1276,12 @@ discard block |
||
1276 | 1276 | } else $offset = '+00:00'; |
1277 | 1277 | |
1278 | 1278 | if ($globalDBdriver == 'mysql') { |
1279 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1279 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1280 | 1280 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
1281 | 1281 | GROUP BY hour_name |
1282 | 1282 | ORDER BY hour_name ASC"; |
1283 | 1283 | } else { |
1284 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1284 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1285 | 1285 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1286 | 1286 | GROUP BY hour_name |
1287 | 1287 | ORDER BY hour_name ASC"; |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | $hour_array = array(); |
1294 | 1294 | $temp_array = array(); |
1295 | 1295 | |
1296 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1296 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1297 | 1297 | { |
1298 | 1298 | $temp_array['hour_name'] = $row['hour_name']; |
1299 | 1299 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1315,8 +1315,8 @@ discard block |
||
1315 | 1315 | public function countAllHoursByIdent($ident, $filters = array()) |
1316 | 1316 | { |
1317 | 1317 | global $globalTimezone, $globalDBdriver; |
1318 | - $filter_query = $this->getFilter($filters,true,true); |
|
1319 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1318 | + $filter_query = $this->getFilter($filters, true, true); |
|
1319 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1320 | 1320 | if ($globalTimezone != '') { |
1321 | 1321 | date_default_timezone_set($globalTimezone); |
1322 | 1322 | $datetime = new DateTime(); |
@@ -1324,12 +1324,12 @@ discard block |
||
1324 | 1324 | } else $offset = '+00:00'; |
1325 | 1325 | |
1326 | 1326 | if ($globalDBdriver == 'mysql') { |
1327 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1327 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1328 | 1328 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1329 | 1329 | GROUP BY hour_name |
1330 | 1330 | ORDER BY hour_name ASC"; |
1331 | 1331 | } else { |
1332 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1332 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1333 | 1333 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1334 | 1334 | GROUP BY hour_name |
1335 | 1335 | ORDER BY hour_name ASC"; |
@@ -1337,12 +1337,12 @@ discard block |
||
1337 | 1337 | |
1338 | 1338 | |
1339 | 1339 | $sth = $this->db->prepare($query); |
1340 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1340 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1341 | 1341 | |
1342 | 1342 | $hour_array = array(); |
1343 | 1343 | $temp_array = array(); |
1344 | 1344 | |
1345 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1345 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1346 | 1346 | { |
1347 | 1347 | $temp_array['hour_name'] = $row['hour_name']; |
1348 | 1348 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1361,33 +1361,33 @@ discard block |
||
1361 | 1361 | * @return Integer the number of vessels |
1362 | 1362 | * |
1363 | 1363 | */ |
1364 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
1364 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
1365 | 1365 | { |
1366 | 1366 | global $globalDBdriver; |
1367 | 1367 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
1368 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1368 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1369 | 1369 | $query_values = array(); |
1370 | 1370 | $query = ''; |
1371 | 1371 | if ($year != '') { |
1372 | 1372 | if ($globalDBdriver == 'mysql') { |
1373 | 1373 | $query .= " AND YEAR(marine_output.date) = :year"; |
1374 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1374 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1375 | 1375 | } else { |
1376 | 1376 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1377 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1377 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1378 | 1378 | } |
1379 | 1379 | } |
1380 | 1380 | if ($month != '') { |
1381 | 1381 | if ($globalDBdriver == 'mysql') { |
1382 | 1382 | $query .= " AND MONTH(marine_output.date) = :month"; |
1383 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1383 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1384 | 1384 | } else { |
1385 | 1385 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1386 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1386 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1387 | 1387 | } |
1388 | 1388 | } |
1389 | 1389 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1390 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1390 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1391 | 1391 | |
1392 | 1392 | $sth = $this->db->prepare($queryi); |
1393 | 1393 | $sth->execute($query_values); |
@@ -1400,32 +1400,32 @@ discard block |
||
1400 | 1400 | * @return Integer the number of vessels |
1401 | 1401 | * |
1402 | 1402 | */ |
1403 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
1403 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
1404 | 1404 | { |
1405 | 1405 | global $globalDBdriver; |
1406 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1406 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1407 | 1407 | $query_values = array(); |
1408 | 1408 | $query = ''; |
1409 | 1409 | if ($year != '') { |
1410 | 1410 | if ($globalDBdriver == 'mysql') { |
1411 | 1411 | $query .= " AND YEAR(marine_output.date) = :year"; |
1412 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1412 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1413 | 1413 | } else { |
1414 | 1414 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1415 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1415 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1416 | 1416 | } |
1417 | 1417 | } |
1418 | 1418 | if ($month != '') { |
1419 | 1419 | if ($globalDBdriver == 'mysql') { |
1420 | 1420 | $query .= " AND MONTH(marine_output.date) = :month"; |
1421 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1421 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1422 | 1422 | } else { |
1423 | 1423 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1424 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1424 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1425 | 1425 | } |
1426 | 1426 | } |
1427 | 1427 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1428 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1428 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1429 | 1429 | |
1430 | 1430 | $sth = $this->db->prepare($queryi); |
1431 | 1431 | $sth->execute($query_values); |
@@ -1442,7 +1442,7 @@ discard block |
||
1442 | 1442 | public function countAllHoursFromToday($filters = array()) |
1443 | 1443 | { |
1444 | 1444 | global $globalTimezone, $globalDBdriver; |
1445 | - $filter_query = $this->getFilter($filters,true,true); |
|
1445 | + $filter_query = $this->getFilter($filters, true, true); |
|
1446 | 1446 | if ($globalTimezone != '') { |
1447 | 1447 | date_default_timezone_set($globalTimezone); |
1448 | 1448 | $datetime = new DateTime(); |
@@ -1450,12 +1450,12 @@ discard block |
||
1450 | 1450 | } else $offset = '+00:00'; |
1451 | 1451 | |
1452 | 1452 | if ($globalDBdriver == 'mysql') { |
1453 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1453 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1454 | 1454 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
1455 | 1455 | GROUP BY hour_name |
1456 | 1456 | ORDER BY hour_name ASC"; |
1457 | 1457 | } else { |
1458 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1458 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1459 | 1459 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1460 | 1460 | GROUP BY hour_name |
1461 | 1461 | ORDER BY hour_name ASC"; |
@@ -1467,7 +1467,7 @@ discard block |
||
1467 | 1467 | $hour_array = array(); |
1468 | 1468 | $temp_array = array(); |
1469 | 1469 | |
1470 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1470 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1471 | 1471 | { |
1472 | 1472 | $temp_array['hour_name'] = $row['hour_name']; |
1473 | 1473 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1486,9 +1486,9 @@ discard block |
||
1486 | 1486 | */ |
1487 | 1487 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1488 | 1488 | { |
1489 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1489 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
1490 | 1490 | |
1491 | - $query = "SELECT marine_output.marine_id |
|
1491 | + $query = "SELECT marine_output.marine_id |
|
1492 | 1492 | FROM marine_output |
1493 | 1493 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
1494 | 1494 | |
@@ -1496,7 +1496,7 @@ discard block |
||
1496 | 1496 | $sth = $this->db->prepare($query); |
1497 | 1497 | $sth->execute(); |
1498 | 1498 | |
1499 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1499 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1500 | 1500 | { |
1501 | 1501 | return $row['marine_id']; |
1502 | 1502 | } |
@@ -1521,23 +1521,23 @@ discard block |
||
1521 | 1521 | } |
1522 | 1522 | |
1523 | 1523 | $current_date = date("Y-m-d H:i:s"); |
1524 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1524 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1525 | 1525 | |
1526 | 1526 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1527 | 1527 | |
1528 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1528 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1529 | 1529 | $years = $time_array['years']; |
1530 | 1530 | |
1531 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1531 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1532 | 1532 | $months = $time_array['months']; |
1533 | 1533 | |
1534 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1534 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1535 | 1535 | $days = $time_array['days']; |
1536 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1536 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1537 | 1537 | $hours = $time_array['hours']; |
1538 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1538 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1539 | 1539 | $minutes = $time_array['minutes']; |
1540 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1540 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1541 | 1541 | |
1542 | 1542 | return $time_array; |
1543 | 1543 | } |
@@ -1560,63 +1560,63 @@ discard block |
||
1560 | 1560 | $temp_array['direction_degree'] = $direction; |
1561 | 1561 | $temp_array['direction_shortname'] = "N"; |
1562 | 1562 | $temp_array['direction_fullname'] = "North"; |
1563 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1563 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1564 | 1564 | $temp_array['direction_degree'] = $direction; |
1565 | 1565 | $temp_array['direction_shortname'] = "NNE"; |
1566 | 1566 | $temp_array['direction_fullname'] = "North-Northeast"; |
1567 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1567 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1568 | 1568 | $temp_array['direction_degree'] = $direction; |
1569 | 1569 | $temp_array['direction_shortname'] = "NE"; |
1570 | 1570 | $temp_array['direction_fullname'] = "Northeast"; |
1571 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1571 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1572 | 1572 | $temp_array['direction_degree'] = $direction; |
1573 | 1573 | $temp_array['direction_shortname'] = "ENE"; |
1574 | 1574 | $temp_array['direction_fullname'] = "East-Northeast"; |
1575 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1575 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1576 | 1576 | $temp_array['direction_degree'] = $direction; |
1577 | 1577 | $temp_array['direction_shortname'] = "E"; |
1578 | 1578 | $temp_array['direction_fullname'] = "East"; |
1579 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1579 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1580 | 1580 | $temp_array['direction_degree'] = $direction; |
1581 | 1581 | $temp_array['direction_shortname'] = "ESE"; |
1582 | 1582 | $temp_array['direction_fullname'] = "East-Southeast"; |
1583 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1583 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1584 | 1584 | $temp_array['direction_degree'] = $direction; |
1585 | 1585 | $temp_array['direction_shortname'] = "SE"; |
1586 | 1586 | $temp_array['direction_fullname'] = "Southeast"; |
1587 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1587 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1588 | 1588 | $temp_array['direction_degree'] = $direction; |
1589 | 1589 | $temp_array['direction_shortname'] = "SSE"; |
1590 | 1590 | $temp_array['direction_fullname'] = "South-Southeast"; |
1591 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1591 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1592 | 1592 | $temp_array['direction_degree'] = $direction; |
1593 | 1593 | $temp_array['direction_shortname'] = "S"; |
1594 | 1594 | $temp_array['direction_fullname'] = "South"; |
1595 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1595 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1596 | 1596 | $temp_array['direction_degree'] = $direction; |
1597 | 1597 | $temp_array['direction_shortname'] = "SSW"; |
1598 | 1598 | $temp_array['direction_fullname'] = "South-Southwest"; |
1599 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1599 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1600 | 1600 | $temp_array['direction_degree'] = $direction; |
1601 | 1601 | $temp_array['direction_shortname'] = "SW"; |
1602 | 1602 | $temp_array['direction_fullname'] = "Southwest"; |
1603 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1603 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1604 | 1604 | $temp_array['direction_degree'] = $direction; |
1605 | 1605 | $temp_array['direction_shortname'] = "WSW"; |
1606 | 1606 | $temp_array['direction_fullname'] = "West-Southwest"; |
1607 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1607 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1608 | 1608 | $temp_array['direction_degree'] = $direction; |
1609 | 1609 | $temp_array['direction_shortname'] = "W"; |
1610 | 1610 | $temp_array['direction_fullname'] = "West"; |
1611 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1611 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1612 | 1612 | $temp_array['direction_degree'] = $direction; |
1613 | 1613 | $temp_array['direction_shortname'] = "WNW"; |
1614 | 1614 | $temp_array['direction_fullname'] = "West-Northwest"; |
1615 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1615 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1616 | 1616 | $temp_array['direction_degree'] = $direction; |
1617 | 1617 | $temp_array['direction_shortname'] = "NW"; |
1618 | 1618 | $temp_array['direction_fullname'] = "Northwest"; |
1619 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1619 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1620 | 1620 | $temp_array['direction_degree'] = $direction; |
1621 | 1621 | $temp_array['direction_shortname'] = "NNW"; |
1622 | 1622 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1633,11 +1633,11 @@ discard block |
||
1633 | 1633 | * @param Float $longitude longitute of the flight |
1634 | 1634 | * @return String the countrie |
1635 | 1635 | */ |
1636 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1636 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1637 | 1637 | { |
1638 | 1638 | global $globalDBdriver, $globalDebug; |
1639 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1640 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1639 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1640 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1641 | 1641 | |
1642 | 1642 | $Connection = new Connection($this->db); |
1643 | 1643 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1677,7 +1677,7 @@ discard block |
||
1677 | 1677 | public function getCountryFromISO2($iso2) |
1678 | 1678 | { |
1679 | 1679 | global $globalDBdriver, $globalDebug; |
1680 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1680 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1681 | 1681 | |
1682 | 1682 | $Connection = new Connection($this->db); |
1683 | 1683 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1725,7 +1725,7 @@ discard block |
||
1725 | 1725 | |
1726 | 1726 | $bitly_data = json_decode($bitly_data); |
1727 | 1727 | $bitly_url = ''; |
1728 | - if ($bitly_data->status_txt = "OK"){ |
|
1728 | + if ($bitly_data->status_txt = "OK") { |
|
1729 | 1729 | $bitly_url = $bitly_data->data->url; |
1730 | 1730 | } |
1731 | 1731 | |
@@ -1739,11 +1739,11 @@ discard block |
||
1739 | 1739 | * @return Array the vessel type list |
1740 | 1740 | * |
1741 | 1741 | */ |
1742 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
1742 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1743 | 1743 | { |
1744 | 1744 | global $globalDBdriver; |
1745 | - $filter_query = $this->getFilter($filters,true,true); |
|
1746 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
1745 | + $filter_query = $this->getFilter($filters, true, true); |
|
1746 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
1747 | 1747 | FROM marine_output ".$filter_query." marine_output.type <> ''"; |
1748 | 1748 | if ($olderthanmonths > 0) { |
1749 | 1749 | if ($globalDBdriver == 'mysql') { |
@@ -1763,28 +1763,28 @@ discard block |
||
1763 | 1763 | if ($year != '') { |
1764 | 1764 | if ($globalDBdriver == 'mysql') { |
1765 | 1765 | $query .= " AND YEAR(marine_output.date) = :year"; |
1766 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1766 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1767 | 1767 | } else { |
1768 | 1768 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1769 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1769 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1770 | 1770 | } |
1771 | 1771 | } |
1772 | 1772 | if ($month != '') { |
1773 | 1773 | if ($globalDBdriver == 'mysql') { |
1774 | 1774 | $query .= " AND MONTH(marine_output.date) = :month"; |
1775 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1775 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1776 | 1776 | } else { |
1777 | 1777 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1778 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1778 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1779 | 1779 | } |
1780 | 1780 | } |
1781 | 1781 | if ($day != '') { |
1782 | 1782 | if ($globalDBdriver == 'mysql') { |
1783 | 1783 | $query .= " AND DAY(marine_output.date) = :day"; |
1784 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1784 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1785 | 1785 | } else { |
1786 | 1786 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1787 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1787 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1788 | 1788 | } |
1789 | 1789 | } |
1790 | 1790 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
@@ -1793,7 +1793,7 @@ discard block |
||
1793 | 1793 | $sth->execute($query_values); |
1794 | 1794 | $marine_array = array(); |
1795 | 1795 | $temp_array = array(); |
1796 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1796 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1797 | 1797 | { |
1798 | 1798 | $temp_array['marine_type'] = $row['marine_type']; |
1799 | 1799 | $temp_array['marine_type_count'] = $row['marine_type_count']; |
@@ -1804,7 +1804,7 @@ discard block |
||
1804 | 1804 | |
1805 | 1805 | public function getOrderBy() |
1806 | 1806 | { |
1807 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
1807 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
1808 | 1808 | |
1809 | 1809 | return $orderby; |
1810 | 1810 |