@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | $Stats = new Stats(); |
8 | 8 | |
9 | 9 | if (!isset($filter_name)) $filter_name = ''; |
10 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
10 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
11 | 11 | if ($airline_icao == '' && isset($globalFilter)) { |
12 | 12 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
13 | 13 | } |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | $title = _("Statistics"); |
23 | 23 | } |
24 | 24 | |
25 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
26 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
25 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
26 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
27 | 27 | |
28 | 28 | require_once('header.php'); |
29 | 29 | |
@@ -44,36 +44,36 @@ discard block |
||
44 | 44 | date_default_timezone_set('UTC'); |
45 | 45 | $lastupdate = strtotime($last_update[0]['value']); |
46 | 46 | if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone); |
47 | - print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>'; |
|
47 | + print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>'; |
|
48 | 48 | } |
49 | 49 | ?> |
50 | 50 | </div> |
51 | 51 | <?php include('statistics-sub-menu.php'); ?> |
52 | 52 | <p class="global-stats"> |
53 | - <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span> |
|
54 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
55 | - <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span> |
|
56 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
53 | + <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span> |
|
54 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
55 | + <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span> |
|
56 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
57 | 57 | <?php |
58 | 58 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) { |
59 | 59 | ?> |
60 | - <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span> |
|
61 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
60 | + <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span> |
|
61 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
62 | 62 | <?php |
63 | 63 | } else { |
64 | 64 | ?> |
65 | - <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span> |
|
66 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
65 | + <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span> |
|
66 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
67 | 67 | <?php |
68 | 68 | } |
69 | 69 | ?> |
70 | - <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span> |
|
71 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
70 | + <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span> |
|
71 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
72 | 72 | <?php |
73 | 73 | if ($airline_icao == '') { |
74 | 74 | ?> |
75 | - <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span> |
|
76 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
75 | + <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span> |
|
76 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
77 | 77 | <?php |
78 | 78 | } |
79 | 79 | ?> |
@@ -81,20 +81,20 @@ discard block |
||
81 | 81 | if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) { |
82 | 82 | if ($airline_icao == '' || $airline_icao == 'all') { |
83 | 83 | ?> |
84 | - <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span> |
|
85 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
84 | + <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span> |
|
85 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
86 | 86 | <?php |
87 | 87 | } |
88 | 88 | } |
89 | 89 | ?> |
90 | 90 | </p> |
91 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
91 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
92 | 92 | <div class="specific-stats"> |
93 | 93 | <div class="row column"> |
94 | 94 | <div class="col-md-6"> |
95 | 95 | <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2> |
96 | 96 | <?php |
97 | - $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month); |
|
97 | + $aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month); |
|
98 | 98 | if (count($aircraft_array) == 0) print _("No data available"); |
99 | 99 | else { |
100 | 100 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | var data = google.visualization.arrayToDataTable([ |
107 | 107 | ["'._("Aircraft").'", "'._("# of times").'"], '; |
108 | 108 | $aircraft_data = ''; |
109 | - foreach($aircraft_array as $aircraft_item) |
|
109 | + foreach ($aircraft_array as $aircraft_item) |
|
110 | 110 | { |
111 | 111 | $aircraft_data .= '[ "'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],'; |
112 | 112 | } |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | ?> |
144 | 144 | </div> |
145 | 145 | </div> |
146 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
146 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
147 | 147 | <?php |
148 | 148 | // echo $airline_icao; |
149 | 149 | if ($airline_icao == '' || $airline_icao == 'all') { |
150 | - $airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month); |
|
150 | + $airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month); |
|
151 | 151 | if (count($airline_array) > 0) { |
152 | 152 | print '<div class="col-md-6">'; |
153 | 153 | print '<h2>'._("Top 10 Most Common Airline").'</h2>'; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | var data = google.visualization.arrayToDataTable([ |
160 | 160 | ["'._("Airline").'", "'._("# of times").'"], '; |
161 | 161 | $airline_data = ''; |
162 | - foreach($airline_array as $airline_item) |
|
162 | + foreach ($airline_array as $airline_item) |
|
163 | 163 | { |
164 | 164 | $airline_data .= '[ "'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],'; |
165 | 165 | } |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | } |
190 | 190 | ?> |
191 | 191 | </div> |
192 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
192 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
193 | 193 | <?php |
194 | 194 | } |
195 | 195 | ?> |
196 | 196 | <div class="row column"> |
197 | 197 | <?php |
198 | - $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month); |
|
198 | + $flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month); |
|
199 | 199 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) { |
200 | 200 | if (empty($flightover_array)) { |
201 | 201 | print '<div class="col-md-12">'; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | ?> |
206 | 206 | <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2> |
207 | 207 | <?php |
208 | - $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month); |
|
208 | + $pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month); |
|
209 | 209 | if (count($pilot_array) == 0) print _("No data available"); |
210 | 210 | else { |
211 | 211 | print '<div id="chart7" class="chart" width="100%"></div> |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | var data = google.visualization.arrayToDataTable([ |
217 | 217 | ["'._("Pilots").'", "'._("# of times").'"], '; |
218 | 218 | $pilot_data = ''; |
219 | - foreach($pilot_array as $pilot_item) |
|
219 | + foreach ($pilot_array as $pilot_item) |
|
220 | 220 | { |
221 | 221 | $pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],'; |
222 | 222 | } |
@@ -244,14 +244,14 @@ discard block |
||
244 | 244 | ?> |
245 | 245 | </div> |
246 | 246 | |
247 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
247 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
248 | 248 | <?php |
249 | 249 | } else { |
250 | 250 | ?> |
251 | 251 | <div class="col-md-6"> |
252 | 252 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
253 | 253 | <?php |
254 | - $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month); |
|
254 | + $owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month); |
|
255 | 255 | if (count($owner_array) == 0) print _("No data available"); |
256 | 256 | else { |
257 | 257 | print '<div id="chart7" class="chart" width="100%"></div> |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | var data = google.visualization.arrayToDataTable([ |
263 | 263 | ["'._("Owner").'", "'._("# of times").'"], '; |
264 | 264 | $owner_data = ''; |
265 | - foreach($owner_array as $owner_item) |
|
265 | + foreach ($owner_array as $owner_item) |
|
266 | 266 | { |
267 | 267 | $owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],'; |
268 | 268 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | </div> |
291 | 291 | </div> |
292 | 292 | |
293 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
293 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
294 | 294 | <?php |
295 | 295 | } |
296 | 296 | if (!empty($flightover_array)) { |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | var data = google.visualization.arrayToDataTable([ |
310 | 310 | ["'._("Country").'", "'._("# of times").'"], '; |
311 | 311 | $flightover_data = ''; |
312 | - foreach($flightover_array as $flightover_item) |
|
312 | + foreach ($flightover_array as $flightover_item) |
|
313 | 313 | { |
314 | 314 | $flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],'; |
315 | 315 | } |
@@ -342,14 +342,14 @@ discard block |
||
342 | 342 | } |
343 | 343 | ?> |
344 | 344 | </div> |
345 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
345 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
346 | 346 | |
347 | 347 | |
348 | 348 | </div> |
349 | 349 | <div class="row column"> |
350 | 350 | <div class="col-md-6"> |
351 | 351 | <?php |
352 | - $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month); |
|
352 | + $airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month); |
|
353 | 353 | if (count($airport_airport_array) > 0) { |
354 | 354 | print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>'; |
355 | 355 | print '<div id="chart3" class="chart" width="100%"></div> |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | var data = google.visualization.arrayToDataTable([ |
365 | 365 | ["'._("Airport").'", "'._("# of times").'"],'; |
366 | 366 | $airport_data = ''; |
367 | - foreach($airport_airport_array as $airport_item) |
|
367 | + foreach ($airport_airport_array as $airport_item) |
|
368 | 368 | { |
369 | 369 | $name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')'; |
370 | 370 | $name = str_replace("'", "", $name); |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | } |
392 | 392 | ?> |
393 | 393 | </div> |
394 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
394 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
395 | 395 | |
396 | 396 | <div class="col-md-6"> |
397 | 397 | <?php |
398 | - $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month); |
|
398 | + $airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month); |
|
399 | 399 | if (count($airport_airport_array2) > 0) { |
400 | 400 | print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>'; |
401 | 401 | print '<div id="chart4" class="chart" width="100%"></div> |
@@ -410,10 +410,10 @@ discard block |
||
410 | 410 | var data = google.visualization.arrayToDataTable([ |
411 | 411 | ["'._("Airport").'", "'._("# of times").'"],'; |
412 | 412 | $airport_data2 = ''; |
413 | - foreach($airport_airport_array2 as $airport_item2) |
|
413 | + foreach ($airport_airport_array2 as $airport_item2) |
|
414 | 414 | { |
415 | 415 | $name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')'; |
416 | - $name2 = str_replace(array("'",'"'), '', $name2); |
|
416 | + $name2 = str_replace(array("'", '"'), '', $name2); |
|
417 | 417 | $airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],'; |
418 | 418 | } |
419 | 419 | $airport_data2 = substr($airport_data2, 0, -1); |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | ?> |
438 | 438 | </div> |
439 | 439 | </div> |
440 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
440 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
441 | 441 | <?php |
442 | 442 | if ($year == '' && $month == '') { |
443 | 443 | ?> |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | <div class="col-md-6"> |
446 | 446 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
447 | 447 | <?php |
448 | - $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
|
448 | + $year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name); |
|
449 | 449 | if (count($year_array) == 0) print _("No data available"); |
450 | 450 | else { |
451 | 451 | print '<div id="chart8" class="chart" width="100%"></div> |
@@ -456,9 +456,9 @@ discard block |
||
456 | 456 | var data = google.visualization.arrayToDataTable([ |
457 | 457 | ["'._("Month").'", "'._("# of Flights").'"], '; |
458 | 458 | $year_data = ''; |
459 | - foreach($year_array as $year_item) |
|
459 | + foreach ($year_array as $year_item) |
|
460 | 460 | { |
461 | - $year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],'; |
|
461 | + $year_data .= '[ "'.date('F, Y', strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],'; |
|
462 | 462 | } |
463 | 463 | $year_data = substr($year_data, 0, -1); |
464 | 464 | print $year_data; |
@@ -486,11 +486,11 @@ discard block |
||
486 | 486 | <a href="<?php print $globalURL; ?>/statistics/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
487 | 487 | </div> |
488 | 488 | </div> |
489 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
489 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
490 | 490 | <div class="col-md-6"> |
491 | 491 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
492 | 492 | <?php |
493 | - $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
|
493 | + $month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name); |
|
494 | 494 | if (count($month_array) == 0) print _("No data available"); |
495 | 495 | else { |
496 | 496 | print '<div id="chart9" class="chart" width="100%"></div> |
@@ -501,9 +501,9 @@ discard block |
||
501 | 501 | var data = google.visualization.arrayToDataTable([ |
502 | 502 | ["'._("Day").'", "'._("# of Flights").'"], '; |
503 | 503 | $month_data = ''; |
504 | - foreach($month_array as $month_item) |
|
504 | + foreach ($month_array as $month_item) |
|
505 | 505 | { |
506 | - $month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],'; |
|
506 | + $month_data .= '[ "'.date('F j, Y', strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],'; |
|
507 | 507 | } |
508 | 508 | $month_data = substr($month_data, 0, -1); |
509 | 509 | print $month_data; |
@@ -531,12 +531,12 @@ discard block |
||
531 | 531 | <a href="<?php print $globalURL; ?>/statistics/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
532 | 532 | </div> |
533 | 533 | </div> |
534 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
534 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
535 | 535 | |
536 | 536 | <div class="col-md-6"> |
537 | 537 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
538 | 538 | <?php |
539 | - $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
|
539 | + $date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name); |
|
540 | 540 | if (empty($date_array)) print _("No data available"); |
541 | 541 | else { |
542 | 542 | print '<div id="chart5" class="chart" width="100%"></div> |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | ["'._("Date").'", "'._("# of Flights").'"], '; |
549 | 549 | $date_data = ''; |
550 | 550 | |
551 | - foreach($date_array as $date_item) |
|
551 | + foreach ($date_array as $date_item) |
|
552 | 552 | { |
553 | 553 | $date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],'; |
554 | 554 | } |
@@ -578,11 +578,11 @@ discard block |
||
578 | 578 | <a href="<?php print $globalURL; ?>/statistics/date" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
579 | 579 | </div> |
580 | 580 | </div> |
581 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
581 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
582 | 582 | <div class="col-md-6"> |
583 | 583 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
584 | 584 | <?php |
585 | - $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
|
585 | + $hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name); |
|
586 | 586 | if (empty($hour_array)) print _("No data available"); |
587 | 587 | else { |
588 | 588 | |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | var data = google.visualization.arrayToDataTable([ |
595 | 595 | ["'._("Hour").'", "'._("# of Flights").'"], '; |
596 | 596 | $hour_data = ''; |
597 | - foreach($hour_array as $hour_item) |
|
597 | + foreach ($hour_array as $hour_item) |
|
598 | 598 | { |
599 | 599 | $hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],'; |
600 | 600 | } |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | <a href="<?php print $globalURL; ?>/statistics/time" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
625 | 625 | </div> |
626 | 626 | </div> |
627 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
627 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
628 | 628 | </div> |
629 | 629 | <?php |
630 | 630 | } |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | var data = google.visualization.arrayToDataTable([ |
651 | 651 | ["'._("Year").'", "'._("# of Fatalities").'"], '; |
652 | 652 | $year_data = ''; |
653 | - foreach($year_array as $year_item) |
|
653 | + foreach ($year_array as $year_item) |
|
654 | 654 | { |
655 | 655 | $year_data .= '[ "'.$year_item['year'].'",'.$year_item['count'].'],'; |
656 | 656 | } |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
681 | 681 | </div> |
682 | 682 | </div> |
683 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
683 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
684 | 684 | |
685 | 685 | <div class="row column"> |
686 | 686 | <div class="col-md-6"> |
@@ -699,9 +699,9 @@ discard block |
||
699 | 699 | var data = google.visualization.arrayToDataTable([ |
700 | 700 | ["'._("Month").'", "'._("# of Fatalities").'"], '; |
701 | 701 | $year_data = ''; |
702 | - foreach($year_array as $year_item) |
|
702 | + foreach ($year_array as $year_item) |
|
703 | 703 | { |
704 | - $year_data .= '[ "'.date('F, Y',strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],'; |
|
704 | + $year_data .= '[ "'.date('F, Y', strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],'; |
|
705 | 705 | } |
706 | 706 | $year_data = substr($year_data, 0, -1); |
707 | 707 | print $year_data; |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
730 | 730 | </div> |
731 | 731 | </div> |
732 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
732 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
733 | 733 | <br/> |
734 | 734 | <?php |
735 | 735 | } |
@@ -742,9 +742,9 @@ discard block |
||
742 | 742 | <?php |
743 | 743 | //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar'); |
744 | 744 | if ($year == '' && $month == '') { |
745 | - $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d')); |
|
745 | + $polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d')); |
|
746 | 746 | } else { |
747 | - $polar = $Stats->getStatsSource('polar',$year,$month); |
|
747 | + $polar = $Stats->getStatsSource('polar', $year, $month); |
|
748 | 748 | } |
749 | 749 | if (!empty($polar)) { |
750 | 750 | print '<h2>'._("Coverage pattern").'</h2>'; |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | unset($polar_data); |
753 | 753 | $Spotter = new Spotter(); |
754 | 754 | $data = json_decode($eachpolar['source_data']); |
755 | - foreach($data as $value => $key) { |
|
755 | + foreach ($data as $value => $key) { |
|
756 | 756 | $direction = $Spotter->parseDirection(($value*22.5)); |
757 | 757 | $distance = $key; |
758 | 758 | $unit = 'km'; |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | ?> |
773 | 773 | <div class="col-md-6"> |
774 | 774 | <h4><?php print $eachpolar['source_name']; ?></h4> |
775 | - <div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div> |
|
775 | + <div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div> |
|
776 | 776 | <script> |
777 | 777 | (function() { |
778 | 778 | var margin = {top: 100, right: 100, bottom: 100, left: 100}, |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | color: color, |
797 | 797 | unit: '<?php echo $unit; ?>' |
798 | 798 | }; |
799 | - RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions); |
|
799 | + RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions); |
|
800 | 800 | })(); |
801 | 801 | </script> |
802 | 802 | </div> |
@@ -810,22 +810,22 @@ discard block |
||
810 | 810 | <?php |
811 | 811 | //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg'); |
812 | 812 | if ($year == '' && $month == '') { |
813 | - $msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d')); |
|
813 | + $msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d')); |
|
814 | 814 | } else { |
815 | - $msg = $Stats->getStatsSource('msg',$year,$month); |
|
815 | + $msg = $Stats->getStatsSource('msg', $year, $month); |
|
816 | 816 | } |
817 | 817 | if (!empty($msg)) { |
818 | 818 | print '<h2>'._("Messages received").'</h2>'; |
819 | 819 | foreach ($msg as $eachmsg) { |
820 | 820 | //$eachmsg = $msg[0]; |
821 | 821 | $data = $eachmsg['source_data']; |
822 | - if ($data > 500) $max = (round(($data+100)/100))*100; |
|
822 | + if ($data > 500) $max = (round(($data + 100)/100))*100; |
|
823 | 823 | else $max = 500; |
824 | 824 | ?> |
825 | - <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
|
825 | + <div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
|
826 | 826 | <script> |
827 | 827 | var g = new JustGage({ |
828 | - id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>", |
|
828 | + id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>", |
|
829 | 829 | value: <?php echo $data; ?>, |
830 | 830 | min: 0, |
831 | 831 | max: <?php print $max; ?>, |
@@ -847,15 +847,15 @@ discard block |
||
847 | 847 | <?php |
848 | 848 | //$hist = $Stats->getStatsSource(date('Y-m-d'),'hist'); |
849 | 849 | if ($year == '' && $month == '') { |
850 | - $hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d')); |
|
850 | + $hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d')); |
|
851 | 851 | } else { |
852 | - $hist = $Stats->getStatsSource('hist',$year,$month); |
|
852 | + $hist = $Stats->getStatsSource('hist', $year, $month); |
|
853 | 853 | } |
854 | 854 | foreach ($hist as $hists) { |
855 | 855 | $hist_data = ''; |
856 | 856 | $source = $hists['source_name']; |
857 | 857 | $hist_array = json_decode($hists['source_data']); |
858 | - foreach($hist_array as $distance => $nb) |
|
858 | + foreach ($hist_array as $distance => $nb) |
|
859 | 859 | { |
860 | 860 | $unit = 'km'; |
861 | 861 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
@@ -873,13 +873,13 @@ discard block |
||
873 | 873 | $hist_data = substr($hist_data, 0, -1); |
874 | 874 | ?> |
875 | 875 | <div class="col-md-6"> |
876 | - <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2> |
|
876 | + <h2><?php echo sprintf(_("Flights Distance for %s"), $source); ?></h2> |
|
877 | 877 | <?php |
878 | - print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div> |
|
878 | + print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div> |
|
879 | 879 | <script> |
880 | 880 | google.load("visualization", "1", {packages:["corechart"]}); |
881 | - google.setOnLoadCallback(drawCharthist_'.str_replace(' ','_',strtolower($source)).'); |
|
882 | - function drawCharthist_'.str_replace(' ','_',strtolower($source)).'() { |
|
881 | + google.setOnLoadCallback(drawCharthist_'.str_replace(' ', '_', strtolower($source)).'); |
|
882 | + function drawCharthist_'.str_replace(' ', '_', strtolower($source)).'() { |
|
883 | 883 | var data = google.visualization.arrayToDataTable([ |
884 | 884 | ["'._("Distance").'", "'._("# of Flights").'"], '; |
885 | 885 | print $hist_data; |
@@ -894,16 +894,16 @@ discard block |
||
894 | 894 | colors: ["#1a3151"] |
895 | 895 | }; |
896 | 896 | |
897 | - var chart = new google.visualization.AreaChart(document.getElementById("charthist-'.str_replace(' ','_',strtolower($source)).'")); |
|
897 | + var chart = new google.visualization.AreaChart(document.getElementById("charthist-'.str_replace(' ', '_', strtolower($source)).'")); |
|
898 | 898 | chart.draw(data, options); |
899 | 899 | } |
900 | 900 | $(window).resize(function(){ |
901 | - drawCharthist_'.str_replace(' ','_',strtolower($source)).'(); |
|
901 | + drawCharthist_'.str_replace(' ', '_', strtolower($source)).'(); |
|
902 | 902 | }); |
903 | 903 | </script>'; |
904 | 904 | ?> |
905 | 905 | </div> |
906 | - <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
|
906 | + <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> --> |
|
907 | 907 | <?php |
908 | 908 | } |
909 | 909 | ?> |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $Connection = new Connection(); |
55 | 55 | $sth = $Connection->db->prepare($query); |
56 | 56 | $sth->execute(); |
57 | - } catch(PDOException $e) { |
|
57 | + } catch (PDOException $e) { |
|
58 | 58 | return "error : ".$e->getMessage(); |
59 | 59 | } |
60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $Connection = new Connection(); |
71 | 71 | $sth = $Connection->db->prepare($query); |
72 | 72 | $sth->execute(); |
73 | - } catch(PDOException $e) { |
|
73 | + } catch (PDOException $e) { |
|
74 | 74 | return "error : ".$e->getMessage(); |
75 | 75 | } |
76 | 76 | } |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | public function parse($data) { |
81 | 81 | //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
82 | 82 | $codes = implode('|', array_keys($this->texts)); |
83 | - $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
83 | + $regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#'; |
|
84 | 84 | //$pieces = explode(' ',$data); |
85 | - $pieces = preg_split('/\s/',$data); |
|
85 | + $pieces = preg_split('/\s/', $data); |
|
86 | 86 | $pos = 0; |
87 | 87 | if ($pieces[0] == 'METAR') $pos++; |
88 | 88 | elseif ($pieces[0] == 'SPECI') $pos++; |
@@ -90,25 +90,25 @@ discard block |
||
90 | 90 | $result = array(); |
91 | 91 | $result['location'] = $pieces[$pos]; |
92 | 92 | $pos++; |
93 | - $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
94 | - $result['time'] = substr($pieces[$pos],2,4); |
|
93 | + $result['dayofmonth'] = substr($pieces[$pos], 0, 2); |
|
94 | + $result['time'] = substr($pieces[$pos], 2, 4); |
|
95 | 95 | $c = count($pieces); |
96 | - for($pos++; $pos < $c; $pos++) { |
|
96 | + for ($pos++; $pos < $c; $pos++) { |
|
97 | 97 | $piece = $pieces[$pos]; |
98 | 98 | if ($piece == 'RMK') break; |
99 | 99 | if ($piece == 'AUTO') $result['auto'] = true; |
100 | 100 | if ($piece == 'COR') $result['correction'] = true; |
101 | 101 | // Wind Speed |
102 | 102 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
103 | - $result['wind']['direction'] = (float)$matches[1]; |
|
103 | + $result['wind']['direction'] = (float) $matches[1]; |
|
104 | 104 | $result['wind']['unit'] = $matches[4]; |
105 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
106 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
107 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
108 | - $result['wind']['gust'] = (float)$matches[3]; |
|
105 | + if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2); |
|
106 | + elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2); |
|
107 | + elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2); |
|
108 | + $result['wind']['gust'] = (float) $matches[3]; |
|
109 | 109 | $result['wind']['unit'] = $matches[4]; |
110 | - $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
|
111 | - $result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0; |
|
110 | + $result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0; |
|
111 | + $result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /* if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) { |
@@ -128,14 +128,14 @@ discard block |
||
128 | 128 | */ |
129 | 129 | // Temperature |
130 | 130 | if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
131 | - $temp = (float)$matches[1]; |
|
131 | + $temp = (float) $matches[1]; |
|
132 | 132 | if ($matches[1]{0} == 'M') { |
133 | - $temp = ((float)substr($matches[1], 1)) * -1; |
|
133 | + $temp = ((float) substr($matches[1], 1))*-1; |
|
134 | 134 | } |
135 | 135 | $result['temperature'] = $temp; |
136 | - $dew = (float)$matches[2]; |
|
136 | + $dew = (float) $matches[2]; |
|
137 | 137 | if ($matches[2]{0} == 'M') { |
138 | - $dew = ((float)substr($matches[2], 1)) * -1; |
|
138 | + $dew = ((float) substr($matches[2], 1))*-1; |
|
139 | 139 | } |
140 | 140 | $result['dew'] = $dew; |
141 | 141 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $result['QNH'] = $matches[2]; |
148 | 148 | } else { |
149 | 149 | // inHg |
150 | - $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
150 | + $result['QNH'] = round(($matches[2]/100)*33.86389, 2); |
|
151 | 151 | } |
152 | 152 | /* |
153 | 153 | $result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100); |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | // Visibility |
169 | 169 | if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
170 | 170 | if (isset($matches[3]) && strlen($matches[3]) > 0) { |
171 | - $result['visibility'] = (float)$matches[3] * 1609.34; |
|
171 | + $result['visibility'] = (float) $matches[3]*1609.34; |
|
172 | 172 | } else { |
173 | 173 | if ($matches[1] == '9999') { |
174 | 174 | $result['visibility'] = '> 10000'; |
175 | 175 | } else { |
176 | - $result['visibility'] = (float)$matches[1]; |
|
176 | + $result['visibility'] = (float) $matches[1]; |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | if (preg_match('#^CAVOK$#', $piece, $matches)) { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
196 | 196 | elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
197 | 197 | $cloud['type_code'] = $type; |
198 | - $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
198 | + $cloud['level'] = round(((float) $matches[2])*100*0.3048); |
|
199 | 199 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
200 | 200 | $result['cloud'][] = $cloud; |
201 | 201 | } |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | $rvr['runway'] = $matches[1]; |
206 | 206 | $rvr['assessment'] = $matches[2]; |
207 | 207 | $rvr['rvr'] = $matches[3]; |
208 | - $rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0; |
|
209 | - $rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : ''; |
|
208 | + $rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0; |
|
209 | + $rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : ''; |
|
210 | 210 | $result['RVR'] = $rvr; |
211 | 211 | } |
212 | 212 | |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
224 | 224 | //echo $piece; |
225 | 225 | //print_r($matches); |
226 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
226 | + if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | + else $range = array('exact' => (float) $matches[2], 'unit' => 'M'); |
|
228 | 228 | if (isset($matches[3])) { |
229 | 229 | $range = Array( |
230 | - 'from' => (float)$matches[2], |
|
231 | - 'to' => (float)$matches[4], |
|
230 | + 'from' => (float) $matches[2], |
|
231 | + 'to' => (float) $matches[4], |
|
232 | 232 | 'unit' => $matches[5] ? 'FT' : 'M' |
233 | 233 | ); |
234 | 234 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | try { |
278 | 278 | $sth = $this->db->prepare($query); |
279 | 279 | $sth->execute($query_values); |
280 | - } catch(PDOException $e) { |
|
280 | + } catch (PDOException $e) { |
|
281 | 281 | return "error : ".$e->getMessage(); |
282 | 282 | } |
283 | 283 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -287,19 +287,19 @@ discard block |
||
287 | 287 | return $all; |
288 | 288 | } |
289 | 289 | |
290 | - public function addMETAR($location,$metar,$date) { |
|
290 | + public function addMETAR($location, $metar, $date) { |
|
291 | 291 | global $globalDBdriver; |
292 | - $date = date('Y-m-d H:i:s',strtotime($date)); |
|
292 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
293 | 293 | if ($globalDBdriver == 'mysql') { |
294 | 294 | $query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar"; |
295 | 295 | } else { |
296 | 296 | $query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);"; |
297 | 297 | } |
298 | - $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
298 | + $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar)); |
|
299 | 299 | try { |
300 | 300 | $sth = $this->db->prepare($query); |
301 | 301 | $sth->execute($query_values); |
302 | - } catch(PDOException $e) { |
|
302 | + } catch (PDOException $e) { |
|
303 | 303 | return "error : ".$e->getMessage(); |
304 | 304 | } |
305 | 305 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | try { |
311 | 311 | $sth = $this->db->prepare($query); |
312 | 312 | $sth->execute($query_values); |
313 | - } catch(PDOException $e) { |
|
313 | + } catch (PDOException $e) { |
|
314 | 314 | return "error : ".$e->getMessage(); |
315 | 315 | } |
316 | 316 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | try { |
320 | 320 | $sth = $this->db->prepare($query); |
321 | 321 | $sth->execute(); |
322 | - } catch(PDOException $e) { |
|
322 | + } catch (PDOException $e) { |
|
323 | 323 | return "error : ".$e->getMessage(); |
324 | 324 | } |
325 | 325 | } |
@@ -331,30 +331,30 @@ discard block |
||
331 | 331 | $Common = new Common(); |
332 | 332 | if (isset($globalIVAO) && $globalIVAO) { |
333 | 333 | //$cycle = $Common->getData('http://wx.ivao.aero/metar.php'); |
334 | - $Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
335 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
334 | + $Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
335 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r"); |
|
336 | 336 | } else { |
337 | 337 | //$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT'); |
338 | - $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
339 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
338 | + $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
339 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r"); |
|
340 | 340 | } |
341 | 341 | if ($handle) { |
342 | 342 | if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
343 | 343 | $date = ''; |
344 | 344 | //foreach(explode("\n",$cycle) as $line) { |
345 | 345 | if ($globalTransaction) $this->db->beginTransaction(); |
346 | - while(($line = fgets($handle,4096)) !== false) { |
|
347 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
346 | + while (($line = fgets($handle, 4096)) !== false) { |
|
347 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
348 | 348 | $date = $line; |
349 | 349 | } elseif ($line != '') { |
350 | 350 | //$this->parse($line); |
351 | 351 | if ($date == '') $date = date('Y/m/d H:m'); |
352 | 352 | $pos = 0; |
353 | - $pieces = preg_split('/\s/',$line); |
|
353 | + $pieces = preg_split('/\s/', $line); |
|
354 | 354 | if ($pieces[0] == 'METAR') $pos++; |
355 | 355 | if (strlen($pieces[$pos]) != 4) $pos++; |
356 | 356 | $location = $pieces[$pos]; |
357 | - echo $this->addMETAR($location,$line,$date); |
|
357 | + echo $this->addMETAR($location, $line, $date); |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | fclose($handle); |
@@ -368,11 +368,11 @@ discard block |
||
368 | 368 | if ($globalMETARurl == '') return array(); |
369 | 369 | date_default_timezone_set("UTC"); |
370 | 370 | $Common = new Common(); |
371 | - $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
371 | + $url = str_replace('{icao}', $icao, $globalMETARurl); |
|
372 | 372 | $cycle = $Common->getData($url); |
373 | 373 | $date = ''; |
374 | - foreach(explode("\n",$cycle) as $line) { |
|
375 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
374 | + foreach (explode("\n", $cycle) as $line) { |
|
375 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
376 | 376 | //echo "date : ".$line."\n"; |
377 | 377 | $date = $line; |
378 | 378 | } |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | //echo $line; |
382 | 382 | if ($date == '') $date = date('Y/m/d H:m'); |
383 | 383 | $pos = 0; |
384 | - $pieces = preg_split('/\s/',$line); |
|
384 | + $pieces = preg_split('/\s/', $line); |
|
385 | 385 | if ($pieces[0] == 'METAR') $pos++; |
386 | 386 | if (strlen($pieces[$pos]) != 4) $pos++; |
387 | 387 | $location = $pieces[$pos]; |
388 | 388 | if (strlen($location == 4)) { |
389 | - $this->addMETAR($location,$line,$date); |
|
389 | + $this->addMETAR($location, $line, $date); |
|
390 | 390 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
391 | 391 | } else return array(); |
392 | 392 | } |
@@ -13,45 +13,45 @@ discard block |
||
13 | 13 | * @param Array $filter the filter |
14 | 14 | * @return Array the SQL part |
15 | 15 | */ |
16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
16 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
18 | 18 | $filters = array(); |
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
20 | 20 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
21 | 21 | $filters = $globalStatsFilters[$globalFilterName]; |
22 | 22 | } else { |
23 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
23 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
24 | 24 | } |
25 | 25 | } |
26 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
26 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
27 | 27 | $filter_query_join = ''; |
28 | 28 | $filter_query_where = ''; |
29 | - foreach($filters as $flt) { |
|
29 | + foreach ($filters as $flt) { |
|
30 | 30 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
31 | 31 | if ($flt['airlines'][0] != '') { |
32 | 32 | if (isset($flt['source'])) { |
33 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
33 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
34 | 34 | } else { |
35 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
35 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | } |
39 | 39 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
40 | 40 | if (isset($flt['source'])) { |
41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
42 | 42 | } else { |
43 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
43 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
47 | 47 | if (isset($flt['source'])) { |
48 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
48 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | } |
52 | 52 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
53 | 53 | if ($filter['airlines'][0] != '') { |
54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -59,19 +59,19 @@ discard block |
||
59 | 59 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
60 | 60 | } |
61 | 61 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
62 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
62 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
63 | 63 | } |
64 | 64 | if (isset($filter['source']) && !empty($filter['source'])) { |
65 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
65 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
66 | 66 | } |
67 | 67 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
68 | 68 | $filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
69 | 69 | } |
70 | 70 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
71 | 71 | if ($filter_query_where == '') { |
72 | - $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
72 | + $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
73 | 73 | } else { |
74 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
74 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
@@ -81,28 +81,28 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | // Spotter_archive |
84 | - public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
84 | + public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
85 | 85 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
86 | 86 | if ($over_country == '') { |
87 | 87 | $Spotter = new Spotter($this->db); |
88 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
88 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
89 | 89 | if (!empty($data_country)) $country = $data_country['iso2']; |
90 | 90 | else $country = ''; |
91 | 91 | } else $country = $over_country; |
92 | - if ($airline_type === NULL) $airline_type =''; |
|
92 | + if ($airline_type === NULL) $airline_type = ''; |
|
93 | 93 | |
94 | 94 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
95 | 95 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
96 | 96 | |
97 | 97 | // Route is not added in spotter_archive |
98 | - $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
98 | + $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
99 | 99 | VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)"; |
100 | 100 | |
101 | - $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
101 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
102 | 102 | try { |
103 | 103 | $sth = $this->db->prepare($query); |
104 | 104 | $sth->execute($query_values); |
105 | - } catch(PDOException $e) { |
|
105 | + } catch (PDOException $e) { |
|
106 | 106 | return "error : ".$e->getMessage(); |
107 | 107 | } |
108 | 108 | return "success"; |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | |
123 | 123 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
124 | 124 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
125 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
125 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
126 | 126 | |
127 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
127 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
128 | 128 | |
129 | 129 | return $spotter_array; |
130 | 130 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
144 | 144 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
145 | 145 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
146 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
146 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
147 | 147 | |
148 | 148 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
149 | 149 | /* |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
158 | 158 | */ |
159 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
159 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
160 | 160 | |
161 | 161 | return $spotter_array; |
162 | 162 | } |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | { |
172 | 172 | date_default_timezone_set('UTC'); |
173 | 173 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
174 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
174 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
175 | 175 | |
176 | 176 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
177 | 177 | |
178 | 178 | try { |
179 | 179 | $sth = $this->db->prepare($query); |
180 | 180 | $sth->execute(array(':id' => $id)); |
181 | - } catch(PDOException $e) { |
|
181 | + } catch (PDOException $e) { |
|
182 | 182 | echo $e->getMessage(); |
183 | 183 | die; |
184 | 184 | } |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | { |
198 | 198 | date_default_timezone_set('UTC'); |
199 | 199 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
200 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
200 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
201 | 201 | |
202 | 202 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
203 | 203 | |
204 | 204 | try { |
205 | 205 | $sth = $this->db->prepare($query); |
206 | 206 | $sth->execute(array(':id' => $id)); |
207 | - } catch(PDOException $e) { |
|
207 | + } catch (PDOException $e) { |
|
208 | 208 | echo $e->getMessage(); |
209 | 209 | die; |
210 | 210 | } |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | date_default_timezone_set('UTC'); |
227 | 227 | |
228 | 228 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
229 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
229 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
230 | 230 | |
231 | 231 | try { |
232 | 232 | $sth = $this->db->prepare($query); |
233 | 233 | $sth->execute(array(':ident' => $ident)); |
234 | - } catch(PDOException $e) { |
|
234 | + } catch (PDOException $e) { |
|
235 | 235 | echo $e->getMessage(); |
236 | 236 | die; |
237 | 237 | } |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | date_default_timezone_set('UTC'); |
253 | 253 | |
254 | 254 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
255 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
255 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
256 | 256 | |
257 | 257 | try { |
258 | 258 | $sth = $this->db->prepare($query); |
259 | 259 | $sth->execute(array(':id' => $id)); |
260 | - } catch(PDOException $e) { |
|
260 | + } catch (PDOException $e) { |
|
261 | 261 | echo $e->getMessage(); |
262 | 262 | die; |
263 | 263 | } |
@@ -278,12 +278,12 @@ discard block |
||
278 | 278 | date_default_timezone_set('UTC'); |
279 | 279 | |
280 | 280 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
281 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
281 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
282 | 282 | |
283 | 283 | try { |
284 | 284 | $sth = $this->db->prepare($query); |
285 | 285 | $sth->execute(array(':id' => $id)); |
286 | - } catch(PDOException $e) { |
|
286 | + } catch (PDOException $e) { |
|
287 | 287 | echo $e->getMessage(); |
288 | 288 | die; |
289 | 289 | } |
@@ -305,13 +305,13 @@ discard block |
||
305 | 305 | date_default_timezone_set('UTC'); |
306 | 306 | |
307 | 307 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
308 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
308 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
309 | 309 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
310 | 310 | |
311 | 311 | try { |
312 | 312 | $sth = $this->db->prepare($query); |
313 | 313 | $sth->execute(array(':ident' => $ident)); |
314 | - } catch(PDOException $e) { |
|
314 | + } catch (PDOException $e) { |
|
315 | 315 | echo $e->getMessage(); |
316 | 316 | die; |
317 | 317 | } |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | * @return Array the spotter information |
329 | 329 | * |
330 | 330 | */ |
331 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
331 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
332 | 332 | { |
333 | 333 | $Spotter = new Spotter($this->db); |
334 | 334 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
335 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
335 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
336 | 336 | |
337 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
337 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
338 | 338 | |
339 | 339 | return $spotter_array; |
340 | 340 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | try { |
348 | 348 | $sth = $this->db->prepare($query); |
349 | 349 | $sth->execute(); |
350 | - } catch(PDOException $e) { |
|
350 | + } catch (PDOException $e) { |
|
351 | 351 | echo $e->getMessage(); |
352 | 352 | die; |
353 | 353 | } |
@@ -359,24 +359,24 @@ discard block |
||
359 | 359 | * @return Array the spotter information |
360 | 360 | * |
361 | 361 | */ |
362 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
362 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
363 | 363 | { |
364 | 364 | global $globalDBdriver, $globalLiveInterval; |
365 | 365 | date_default_timezone_set('UTC'); |
366 | 366 | |
367 | 367 | $filter_query = ''; |
368 | 368 | if (isset($filter['source']) && !empty($filter['source'])) { |
369 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
369 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
370 | 370 | } |
371 | 371 | // Use spotter_output also ? |
372 | 372 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
373 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
373 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
374 | 374 | } |
375 | 375 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
376 | 376 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
377 | 377 | } |
378 | 378 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
379 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
379 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -395,14 +395,14 @@ discard block |
||
395 | 395 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
396 | 396 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
397 | 397 | */ |
398 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
398 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
399 | 399 | FROM spotter_archive |
400 | 400 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
401 | 401 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
402 | 402 | '.$filter_query.' ORDER BY flightaware_id'; |
403 | 403 | } else { |
404 | 404 | //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
405 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
405 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
406 | 406 | FROM spotter_archive |
407 | 407 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
408 | 408 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | try { |
413 | 413 | $sth = $this->db->prepare($query); |
414 | 414 | $sth->execute(); |
415 | - } catch(PDOException $e) { |
|
415 | + } catch (PDOException $e) { |
|
416 | 416 | echo $e->getMessage(); |
417 | 417 | die; |
418 | 418 | } |
@@ -427,24 +427,24 @@ discard block |
||
427 | 427 | * @return Array the spotter information |
428 | 428 | * |
429 | 429 | */ |
430 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
430 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
431 | 431 | { |
432 | 432 | global $globalDBdriver, $globalLiveInterval; |
433 | 433 | date_default_timezone_set('UTC'); |
434 | 434 | |
435 | 435 | $filter_query = ''; |
436 | 436 | if (isset($filter['source']) && !empty($filter['source'])) { |
437 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
437 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
438 | 438 | } |
439 | 439 | // Should use spotter_output also ? |
440 | 440 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
441 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
441 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
442 | 442 | } |
443 | 443 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
444 | 444 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
445 | 445 | } |
446 | 446 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
447 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
447 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | FROM spotter_archive |
455 | 455 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
456 | 456 | */ |
457 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
457 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
458 | 458 | FROM spotter_archive_output |
459 | 459 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
460 | 460 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
470 | 470 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
471 | 471 | */ |
472 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
472 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
473 | 473 | FROM spotter_archive_output |
474 | 474 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
475 | 475 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | try { |
482 | 482 | $sth = $this->db->prepare($query); |
483 | 483 | $sth->execute(); |
484 | - } catch(PDOException $e) { |
|
484 | + } catch (PDOException $e) { |
|
485 | 485 | echo $e->getMessage(); |
486 | 486 | die; |
487 | 487 | } |
@@ -496,23 +496,23 @@ discard block |
||
496 | 496 | * @return Array the spotter information |
497 | 497 | * |
498 | 498 | */ |
499 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
499 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
500 | 500 | { |
501 | 501 | global $globalDBdriver, $globalLiveInterval; |
502 | 502 | date_default_timezone_set('UTC'); |
503 | 503 | |
504 | 504 | $filter_query = ''; |
505 | 505 | if (isset($filter['source']) && !empty($filter['source'])) { |
506 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
506 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
507 | 507 | } |
508 | 508 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
509 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
509 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
510 | 510 | } |
511 | 511 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
512 | 512 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
513 | 513 | } |
514 | 514 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
515 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
515 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $this->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | echo $e->getMessage(); |
532 | 532 | die; |
533 | 533 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | * @return Array the spotter information |
548 | 548 | * |
549 | 549 | */ |
550 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
550 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
551 | 551 | { |
552 | 552 | global $globalTimezone, $globalDBdriver; |
553 | 553 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | |
570 | 570 | $q_array = explode(" ", $q); |
571 | 571 | |
572 | - foreach ($q_array as $q_item){ |
|
572 | + foreach ($q_array as $q_item) { |
|
573 | 573 | $additional_query .= " AND ("; |
574 | 574 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
575 | 575 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | |
602 | 602 | if ($registration != "") |
603 | 603 | { |
604 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
604 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
605 | 605 | if (!is_string($registration)) |
606 | 606 | { |
607 | 607 | return false; |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | if ($aircraft_icao != "") |
614 | 614 | { |
615 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
615 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
616 | 616 | if (!is_string($aircraft_icao)) |
617 | 617 | { |
618 | 618 | return false; |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | |
624 | 624 | if ($aircraft_manufacturer != "") |
625 | 625 | { |
626 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
626 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
627 | 627 | if (!is_string($aircraft_manufacturer)) |
628 | 628 | { |
629 | 629 | return false; |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | |
645 | 645 | if ($airline_icao != "") |
646 | 646 | { |
647 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
647 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
648 | 648 | if (!is_string($airline_icao)) |
649 | 649 | { |
650 | 650 | return false; |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | |
656 | 656 | if ($airline_country != "") |
657 | 657 | { |
658 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
658 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
659 | 659 | if (!is_string($airline_country)) |
660 | 660 | { |
661 | 661 | return false; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | |
667 | 667 | if ($airline_type != "") |
668 | 668 | { |
669 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
669 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
670 | 670 | if (!is_string($airline_type)) |
671 | 671 | { |
672 | 672 | return false; |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | |
689 | 689 | if ($airport != "") |
690 | 690 | { |
691 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
691 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
692 | 692 | if (!is_string($airport)) |
693 | 693 | { |
694 | 694 | return false; |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | |
700 | 700 | if ($airport_country != "") |
701 | 701 | { |
702 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
702 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
703 | 703 | if (!is_string($airport_country)) |
704 | 704 | { |
705 | 705 | return false; |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | |
711 | 711 | if ($callsign != "") |
712 | 712 | { |
713 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
713 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
714 | 714 | if (!is_string($callsign)) |
715 | 715 | { |
716 | 716 | return false; |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | $translate = $Translation->ident2icao($callsign); |
719 | 719 | if ($translate != $callsign) { |
720 | 720 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
721 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
721 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
722 | 722 | } else { |
723 | 723 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
724 | 724 | } |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | |
728 | 728 | if ($owner != "") |
729 | 729 | { |
730 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
730 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
731 | 731 | if (!is_string($owner)) |
732 | 732 | { |
733 | 733 | return false; |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | |
739 | 739 | if ($pilot_name != "") |
740 | 740 | { |
741 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
741 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
742 | 742 | if (!is_string($pilot_name)) |
743 | 743 | { |
744 | 744 | return false; |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | |
750 | 750 | if ($pilot_id != "") |
751 | 751 | { |
752 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
752 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
753 | 753 | if (!is_string($pilot_id)) |
754 | 754 | { |
755 | 755 | return false; |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | |
761 | 761 | if ($departure_airport_route != "") |
762 | 762 | { |
763 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
763 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
764 | 764 | if (!is_string($departure_airport_route)) |
765 | 765 | { |
766 | 766 | return false; |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | |
772 | 772 | if ($arrival_airport_route != "") |
773 | 773 | { |
774 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
774 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
775 | 775 | if (!is_string($arrival_airport_route)) |
776 | 776 | { |
777 | 777 | return false; |
@@ -784,8 +784,8 @@ discard block |
||
784 | 784 | { |
785 | 785 | $altitude_array = explode(",", $altitude); |
786 | 786 | |
787 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
787 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
788 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
789 | 789 | |
790 | 790 | |
791 | 791 | if ($altitude_array[1] != "") |
@@ -803,8 +803,8 @@ discard block |
||
803 | 803 | { |
804 | 804 | $date_array = explode(",", $date_posted); |
805 | 805 | |
806 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
807 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
806 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
807 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
808 | 808 | |
809 | 809 | if ($globalTimezone != '') { |
810 | 810 | date_default_timezone_set($globalTimezone); |
@@ -836,8 +836,8 @@ discard block |
||
836 | 836 | { |
837 | 837 | $limit_array = explode(",", $limit); |
838 | 838 | |
839 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
840 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
839 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
840 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
841 | 841 | |
842 | 842 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
843 | 843 | { |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | |
849 | 849 | |
850 | 850 | if ($origLat != "" && $origLon != "" && $dist != "") { |
851 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
852 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
851 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
852 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
853 | 853 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
854 | 854 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
855 | 855 | } else { |
@@ -866,12 +866,12 @@ discard block |
||
866 | 866 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
867 | 867 | } |
868 | 868 | |
869 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
869 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
870 | 870 | WHERE spotter_archive_output.ident <> '' |
871 | 871 | ".$additional_query." |
872 | 872 | ".$filter_query.$orderby_query; |
873 | 873 | } |
874 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
874 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
875 | 875 | |
876 | 876 | return $spotter_array; |
877 | 877 | } |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | try { |
889 | 889 | $sth = $this->db->prepare($query); |
890 | 890 | $sth->execute(); |
891 | - } catch(PDOException $e) { |
|
891 | + } catch (PDOException $e) { |
|
892 | 892 | return "error"; |
893 | 893 | } |
894 | 894 | } |
@@ -925,8 +925,8 @@ discard block |
||
925 | 925 | { |
926 | 926 | $limit_array = explode(",", $limit); |
927 | 927 | |
928 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
929 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
928 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
929 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
930 | 930 | |
931 | 931 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
932 | 932 | { |
@@ -983,8 +983,8 @@ discard block |
||
983 | 983 | { |
984 | 984 | $limit_array = explode(",", $limit); |
985 | 985 | |
986 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
987 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
986 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
987 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
988 | 988 | |
989 | 989 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
990 | 990 | { |
@@ -1035,8 +1035,8 @@ discard block |
||
1035 | 1035 | { |
1036 | 1036 | $limit_array = explode(",", $limit); |
1037 | 1037 | |
1038 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1039 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1038 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1039 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1040 | 1040 | |
1041 | 1041 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1042 | 1042 | { |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | * @return Array the airline country list |
1067 | 1067 | * |
1068 | 1068 | */ |
1069 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1069 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1070 | 1070 | { |
1071 | 1071 | global $globalDBdriver; |
1072 | 1072 | /* |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | $flight_array = array(); |
1096 | 1096 | $temp_array = array(); |
1097 | 1097 | |
1098 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1098 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1099 | 1099 | { |
1100 | 1100 | $temp_array['flight_count'] = $row['nb']; |
1101 | 1101 | $temp_array['flight_country'] = $row['name']; |
@@ -1112,7 +1112,7 @@ discard block |
||
1112 | 1112 | * @return Array the airline country list |
1113 | 1113 | * |
1114 | 1114 | */ |
1115 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1115 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1116 | 1116 | { |
1117 | 1117 | global $globalDBdriver; |
1118 | 1118 | /* |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | $flight_array = array(); |
1142 | 1142 | $temp_array = array(); |
1143 | 1143 | |
1144 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1144 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1145 | 1145 | { |
1146 | 1146 | $temp_array['airline_icao'] = $row['airline_icao']; |
1147 | 1147 | $temp_array['flight_count'] = $row['nb']; |
@@ -1159,14 +1159,14 @@ discard block |
||
1159 | 1159 | * @return Array the spotter information |
1160 | 1160 | * |
1161 | 1161 | */ |
1162 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1162 | + public function getDateArchiveSpotterDataById($id, $date) |
|
1163 | 1163 | { |
1164 | 1164 | $Spotter = new Spotter($this->db); |
1165 | 1165 | date_default_timezone_set('UTC'); |
1166 | 1166 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1167 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1168 | - $date = date('c',$date); |
|
1169 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1167 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1168 | + $date = date('c', $date); |
|
1169 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1170 | 1170 | return $spotter_array; |
1171 | 1171 | } |
1172 | 1172 | |
@@ -1176,14 +1176,14 @@ discard block |
||
1176 | 1176 | * @return Array the spotter information |
1177 | 1177 | * |
1178 | 1178 | */ |
1179 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1179 | + public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
1180 | 1180 | { |
1181 | 1181 | $Spotter = new Spotter($this->db); |
1182 | 1182 | date_default_timezone_set('UTC'); |
1183 | 1183 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1184 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1185 | - $date = date('c',$date); |
|
1186 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1184 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1185 | + $date = date('c', $date); |
|
1186 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1187 | 1187 | return $spotter_array; |
1188 | 1188 | } |
1189 | 1189 | |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | * @return Array the spotter information |
1194 | 1194 | * |
1195 | 1195 | */ |
1196 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1196 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1197 | 1197 | { |
1198 | 1198 | global $global_query; |
1199 | 1199 | $Spotter = new Spotter(); |
@@ -1201,7 +1201,7 @@ discard block |
||
1201 | 1201 | $query_values = array(); |
1202 | 1202 | $limit_query = ''; |
1203 | 1203 | $additional_query = ''; |
1204 | - $filter_query = $this->getFilter($filters,true,true); |
|
1204 | + $filter_query = $this->getFilter($filters, true, true); |
|
1205 | 1205 | |
1206 | 1206 | if ($airport != "") |
1207 | 1207 | { |
@@ -1218,8 +1218,8 @@ discard block |
||
1218 | 1218 | { |
1219 | 1219 | $limit_array = explode(",", $limit); |
1220 | 1220 | |
1221 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1222 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1221 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1222 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1223 | 1223 | |
1224 | 1224 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1225 | 1225 | { |
@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | $this->db = $Connection->db(); |
18 | 18 | } |
19 | 19 | |
20 | - public function addLastStatsUpdate($type,$stats_date) { |
|
20 | + public function addLastStatsUpdate($type, $stats_date) { |
|
21 | 21 | $query = "DELETE FROM config WHERE name = :type; |
22 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
23 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
23 | + $query_values = array('type' => $type, ':stats_date' => $stats_date); |
|
24 | 24 | try { |
25 | 25 | $sth = $this->db->prepare($query); |
26 | 26 | $sth->execute($query_values); |
27 | - } catch(PDOException $e) { |
|
27 | + } catch (PDOException $e) { |
|
28 | 28 | return "error : ".$e->getMessage(); |
29 | 29 | } |
30 | 30 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | try { |
35 | 35 | $sth = $this->db->prepare($query); |
36 | 36 | $sth->execute(array(':type' => $type)); |
37 | - } catch(PDOException $e) { |
|
37 | + } catch (PDOException $e) { |
|
38 | 38 | echo "error : ".$e->getMessage(); |
39 | 39 | } |
40 | 40 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | try { |
55 | 55 | $sth = $this->db->prepare($query); |
56 | 56 | $sth->execute(array(':filter_name' => $filter_name)); |
57 | - } catch(PDOException $e) { |
|
57 | + } catch (PDOException $e) { |
|
58 | 58 | return "error : ".$e->getMessage(); |
59 | 59 | } |
60 | 60 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | try { |
65 | 65 | $sth = $this->db->prepare($query); |
66 | 66 | $sth->execute(); |
67 | - } catch(PDOException $e) { |
|
67 | + } catch (PDOException $e) { |
|
68 | 68 | return "error : ".$e->getMessage(); |
69 | 69 | } |
70 | 70 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | try { |
73 | 73 | $sth = $this->db->prepare($query); |
74 | 74 | $sth->execute(array(':filter_name' => $filter_name)); |
75 | - } catch(PDOException $e) { |
|
75 | + } catch (PDOException $e) { |
|
76 | 76 | return "error : ".$e->getMessage(); |
77 | 77 | } |
78 | 78 | } |
@@ -82,69 +82,69 @@ discard block |
||
82 | 82 | try { |
83 | 83 | $sth = $this->db->prepare($query); |
84 | 84 | $sth->execute(array(':filter_name' => $filter_name)); |
85 | - } catch(PDOException $e) { |
|
85 | + } catch (PDOException $e) { |
|
86 | 86 | echo "error : ".$e->getMessage(); |
87 | 87 | } |
88 | 88 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
89 | 89 | return $all; |
90 | 90 | } |
91 | - public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
|
91 | + public function getAllAircraftTypes($stats_airline = '', $filter_name = '') { |
|
92 | 92 | if ($filter_name == '') $filter_name = $this->filter_name; |
93 | 93 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
94 | 94 | try { |
95 | 95 | $sth = $this->db->prepare($query); |
96 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
97 | - } catch(PDOException $e) { |
|
96 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
97 | + } catch (PDOException $e) { |
|
98 | 98 | echo "error : ".$e->getMessage(); |
99 | 99 | } |
100 | 100 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
101 | 101 | return $all; |
102 | 102 | } |
103 | - public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
|
103 | + public function getAllManufacturers($stats_airline = '', $filter_name = '') { |
|
104 | 104 | if ($filter_name == '') $filter_name = $this->filter_name; |
105 | 105 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
106 | 106 | try { |
107 | 107 | $sth = $this->db->prepare($query); |
108 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
109 | - } catch(PDOException $e) { |
|
108 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
109 | + } catch (PDOException $e) { |
|
110 | 110 | echo "error : ".$e->getMessage(); |
111 | 111 | } |
112 | 112 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
113 | 113 | return $all; |
114 | 114 | } |
115 | - public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
|
115 | + public function getAllAirportNames($stats_airline = '', $filter_name = '') { |
|
116 | 116 | if ($filter_name == '') $filter_name = $this->filter_name; |
117 | 117 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
118 | 118 | try { |
119 | 119 | $sth = $this->db->prepare($query); |
120 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
121 | - } catch(PDOException $e) { |
|
120 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
121 | + } catch (PDOException $e) { |
|
122 | 122 | echo "error : ".$e->getMessage(); |
123 | 123 | } |
124 | 124 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
125 | 125 | return $all; |
126 | 126 | } |
127 | 127 | |
128 | - public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
|
128 | + public function getAllOwnerNames($stats_airline = '', $filter_name = '') { |
|
129 | 129 | if ($filter_name == '') $filter_name = $this->filter_name; |
130 | 130 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
131 | 131 | try { |
132 | 132 | $sth = $this->db->prepare($query); |
133 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
134 | - } catch(PDOException $e) { |
|
133 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
134 | + } catch (PDOException $e) { |
|
135 | 135 | echo "error : ".$e->getMessage(); |
136 | 136 | } |
137 | 137 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
138 | 138 | return $all; |
139 | 139 | } |
140 | 140 | |
141 | - public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
|
141 | + public function getAllPilotNames($stats_airline = '', $filter_name = '') { |
|
142 | 142 | if ($filter_name == '') $filter_name = $this->filter_name; |
143 | 143 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
144 | 144 | try { |
145 | 145 | $sth = $this->db->prepare($query); |
146 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
147 | - } catch(PDOException $e) { |
|
146 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
147 | + } catch (PDOException $e) { |
|
148 | 148 | echo "error : ".$e->getMessage(); |
149 | 149 | } |
150 | 150 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | - public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
155 | + public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
156 | 156 | global $globalStatsFilters; |
157 | 157 | if ($filter_name == '') $filter_name = $this->filter_name; |
158 | 158 | if ($year == '' && $month == '') { |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
161 | 161 | try { |
162 | 162 | $sth = $this->db->prepare($query); |
163 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
164 | - } catch(PDOException $e) { |
|
163 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
164 | + } catch (PDOException $e) { |
|
165 | 165 | echo "error : ".$e->getMessage(); |
166 | 166 | } |
167 | 167 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | if (empty($all)) { |
170 | 170 | $filters = array('airlines' => array($stats_airline)); |
171 | 171 | if ($filter_name != '') { |
172 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
172 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
173 | 173 | } |
174 | 174 | $Spotter = new Spotter($this->db); |
175 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month); |
|
175 | + $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters, $year, $month); |
|
176 | 176 | } |
177 | 177 | return $all; |
178 | 178 | } |
179 | - public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
|
179 | + public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') { |
|
180 | 180 | global $globalStatsFilters; |
181 | 181 | if ($filter_name == '') $filter_name = $this->filter_name; |
182 | 182 | if ($year == '' && $month == '') { |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | try { |
186 | 186 | $sth = $this->db->prepare($query); |
187 | 187 | $sth->execute(array(':filter_name' => $filter_name)); |
188 | - } catch(PDOException $e) { |
|
188 | + } catch (PDOException $e) { |
|
189 | 189 | echo "error : ".$e->getMessage(); |
190 | 190 | } |
191 | 191 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -194,13 +194,13 @@ discard block |
||
194 | 194 | $Spotter = new Spotter($this->db); |
195 | 195 | $filters = array(); |
196 | 196 | if ($filter_name != '') { |
197 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
197 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
198 | 198 | } |
199 | - $all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month); |
|
199 | + $all = $Spotter->countAllAirlineCountries($limit, $filters, $year, $month); |
|
200 | 200 | } |
201 | 201 | return $all; |
202 | 202 | } |
203 | - public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
203 | + public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
204 | 204 | global $globalStatsFilters; |
205 | 205 | if ($filter_name == '') $filter_name = $this->filter_name; |
206 | 206 | if ($year == '' && $month == '') { |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
209 | 209 | try { |
210 | 210 | $sth = $this->db->prepare($query); |
211 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
212 | - } catch(PDOException $e) { |
|
211 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
212 | + } catch (PDOException $e) { |
|
213 | 213 | echo "error : ".$e->getMessage(); |
214 | 214 | } |
215 | 215 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -217,15 +217,15 @@ discard block |
||
217 | 217 | if (empty($all)) { |
218 | 218 | $filters = array('airlines' => array($stats_airline)); |
219 | 219 | if ($filter_name != '') { |
220 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
220 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
221 | 221 | } |
222 | 222 | $Spotter = new Spotter($this->db); |
223 | - $all = $Spotter->countAllAircraftManufacturers($filters,$year,$month); |
|
223 | + $all = $Spotter->countAllAircraftManufacturers($filters, $year, $month); |
|
224 | 224 | } |
225 | 225 | return $all; |
226 | 226 | } |
227 | 227 | |
228 | - public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
|
228 | + public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
229 | 229 | global $globalStatsFilters; |
230 | 230 | if ($filter_name == '') $filter_name = $this->filter_name; |
231 | 231 | if ($year == '' && $month == '') { |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
234 | 234 | try { |
235 | 235 | $sth = $this->db->prepare($query); |
236 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
237 | - } catch(PDOException $e) { |
|
236 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
237 | + } catch (PDOException $e) { |
|
238 | 238 | echo "error : ".$e->getMessage(); |
239 | 239 | } |
240 | 240 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | if (empty($all)) { |
243 | 243 | $filters = array('airlines' => array($stats_airline)); |
244 | 244 | if ($filter_name != '') { |
245 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
245 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
246 | 246 | } |
247 | 247 | $Spotter = new Spotter($this->db); |
248 | - $all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month); |
|
248 | + $all = $Spotter->countAllArrivalCountries($limit, $filters, $year, $month); |
|
249 | 249 | } |
250 | 250 | return $all; |
251 | 251 | } |
@@ -256,23 +256,23 @@ discard block |
||
256 | 256 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
257 | 257 | try { |
258 | 258 | $sth = $this->db->prepare($query); |
259 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
260 | - } catch(PDOException $e) { |
|
259 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
260 | + } catch (PDOException $e) { |
|
261 | 261 | echo "error : ".$e->getMessage(); |
262 | 262 | } |
263 | 263 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
264 | 264 | if (empty($all)) { |
265 | 265 | $filters = array('airlines' => array($stats_airline)); |
266 | 266 | if ($filter_name != '') { |
267 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
267 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
268 | 268 | } |
269 | 269 | $Spotter = new Spotter($this->db); |
270 | - $all = $Spotter->countAllDepartureCountries($filters,$year,$month); |
|
270 | + $all = $Spotter->countAllDepartureCountries($filters, $year, $month); |
|
271 | 271 | } |
272 | 272 | return $all; |
273 | 273 | } |
274 | 274 | |
275 | - public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
|
275 | + public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') { |
|
276 | 276 | global $globalStatsFilters; |
277 | 277 | if ($filter_name == '') $filter_name = $this->filter_name; |
278 | 278 | if ($year == '' && $month == '') { |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | try { |
282 | 282 | $sth = $this->db->prepare($query); |
283 | 283 | $sth->execute(array(':filter_name' => $filter_name)); |
284 | - } catch(PDOException $e) { |
|
284 | + } catch (PDOException $e) { |
|
285 | 285 | echo "error : ".$e->getMessage(); |
286 | 286 | } |
287 | 287 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -290,14 +290,14 @@ discard block |
||
290 | 290 | $Spotter = new Spotter($this->db); |
291 | 291 | $filters = array(); |
292 | 292 | if ($filter_name != '') { |
293 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
293 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
294 | 294 | } |
295 | 295 | |
296 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month); |
|
296 | + $all = $Spotter->countAllAirlines($limit, 0, '', $filters, $year, $month); |
|
297 | 297 | } |
298 | 298 | return $all; |
299 | 299 | } |
300 | - public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
300 | + public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
301 | 301 | global $globalStatsFilters; |
302 | 302 | if ($filter_name == '') $filter_name = $this->filter_name; |
303 | 303 | if ($year == '' && $month == '') { |
@@ -305,8 +305,8 @@ discard block |
||
305 | 305 | else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
306 | 306 | try { |
307 | 307 | $sth = $this->db->prepare($query); |
308 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
309 | - } catch(PDOException $e) { |
|
308 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
309 | + } catch (PDOException $e) { |
|
310 | 310 | echo "error : ".$e->getMessage(); |
311 | 311 | } |
312 | 312 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -314,14 +314,14 @@ discard block |
||
314 | 314 | if (empty($all)) { |
315 | 315 | $filters = array('airlines' => array($stats_airline)); |
316 | 316 | if ($filter_name != '') { |
317 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
317 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
318 | 318 | } |
319 | 319 | $Spotter = new Spotter($this->db); |
320 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month); |
|
320 | + $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters, $year, $month); |
|
321 | 321 | } |
322 | 322 | return $all; |
323 | 323 | } |
324 | - public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
324 | + public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
325 | 325 | global $globalStatsFilters; |
326 | 326 | if ($filter_name == '') $filter_name = $this->filter_name; |
327 | 327 | if ($year == '' && $month == '') { |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
330 | 330 | try { |
331 | 331 | $sth = $this->db->prepare($query); |
332 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
333 | - } catch(PDOException $e) { |
|
332 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
333 | + } catch (PDOException $e) { |
|
334 | 334 | echo "error : ".$e->getMessage(); |
335 | 335 | } |
336 | 336 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | if (empty($all)) { |
339 | 339 | $filters = array('airlines' => array($stats_airline)); |
340 | 340 | if ($filter_name != '') { |
341 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
341 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
342 | 342 | } |
343 | 343 | $Spotter = new Spotter($this->db); |
344 | - $all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month); |
|
344 | + $all = $Spotter->countAllCallsigns($limit, 0, '', $filters, $year, $month); |
|
345 | 345 | } |
346 | 346 | return $all; |
347 | 347 | } |
348 | - public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
348 | + public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
349 | 349 | $Connection = new Connection(); |
350 | 350 | if ($filter_name == '') $filter_name = $this->filter_name; |
351 | 351 | if ($Connection->tableExists('countries')) { |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
355 | 355 | try { |
356 | 356 | $sth = $this->db->prepare($query); |
357 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
358 | - } catch(PDOException $e) { |
|
357 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
358 | + } catch (PDOException $e) { |
|
359 | 359 | echo "error : ".$e->getMessage(); |
360 | 360 | } |
361 | 361 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | return array(); |
372 | 372 | } |
373 | 373 | } |
374 | - public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
|
374 | + public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
375 | 375 | global $globalStatsFilters; |
376 | 376 | if ($filter_name == '') $filter_name = $this->filter_name; |
377 | 377 | if ($year == '' && $month == '') { |
@@ -379,8 +379,8 @@ discard block |
||
379 | 379 | else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
380 | 380 | try { |
381 | 381 | $sth = $this->db->prepare($query); |
382 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
383 | - } catch(PDOException $e) { |
|
382 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
383 | + } catch (PDOException $e) { |
|
384 | 384 | echo "error : ".$e->getMessage(); |
385 | 385 | } |
386 | 386 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -388,15 +388,15 @@ discard block |
||
388 | 388 | if (empty($all)) { |
389 | 389 | $filters = array('airlines' => array($stats_airline)); |
390 | 390 | if ($filter_name != '') { |
391 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
391 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
392 | 392 | } |
393 | 393 | $Spotter = new Spotter($this->db); |
394 | - $all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month); |
|
394 | + $all = $Spotter->countAllPilots($limit, 0, '', $filters, $year, $month); |
|
395 | 395 | } |
396 | 396 | return $all; |
397 | 397 | } |
398 | 398 | |
399 | - public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
399 | + public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
400 | 400 | global $globalStatsFilters; |
401 | 401 | if ($filter_name == '') $filter_name = $this->filter_name; |
402 | 402 | if ($year == '' && $month == '') { |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
405 | 405 | try { |
406 | 406 | $sth = $this->db->prepare($query); |
407 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
408 | - } catch(PDOException $e) { |
|
407 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
408 | + } catch (PDOException $e) { |
|
409 | 409 | echo "error : ".$e->getMessage(); |
410 | 410 | } |
411 | 411 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -413,14 +413,14 @@ discard block |
||
413 | 413 | if (empty($all)) { |
414 | 414 | $filters = array('airlines' => array($stats_airline)); |
415 | 415 | if ($filter_name != '') { |
416 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
416 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
417 | 417 | } |
418 | 418 | $Spotter = new Spotter($this->db); |
419 | - $all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month); |
|
419 | + $all = $Spotter->countAllOwners($limit, 0, '', $filters, $year, $month); |
|
420 | 420 | } |
421 | 421 | return $all; |
422 | 422 | } |
423 | - public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
423 | + public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
424 | 424 | global $globalStatsFilters; |
425 | 425 | if ($filter_name == '') $filter_name = $this->filter_name; |
426 | 426 | if ($year == '' && $month == '') { |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
429 | 429 | try { |
430 | 430 | $sth = $this->db->prepare($query); |
431 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
432 | - } catch(PDOException $e) { |
|
431 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
432 | + } catch (PDOException $e) { |
|
433 | 433 | echo "error : ".$e->getMessage(); |
434 | 434 | } |
435 | 435 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -437,11 +437,11 @@ discard block |
||
437 | 437 | if (empty($all)) { |
438 | 438 | $filters = array('airlines' => array($stats_airline)); |
439 | 439 | if ($filter_name != '') { |
440 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
440 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
441 | 441 | } |
442 | 442 | $Spotter = new Spotter($this->db); |
443 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month); |
|
444 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month); |
|
443 | + $pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters, $year, $month); |
|
444 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters, $year, $month); |
|
445 | 445 | $all = array(); |
446 | 446 | foreach ($pall as $value) { |
447 | 447 | $icao = $value['airport_departure_icao']; |
@@ -458,11 +458,11 @@ discard block |
||
458 | 458 | foreach ($all as $key => $row) { |
459 | 459 | $count[$key] = $row['airport_departure_icao_count']; |
460 | 460 | } |
461 | - array_multisort($count,SORT_DESC,$all); |
|
461 | + array_multisort($count, SORT_DESC, $all); |
|
462 | 462 | } |
463 | 463 | return $all; |
464 | 464 | } |
465 | - public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
465 | + public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
466 | 466 | global $globalStatsFilters; |
467 | 467 | if ($filter_name == '') $filter_name = $this->filter_name; |
468 | 468 | if ($year == '' && $month == '') { |
@@ -470,8 +470,8 @@ discard block |
||
470 | 470 | else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
471 | 471 | try { |
472 | 472 | $sth = $this->db->prepare($query); |
473 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
474 | - } catch(PDOException $e) { |
|
473 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
474 | + } catch (PDOException $e) { |
|
475 | 475 | echo "error : ".$e->getMessage(); |
476 | 476 | } |
477 | 477 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -479,11 +479,11 @@ discard block |
||
479 | 479 | if (empty($all)) { |
480 | 480 | $filters = array('airlines' => array($stats_airline)); |
481 | 481 | if ($filter_name != '') { |
482 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
482 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
483 | 483 | } |
484 | 484 | $Spotter = new Spotter($this->db); |
485 | - $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month); |
|
486 | - $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month); |
|
485 | + $pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters, $year, $month); |
|
486 | + $dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters, $year, $month); |
|
487 | 487 | $all = array(); |
488 | 488 | foreach ($pall as $value) { |
489 | 489 | $icao = $value['airport_arrival_icao']; |
@@ -500,12 +500,12 @@ discard block |
||
500 | 500 | foreach ($all as $key => $row) { |
501 | 501 | $count[$key] = $row['airport_arrival_icao_count']; |
502 | 502 | } |
503 | - array_multisort($count,SORT_DESC,$all); |
|
503 | + array_multisort($count, SORT_DESC, $all); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | return $all; |
507 | 507 | } |
508 | - public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
|
508 | + public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') { |
|
509 | 509 | global $globalDBdriver, $globalStatsFilters; |
510 | 510 | if ($filter_name == '') $filter_name = $this->filter_name; |
511 | 511 | if ($globalDBdriver == 'mysql') { |
@@ -515,18 +515,18 @@ discard block |
||
515 | 515 | if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
516 | 516 | else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
517 | 517 | } |
518 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
518 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
519 | 519 | try { |
520 | 520 | $sth = $this->db->prepare($query); |
521 | 521 | $sth->execute($query_data); |
522 | - } catch(PDOException $e) { |
|
522 | + } catch (PDOException $e) { |
|
523 | 523 | echo "error : ".$e->getMessage(); |
524 | 524 | } |
525 | 525 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
526 | 526 | if (empty($all)) { |
527 | 527 | $filters = array('airlines' => array($stats_airline)); |
528 | 528 | if ($filter_name != '') { |
529 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
529 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
530 | 530 | } |
531 | 531 | $Spotter = new Spotter($this->db); |
532 | 532 | $all = $Spotter->countAllMonthsLastYear($filters); |
@@ -535,29 +535,29 @@ discard block |
||
535 | 535 | return $all; |
536 | 536 | } |
537 | 537 | |
538 | - public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
|
538 | + public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') { |
|
539 | 539 | global $globalStatsFilters; |
540 | 540 | if ($filter_name == '') $filter_name = $this->filter_name; |
541 | 541 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
542 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
542 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
543 | 543 | try { |
544 | 544 | $sth = $this->db->prepare($query); |
545 | 545 | $sth->execute($query_data); |
546 | - } catch(PDOException $e) { |
|
546 | + } catch (PDOException $e) { |
|
547 | 547 | echo "error : ".$e->getMessage(); |
548 | 548 | } |
549 | 549 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
550 | 550 | if (empty($all)) { |
551 | 551 | $filters = array('airlines' => array($stats_airline)); |
552 | 552 | if ($filter_name != '') { |
553 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
553 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
554 | 554 | } |
555 | 555 | $Spotter = new Spotter($this->db); |
556 | 556 | $all = $Spotter->countAllDatesLastMonth($filters); |
557 | 557 | } |
558 | 558 | return $all; |
559 | 559 | } |
560 | - public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
|
560 | + public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') { |
|
561 | 561 | global $globalDBdriver, $globalStatsFilters; |
562 | 562 | if ($filter_name == '') $filter_name = $this->filter_name; |
563 | 563 | if ($globalDBdriver == 'mysql') { |
@@ -565,40 +565,40 @@ discard block |
||
565 | 565 | } else { |
566 | 566 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
567 | 567 | } |
568 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
568 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
569 | 569 | try { |
570 | 570 | $sth = $this->db->prepare($query); |
571 | 571 | $sth->execute($query_data); |
572 | - } catch(PDOException $e) { |
|
572 | + } catch (PDOException $e) { |
|
573 | 573 | echo "error : ".$e->getMessage(); |
574 | 574 | } |
575 | 575 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
576 | 576 | if (empty($all)) { |
577 | 577 | $filters = array('airlines' => array($stats_airline)); |
578 | 578 | if ($filter_name != '') { |
579 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
579 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
580 | 580 | } |
581 | 581 | $Spotter = new Spotter($this->db); |
582 | 582 | $all = $Spotter->countAllDatesLast7Days($filters); |
583 | 583 | } |
584 | 584 | return $all; |
585 | 585 | } |
586 | - public function countAllDates($stats_airline = '',$filter_name = '') { |
|
586 | + public function countAllDates($stats_airline = '', $filter_name = '') { |
|
587 | 587 | global $globalStatsFilters; |
588 | 588 | if ($filter_name == '') $filter_name = $this->filter_name; |
589 | 589 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
590 | - $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
590 | + $query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
591 | 591 | try { |
592 | 592 | $sth = $this->db->prepare($query); |
593 | 593 | $sth->execute($query_data); |
594 | - } catch(PDOException $e) { |
|
594 | + } catch (PDOException $e) { |
|
595 | 595 | echo "error : ".$e->getMessage(); |
596 | 596 | } |
597 | 597 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
598 | 598 | if (empty($all)) { |
599 | 599 | $filters = array('airlines' => array($stats_airline)); |
600 | 600 | if ($filter_name != '') { |
601 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
601 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
602 | 602 | } |
603 | 603 | $Spotter = new Spotter($this->db); |
604 | 604 | $all = $Spotter->countAllDates($filters); |
@@ -613,28 +613,28 @@ discard block |
||
613 | 613 | try { |
614 | 614 | $sth = $this->db->prepare($query); |
615 | 615 | $sth->execute($query_data); |
616 | - } catch(PDOException $e) { |
|
616 | + } catch (PDOException $e) { |
|
617 | 617 | echo "error : ".$e->getMessage(); |
618 | 618 | } |
619 | 619 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
620 | 620 | if (empty($all)) { |
621 | 621 | $filters = array(); |
622 | 622 | if ($filter_name != '') { |
623 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
623 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
624 | 624 | } |
625 | 625 | $Spotter = new Spotter($this->db); |
626 | 626 | $all = $Spotter->countAllDatesByAirlines($filters); |
627 | 627 | } |
628 | 628 | return $all; |
629 | 629 | } |
630 | - public function countAllMonths($stats_airline = '',$filter_name = '') { |
|
630 | + public function countAllMonths($stats_airline = '', $filter_name = '') { |
|
631 | 631 | global $globalStatsFilters; |
632 | 632 | if ($filter_name == '') $filter_name = $this->filter_name; |
633 | 633 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
634 | 634 | try { |
635 | 635 | $sth = $this->db->prepare($query); |
636 | 636 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
637 | - } catch(PDOException $e) { |
|
637 | + } catch (PDOException $e) { |
|
638 | 638 | echo "error : ".$e->getMessage(); |
639 | 639 | } |
640 | 640 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | if (empty($all)) { |
643 | 643 | $filters = array('airlines' => array($stats_airline)); |
644 | 644 | if ($filter_name != '') { |
645 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
645 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
646 | 646 | } |
647 | 647 | $Spotter = new Spotter($this->db); |
648 | 648 | $all = $Spotter->countAllMonths($filters); |
@@ -657,21 +657,21 @@ discard block |
||
657 | 657 | try { |
658 | 658 | $sth = $this->db->prepare($query); |
659 | 659 | $sth->execute(array(':filter_name' => $filter_name)); |
660 | - } catch(PDOException $e) { |
|
660 | + } catch (PDOException $e) { |
|
661 | 661 | echo "error : ".$e->getMessage(); |
662 | 662 | } |
663 | 663 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
664 | 664 | if (empty($all)) { |
665 | 665 | $filters = array(); |
666 | 666 | if ($filter_name != '') { |
667 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
667 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
668 | 668 | } |
669 | 669 | $Spotter = new Spotter($this->db); |
670 | 670 | $all = $Spotter->countAllMilitaryMonths($filters); |
671 | 671 | } |
672 | 672 | return $all; |
673 | 673 | } |
674 | - public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
|
674 | + public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') { |
|
675 | 675 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
676 | 676 | if ($filter_name == '') $filter_name = $this->filter_name; |
677 | 677 | if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -688,82 +688,82 @@ discard block |
||
688 | 688 | try { |
689 | 689 | $sth = $this->db->prepare($query); |
690 | 690 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
691 | - } catch(PDOException $e) { |
|
691 | + } catch (PDOException $e) { |
|
692 | 692 | echo "error : ".$e->getMessage(); |
693 | 693 | } |
694 | 694 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
695 | 695 | if (empty($all)) { |
696 | 696 | $filters = array('airlines' => array($stats_airline)); |
697 | 697 | if ($filter_name != '') { |
698 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
698 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
699 | 699 | } |
700 | 700 | $Spotter = new Spotter($this->db); |
701 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
701 | + $all = $Spotter->countAllHours($orderby, $filters); |
|
702 | 702 | } |
703 | 703 | return $all; |
704 | 704 | } |
705 | 705 | |
706 | - public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
|
706 | + public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
707 | 707 | global $globalStatsFilters; |
708 | 708 | if ($filter_name == '') $filter_name = $this->filter_name; |
709 | 709 | if ($year == '') $year = date('Y'); |
710 | - $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
|
710 | + $all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month); |
|
711 | 711 | if (empty($all)) { |
712 | 712 | $filters = array('airlines' => array($stats_airline)); |
713 | 713 | if ($filter_name != '') { |
714 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
714 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
715 | 715 | } |
716 | 716 | $Spotter = new Spotter($this->db); |
717 | - $all = $Spotter->countOverallFlights($filters,$year,$month); |
|
717 | + $all = $Spotter->countOverallFlights($filters, $year, $month); |
|
718 | 718 | } |
719 | 719 | return $all; |
720 | 720 | } |
721 | - public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
|
721 | + public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') { |
|
722 | 722 | global $globalStatsFilters; |
723 | 723 | if ($filter_name == '') $filter_name = $this->filter_name; |
724 | 724 | if ($year == '') $year = date('Y'); |
725 | - $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
|
725 | + $all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month); |
|
726 | 726 | if (empty($all)) { |
727 | 727 | $filters = array(); |
728 | 728 | if ($filter_name != '') { |
729 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
729 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
730 | 730 | } |
731 | 731 | $Spotter = new Spotter($this->db); |
732 | - $all = $Spotter->countOverallMilitaryFlights($filters,$year,$month); |
|
732 | + $all = $Spotter->countOverallMilitaryFlights($filters, $year, $month); |
|
733 | 733 | } |
734 | 734 | return $all; |
735 | 735 | } |
736 | - public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
|
736 | + public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
737 | 737 | global $globalStatsFilters; |
738 | 738 | if ($filter_name == '') $filter_name = $this->filter_name; |
739 | 739 | if ($year == '') $year = date('Y'); |
740 | - $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
|
740 | + $all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month); |
|
741 | 741 | if (empty($all)) { |
742 | 742 | $filters = array('airlines' => array($stats_airline)); |
743 | 743 | if ($filter_name != '') { |
744 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
744 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
745 | 745 | } |
746 | 746 | $Spotter = new Spotter($this->db); |
747 | - $all = $Spotter->countOverallArrival($filters,$year,$month); |
|
747 | + $all = $Spotter->countOverallArrival($filters, $year, $month); |
|
748 | 748 | } |
749 | 749 | return $all; |
750 | 750 | } |
751 | - public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
751 | + public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
752 | 752 | global $globalStatsFilters; |
753 | 753 | if ($filter_name == '') $filter_name = $this->filter_name; |
754 | 754 | if ($year == '') $year = date('Y'); |
755 | - $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
755 | + $all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month); |
|
756 | 756 | if (empty($all)) { |
757 | 757 | $filters = array('airlines' => array($stats_airline)); |
758 | 758 | if ($filter_name != '') { |
759 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
759 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
760 | 760 | } |
761 | 761 | $Spotter = new Spotter($this->db); |
762 | - $all = $Spotter->countOverallAircrafts($filters,$year,$month); |
|
762 | + $all = $Spotter->countOverallAircrafts($filters, $year, $month); |
|
763 | 763 | } |
764 | 764 | return $all; |
765 | 765 | } |
766 | - public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
|
766 | + public function countOverallAirlines($filter_name = '', $year = '', $month = '') { |
|
767 | 767 | global $globalStatsFilters; |
768 | 768 | if ($filter_name == '') $filter_name = $this->filter_name; |
769 | 769 | if ($year == '' && $month == '') { |
@@ -771,23 +771,23 @@ discard block |
||
771 | 771 | try { |
772 | 772 | $sth = $this->db->prepare($query); |
773 | 773 | $sth->execute(array(':filter_name' => $filter_name)); |
774 | - } catch(PDOException $e) { |
|
774 | + } catch (PDOException $e) { |
|
775 | 775 | echo "error : ".$e->getMessage(); |
776 | 776 | } |
777 | 777 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
778 | 778 | $all = $result[0]['nb_airline']; |
779 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
779 | + } else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month); |
|
780 | 780 | if (empty($all)) { |
781 | 781 | $filters = array(); |
782 | 782 | if ($filter_name != '') { |
783 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
783 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
784 | 784 | } |
785 | 785 | $Spotter = new Spotter($this->db); |
786 | - $all = $Spotter->countOverallAirlines($filters,$year,$month); |
|
786 | + $all = $Spotter->countOverallAirlines($filters, $year, $month); |
|
787 | 787 | } |
788 | 788 | return $all; |
789 | 789 | } |
790 | - public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
|
790 | + public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
791 | 791 | global $globalStatsFilters; |
792 | 792 | if ($filter_name == '') $filter_name = $this->filter_name; |
793 | 793 | if ($year == '') $year = date('Y'); |
@@ -802,83 +802,83 @@ discard block |
||
802 | 802 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
803 | 803 | $all = $result[0]['nb_owner']; |
804 | 804 | */ |
805 | - $all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month); |
|
805 | + $all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month); |
|
806 | 806 | if (empty($all)) { |
807 | 807 | $filters = array('airlines' => array($stats_airline)); |
808 | 808 | if ($filter_name != '') { |
809 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
809 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
810 | 810 | } |
811 | 811 | $Spotter = new Spotter($this->db); |
812 | - $all = $Spotter->countOverallOwners($filters,$year,$month); |
|
812 | + $all = $Spotter->countOverallOwners($filters, $year, $month); |
|
813 | 813 | } |
814 | 814 | return $all; |
815 | 815 | } |
816 | - public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
|
816 | + public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') { |
|
817 | 817 | global $globalStatsFilters; |
818 | 818 | if ($filter_name == '') $filter_name = $this->filter_name; |
819 | 819 | if ($year == '') $year = date('Y'); |
820 | - $all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month); |
|
820 | + $all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month); |
|
821 | 821 | if (empty($all)) { |
822 | 822 | $filters = array('airlines' => array($stats_airline)); |
823 | 823 | if ($filter_name != '') { |
824 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
824 | + $filters = array_merge($filters, $globalStatsFilters[$filter_name]); |
|
825 | 825 | } |
826 | 826 | $Spotter = new Spotter($this->db); |
827 | - $all = $Spotter->countOverallPilots($filters,$year,$month); |
|
827 | + $all = $Spotter->countOverallPilots($filters, $year, $month); |
|
828 | 828 | } |
829 | 829 | return $all; |
830 | 830 | } |
831 | 831 | |
832 | - public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
|
832 | + public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') { |
|
833 | 833 | if ($filter_name == '') $filter_name = $this->filter_name; |
834 | 834 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
835 | - $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
835 | + $query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
836 | 836 | try { |
837 | 837 | $sth = $this->db->prepare($query); |
838 | 838 | $sth->execute($query_values); |
839 | - } catch(PDOException $e) { |
|
839 | + } catch (PDOException $e) { |
|
840 | 840 | echo "error : ".$e->getMessage(); |
841 | 841 | } |
842 | 842 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
843 | 843 | return $all; |
844 | 844 | } |
845 | - public function getStats($type,$stats_airline = '', $filter_name = '') { |
|
845 | + public function getStats($type, $stats_airline = '', $filter_name = '') { |
|
846 | 846 | if ($filter_name == '') $filter_name = $this->filter_name; |
847 | 847 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
848 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
848 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
849 | 849 | try { |
850 | 850 | $sth = $this->db->prepare($query); |
851 | 851 | $sth->execute($query_values); |
852 | - } catch(PDOException $e) { |
|
852 | + } catch (PDOException $e) { |
|
853 | 853 | echo "error : ".$e->getMessage(); |
854 | 854 | } |
855 | 855 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
856 | 856 | return $all; |
857 | 857 | } |
858 | - public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
|
858 | + public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') { |
|
859 | 859 | if ($filter_name == '') $filter_name = $this->filter_name; |
860 | 860 | global $globalArchiveMonths, $globalDBdriver; |
861 | 861 | if ($globalDBdriver == 'mysql') { |
862 | 862 | if ($month == '') { |
863 | 863 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
864 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
864 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
865 | 865 | } else { |
866 | 866 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
867 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
867 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
868 | 868 | } |
869 | 869 | } else { |
870 | 870 | if ($month == '') { |
871 | 871 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
872 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
872 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
873 | 873 | } else { |
874 | 874 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
875 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month); |
|
875 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month); |
|
876 | 876 | } |
877 | 877 | } |
878 | 878 | try { |
879 | 879 | $sth = $this->db->prepare($query); |
880 | 880 | $sth->execute($query_values); |
881 | - } catch(PDOException $e) { |
|
881 | + } catch (PDOException $e) { |
|
882 | 882 | echo "error : ".$e->getMessage(); |
883 | 883 | } |
884 | 884 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | try { |
897 | 897 | $sth = $this->db->prepare($query); |
898 | 898 | $sth->execute($query_values); |
899 | - } catch(PDOException $e) { |
|
899 | + } catch (PDOException $e) { |
|
900 | 900 | echo "error : ".$e->getMessage(); |
901 | 901 | } |
902 | 902 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | try { |
914 | 914 | $sth = $this->db->prepare($query); |
915 | 915 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
916 | - } catch(PDOException $e) { |
|
916 | + } catch (PDOException $e) { |
|
917 | 917 | echo "error : ".$e->getMessage(); |
918 | 918 | } |
919 | 919 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | try { |
931 | 931 | $sth = $this->db->prepare($query); |
932 | 932 | $sth->execute(array(':filter_name' => $filter_name)); |
933 | - } catch(PDOException $e) { |
|
933 | + } catch (PDOException $e) { |
|
934 | 934 | echo "error : ".$e->getMessage(); |
935 | 935 | } |
936 | 936 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | try { |
948 | 948 | $sth = $this->db->prepare($query); |
949 | 949 | $sth->execute(array(':filter_name' => $filter_name)); |
950 | - } catch(PDOException $e) { |
|
950 | + } catch (PDOException $e) { |
|
951 | 951 | echo "error : ".$e->getMessage(); |
952 | 952 | } |
953 | 953 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -964,14 +964,14 @@ discard block |
||
964 | 964 | try { |
965 | 965 | $sth = $this->db->prepare($query); |
966 | 966 | $sth->execute(array(':filter_name' => $filter_name)); |
967 | - } catch(PDOException $e) { |
|
967 | + } catch (PDOException $e) { |
|
968 | 968 | echo "error : ".$e->getMessage(); |
969 | 969 | } |
970 | 970 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
971 | 971 | return $all[0]['total']; |
972 | 972 | } |
973 | 973 | |
974 | - public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
974 | + public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
975 | 975 | global $globalDBdriver; |
976 | 976 | if ($filter_name == '') $filter_name = $this->filter_name; |
977 | 977 | if ($globalDBdriver == 'mysql') { |
@@ -979,15 +979,15 @@ discard block |
||
979 | 979 | } else { |
980 | 980 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
981 | 981 | } |
982 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
982 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
983 | 983 | try { |
984 | 984 | $sth = $this->db->prepare($query); |
985 | 985 | $sth->execute($query_values); |
986 | - } catch(PDOException $e) { |
|
986 | + } catch (PDOException $e) { |
|
987 | 987 | return "error : ".$e->getMessage(); |
988 | 988 | } |
989 | 989 | } |
990 | - public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
|
990 | + public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') { |
|
991 | 991 | global $globalDBdriver; |
992 | 992 | if ($filter_name == '') $filter_name = $this->filter_name; |
993 | 993 | if ($globalDBdriver == 'mysql') { |
@@ -996,11 +996,11 @@ discard block |
||
996 | 996 | //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
997 | 997 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
998 | 998 | } |
999 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
999 | + $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1000 | 1000 | try { |
1001 | 1001 | $sth = $this->db->prepare($query); |
1002 | 1002 | $sth->execute($query_values); |
1003 | - } catch(PDOException $e) { |
|
1003 | + } catch (PDOException $e) { |
|
1004 | 1004 | return "error : ".$e->getMessage(); |
1005 | 1005 | } |
1006 | 1006 | } |
@@ -1024,75 +1024,75 @@ discard block |
||
1024 | 1024 | } |
1025 | 1025 | */ |
1026 | 1026 | |
1027 | - public function getStatsSource($stats_type,$year = '',$month = '',$day = '') { |
|
1027 | + public function getStatsSource($stats_type, $year = '', $month = '', $day = '') { |
|
1028 | 1028 | global $globalDBdriver; |
1029 | 1029 | $query = "SELECT * FROM stats_source WHERE stats_type = :stats_type"; |
1030 | 1030 | $query_values = array(); |
1031 | 1031 | if ($globalDBdriver == 'mysql') { |
1032 | 1032 | if ($year != '') { |
1033 | 1033 | $query .= ' AND YEAR(stats_date) = :year'; |
1034 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1034 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1035 | 1035 | } |
1036 | 1036 | if ($month != '') { |
1037 | 1037 | $query .= ' AND MONTH(stats_date) = :month'; |
1038 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1038 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1039 | 1039 | } |
1040 | 1040 | if ($day != '') { |
1041 | 1041 | $query .= ' AND DAY(stats_date) = :day'; |
1042 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1042 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1043 | 1043 | } |
1044 | 1044 | } else { |
1045 | 1045 | if ($year != '') { |
1046 | 1046 | $query .= ' AND EXTRACT(YEAR FROM stats_date) = :year'; |
1047 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1047 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1048 | 1048 | } |
1049 | 1049 | if ($month != '') { |
1050 | 1050 | $query .= ' AND EXTRACT(MONTH FROM stats_date) = :month'; |
1051 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1051 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1052 | 1052 | } |
1053 | 1053 | if ($day != '') { |
1054 | 1054 | $query .= ' AND EXTRACT(DAY FROM stats_date) = :day'; |
1055 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1055 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1056 | 1056 | } |
1057 | 1057 | } |
1058 | 1058 | $query .= " ORDER BY source_name"; |
1059 | - $query_values = array_merge($query_values,array(':stats_type' => $stats_type)); |
|
1059 | + $query_values = array_merge($query_values, array(':stats_type' => $stats_type)); |
|
1060 | 1060 | try { |
1061 | 1061 | $sth = $this->db->prepare($query); |
1062 | 1062 | $sth->execute($query_values); |
1063 | - } catch(PDOException $e) { |
|
1063 | + } catch (PDOException $e) { |
|
1064 | 1064 | echo "error : ".$e->getMessage(); |
1065 | 1065 | } |
1066 | 1066 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
1067 | 1067 | return $all; |
1068 | 1068 | } |
1069 | 1069 | |
1070 | - public function addStatSource($data,$source_name,$stats_type,$date) { |
|
1070 | + public function addStatSource($data, $source_name, $stats_type, $date) { |
|
1071 | 1071 | global $globalDBdriver; |
1072 | 1072 | if ($globalDBdriver == 'mysql') { |
1073 | 1073 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
1074 | 1074 | } else { |
1075 | 1075 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
1076 | 1076 | } |
1077 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
1077 | + $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type); |
|
1078 | 1078 | try { |
1079 | 1079 | $sth = $this->db->prepare($query); |
1080 | 1080 | $sth->execute($query_values); |
1081 | - } catch(PDOException $e) { |
|
1081 | + } catch (PDOException $e) { |
|
1082 | 1082 | return "error : ".$e->getMessage(); |
1083 | 1083 | } |
1084 | 1084 | } |
1085 | - public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
|
1085 | + public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') { |
|
1086 | 1086 | $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
1087 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1087 | + $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1088 | 1088 | try { |
1089 | 1089 | $sth = $this->db->prepare($query); |
1090 | 1090 | $sth->execute($query_values); |
1091 | - } catch(PDOException $e) { |
|
1091 | + } catch (PDOException $e) { |
|
1092 | 1092 | return "error : ".$e->getMessage(); |
1093 | 1093 | } |
1094 | 1094 | } |
1095 | - public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) { |
|
1095 | + public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
1096 | 1096 | global $globalDBdriver; |
1097 | 1097 | if ($globalDBdriver == 'mysql') { |
1098 | 1098 | if ($reset) { |
@@ -1107,15 +1107,15 @@ discard block |
||
1107 | 1107 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1108 | 1108 | } |
1109 | 1109 | } |
1110 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1110 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1111 | 1111 | try { |
1112 | 1112 | $sth = $this->db->prepare($query); |
1113 | 1113 | $sth->execute($query_values); |
1114 | - } catch(PDOException $e) { |
|
1114 | + } catch (PDOException $e) { |
|
1115 | 1115 | return "error : ".$e->getMessage(); |
1116 | 1116 | } |
1117 | 1117 | } |
1118 | - public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) { |
|
1118 | + public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1119 | 1119 | global $globalDBdriver; |
1120 | 1120 | if ($globalDBdriver == 'mysql') { |
1121 | 1121 | if ($reset) { |
@@ -1130,15 +1130,15 @@ discard block |
||
1130 | 1130 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
1131 | 1131 | } |
1132 | 1132 | } |
1133 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1133 | + $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1134 | 1134 | try { |
1135 | 1135 | $sth = $this->db->prepare($query); |
1136 | 1136 | $sth->execute($query_values); |
1137 | - } catch(PDOException $e) { |
|
1137 | + } catch (PDOException $e) { |
|
1138 | 1138 | return "error : ".$e->getMessage(); |
1139 | 1139 | } |
1140 | 1140 | } |
1141 | - public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) { |
|
1141 | + public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1142 | 1142 | global $globalDBdriver; |
1143 | 1143 | if ($globalDBdriver == 'mysql') { |
1144 | 1144 | if ($reset) { |
@@ -1153,15 +1153,15 @@ discard block |
||
1153 | 1153 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; |
1154 | 1154 | } |
1155 | 1155 | } |
1156 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao); |
|
1156 | + $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao); |
|
1157 | 1157 | try { |
1158 | 1158 | $sth = $this->db->prepare($query); |
1159 | 1159 | $sth->execute($query_values); |
1160 | - } catch(PDOException $e) { |
|
1160 | + } catch (PDOException $e) { |
|
1161 | 1161 | return "error : ".$e->getMessage(); |
1162 | 1162 | } |
1163 | 1163 | } |
1164 | - public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
1164 | + public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) { |
|
1165 | 1165 | global $globalDBdriver; |
1166 | 1166 | if ($globalDBdriver == 'mysql') { |
1167 | 1167 | if ($reset) { |
@@ -1176,15 +1176,15 @@ discard block |
||
1176 | 1176 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1177 | 1177 | } |
1178 | 1178 | } |
1179 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1179 | + $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1180 | 1180 | try { |
1181 | 1181 | $sth = $this->db->prepare($query); |
1182 | 1182 | $sth->execute($query_values); |
1183 | - } catch(PDOException $e) { |
|
1183 | + } catch (PDOException $e) { |
|
1184 | 1184 | return "error : ".$e->getMessage(); |
1185 | 1185 | } |
1186 | 1186 | } |
1187 | - public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) { |
|
1187 | + public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) { |
|
1188 | 1188 | global $globalDBdriver; |
1189 | 1189 | if ($globalDBdriver == 'mysql') { |
1190 | 1190 | if ($reset) { |
@@ -1199,15 +1199,15 @@ discard block |
||
1199 | 1199 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
1200 | 1200 | } |
1201 | 1201 | } |
1202 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
1202 | + $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name); |
|
1203 | 1203 | try { |
1204 | 1204 | $sth = $this->db->prepare($query); |
1205 | 1205 | $sth->execute($query_values); |
1206 | - } catch(PDOException $e) { |
|
1206 | + } catch (PDOException $e) { |
|
1207 | 1207 | return "error : ".$e->getMessage(); |
1208 | 1208 | } |
1209 | 1209 | } |
1210 | - public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) { |
|
1210 | + public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) { |
|
1211 | 1211 | global $globalDBdriver; |
1212 | 1212 | if ($globalDBdriver == 'mysql') { |
1213 | 1213 | if ($reset) { |
@@ -1222,15 +1222,15 @@ discard block |
||
1222 | 1222 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1223 | 1223 | } |
1224 | 1224 | } |
1225 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1225 | + $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
1226 | 1226 | try { |
1227 | 1227 | $sth = $this->db->prepare($query); |
1228 | 1228 | $sth->execute($query_values); |
1229 | - } catch(PDOException $e) { |
|
1229 | + } catch (PDOException $e) { |
|
1230 | 1230 | return "error : ".$e->getMessage(); |
1231 | 1231 | } |
1232 | 1232 | } |
1233 | - public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) { |
|
1233 | + public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) { |
|
1234 | 1234 | global $globalDBdriver; |
1235 | 1235 | if ($globalDBdriver == 'mysql') { |
1236 | 1236 | if ($reset) { |
@@ -1245,15 +1245,15 @@ discard block |
||
1245 | 1245 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; |
1246 | 1246 | } |
1247 | 1247 | } |
1248 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source); |
|
1248 | + $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source); |
|
1249 | 1249 | try { |
1250 | 1250 | $sth = $this->db->prepare($query); |
1251 | 1251 | $sth->execute($query_values); |
1252 | - } catch(PDOException $e) { |
|
1252 | + } catch (PDOException $e) { |
|
1253 | 1253 | return "error : ".$e->getMessage(); |
1254 | 1254 | } |
1255 | 1255 | } |
1256 | - public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) { |
|
1256 | + public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1257 | 1257 | global $globalDBdriver; |
1258 | 1258 | if ($airport_icao != '') { |
1259 | 1259 | if ($globalDBdriver == 'mysql') { |
@@ -1269,16 +1269,16 @@ discard block |
||
1269 | 1269 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1270 | 1270 | } |
1271 | 1271 | } |
1272 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1272 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1273 | 1273 | try { |
1274 | 1274 | $sth = $this->db->prepare($query); |
1275 | 1275 | $sth->execute($query_values); |
1276 | - } catch(PDOException $e) { |
|
1276 | + } catch (PDOException $e) { |
|
1277 | 1277 | return "error : ".$e->getMessage(); |
1278 | 1278 | } |
1279 | 1279 | } |
1280 | 1280 | } |
1281 | - public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
|
1281 | + public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') { |
|
1282 | 1282 | global $globalDBdriver; |
1283 | 1283 | if ($airport_icao != '') { |
1284 | 1284 | if ($globalDBdriver == 'mysql') { |
@@ -1286,16 +1286,16 @@ discard block |
||
1286 | 1286 | } else { |
1287 | 1287 | $query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1288 | 1288 | } |
1289 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1289 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1290 | 1290 | try { |
1291 | 1291 | $sth = $this->db->prepare($query); |
1292 | 1292 | $sth->execute($query_values); |
1293 | - } catch(PDOException $e) { |
|
1293 | + } catch (PDOException $e) { |
|
1294 | 1294 | return "error : ".$e->getMessage(); |
1295 | 1295 | } |
1296 | 1296 | } |
1297 | 1297 | } |
1298 | - public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) { |
|
1298 | + public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) { |
|
1299 | 1299 | global $globalDBdriver; |
1300 | 1300 | if ($airport_icao != '') { |
1301 | 1301 | if ($globalDBdriver == 'mysql') { |
@@ -1311,16 +1311,16 @@ discard block |
||
1311 | 1311 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1312 | 1312 | } |
1313 | 1313 | } |
1314 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1314 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1315 | 1315 | try { |
1316 | 1316 | $sth = $this->db->prepare($query); |
1317 | 1317 | $sth->execute($query_values); |
1318 | - } catch(PDOException $e) { |
|
1318 | + } catch (PDOException $e) { |
|
1319 | 1319 | return "error : ".$e->getMessage(); |
1320 | 1320 | } |
1321 | 1321 | } |
1322 | 1322 | } |
1323 | - public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
|
1323 | + public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') { |
|
1324 | 1324 | global $globalDBdriver; |
1325 | 1325 | if ($airport_icao != '') { |
1326 | 1326 | if ($globalDBdriver == 'mysql') { |
@@ -1328,11 +1328,11 @@ discard block |
||
1328 | 1328 | } else { |
1329 | 1329 | $query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1330 | 1330 | } |
1331 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1331 | + $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
1332 | 1332 | try { |
1333 | 1333 | $sth = $this->db->prepare($query); |
1334 | 1334 | $sth->execute($query_values); |
1335 | - } catch(PDOException $e) { |
|
1335 | + } catch (PDOException $e) { |
|
1336 | 1336 | return "error : ".$e->getMessage(); |
1337 | 1337 | } |
1338 | 1338 | } |
@@ -1344,7 +1344,7 @@ discard block |
||
1344 | 1344 | try { |
1345 | 1345 | $sth = $this->db->prepare($query); |
1346 | 1346 | $sth->execute($query_values); |
1347 | - } catch(PDOException $e) { |
|
1347 | + } catch (PDOException $e) { |
|
1348 | 1348 | return "error : ".$e->getMessage(); |
1349 | 1349 | } |
1350 | 1350 | } |
@@ -1354,7 +1354,7 @@ discard block |
||
1354 | 1354 | try { |
1355 | 1355 | $sth = $this->db->prepare($query); |
1356 | 1356 | $sth->execute($query_values); |
1357 | - } catch(PDOException $e) { |
|
1357 | + } catch (PDOException $e) { |
|
1358 | 1358 | return "error : ".$e->getMessage(); |
1359 | 1359 | } |
1360 | 1360 | } |
@@ -1364,13 +1364,13 @@ discard block |
||
1364 | 1364 | try { |
1365 | 1365 | $sth = $this->db->prepare($query); |
1366 | 1366 | $sth->execute($query_values); |
1367 | - } catch(PDOException $e) { |
|
1367 | + } catch (PDOException $e) { |
|
1368 | 1368 | return "error : ".$e->getMessage(); |
1369 | 1369 | } |
1370 | 1370 | } |
1371 | 1371 | |
1372 | 1372 | public function addOldStats() { |
1373 | - global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear; |
|
1373 | + global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear; |
|
1374 | 1374 | $Common = new Common(); |
1375 | 1375 | $Connection = new Connection(); |
1376 | 1376 | date_default_timezone_set('UTC'); |
@@ -1387,40 +1387,40 @@ discard block |
||
1387 | 1387 | $Spotter = new Spotter($this->db); |
1388 | 1388 | |
1389 | 1389 | if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
1390 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
|
1390 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day); |
|
1391 | 1391 | foreach ($alldata as $number) { |
1392 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
|
1392 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset); |
|
1393 | 1393 | } |
1394 | 1394 | if ($globalDebug) echo 'Count all airlines...'."\n"; |
1395 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
|
1395 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day); |
|
1396 | 1396 | foreach ($alldata as $number) { |
1397 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
|
1397 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset); |
|
1398 | 1398 | } |
1399 | 1399 | if ($globalDebug) echo 'Count all registrations...'."\n"; |
1400 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
|
1400 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day); |
|
1401 | 1401 | foreach ($alldata as $number) { |
1402 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
|
1402 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset); |
|
1403 | 1403 | } |
1404 | 1404 | if ($globalDebug) echo 'Count all callsigns...'."\n"; |
1405 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
|
1405 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day); |
|
1406 | 1406 | foreach ($alldata as $number) { |
1407 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
1407 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
1408 | 1408 | } |
1409 | 1409 | if ($globalDebug) echo 'Count all owners...'."\n"; |
1410 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
|
1410 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day); |
|
1411 | 1411 | foreach ($alldata as $number) { |
1412 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
|
1412 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset); |
|
1413 | 1413 | } |
1414 | 1414 | if ($globalDebug) echo 'Count all pilots...'."\n"; |
1415 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
|
1415 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day); |
|
1416 | 1416 | foreach ($alldata as $number) { |
1417 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
|
1417 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset); |
|
1418 | 1418 | } |
1419 | 1419 | |
1420 | 1420 | if ($globalDebug) echo 'Count all departure airports...'."\n"; |
1421 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
|
1421 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day); |
|
1422 | 1422 | if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
1423 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1423 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day); |
|
1424 | 1424 | if ($globalDebug) echo 'Order departure airports...'."\n"; |
1425 | 1425 | $alldata = array(); |
1426 | 1426 | |
@@ -1438,14 +1438,14 @@ discard block |
||
1438 | 1438 | foreach ($alldata as $key => $row) { |
1439 | 1439 | $count[$key] = $row['airport_departure_icao_count']; |
1440 | 1440 | } |
1441 | - array_multisort($count,SORT_DESC,$alldata); |
|
1441 | + array_multisort($count, SORT_DESC, $alldata); |
|
1442 | 1442 | foreach ($alldata as $number) { |
1443 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
|
1443 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset); |
|
1444 | 1444 | } |
1445 | 1445 | if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
1446 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
|
1446 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day); |
|
1447 | 1447 | if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
1448 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1448 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day); |
|
1449 | 1449 | if ($globalDebug) echo 'Order arrival airports...'."\n"; |
1450 | 1450 | $alldata = array(); |
1451 | 1451 | foreach ($pall as $value) { |
@@ -1462,16 +1462,16 @@ discard block |
||
1462 | 1462 | foreach ($alldata as $key => $row) { |
1463 | 1463 | $count[$key] = $row['airport_arrival_icao_count']; |
1464 | 1464 | } |
1465 | - array_multisort($count,SORT_DESC,$alldata); |
|
1465 | + array_multisort($count, SORT_DESC, $alldata); |
|
1466 | 1466 | foreach ($alldata as $number) { |
1467 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
|
1467 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset); |
|
1468 | 1468 | } |
1469 | 1469 | if ($Connection->tableExists('countries')) { |
1470 | 1470 | if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
1471 | 1471 | $SpotterArchive = new SpotterArchive(); |
1472 | - $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
|
1472 | + $alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day); |
|
1473 | 1473 | foreach ($alldata as $number) { |
1474 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset); |
|
1474 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset); |
|
1475 | 1475 | } |
1476 | 1476 | } |
1477 | 1477 | |
@@ -1485,37 +1485,37 @@ discard block |
||
1485 | 1485 | $lastyear = false; |
1486 | 1486 | foreach ($alldata as $number) { |
1487 | 1487 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1488 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
1488 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
1489 | 1489 | } |
1490 | 1490 | if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
1491 | 1491 | $alldata = $Spotter->countAllMilitaryMonths(); |
1492 | 1492 | foreach ($alldata as $number) { |
1493 | - $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
1493 | + $this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
1494 | 1494 | } |
1495 | 1495 | if ($globalDebug) echo 'Count all owners by months...'."\n"; |
1496 | 1496 | $alldata = $Spotter->countAllMonthsOwners(); |
1497 | 1497 | foreach ($alldata as $number) { |
1498 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
1498 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
1499 | 1499 | } |
1500 | 1500 | if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
1501 | 1501 | $alldata = $Spotter->countAllMonthsPilots(); |
1502 | 1502 | foreach ($alldata as $number) { |
1503 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
1503 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
1504 | 1504 | } |
1505 | 1505 | if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
1506 | 1506 | $alldata = $Spotter->countAllMonthsAirlines(); |
1507 | 1507 | foreach ($alldata as $number) { |
1508 | - $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
1508 | + $this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
1509 | 1509 | } |
1510 | 1510 | if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
1511 | 1511 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1512 | 1512 | foreach ($alldata as $number) { |
1513 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
1513 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
1514 | 1514 | } |
1515 | 1515 | if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
1516 | 1516 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1517 | 1517 | foreach ($alldata as $number) { |
1518 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
|
1518 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name']))); |
|
1519 | 1519 | } |
1520 | 1520 | if ($globalDebug) echo 'Airports data...'."\n"; |
1521 | 1521 | if ($globalDebug) echo '...Departure'."\n"; |
@@ -1560,7 +1560,7 @@ discard block |
||
1560 | 1560 | } |
1561 | 1561 | $alldata = $pall; |
1562 | 1562 | foreach ($alldata as $number) { |
1563 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
|
1563 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']); |
|
1564 | 1564 | } |
1565 | 1565 | echo '...Arrival'."\n"; |
1566 | 1566 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
@@ -1602,7 +1602,7 @@ discard block |
||
1602 | 1602 | } |
1603 | 1603 | $alldata = $pall; |
1604 | 1604 | foreach ($alldata as $number) { |
1605 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
|
1605 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']); |
|
1606 | 1606 | } |
1607 | 1607 | |
1608 | 1608 | echo 'Flights data...'."\n"; |
@@ -1610,28 +1610,28 @@ discard block |
||
1610 | 1610 | echo '-> countAllDatesLastMonth...'."\n"; |
1611 | 1611 | $alldata = $Spotter->countAllDatesLastMonth(); |
1612 | 1612 | foreach ($alldata as $number) { |
1613 | - $this->addStatFlight('month',$number['date_name'],$number['date_count']); |
|
1613 | + $this->addStatFlight('month', $number['date_name'], $number['date_count']); |
|
1614 | 1614 | } |
1615 | 1615 | echo '-> countAllDates...'."\n"; |
1616 | 1616 | $previousdata = $this->countAllDates(); |
1617 | 1617 | $previousdatabyairlines = $this->countAllDatesByAirlines(); |
1618 | 1618 | $this->deleteStatFlight('date'); |
1619 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates()); |
|
1619 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates()); |
|
1620 | 1620 | $values = array(); |
1621 | 1621 | foreach ($alldata as $cnt) { |
1622 | 1622 | $values[] = $cnt['date_count']; |
1623 | 1623 | } |
1624 | - array_multisort($values,SORT_DESC,$alldata); |
|
1625 | - array_splice($alldata,11); |
|
1624 | + array_multisort($values, SORT_DESC, $alldata); |
|
1625 | + array_splice($alldata, 11); |
|
1626 | 1626 | foreach ($alldata as $number) { |
1627 | - $this->addStatFlight('date',$number['date_name'],$number['date_count']); |
|
1627 | + $this->addStatFlight('date', $number['date_name'], $number['date_count']); |
|
1628 | 1628 | } |
1629 | 1629 | |
1630 | 1630 | $this->deleteStatFlight('hour'); |
1631 | 1631 | echo '-> countAllHours...'."\n"; |
1632 | 1632 | $alldata = $Spotter->countAllHours('hour'); |
1633 | 1633 | foreach ($alldata as $number) { |
1634 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count']); |
|
1634 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count']); |
|
1635 | 1635 | } |
1636 | 1636 | |
1637 | 1637 | |
@@ -1641,41 +1641,41 @@ discard block |
||
1641 | 1641 | if ($Connection->tableExists('countries')) { |
1642 | 1642 | if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
1643 | 1643 | $SpotterArchive = new SpotterArchive(); |
1644 | - $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
|
1644 | + $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day); |
|
1645 | 1645 | foreach ($alldata as $number) { |
1646 | - $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
|
1646 | + $this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset); |
|
1647 | 1647 | } |
1648 | 1648 | } |
1649 | 1649 | if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
1650 | 1650 | $Spotter = new Spotter($this->db); |
1651 | - $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
|
1651 | + $alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day); |
|
1652 | 1652 | foreach ($alldata as $number) { |
1653 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
|
1653 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset); |
|
1654 | 1654 | } |
1655 | 1655 | if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
1656 | - $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
|
1656 | + $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day); |
|
1657 | 1657 | foreach ($alldata as $number) { |
1658 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
|
1658 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset); |
|
1659 | 1659 | } |
1660 | 1660 | if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
1661 | - $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
|
1661 | + $alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day); |
|
1662 | 1662 | foreach ($alldata as $number) { |
1663 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
|
1663 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset); |
|
1664 | 1664 | } |
1665 | 1665 | if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
1666 | - $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
|
1666 | + $alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day); |
|
1667 | 1667 | foreach ($alldata as $number) { |
1668 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
|
1668 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset); |
|
1669 | 1669 | } |
1670 | 1670 | if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
1671 | - $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
|
1671 | + $alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day); |
|
1672 | 1672 | foreach ($alldata as $number) { |
1673 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
|
1673 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset); |
|
1674 | 1674 | } |
1675 | 1675 | if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
1676 | - $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1676 | + $pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
1677 | 1677 | if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
1678 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1678 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day); |
|
1679 | 1679 | if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
1680 | 1680 | //$alldata = array(); |
1681 | 1681 | foreach ($dall as $value) { |
@@ -1695,12 +1695,12 @@ discard block |
||
1695 | 1695 | } |
1696 | 1696 | $alldata = $pall; |
1697 | 1697 | foreach ($alldata as $number) { |
1698 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
|
1698 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], $number['airline_icao'], '', $reset); |
|
1699 | 1699 | } |
1700 | 1700 | if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
1701 | - $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1701 | + $pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
1702 | 1702 | if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
1703 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1703 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day); |
|
1704 | 1704 | if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
1705 | 1705 | //$alldata = array(); |
1706 | 1706 | foreach ($dall as $value) { |
@@ -1720,7 +1720,7 @@ discard block |
||
1720 | 1720 | } |
1721 | 1721 | $alldata = $pall; |
1722 | 1722 | foreach ($alldata as $number) { |
1723 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
1723 | + if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], $number['airline_icao'], '', $reset); |
|
1724 | 1724 | } |
1725 | 1725 | if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
1726 | 1726 | $Spotter = new Spotter($this->db); |
@@ -1728,27 +1728,27 @@ discard block |
||
1728 | 1728 | $lastyear = false; |
1729 | 1729 | foreach ($alldata as $number) { |
1730 | 1730 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1731 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
1731 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
1732 | 1732 | } |
1733 | 1733 | if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
1734 | 1734 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1735 | 1735 | foreach ($alldata as $number) { |
1736 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
1736 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
1737 | 1737 | } |
1738 | 1738 | if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
1739 | 1739 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1740 | 1740 | foreach ($alldata as $number) { |
1741 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
1741 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
1742 | 1742 | } |
1743 | 1743 | if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
1744 | 1744 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1745 | 1745 | foreach ($alldata as $number) { |
1746 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
1746 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
1747 | 1747 | } |
1748 | 1748 | if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
1749 | 1749 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1750 | 1750 | foreach ($alldata as $number) { |
1751 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
|
1751 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']); |
|
1752 | 1752 | } |
1753 | 1753 | if ($globalDebug) echo '...Departure'."\n"; |
1754 | 1754 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
@@ -1771,7 +1771,7 @@ discard block |
||
1771 | 1771 | } |
1772 | 1772 | $alldata = $pall; |
1773 | 1773 | foreach ($alldata as $number) { |
1774 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
|
1774 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], $number['airline_icao']); |
|
1775 | 1775 | } |
1776 | 1776 | if ($globalDebug) echo '...Arrival'."\n"; |
1777 | 1777 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
@@ -1794,32 +1794,32 @@ discard block |
||
1794 | 1794 | } |
1795 | 1795 | $alldata = $pall; |
1796 | 1796 | foreach ($alldata as $number) { |
1797 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
|
1797 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], $number['airline_icao']); |
|
1798 | 1798 | } |
1799 | 1799 | |
1800 | 1800 | if ($globalDebug) echo 'Flights data...'."\n"; |
1801 | 1801 | if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
1802 | 1802 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1803 | 1803 | foreach ($alldata as $number) { |
1804 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
|
1804 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
1805 | 1805 | } |
1806 | 1806 | if ($globalDebug) echo '-> countAllDates...'."\n"; |
1807 | 1807 | //$previousdata = $this->countAllDatesByAirlines(); |
1808 | - $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
|
1808 | + $alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines()); |
|
1809 | 1809 | $values = array(); |
1810 | 1810 | foreach ($alldata as $cnt) { |
1811 | 1811 | $values[] = $cnt['date_count']; |
1812 | 1812 | } |
1813 | - array_multisort($values,SORT_DESC,$alldata); |
|
1814 | - array_splice($alldata,11); |
|
1813 | + array_multisort($values, SORT_DESC, $alldata); |
|
1814 | + array_splice($alldata, 11); |
|
1815 | 1815 | foreach ($alldata as $number) { |
1816 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
|
1816 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']); |
|
1817 | 1817 | } |
1818 | 1818 | |
1819 | 1819 | if ($globalDebug) echo '-> countAllHours...'."\n"; |
1820 | 1820 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1821 | 1821 | foreach ($alldata as $number) { |
1822 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
|
1822 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']); |
|
1823 | 1823 | } |
1824 | 1824 | |
1825 | 1825 | |
@@ -1838,32 +1838,32 @@ discard block |
||
1838 | 1838 | // Count by filter |
1839 | 1839 | if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
1840 | 1840 | $Spotter = new Spotter($this->db); |
1841 | - $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
|
1841 | + $alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter); |
|
1842 | 1842 | foreach ($alldata as $number) { |
1843 | - $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset); |
|
1843 | + $this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset); |
|
1844 | 1844 | } |
1845 | - $alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter); |
|
1845 | + $alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter); |
|
1846 | 1846 | foreach ($alldata as $number) { |
1847 | - $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset); |
|
1847 | + $this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset); |
|
1848 | 1848 | } |
1849 | - $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter); |
|
1849 | + $alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter); |
|
1850 | 1850 | foreach ($alldata as $number) { |
1851 | - $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset); |
|
1851 | + $this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset); |
|
1852 | 1852 | } |
1853 | - $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter); |
|
1853 | + $alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter); |
|
1854 | 1854 | foreach ($alldata as $number) { |
1855 | - $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset); |
|
1855 | + $this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset); |
|
1856 | 1856 | } |
1857 | - $alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter); |
|
1857 | + $alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter); |
|
1858 | 1858 | foreach ($alldata as $number) { |
1859 | - $this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset); |
|
1859 | + $this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset); |
|
1860 | 1860 | } |
1861 | - $alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter); |
|
1861 | + $alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter); |
|
1862 | 1862 | foreach ($alldata as $number) { |
1863 | - $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset); |
|
1863 | + $this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset); |
|
1864 | 1864 | } |
1865 | - $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
|
1866 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1865 | + $pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter); |
|
1866 | + $dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter); |
|
1867 | 1867 | $alldata = array(); |
1868 | 1868 | foreach ($pall as $value) { |
1869 | 1869 | $icao = $value['airport_departure_icao']; |
@@ -1879,12 +1879,12 @@ discard block |
||
1879 | 1879 | foreach ($alldata as $key => $row) { |
1880 | 1880 | $count[$key] = $row['airport_departure_icao_count']; |
1881 | 1881 | } |
1882 | - array_multisort($count,SORT_DESC,$alldata); |
|
1882 | + array_multisort($count, SORT_DESC, $alldata); |
|
1883 | 1883 | foreach ($alldata as $number) { |
1884 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset); |
|
1884 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', $filter_name, $reset); |
|
1885 | 1885 | } |
1886 | - $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter); |
|
1887 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter); |
|
1886 | + $pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
1887 | + $dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter); |
|
1888 | 1888 | $alldata = array(); |
1889 | 1889 | foreach ($pall as $value) { |
1890 | 1890 | $icao = $value['airport_arrival_icao']; |
@@ -1900,40 +1900,40 @@ discard block |
||
1900 | 1900 | foreach ($alldata as $key => $row) { |
1901 | 1901 | $count[$key] = $row['airport_arrival_icao_count']; |
1902 | 1902 | } |
1903 | - array_multisort($count,SORT_DESC,$alldata); |
|
1903 | + array_multisort($count, SORT_DESC, $alldata); |
|
1904 | 1904 | foreach ($alldata as $number) { |
1905 | - echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset); |
|
1905 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', $filter_name, $reset); |
|
1906 | 1906 | } |
1907 | 1907 | $Spotter = new Spotter($this->db); |
1908 | 1908 | $alldata = $Spotter->countAllMonths($filter); |
1909 | 1909 | $lastyear = false; |
1910 | 1910 | foreach ($alldata as $number) { |
1911 | 1911 | if ($number['year_name'] != date('Y')) $lastyear = true; |
1912 | - $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
1912 | + $this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
1913 | 1913 | } |
1914 | 1914 | $alldata = $Spotter->countAllMonthsOwners($filter); |
1915 | 1915 | foreach ($alldata as $number) { |
1916 | - $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
1916 | + $this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
1917 | 1917 | } |
1918 | 1918 | $alldata = $Spotter->countAllMonthsPilots($filter); |
1919 | 1919 | foreach ($alldata as $number) { |
1920 | - $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
1920 | + $this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
1921 | 1921 | } |
1922 | 1922 | $alldata = $Spotter->countAllMilitaryMonths($filter); |
1923 | 1923 | foreach ($alldata as $number) { |
1924 | - $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
1924 | + $this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
1925 | 1925 | } |
1926 | 1926 | $alldata = $Spotter->countAllMonthsAircrafts($filter); |
1927 | 1927 | foreach ($alldata as $number) { |
1928 | - $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
1928 | + $this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
1929 | 1929 | } |
1930 | 1930 | $alldata = $Spotter->countAllMonthsRealArrivals($filter); |
1931 | 1931 | foreach ($alldata as $number) { |
1932 | - $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
|
1932 | + $this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name); |
|
1933 | 1933 | } |
1934 | 1934 | echo '...Departure'."\n"; |
1935 | - $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
|
1936 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1935 | + $pall = $Spotter->getLast7DaysAirportsDeparture('', $filter); |
|
1936 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter); |
|
1937 | 1937 | foreach ($dall as $value) { |
1938 | 1938 | $icao = $value['departure_airport_icao']; |
1939 | 1939 | $ddate = $value['date']; |
@@ -1951,11 +1951,11 @@ discard block |
||
1951 | 1951 | } |
1952 | 1952 | $alldata = $pall; |
1953 | 1953 | foreach ($alldata as $number) { |
1954 | - $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
|
1954 | + $this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count'], '', $filter_name); |
|
1955 | 1955 | } |
1956 | 1956 | echo '...Arrival'."\n"; |
1957 | - $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
|
1958 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1957 | + $pall = $Spotter->getLast7DaysAirportsArrival('', $filter); |
|
1958 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter); |
|
1959 | 1959 | foreach ($dall as $value) { |
1960 | 1960 | $icao = $value['arrival_airport_icao']; |
1961 | 1961 | $ddate = $value['date']; |
@@ -1973,40 +1973,40 @@ discard block |
||
1973 | 1973 | } |
1974 | 1974 | $alldata = $pall; |
1975 | 1975 | foreach ($alldata as $number) { |
1976 | - $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
|
1976 | + $this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count'], '', $filter_name); |
|
1977 | 1977 | } |
1978 | 1978 | |
1979 | 1979 | echo 'Flights data...'."\n"; |
1980 | 1980 | echo '-> countAllDatesLastMonth...'."\n"; |
1981 | 1981 | $alldata = $Spotter->countAllDatesLastMonth($filter); |
1982 | 1982 | foreach ($alldata as $number) { |
1983 | - $this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name); |
|
1983 | + $this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name); |
|
1984 | 1984 | } |
1985 | 1985 | echo '-> countAllDates...'."\n"; |
1986 | - $previousdata = $this->countAllDates('',$filter_name); |
|
1987 | - $alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter)); |
|
1986 | + $previousdata = $this->countAllDates('', $filter_name); |
|
1987 | + $alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter)); |
|
1988 | 1988 | $values = array(); |
1989 | 1989 | foreach ($alldata as $cnt) { |
1990 | 1990 | $values[] = $cnt['date_count']; |
1991 | 1991 | } |
1992 | - array_multisort($values,SORT_DESC,$alldata); |
|
1993 | - array_splice($alldata,11); |
|
1992 | + array_multisort($values, SORT_DESC, $alldata); |
|
1993 | + array_splice($alldata, 11); |
|
1994 | 1994 | foreach ($alldata as $number) { |
1995 | - $this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name); |
|
1995 | + $this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name); |
|
1996 | 1996 | } |
1997 | 1997 | |
1998 | 1998 | echo '-> countAllHours...'."\n"; |
1999 | - $alldata = $Spotter->countAllHours('hour',$filter); |
|
1999 | + $alldata = $Spotter->countAllHours('hour', $filter); |
|
2000 | 2000 | foreach ($alldata as $number) { |
2001 | - $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name); |
|
2001 | + $this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name); |
|
2002 | 2002 | } |
2003 | 2003 | echo 'Insert last stats update date...'."\n"; |
2004 | 2004 | date_default_timezone_set('UTC'); |
2005 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s')); |
|
2005 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s')); |
|
2006 | 2006 | if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) { |
2007 | - if (date('Y',strtotime($last_update_day)) != date('Y')) { |
|
2007 | + if (date('Y', strtotime($last_update_day)) != date('Y')) { |
|
2008 | 2008 | $this->deleteOldStats($filter_name); |
2009 | - $this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00'); |
|
2009 | + $this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00'); |
|
2010 | 2010 | } |
2011 | 2011 | } |
2012 | 2012 | |
@@ -2019,16 +2019,16 @@ discard block |
||
2019 | 2019 | // SUM all previous month to put as year |
2020 | 2020 | $previous_year = date('Y'); |
2021 | 2021 | $previous_year--; |
2022 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2023 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2024 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2025 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00'); |
|
2022 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2023 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2024 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2025 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00'); |
|
2026 | 2026 | $allairlines = $this->getAllAirlineNames(); |
2027 | 2027 | foreach ($allairlines as $data) { |
2028 | - $this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2029 | - $this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2030 | - $this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2031 | - $this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']); |
|
2028 | + $this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2029 | + $this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2030 | + $this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2031 | + $this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']); |
|
2032 | 2032 | } |
2033 | 2033 | |
2034 | 2034 | if (isset($globalArchiveYear) && $globalArchiveYear) { |
@@ -2037,7 +2037,7 @@ discard block |
||
2037 | 2037 | try { |
2038 | 2038 | $sth = $this->db->prepare($query); |
2039 | 2039 | $sth->execute(); |
2040 | - } catch(PDOException $e) { |
|
2040 | + } catch (PDOException $e) { |
|
2041 | 2041 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
2042 | 2042 | } |
2043 | 2043 | } |
@@ -2046,15 +2046,15 @@ discard block |
||
2046 | 2046 | try { |
2047 | 2047 | $sth = $this->db->prepare($query); |
2048 | 2048 | $sth->execute(); |
2049 | - } catch(PDOException $e) { |
|
2049 | + } catch (PDOException $e) { |
|
2050 | 2050 | return "error : ".$e->getMessage().' - query : '.$query."\n"; |
2051 | 2051 | } |
2052 | 2052 | } |
2053 | 2053 | if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) { |
2054 | 2054 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
2055 | - if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) { |
|
2055 | + if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) { |
|
2056 | 2056 | $this->deleteOldStats(); |
2057 | - $this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00'); |
|
2057 | + $this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00'); |
|
2058 | 2058 | $lastyearupdate = true; |
2059 | 2059 | } |
2060 | 2060 | } |
@@ -2076,7 +2076,7 @@ discard block |
||
2076 | 2076 | try { |
2077 | 2077 | $sth = $this->db->prepare($query); |
2078 | 2078 | $sth->execute(); |
2079 | - } catch(PDOException $e) { |
|
2079 | + } catch (PDOException $e) { |
|
2080 | 2080 | return "error : ".$e->getMessage(); |
2081 | 2081 | } |
2082 | 2082 | } |
@@ -2090,14 +2090,14 @@ discard block |
||
2090 | 2090 | try { |
2091 | 2091 | $sth = $this->db->prepare($query); |
2092 | 2092 | $sth->execute(); |
2093 | - } catch(PDOException $e) { |
|
2093 | + } catch (PDOException $e) { |
|
2094 | 2094 | return "error : ".$e->getMessage(); |
2095 | 2095 | } |
2096 | 2096 | } |
2097 | 2097 | if (!isset($lastyearupdate)) { |
2098 | 2098 | echo 'Insert last stats update date...'."\n"; |
2099 | 2099 | date_default_timezone_set('UTC'); |
2100 | - $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
|
2100 | + $this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s')); |
|
2101 | 2101 | } |
2102 | 2102 | if ($globalStatsResetYear) { |
2103 | 2103 | require_once(dirname(__FILE__).'/../install/class.settings.php'); |