@@ -5,11 +5,15 @@ |
||
| 5 | 5 | $Stats = new Stats(); |
| 6 | 6 | $title = _("Statistics").' - '._("Most common Pilots"); |
| 7 | 7 | |
| 8 | -if (!isset($filter_name)) $filter_name = ''; |
|
| 8 | +if (!isset($filter_name)) { |
|
| 9 | + $filter_name = ''; |
|
| 10 | +} |
|
| 9 | 11 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 10 | 12 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 12 | -} |
|
| 13 | + if (isset($globalFilter['airline'])) { |
|
| 14 | + $airline_icao = $globalFilter['airline'][0]; |
|
| 15 | + } |
|
| 16 | + } |
|
| 13 | 17 | setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/'); |
| 14 | 18 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
| 15 | 19 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 12 | 12 | } |
| 13 | 13 | setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/'); |
| 14 | 14 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
@@ -6,13 +6,13 @@ discard block |
||
| 6 | 6 | $title = _("Statistics").' - '._("Most common Pilots"); |
| 7 | 7 | |
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
| 9 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | 11 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
| 12 | 12 | } |
| 13 | -setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/'); |
|
| 14 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
| 15 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
| 13 | +setcookie('stats_airline_icao', $airline_icao, time() + 60*60*24, '/'); |
|
| 14 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
| 15 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
| 16 | 16 | require_once('header.php'); |
| 17 | 17 | include('statistics-sub-menu.php'); |
| 18 | 18 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -22,10 +22,10 @@ discard block |
||
| 22 | 22 | </div> |
| 23 | 23 | <p>'._("Below are the <strong>Top 10</strong> most common pilot.").'</p>'; |
| 24 | 24 | |
| 25 | -$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month); |
|
| 25 | +$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month); |
|
| 26 | 26 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
| 27 | 27 | $pilot_data = ''; |
| 28 | -foreach($pilot_array as $pilot_item) |
|
| 28 | +foreach ($pilot_array as $pilot_item) |
|
| 29 | 29 | { |
| 30 | 30 | $pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],'; |
| 31 | 31 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | print '</thead>'; |
| 51 | 51 | print '<tbody>'; |
| 52 | 52 | $i = 1; |
| 53 | - foreach($pilot_array as $pilot_item) |
|
| 53 | + foreach ($pilot_array as $pilot_item) |
|
| 54 | 54 | { |
| 55 | 55 | print '<tr>'; |
| 56 | 56 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | require_once('header.php'); |
@@ -16,11 +16,15 @@ discard block |
||
| 16 | 16 | $Tracker = new Tracker(); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -if (!isset($filter_name)) $filter_name = ''; |
|
| 19 | +if (!isset($filter_name)) { |
|
| 20 | + $filter_name = ''; |
|
| 21 | +} |
|
| 20 | 22 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 21 | 23 | if ($airline_icao == '' && isset($globalFilter)) { |
| 22 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 23 | -} |
|
| 24 | + if (isset($globalFilter['airline'])) { |
|
| 25 | + $airline_icao = $globalFilter['airline'][0]; |
|
| 26 | + } |
|
| 27 | + } |
|
| 24 | 28 | |
| 25 | 29 | require_once('header.php'); |
| 26 | 30 | include('statistics-sub-menu.php'); |
@@ -33,9 +37,13 @@ discard block |
||
| 33 | 37 | </div> |
| 34 | 38 | <p>'._("Below is a list of the most common <strong>time of day</strong>.").'</p>'; |
| 35 | 39 | |
| 36 | -if ($type == 'aircraft') $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
|
| 37 | -elseif ($type == 'marine') $hour_array = $Marine->countAllHours('hour',true); |
|
| 38 | -elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('hour',true); |
|
| 40 | +if ($type == 'aircraft') { |
|
| 41 | + $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
|
| 42 | +} elseif ($type == 'marine') { |
|
| 43 | + $hour_array = $Marine->countAllHours('hour',true); |
|
| 44 | +} elseif ($type == 'tracker') { |
|
| 45 | + $hour_array = $Tracker->countAllHours('hour',true); |
|
| 46 | +} |
|
| 39 | 47 | print '<div id="chartHour" class="chart" width="100%"></div><script>'; |
| 40 | 48 | $hour_data = ''; |
| 41 | 49 | $hour_cnt = ''; |
@@ -53,9 +61,13 @@ discard block |
||
| 53 | 61 | axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});'; |
| 54 | 62 | print '</script>'; |
| 55 | 63 | |
| 56 | -if ($type == 'aircraft') $hour_array = $Stats->countAllHours('count',true,$airline_icao,$filter_name); |
|
| 57 | -elseif ($type == 'marine') $hour_array = $Marine->countAllHours('count',true); |
|
| 58 | -elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('count',true); |
|
| 64 | +if ($type == 'aircraft') { |
|
| 65 | + $hour_array = $Stats->countAllHours('count',true,$airline_icao,$filter_name); |
|
| 66 | +} elseif ($type == 'marine') { |
|
| 67 | + $hour_array = $Marine->countAllHours('count',true); |
|
| 68 | +} elseif ($type == 'tracker') { |
|
| 69 | + $hour_array = $Tracker->countAllHours('count',true); |
|
| 70 | +} |
|
| 59 | 71 | if (!empty($hour_array)) |
| 60 | 72 | { |
| 61 | 73 | print '<div class="table-responsive">'; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | if (!isset($filter_name)) $filter_name = ''; |
| 20 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
| 20 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
| 21 | 21 | if ($airline_icao == '' && isset($globalFilter)) { |
| 22 | 22 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
| 23 | 23 | } |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | </div> |
| 34 | 34 | <p>'._("Below is a list of the most common <strong>time of day</strong>.").'</p>'; |
| 35 | 35 | |
| 36 | -if ($type == 'aircraft') $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
|
| 37 | -elseif ($type == 'marine') $hour_array = $Marine->countAllHours('hour',true); |
|
| 38 | -elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('hour',true); |
|
| 36 | +if ($type == 'aircraft') $hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name); |
|
| 37 | +elseif ($type == 'marine') $hour_array = $Marine->countAllHours('hour', true); |
|
| 38 | +elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('hour', true); |
|
| 39 | 39 | print '<div id="chartHour" class="chart" width="100%"></div><script>'; |
| 40 | 40 | $hour_data = ''; |
| 41 | 41 | $hour_cnt = ''; |
| 42 | 42 | $last = 0; |
| 43 | -foreach($hour_array as $hour_item) |
|
| 43 | +foreach ($hour_array as $hour_item) |
|
| 44 | 44 | { |
| 45 | - while($last != $hour_item['hour_name']) { |
|
| 45 | + while ($last != $hour_item['hour_name']) { |
|
| 46 | 46 | $hour_data .= '"'.$last.':00",'; |
| 47 | 47 | $hour_cnt .= '0,'; |
| 48 | 48 | $last++; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $hour_cnt .= $hour_item['hour_count'].','; |
| 53 | 53 | } |
| 54 | 54 | $hour_data = "[".substr($hour_data, 0, -1)."]"; |
| 55 | -$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]"; |
|
| 55 | +$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]"; |
|
| 56 | 56 | print 'c3.generate({ |
| 57 | 57 | bindto: "#chartHour", |
| 58 | 58 | data: { |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});'; |
| 61 | 61 | print '</script>'; |
| 62 | 62 | |
| 63 | -if ($type == 'aircraft') $hour_array = $Stats->countAllHours('count',true,$airline_icao,$filter_name); |
|
| 64 | -elseif ($type == 'marine') $hour_array = $Marine->countAllHours('count',true); |
|
| 65 | -elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('count',true); |
|
| 63 | +if ($type == 'aircraft') $hour_array = $Stats->countAllHours('count', true, $airline_icao, $filter_name); |
|
| 64 | +elseif ($type == 'marine') $hour_array = $Marine->countAllHours('count', true); |
|
| 65 | +elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('count', true); |
|
| 66 | 66 | if (!empty($hour_array)) |
| 67 | 67 | { |
| 68 | 68 | print '<div class="table-responsive">'; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | print '</thead>'; |
| 75 | 75 | print '<tbody>'; |
| 76 | 76 | $i = 1; |
| 77 | - foreach($hour_array as $hour_item) |
|
| 77 | + foreach ($hour_array as $hour_item) |
|
| 78 | 78 | { |
| 79 | 79 | print '<tr>'; |
| 80 | 80 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | require_once('header.php'); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | if (!isset($filter_name)) $filter_name = ''; |
| 20 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
| 20 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
| 21 | 21 | if ($airline_icao == '' && isset($globalFilter)) { |
| 22 | 22 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
| 23 | 23 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | </div> |
| 34 | 34 | <p>'._("Below is a chart that plots the busiest day during the <strong>last 7 days</strong>.").'</p>'; |
| 35 | 35 | |
| 36 | -if ($type == 'aircraft') $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
|
| 36 | +if ($type == 'aircraft') $date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name); |
|
| 37 | 37 | elseif ($type == 'marine') $date_array = $Marine->countAllDatesLast7Days(); |
| 38 | 38 | elseif ($type == 'tracker') $date_array = $Tracker->countAllDatesLast7Days(); |
| 39 | 39 | if (count($date_array) == 0) { |
@@ -42,13 +42,13 @@ discard block |
||
| 42 | 42 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
| 43 | 43 | $date_data = ''; |
| 44 | 44 | $date_cnt = ''; |
| 45 | -foreach($date_array as $date_item) |
|
| 45 | +foreach ($date_array as $date_item) |
|
| 46 | 46 | { |
| 47 | 47 | $date_data .= '"'.$date_item['date_name'].'",'; |
| 48 | 48 | $date_cnt .= $date_item['date_count'].','; |
| 49 | 49 | } |
| 50 | 50 | $date_data = "['x',".substr($date_data, 0, -1)."]"; |
| 51 | -$date_cnt = "['flights',".substr($date_cnt,0,-1)."]"; |
|
| 51 | +$date_cnt = "['flights',".substr($date_cnt, 0, -1)."]"; |
|
| 52 | 52 | print 'c3.generate({ |
| 53 | 53 | bindto: "#chart", |
| 54 | 54 | data: { x: "x", |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | print '</script>'; |
| 58 | 58 | } |
| 59 | 59 | if (isset($globalDBArchiveMonths) && $globalDBArchiveMonths > 0) { |
| 60 | - print '<p>'.sprintf(_("Below are the <strong>Top 10</strong> most busiest dates of last %d month(s)."),$globalDBArchiveMonths).'</p>'; |
|
| 60 | + print '<p>'.sprintf(_("Below are the <strong>Top 10</strong> most busiest dates of last %d month(s)."), $globalDBArchiveMonths).'</p>'; |
|
| 61 | 61 | } else { |
| 62 | 62 | print '<p>'._("Below are the <strong>Top 10</strong> most busiest dates.").'</p>'; |
| 63 | 63 | } |
| 64 | -if ($type == 'aircraft') $date_array = $Stats->countAllDates($airline_icao,$filter_name); |
|
| 64 | +if ($type == 'aircraft') $date_array = $Stats->countAllDates($airline_icao, $filter_name); |
|
| 65 | 65 | elseif ($type == 'marine') $date_array = $Marine->countAllDates(); |
| 66 | 66 | elseif ($type == 'tracker') $date_array = $Tracker->countAllDates(); |
| 67 | 67 | if (!empty($date_array)) |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | print '</thead>'; |
| 76 | 76 | print '<tbody>'; |
| 77 | 77 | $i = 1; |
| 78 | - foreach($date_array as $date_item) |
|
| 78 | + foreach ($date_array as $date_item) |
|
| 79 | 79 | { |
| 80 | 80 | print '<tr>'; |
| 81 | 81 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -16,11 +16,15 @@ discard block |
||
| 16 | 16 | $Tracker = new Tracker(); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -if (!isset($filter_name)) $filter_name = ''; |
|
| 19 | +if (!isset($filter_name)) { |
|
| 20 | + $filter_name = ''; |
|
| 21 | +} |
|
| 20 | 22 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 21 | 23 | if ($airline_icao == '' && isset($globalFilter)) { |
| 22 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 23 | -} |
|
| 24 | + if (isset($globalFilter['airline'])) { |
|
| 25 | + $airline_icao = $globalFilter['airline'][0]; |
|
| 26 | + } |
|
| 27 | + } |
|
| 24 | 28 | |
| 25 | 29 | require_once('header.php'); |
| 26 | 30 | include('statistics-sub-menu.php'); |
@@ -33,9 +37,13 @@ discard block |
||
| 33 | 37 | </div> |
| 34 | 38 | <p>'._("Below is a chart that plots the busiest day during the <strong>last 7 days</strong>.").'</p>'; |
| 35 | 39 | |
| 36 | -if ($type == 'aircraft') $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
|
| 37 | -elseif ($type == 'marine') $date_array = $Marine->countAllDatesLast7Days(); |
|
| 38 | -elseif ($type == 'tracker') $date_array = $Tracker->countAllDatesLast7Days(); |
|
| 40 | +if ($type == 'aircraft') { |
|
| 41 | + $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
|
| 42 | +} elseif ($type == 'marine') { |
|
| 43 | + $date_array = $Marine->countAllDatesLast7Days(); |
|
| 44 | +} elseif ($type == 'tracker') { |
|
| 45 | + $date_array = $Tracker->countAllDatesLast7Days(); |
|
| 46 | +} |
|
| 39 | 47 | if (count($date_array) == 0) { |
| 40 | 48 | print _("No data available"); |
| 41 | 49 | } else { |
@@ -61,9 +69,13 @@ discard block |
||
| 61 | 69 | } else { |
| 62 | 70 | print '<p>'._("Below are the <strong>Top 10</strong> most busiest dates.").'</p>'; |
| 63 | 71 | } |
| 64 | -if ($type == 'aircraft') $date_array = $Stats->countAllDates($airline_icao,$filter_name); |
|
| 65 | -elseif ($type == 'marine') $date_array = $Marine->countAllDates(); |
|
| 66 | -elseif ($type == 'tracker') $date_array = $Tracker->countAllDates(); |
|
| 72 | +if ($type == 'aircraft') { |
|
| 73 | + $date_array = $Stats->countAllDates($airline_icao,$filter_name); |
|
| 74 | +} elseif ($type == 'marine') { |
|
| 75 | + $date_array = $Marine->countAllDates(); |
|
| 76 | +} elseif ($type == 'tracker') { |
|
| 77 | + $date_array = $Tracker->countAllDates(); |
|
| 78 | +} |
|
| 67 | 79 | if (!empty($date_array)) |
| 68 | 80 | { |
| 69 | 81 | print '<div class="table-responsive">'; |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | require_once('header.php'); |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | if (!isset($filter_name)) $filter_name = ''; |
| 21 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
| 21 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
| 22 | 22 | if ($airline_icao == '' && isset($globalFilter)) { |
| 23 | 23 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
| 24 | 24 | } |
@@ -33,19 +33,19 @@ discard block |
||
| 33 | 33 | </div> |
| 34 | 34 | <p>'._("Below is a chart that plots the busiest month during the <strong>last year</strong>.").'</p>'; |
| 35 | 35 | |
| 36 | -if ($type == 'aircraft') $date_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
|
| 36 | +if ($type == 'aircraft') $date_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name); |
|
| 37 | 37 | elseif ($type == 'marine') $date_array = $Marine->countAllMonthsLastYear(true); |
| 38 | 38 | elseif ($type == 'tracker') $date_array = $Tracker->countAllMonthsLastYear(true); |
| 39 | 39 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
| 40 | 40 | $year_data = ''; |
| 41 | 41 | $year_cnt = ''; |
| 42 | -foreach($date_array as $year_item) |
|
| 42 | +foreach ($date_array as $year_item) |
|
| 43 | 43 | { |
| 44 | 44 | $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",'; |
| 45 | 45 | $year_cnt .= $year_item['date_count'].','; |
| 46 | 46 | } |
| 47 | 47 | $year_data = "['x',".substr($year_data, 0, -1)."]"; |
| 48 | -$year_cnt = "['flights',".substr($year_cnt,0,-1)."]"; |
|
| 48 | +$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]"; |
|
| 49 | 49 | print 'c3.generate({ |
| 50 | 50 | bindto: "#chart", |
| 51 | 51 | data: { x: "x", |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | print '</thead>'; |
| 69 | 69 | print '<tbody>'; |
| 70 | 70 | $i = 1; |
| 71 | - foreach($date_array as $date_item) |
|
| 71 | + foreach ($date_array as $date_item) |
|
| 72 | 72 | { |
| 73 | 73 | print '<tr>'; |
| 74 | 74 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -17,11 +17,15 @@ discard block |
||
| 17 | 17 | $title = _("Statistics").' - '._("Busiest Month of Last Year"); |
| 18 | 18 | |
| 19 | 19 | |
| 20 | -if (!isset($filter_name)) $filter_name = ''; |
|
| 20 | +if (!isset($filter_name)) { |
|
| 21 | + $filter_name = ''; |
|
| 22 | +} |
|
| 21 | 23 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 22 | 24 | if ($airline_icao == '' && isset($globalFilter)) { |
| 23 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 24 | -} |
|
| 25 | + if (isset($globalFilter['airline'])) { |
|
| 26 | + $airline_icao = $globalFilter['airline'][0]; |
|
| 27 | + } |
|
| 28 | + } |
|
| 25 | 29 | |
| 26 | 30 | require_once('header.php'); |
| 27 | 31 | include('statistics-sub-menu.php'); |
@@ -33,9 +37,13 @@ discard block |
||
| 33 | 37 | </div> |
| 34 | 38 | <p>'._("Below is a chart that plots the busiest month during the <strong>last year</strong>.").'</p>'; |
| 35 | 39 | |
| 36 | -if ($type == 'aircraft') $date_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
|
| 37 | -elseif ($type == 'marine') $date_array = $Marine->countAllMonthsLastYear(true); |
|
| 38 | -elseif ($type == 'tracker') $date_array = $Tracker->countAllMonthsLastYear(true); |
|
| 40 | +if ($type == 'aircraft') { |
|
| 41 | + $date_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
|
| 42 | +} elseif ($type == 'marine') { |
|
| 43 | + $date_array = $Marine->countAllMonthsLastYear(true); |
|
| 44 | +} elseif ($type == 'tracker') { |
|
| 45 | + $date_array = $Tracker->countAllMonthsLastYear(true); |
|
| 46 | +} |
|
| 39 | 47 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
| 40 | 48 | $year_data = ''; |
| 41 | 49 | $year_cnt = ''; |
@@ -53,9 +61,13 @@ discard block |
||
| 53 | 61 | axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "#"}},legend: { show: false }});'; |
| 54 | 62 | print '</script>'; |
| 55 | 63 | |
| 56 | -if ($type == 'aircraft') $date_array = $Stats->countAllMonths($airline_icao); |
|
| 57 | -elseif ($type == 'marine') $date_array = $Marine->countAllMonths(); |
|
| 58 | -elseif ($type == 'tracker') $date_array = $Tracker->countAllMonths(); |
|
| 64 | +if ($type == 'aircraft') { |
|
| 65 | + $date_array = $Stats->countAllMonths($airline_icao); |
|
| 66 | +} elseif ($type == 'marine') { |
|
| 67 | + $date_array = $Marine->countAllMonths(); |
|
| 68 | +} elseif ($type == 'tracker') { |
|
| 69 | + $date_array = $Tracker->countAllMonths(); |
|
| 70 | +} |
|
| 59 | 71 | |
| 60 | 72 | if (!empty($date_array)) |
| 61 | 73 | { |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | /** |
| 15 | 15 | * Get SQL query part for filter used |
| 16 | 16 | * @param Array $filter the filter |
| 17 | - * @return Array the SQL part |
|
| 17 | + * @return string the SQL part |
|
| 18 | 18 | */ |
| 19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Get SQL query part for filter used |
|
| 17 | - * @param Array $filter the filter |
|
| 18 | - * @return Array the SQL part |
|
| 19 | - */ |
|
| 16 | + * Get SQL query part for filter used |
|
| 17 | + * @param Array $filter the filter |
|
| 18 | + * @return Array the SQL part |
|
| 19 | + */ |
|
| 20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
@@ -129,11 +129,11 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | - * Gets all the spotter information based on the latest data entry |
|
| 133 | - * |
|
| 134 | - * @return Array the spotter information |
|
| 135 | - * |
|
| 136 | - */ |
|
| 132 | + * Gets all the spotter information based on the latest data entry |
|
| 133 | + * |
|
| 134 | + * @return Array the spotter information |
|
| 135 | + * |
|
| 136 | + */ |
|
| 137 | 137 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
| 138 | 138 | { |
| 139 | 139 | global $globalDBdriver, $globalLiveInterval; |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
| 179 | - * Gets Minimal Live Spotter data |
|
| 180 | - * |
|
| 181 | - * @return Array the spotter information |
|
| 182 | - * |
|
| 183 | - */ |
|
| 179 | + * Gets Minimal Live Spotter data |
|
| 180 | + * |
|
| 181 | + * @return Array the spotter information |
|
| 182 | + * |
|
| 183 | + */ |
|
| 184 | 184 | public function getMinLiveSpotterData($filter = array()) |
| 185 | 185 | { |
| 186 | 186 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -217,11 +217,11 @@ discard block |
||
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
| 220 | - * Gets Minimal Live Spotter data since xx seconds |
|
| 221 | - * |
|
| 222 | - * @return Array the spotter information |
|
| 223 | - * |
|
| 224 | - */ |
|
| 220 | + * Gets Minimal Live Spotter data since xx seconds |
|
| 221 | + * |
|
| 222 | + * @return Array the spotter information |
|
| 223 | + * |
|
| 224 | + */ |
|
| 225 | 225 | public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false) |
| 226 | 226 | { |
| 227 | 227 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
@@ -302,11 +302,11 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | - * Gets number of latest data entry |
|
| 306 | - * |
|
| 307 | - * @return String number of entry |
|
| 308 | - * |
|
| 309 | - */ |
|
| 305 | + * Gets number of latest data entry |
|
| 306 | + * |
|
| 307 | + * @return String number of entry |
|
| 308 | + * |
|
| 309 | + */ |
|
| 310 | 310 | public function getLiveSpotterCount($filter = array()) |
| 311 | 311 | { |
| 312 | 312 | global $globalDBdriver, $globalLiveInterval; |
@@ -333,11 +333,11 @@ discard block |
||
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 337 | - * |
|
| 338 | - * @return Array the spotter information |
|
| 339 | - * |
|
| 340 | - */ |
|
| 336 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 337 | + * |
|
| 338 | + * @return Array the spotter information |
|
| 339 | + * |
|
| 340 | + */ |
|
| 341 | 341 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
| 342 | 342 | { |
| 343 | 343 | global $globalDBdriver, $globalLiveInterval; |
@@ -362,11 +362,11 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
| 365 | - * Gets all the spotter information based on the latest data entry and coord |
|
| 366 | - * |
|
| 367 | - * @return Array the spotter information |
|
| 368 | - * |
|
| 369 | - */ |
|
| 365 | + * Gets all the spotter information based on the latest data entry and coord |
|
| 366 | + * |
|
| 367 | + * @return Array the spotter information |
|
| 368 | + * |
|
| 369 | + */ |
|
| 370 | 370 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
| 371 | 371 | { |
| 372 | 372 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -431,11 +431,11 @@ discard block |
||
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
| 434 | - * Gets all the spotter information based on a user's latitude and longitude |
|
| 435 | - * |
|
| 436 | - * @return Array the spotter information |
|
| 437 | - * |
|
| 438 | - */ |
|
| 434 | + * Gets all the spotter information based on a user's latitude and longitude |
|
| 435 | + * |
|
| 436 | + * @return Array the spotter information |
|
| 437 | + * |
|
| 438 | + */ |
|
| 439 | 439 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
| 440 | 440 | { |
| 441 | 441 | $Spotter = new Spotter($this->db); |
@@ -445,98 +445,98 @@ discard block |
||
| 445 | 445 | return false; |
| 446 | 446 | } |
| 447 | 447 | } |
| 448 | - if ($lng != '') |
|
| 449 | - { |
|
| 450 | - if (!is_numeric($lng)) |
|
| 451 | - { |
|
| 452 | - return false; |
|
| 453 | - } |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - if ($radius != '') |
|
| 457 | - { |
|
| 458 | - if (!is_numeric($radius)) |
|
| 459 | - { |
|
| 460 | - return false; |
|
| 461 | - } |
|
| 462 | - } |
|
| 448 | + if ($lng != '') |
|
| 449 | + { |
|
| 450 | + if (!is_numeric($lng)) |
|
| 451 | + { |
|
| 452 | + return false; |
|
| 453 | + } |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + if ($radius != '') |
|
| 457 | + { |
|
| 458 | + if (!is_numeric($radius)) |
|
| 459 | + { |
|
| 460 | + return false; |
|
| 461 | + } |
|
| 462 | + } |
|
| 463 | 463 | $additional_query = ''; |
| 464 | - if ($interval != '') |
|
| 465 | - { |
|
| 466 | - if (!is_string($interval)) |
|
| 467 | - { |
|
| 468 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 469 | - return false; |
|
| 470 | - } else { |
|
| 471 | - if ($interval == '1m') |
|
| 472 | - { |
|
| 473 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 474 | - } else if ($interval == '15m'){ |
|
| 475 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 476 | - } |
|
| 477 | - } |
|
| 478 | - } else { |
|
| 479 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 464 | + if ($interval != '') |
|
| 465 | + { |
|
| 466 | + if (!is_string($interval)) |
|
| 467 | + { |
|
| 468 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 469 | + return false; |
|
| 470 | + } else { |
|
| 471 | + if ($interval == '1m') |
|
| 472 | + { |
|
| 473 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 474 | + } else if ($interval == '15m'){ |
|
| 475 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
| 476 | + } |
|
| 477 | + } |
|
| 478 | + } else { |
|
| 479 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
| 480 | + } |
|
| 481 | + |
|
| 482 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 483 | 483 | WHERE spotter_live.latitude <> '' |
| 484 | 484 | AND spotter_live.longitude <> '' |
| 485 | 485 | ".$additional_query." |
| 486 | 486 | HAVING distance < :radius |
| 487 | 487 | ORDER BY distance"; |
| 488 | 488 | |
| 489 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 489 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 490 | 490 | |
| 491 | - return $spotter_array; |
|
| 492 | - } |
|
| 491 | + return $spotter_array; |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | 494 | |
| 495 | - /** |
|
| 496 | - * Gets all the spotter information based on a particular callsign |
|
| 497 | - * |
|
| 498 | - * @return Array the spotter information |
|
| 499 | - * |
|
| 500 | - */ |
|
| 495 | + /** |
|
| 496 | + * Gets all the spotter information based on a particular callsign |
|
| 497 | + * |
|
| 498 | + * @return Array the spotter information |
|
| 499 | + * |
|
| 500 | + */ |
|
| 501 | 501 | public function getLastLiveSpotterDataByIdent($ident) |
| 502 | 502 | { |
| 503 | 503 | $Spotter = new Spotter($this->db); |
| 504 | 504 | date_default_timezone_set('UTC'); |
| 505 | 505 | |
| 506 | 506 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 507 | - $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 507 | + $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 508 | 508 | |
| 509 | 509 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
| 510 | 510 | |
| 511 | 511 | return $spotter_array; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - /** |
|
| 515 | - * Gets all the spotter information based on a particular callsign |
|
| 516 | - * |
|
| 517 | - * @return Array the spotter information |
|
| 518 | - * |
|
| 519 | - */ |
|
| 514 | + /** |
|
| 515 | + * Gets all the spotter information based on a particular callsign |
|
| 516 | + * |
|
| 517 | + * @return Array the spotter information |
|
| 518 | + * |
|
| 519 | + */ |
|
| 520 | 520 | public function getDateLiveSpotterDataByIdent($ident,$date) |
| 521 | 521 | { |
| 522 | 522 | $Spotter = new Spotter($this->db); |
| 523 | 523 | date_default_timezone_set('UTC'); |
| 524 | 524 | |
| 525 | 525 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 526 | - $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 526 | + $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 527 | 527 | |
| 528 | - $date = date('c',$date); |
|
| 528 | + $date = date('c',$date); |
|
| 529 | 529 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
| 530 | 530 | |
| 531 | 531 | return $spotter_array; |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - /** |
|
| 535 | - * Gets last spotter information based on a particular callsign |
|
| 536 | - * |
|
| 537 | - * @return Array the spotter information |
|
| 538 | - * |
|
| 539 | - */ |
|
| 534 | + /** |
|
| 535 | + * Gets last spotter information based on a particular callsign |
|
| 536 | + * |
|
| 537 | + * @return Array the spotter information |
|
| 538 | + * |
|
| 539 | + */ |
|
| 540 | 540 | public function getLastLiveSpotterDataById($id) |
| 541 | 541 | { |
| 542 | 542 | $Spotter = new Spotter($this->db); |
@@ -547,12 +547,12 @@ discard block |
||
| 547 | 547 | return $spotter_array; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - /** |
|
| 551 | - * Gets last spotter information based on a particular callsign |
|
| 552 | - * |
|
| 553 | - * @return Array the spotter information |
|
| 554 | - * |
|
| 555 | - */ |
|
| 550 | + /** |
|
| 551 | + * Gets last spotter information based on a particular callsign |
|
| 552 | + * |
|
| 553 | + * @return Array the spotter information |
|
| 554 | + * |
|
| 555 | + */ |
|
| 556 | 556 | public function getDateLiveSpotterDataById($id,$date) |
| 557 | 557 | { |
| 558 | 558 | $Spotter = new Spotter($this->db); |
@@ -565,21 +565,21 @@ discard block |
||
| 565 | 565 | return $spotter_array; |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | - /** |
|
| 569 | - * Gets altitude information based on a particular callsign |
|
| 570 | - * |
|
| 571 | - * @return Array the spotter information |
|
| 572 | - * |
|
| 573 | - */ |
|
| 568 | + /** |
|
| 569 | + * Gets altitude information based on a particular callsign |
|
| 570 | + * |
|
| 571 | + * @return Array the spotter information |
|
| 572 | + * |
|
| 573 | + */ |
|
| 574 | 574 | public function getAltitudeLiveSpotterDataByIdent($ident) |
| 575 | 575 | { |
| 576 | 576 | |
| 577 | 577 | date_default_timezone_set('UTC'); |
| 578 | 578 | |
| 579 | 579 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 580 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 580 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 581 | 581 | |
| 582 | - try { |
|
| 582 | + try { |
|
| 583 | 583 | |
| 584 | 584 | $sth = $this->db->prepare($query); |
| 585 | 585 | $sth->execute(array(':ident' => $ident)); |
@@ -592,12 +592,12 @@ discard block |
||
| 592 | 592 | return $spotter_array; |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - /** |
|
| 596 | - * Gets all the spotter information based on a particular id |
|
| 597 | - * |
|
| 598 | - * @return Array the spotter information |
|
| 599 | - * |
|
| 600 | - */ |
|
| 595 | + /** |
|
| 596 | + * Gets all the spotter information based on a particular id |
|
| 597 | + * |
|
| 598 | + * @return Array the spotter information |
|
| 599 | + * |
|
| 600 | + */ |
|
| 601 | 601 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
| 602 | 602 | { |
| 603 | 603 | global $globalDBdriver, $globalLiveInterval; |
@@ -625,18 +625,18 @@ discard block |
||
| 625 | 625 | return $spotter_array; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | - /** |
|
| 629 | - * Gets all the spotter information based on a particular ident |
|
| 630 | - * |
|
| 631 | - * @return Array the spotter information |
|
| 632 | - * |
|
| 633 | - */ |
|
| 628 | + /** |
|
| 629 | + * Gets all the spotter information based on a particular ident |
|
| 630 | + * |
|
| 631 | + * @return Array the spotter information |
|
| 632 | + * |
|
| 633 | + */ |
|
| 634 | 634 | public function getAllLiveSpotterDataByIdent($ident) |
| 635 | 635 | { |
| 636 | 636 | date_default_timezone_set('UTC'); |
| 637 | 637 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 638 | 638 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
| 639 | - try { |
|
| 639 | + try { |
|
| 640 | 640 | |
| 641 | 641 | $sth = $this->db->prepare($query); |
| 642 | 642 | $sth->execute(array(':ident' => $ident)); |
@@ -650,23 +650,23 @@ discard block |
||
| 650 | 650 | |
| 651 | 651 | |
| 652 | 652 | /** |
| 653 | - * Deletes all info in the table |
|
| 654 | - * |
|
| 655 | - * @return String success or false |
|
| 656 | - * |
|
| 657 | - */ |
|
| 653 | + * Deletes all info in the table |
|
| 654 | + * |
|
| 655 | + * @return String success or false |
|
| 656 | + * |
|
| 657 | + */ |
|
| 658 | 658 | public function deleteLiveSpotterData() |
| 659 | 659 | { |
| 660 | 660 | global $globalDBdriver; |
| 661 | 661 | if ($globalDBdriver == 'mysql') { |
| 662 | 662 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
| 663 | 663 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
| 664 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
| 664 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
| 665 | 665 | } else { |
| 666 | 666 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | - try { |
|
| 669 | + try { |
|
| 670 | 670 | |
| 671 | 671 | $sth = $this->db->prepare($query); |
| 672 | 672 | $sth->execute(); |
@@ -678,18 +678,18 @@ discard block |
||
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | /** |
| 681 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 682 | - * |
|
| 683 | - * @return String success or false |
|
| 684 | - * |
|
| 685 | - */ |
|
| 681 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
| 682 | + * |
|
| 683 | + * @return String success or false |
|
| 684 | + * |
|
| 685 | + */ |
|
| 686 | 686 | public function deleteLiveSpotterDataNotUpdated() |
| 687 | 687 | { |
| 688 | 688 | global $globalDBdriver, $globalDebug; |
| 689 | 689 | if ($globalDBdriver == 'mysql') { |
| 690 | 690 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
| 691 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
| 692 | - try { |
|
| 691 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
| 692 | + try { |
|
| 693 | 693 | |
| 694 | 694 | $sth = $this->db->prepare($query); |
| 695 | 695 | $sth->execute(); |
@@ -697,8 +697,8 @@ discard block |
||
| 697 | 697 | return "error"; |
| 698 | 698 | } |
| 699 | 699 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 700 | - $i = 0; |
|
| 701 | - $j =0; |
|
| 700 | + $i = 0; |
|
| 701 | + $j =0; |
|
| 702 | 702 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 703 | 703 | foreach($all as $row) |
| 704 | 704 | { |
@@ -706,20 +706,20 @@ discard block |
||
| 706 | 706 | $j++; |
| 707 | 707 | if ($j == 30) { |
| 708 | 708 | if ($globalDebug) echo "."; |
| 709 | - try { |
|
| 709 | + try { |
|
| 710 | 710 | |
| 711 | 711 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 712 | 712 | $sth->execute(); |
| 713 | 713 | } catch(PDOException $e) { |
| 714 | 714 | return "error"; |
| 715 | 715 | } |
| 716 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 717 | - $j = 0; |
|
| 716 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
| 717 | + $j = 0; |
|
| 718 | 718 | } |
| 719 | 719 | $query_delete .= "'".$row['flightaware_id']."',"; |
| 720 | 720 | } |
| 721 | 721 | if ($i > 0) { |
| 722 | - try { |
|
| 722 | + try { |
|
| 723 | 723 | |
| 724 | 724 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
| 725 | 725 | $sth->execute(); |
@@ -730,9 +730,9 @@ discard block |
||
| 730 | 730 | return "success"; |
| 731 | 731 | } elseif ($globalDBdriver == 'pgsql') { |
| 732 | 732 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
| 733 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 734 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
| 735 | - try { |
|
| 733 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
| 734 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
| 735 | + try { |
|
| 736 | 736 | |
| 737 | 737 | $sth = $this->db->prepare($query); |
| 738 | 738 | $sth->execute(); |
@@ -776,17 +776,17 @@ discard block |
||
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | /** |
| 779 | - * Deletes all info in the table for an ident |
|
| 780 | - * |
|
| 781 | - * @return String success or false |
|
| 782 | - * |
|
| 783 | - */ |
|
| 779 | + * Deletes all info in the table for an ident |
|
| 780 | + * |
|
| 781 | + * @return String success or false |
|
| 782 | + * |
|
| 783 | + */ |
|
| 784 | 784 | public function deleteLiveSpotterDataByIdent($ident) |
| 785 | 785 | { |
| 786 | 786 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 787 | 787 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
| 788 | 788 | |
| 789 | - try { |
|
| 789 | + try { |
|
| 790 | 790 | |
| 791 | 791 | $sth = $this->db->prepare($query); |
| 792 | 792 | $sth->execute(array(':ident' => $ident)); |
@@ -798,17 +798,17 @@ discard block |
||
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | /** |
| 801 | - * Deletes all info in the table for an id |
|
| 802 | - * |
|
| 803 | - * @return String success or false |
|
| 804 | - * |
|
| 805 | - */ |
|
| 801 | + * Deletes all info in the table for an id |
|
| 802 | + * |
|
| 803 | + * @return String success or false |
|
| 804 | + * |
|
| 805 | + */ |
|
| 806 | 806 | public function deleteLiveSpotterDataById($id) |
| 807 | 807 | { |
| 808 | 808 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 809 | 809 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
| 810 | 810 | |
| 811 | - try { |
|
| 811 | + try { |
|
| 812 | 812 | |
| 813 | 813 | $sth = $this->db->prepare($query); |
| 814 | 814 | $sth->execute(array(':id' => $id)); |
@@ -821,11 +821,11 @@ discard block |
||
| 821 | 821 | |
| 822 | 822 | |
| 823 | 823 | /** |
| 824 | - * Gets the aircraft ident within the last hour |
|
| 825 | - * |
|
| 826 | - * @return String the ident |
|
| 827 | - * |
|
| 828 | - */ |
|
| 824 | + * Gets the aircraft ident within the last hour |
|
| 825 | + * |
|
| 826 | + * @return String the ident |
|
| 827 | + * |
|
| 828 | + */ |
|
| 829 | 829 | public function getIdentFromLastHour($ident) |
| 830 | 830 | { |
| 831 | 831 | global $globalDBdriver, $globalTimezone; |
@@ -851,14 +851,14 @@ discard block |
||
| 851 | 851 | $ident_result = $row['ident']; |
| 852 | 852 | } |
| 853 | 853 | return $ident_result; |
| 854 | - } |
|
| 854 | + } |
|
| 855 | 855 | |
| 856 | 856 | /** |
| 857 | - * Check recent aircraft |
|
| 858 | - * |
|
| 859 | - * @return String the ident |
|
| 860 | - * |
|
| 861 | - */ |
|
| 857 | + * Check recent aircraft |
|
| 858 | + * |
|
| 859 | + * @return String the ident |
|
| 860 | + * |
|
| 861 | + */ |
|
| 862 | 862 | public function checkIdentRecent($ident) |
| 863 | 863 | { |
| 864 | 864 | global $globalDBdriver, $globalTimezone; |
@@ -884,14 +884,14 @@ discard block |
||
| 884 | 884 | $ident_result = $row['flightaware_id']; |
| 885 | 885 | } |
| 886 | 886 | return $ident_result; |
| 887 | - } |
|
| 887 | + } |
|
| 888 | 888 | |
| 889 | 889 | /** |
| 890 | - * Check recent aircraft by id |
|
| 891 | - * |
|
| 892 | - * @return String the ident |
|
| 893 | - * |
|
| 894 | - */ |
|
| 890 | + * Check recent aircraft by id |
|
| 891 | + * |
|
| 892 | + * @return String the ident |
|
| 893 | + * |
|
| 894 | + */ |
|
| 895 | 895 | public function checkIdRecent($id) |
| 896 | 896 | { |
| 897 | 897 | global $globalDBdriver, $globalTimezone; |
@@ -917,14 +917,14 @@ discard block |
||
| 917 | 917 | $ident_result = $row['flightaware_id']; |
| 918 | 918 | } |
| 919 | 919 | return $ident_result; |
| 920 | - } |
|
| 920 | + } |
|
| 921 | 921 | |
| 922 | 922 | /** |
| 923 | - * Check recent aircraft by ModeS |
|
| 924 | - * |
|
| 925 | - * @return String the ModeS |
|
| 926 | - * |
|
| 927 | - */ |
|
| 923 | + * Check recent aircraft by ModeS |
|
| 924 | + * |
|
| 925 | + * @return String the ModeS |
|
| 926 | + * |
|
| 927 | + */ |
|
| 928 | 928 | public function checkModeSRecent($modes) |
| 929 | 929 | { |
| 930 | 930 | global $globalDBdriver, $globalTimezone; |
@@ -951,19 +951,19 @@ discard block |
||
| 951 | 951 | $ident_result = $row['flightaware_id']; |
| 952 | 952 | } |
| 953 | 953 | return $ident_result; |
| 954 | - } |
|
| 954 | + } |
|
| 955 | 955 | |
| 956 | 956 | /** |
| 957 | - * Adds a new spotter data |
|
| 958 | - * |
|
| 959 | - * @param String $flightaware_id the ID from flightaware |
|
| 960 | - * @param String $ident the flight ident |
|
| 961 | - * @param String $aircraft_icao the aircraft type |
|
| 962 | - * @param String $departure_airport_icao the departure airport |
|
| 963 | - * @param String $arrival_airport_icao the arrival airport |
|
| 964 | - * @return String success or false |
|
| 965 | - * |
|
| 966 | - */ |
|
| 957 | + * Adds a new spotter data |
|
| 958 | + * |
|
| 959 | + * @param String $flightaware_id the ID from flightaware |
|
| 960 | + * @param String $ident the flight ident |
|
| 961 | + * @param String $aircraft_icao the aircraft type |
|
| 962 | + * @param String $departure_airport_icao the departure airport |
|
| 963 | + * @param String $arrival_airport_icao the arrival airport |
|
| 964 | + * @return String success or false |
|
| 965 | + * |
|
| 966 | + */ |
|
| 967 | 967 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
| 968 | 968 | { |
| 969 | 969 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1106,10 +1106,10 @@ discard block |
||
| 1106 | 1106 | $arrival_airport_country = ''; |
| 1107 | 1107 | |
| 1108 | 1108 | |
| 1109 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1110 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1111 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1112 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1109 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1110 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1111 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1112 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1113 | 1113 | |
| 1114 | 1114 | $query = ''; |
| 1115 | 1115 | if ($globalArchive) { |
@@ -1130,10 +1130,10 @@ discard block |
||
| 1130 | 1130 | return "error : ".$e->getMessage(); |
| 1131 | 1131 | } |
| 1132 | 1132 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1133 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1134 | - $SpotterArchive = new SpotterArchive($this->db); |
|
| 1135 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1136 | - if ($globalDebug) echo $result.')'; |
|
| 1133 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1134 | + $SpotterArchive = new SpotterArchive($this->db); |
|
| 1135 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1136 | + if ($globalDebug) echo $result.')'; |
|
| 1137 | 1137 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1138 | 1138 | echo '(Not adding to archive)'; |
| 1139 | 1139 | } elseif ($globalDebug && $noarchive === true) { |
@@ -17,62 +17,62 @@ discard block |
||
| 17 | 17 | * @param Array $filter the filter |
| 18 | 18 | * @return Array the SQL part |
| 19 | 19 | */ |
| 20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 22 | 22 | $filters = array(); |
| 23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
| 26 | 26 | } else { |
| 27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | if (isset($filter[0]['source'])) { |
| 31 | - $filters = array_merge($filters,$filter); |
|
| 31 | + $filters = array_merge($filters, $filter); |
|
| 32 | 32 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 34 | 34 | $filter_query_join = ''; |
| 35 | 35 | $filter_query_where = ''; |
| 36 | - foreach($filters as $flt) { |
|
| 36 | + foreach ($filters as $flt) { |
|
| 37 | 37 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 38 | 38 | if ($flt['airlines'][0] != '') { |
| 39 | 39 | if (isset($flt['source'])) { |
| 40 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 40 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 41 | 41 | } else { |
| 42 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 42 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id"; |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 47 | 47 | if (isset($flt['source'])) { |
| 48 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 48 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 49 | 49 | } else { |
| 50 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 50 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id"; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 54 | 54 | if (isset($flt['source'])) { |
| 55 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 55 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 56 | 56 | } else { |
| 57 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 57 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id"; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
| 61 | 61 | if (isset($flt['source'])) { |
| 62 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 62 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 63 | 63 | } else { |
| 64 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 64 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id"; |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
| 68 | 68 | if (isset($flt['source'])) { |
| 69 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 69 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id"; |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 74 | 74 | if ($filter['airlines'][0] != '') { |
| 75 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 75 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id"; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -82,10 +82,10 @@ discard block |
||
| 82 | 82 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
| 83 | 83 | } |
| 84 | 84 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 85 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 85 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id"; |
|
| 86 | 86 | } |
| 87 | 87 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 88 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 88 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 89 | 89 | } |
| 90 | 90 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 91 | 91 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -114,15 +114,15 @@ discard block |
||
| 114 | 114 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 117 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
| 118 | 118 | } |
| 119 | 119 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 120 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 120 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 121 | 121 | } |
| 122 | 122 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 123 | 123 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 124 | 124 | if ($filter_query_where != '') { |
| 125 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 125 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 126 | 126 | } |
| 127 | 127 | $filter_query = $filter_query_join.$filter_query_where; |
| 128 | 128 | return $filter_query; |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | if ($limit != '') |
| 146 | 146 | { |
| 147 | 147 | $limit_array = explode(',', $limit); |
| 148 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 149 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 148 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 149 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 150 | 150 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 151 | 151 | { |
| 152 | 152 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | } else { |
| 171 | 171 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
| 172 | 172 | } |
| 173 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
| 173 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
| 174 | 174 | |
| 175 | 175 | return $spotter_array; |
| 176 | 176 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 187 | 187 | date_default_timezone_set('UTC'); |
| 188 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 188 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 189 | 189 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 190 | 190 | if ($globalDBdriver == 'mysql') { |
| 191 | 191 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | try { |
| 209 | 209 | $sth = $this->db->prepare($query); |
| 210 | 210 | $sth->execute(); |
| 211 | - } catch(PDOException $e) { |
|
| 211 | + } catch (PDOException $e) { |
|
| 212 | 212 | echo $e->getMessage(); |
| 213 | 213 | die; |
| 214 | 214 | } |
@@ -222,19 +222,19 @@ discard block |
||
| 222 | 222 | * @return Array the spotter information |
| 223 | 223 | * |
| 224 | 224 | */ |
| 225 | - public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false) |
|
| 225 | + public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = false) |
|
| 226 | 226 | { |
| 227 | 227 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
| 228 | 228 | date_default_timezone_set('UTC'); |
| 229 | 229 | $usecoord = false; |
| 230 | 230 | if (is_array($coord) && !empty($coord)) { |
| 231 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 232 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 233 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 234 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 231 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 232 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 233 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 234 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 235 | 235 | $usecoord = true; |
| 236 | 236 | } |
| 237 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 237 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 238 | 238 | |
| 239 | 239 | if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
| 240 | 240 | if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | try { |
| 296 | 296 | $sth = $this->db->prepare($query); |
| 297 | 297 | $sth->execute(); |
| 298 | - } catch(PDOException $e) { |
|
| 298 | + } catch (PDOException $e) { |
|
| 299 | 299 | echo $e->getMessage(); |
| 300 | 300 | die; |
| 301 | 301 | } |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | public function getLiveSpotterCount($filter = array()) |
| 313 | 313 | { |
| 314 | 314 | global $globalDBdriver, $globalLiveInterval; |
| 315 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 315 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 316 | 316 | |
| 317 | 317 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 318 | 318 | if ($globalDBdriver == 'mysql') { |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | try { |
| 326 | 326 | $sth = $this->db->prepare($query); |
| 327 | 327 | $sth->execute(); |
| 328 | - } catch(PDOException $e) { |
|
| 328 | + } catch (PDOException $e) { |
|
| 329 | 329 | echo $e->getMessage(); |
| 330 | 330 | die; |
| 331 | 331 | } |
@@ -348,10 +348,10 @@ discard block |
||
| 348 | 348 | $filter_query = $this->getFilter($filter); |
| 349 | 349 | |
| 350 | 350 | if (is_array($coord)) { |
| 351 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 352 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 353 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 354 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 351 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 352 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 353 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 354 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 355 | 355 | } else return array(); |
| 356 | 356 | if ($globalDBdriver == 'mysql') { |
| 357 | 357 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -374,23 +374,23 @@ discard block |
||
| 374 | 374 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 375 | 375 | $Spotter = new Spotter($this->db); |
| 376 | 376 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
| 377 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 377 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 378 | 378 | |
| 379 | 379 | if (is_array($coord)) { |
| 380 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 381 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 382 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 383 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 380 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 381 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 382 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 383 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 384 | 384 | } else return array(); |
| 385 | 385 | if ($globalDBdriver == 'mysql') { |
| 386 | 386 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 387 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 387 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 388 | 388 | FROM spotter_live |
| 389 | 389 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
| 390 | 390 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
| 391 | 391 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0'; |
| 392 | 392 | } else { |
| 393 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 393 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 394 | 394 | FROM spotter_live |
| 395 | 395 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 396 | 396 | FROM spotter_live l |
@@ -402,14 +402,14 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | } else { |
| 404 | 404 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 405 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 405 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 406 | 406 | FROM spotter_live |
| 407 | 407 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
| 408 | 408 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
| 409 | 409 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
| 410 | 410 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
| 411 | 411 | } else { |
| 412 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 412 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
| 413 | 413 | FROM spotter_live |
| 414 | 414 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
| 415 | 415 | FROM spotter_live l |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | try { |
| 425 | 425 | $sth = $this->db->prepare($query); |
| 426 | 426 | $sth->execute(); |
| 427 | - } catch(PDOException $e) { |
|
| 427 | + } catch (PDOException $e) { |
|
| 428 | 428 | echo $e->getMessage(); |
| 429 | 429 | die; |
| 430 | 430 | } |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | if ($interval == '1m') |
| 474 | 474 | { |
| 475 | 475 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 476 | - } else if ($interval == '15m'){ |
|
| 476 | + } else if ($interval == '15m') { |
|
| 477 | 477 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
| 478 | 478 | } |
| 479 | 479 | } |
@@ -481,14 +481,14 @@ discard block |
||
| 481 | 481 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 484 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
| 485 | 485 | WHERE spotter_live.latitude <> '' |
| 486 | 486 | AND spotter_live.longitude <> '' |
| 487 | 487 | ".$additional_query." |
| 488 | 488 | HAVING distance < :radius |
| 489 | 489 | ORDER BY distance"; |
| 490 | 490 | |
| 491 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
| 491 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
| 492 | 492 | |
| 493 | 493 | return $spotter_array; |
| 494 | 494 | } |
@@ -506,9 +506,9 @@ discard block |
||
| 506 | 506 | date_default_timezone_set('UTC'); |
| 507 | 507 | |
| 508 | 508 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 509 | - $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 509 | + $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 510 | 510 | |
| 511 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
| 511 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
| 512 | 512 | |
| 513 | 513 | return $spotter_array; |
| 514 | 514 | } |
@@ -519,16 +519,16 @@ discard block |
||
| 519 | 519 | * @return Array the spotter information |
| 520 | 520 | * |
| 521 | 521 | */ |
| 522 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
| 522 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
| 523 | 523 | { |
| 524 | 524 | $Spotter = new Spotter($this->db); |
| 525 | 525 | date_default_timezone_set('UTC'); |
| 526 | 526 | |
| 527 | 527 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 528 | - $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 528 | + $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 529 | 529 | |
| 530 | - $date = date('c',$date); |
|
| 531 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
| 530 | + $date = date('c', $date); |
|
| 531 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
| 532 | 532 | |
| 533 | 533 | return $spotter_array; |
| 534 | 534 | } |
@@ -544,8 +544,8 @@ discard block |
||
| 544 | 544 | $Spotter = new Spotter($this->db); |
| 545 | 545 | date_default_timezone_set('UTC'); |
| 546 | 546 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 547 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 548 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
| 547 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 548 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
| 549 | 549 | return $spotter_array; |
| 550 | 550 | } |
| 551 | 551 | |
@@ -555,15 +555,15 @@ discard block |
||
| 555 | 555 | * @return Array the spotter information |
| 556 | 556 | * |
| 557 | 557 | */ |
| 558 | - public function getDateLiveSpotterDataById($id,$date) |
|
| 558 | + public function getDateLiveSpotterDataById($id, $date) |
|
| 559 | 559 | { |
| 560 | 560 | $Spotter = new Spotter($this->db); |
| 561 | 561 | date_default_timezone_set('UTC'); |
| 562 | 562 | |
| 563 | 563 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 564 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 565 | - $date = date('c',$date); |
|
| 566 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
| 564 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
| 565 | + $date = date('c', $date); |
|
| 566 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
| 567 | 567 | return $spotter_array; |
| 568 | 568 | } |
| 569 | 569 | |
@@ -579,13 +579,13 @@ discard block |
||
| 579 | 579 | date_default_timezone_set('UTC'); |
| 580 | 580 | |
| 581 | 581 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 582 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 582 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
| 583 | 583 | |
| 584 | 584 | try { |
| 585 | 585 | |
| 586 | 586 | $sth = $this->db->prepare($query); |
| 587 | 587 | $sth->execute(array(':ident' => $ident)); |
| 588 | - } catch(PDOException $e) { |
|
| 588 | + } catch (PDOException $e) { |
|
| 589 | 589 | echo $e->getMessage(); |
| 590 | 590 | die; |
| 591 | 591 | } |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | * @return Array the spotter information |
| 601 | 601 | * |
| 602 | 602 | */ |
| 603 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
| 603 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
| 604 | 604 | { |
| 605 | 605 | global $globalDBdriver, $globalLiveInterval; |
| 606 | 606 | date_default_timezone_set('UTC'); |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | try { |
| 620 | 620 | $sth = $this->db->prepare($query); |
| 621 | 621 | $sth->execute(array(':id' => $id)); |
| 622 | - } catch(PDOException $e) { |
|
| 622 | + } catch (PDOException $e) { |
|
| 623 | 623 | echo $e->getMessage(); |
| 624 | 624 | die; |
| 625 | 625 | } |
@@ -637,12 +637,12 @@ discard block |
||
| 637 | 637 | { |
| 638 | 638 | date_default_timezone_set('UTC'); |
| 639 | 639 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 640 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 640 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
| 641 | 641 | try { |
| 642 | 642 | |
| 643 | 643 | $sth = $this->db->prepare($query); |
| 644 | 644 | $sth->execute(array(':ident' => $ident)); |
| 645 | - } catch(PDOException $e) { |
|
| 645 | + } catch (PDOException $e) { |
|
| 646 | 646 | echo $e->getMessage(); |
| 647 | 647 | die; |
| 648 | 648 | } |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | |
| 673 | 673 | $sth = $this->db->prepare($query); |
| 674 | 674 | $sth->execute(); |
| 675 | - } catch(PDOException $e) { |
|
| 675 | + } catch (PDOException $e) { |
|
| 676 | 676 | return "error"; |
| 677 | 677 | } |
| 678 | 678 | |
@@ -695,14 +695,14 @@ discard block |
||
| 695 | 695 | |
| 696 | 696 | $sth = $this->db->prepare($query); |
| 697 | 697 | $sth->execute(); |
| 698 | - } catch(PDOException $e) { |
|
| 698 | + } catch (PDOException $e) { |
|
| 699 | 699 | return "error"; |
| 700 | 700 | } |
| 701 | 701 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
| 702 | 702 | $i = 0; |
| 703 | - $j =0; |
|
| 703 | + $j = 0; |
|
| 704 | 704 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 705 | - foreach($all as $row) |
|
| 705 | + foreach ($all as $row) |
|
| 706 | 706 | { |
| 707 | 707 | $i++; |
| 708 | 708 | $j++; |
@@ -710,9 +710,9 @@ discard block |
||
| 710 | 710 | if ($globalDebug) echo "."; |
| 711 | 711 | try { |
| 712 | 712 | |
| 713 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 713 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 714 | 714 | $sth->execute(); |
| 715 | - } catch(PDOException $e) { |
|
| 715 | + } catch (PDOException $e) { |
|
| 716 | 716 | return "error"; |
| 717 | 717 | } |
| 718 | 718 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -723,9 +723,9 @@ discard block |
||
| 723 | 723 | if ($i > 0) { |
| 724 | 724 | try { |
| 725 | 725 | |
| 726 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
| 726 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
| 727 | 727 | $sth->execute(); |
| 728 | - } catch(PDOException $e) { |
|
| 728 | + } catch (PDOException $e) { |
|
| 729 | 729 | return "error"; |
| 730 | 730 | } |
| 731 | 731 | } |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | |
| 739 | 739 | $sth = $this->db->prepare($query); |
| 740 | 740 | $sth->execute(); |
| 741 | - } catch(PDOException $e) { |
|
| 741 | + } catch (PDOException $e) { |
|
| 742 | 742 | return "error"; |
| 743 | 743 | } |
| 744 | 744 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -786,13 +786,13 @@ discard block |
||
| 786 | 786 | public function deleteLiveSpotterDataByIdent($ident) |
| 787 | 787 | { |
| 788 | 788 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
| 789 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 789 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
| 790 | 790 | |
| 791 | 791 | try { |
| 792 | 792 | |
| 793 | 793 | $sth = $this->db->prepare($query); |
| 794 | 794 | $sth->execute(array(':ident' => $ident)); |
| 795 | - } catch(PDOException $e) { |
|
| 795 | + } catch (PDOException $e) { |
|
| 796 | 796 | return "error"; |
| 797 | 797 | } |
| 798 | 798 | |
@@ -808,13 +808,13 @@ discard block |
||
| 808 | 808 | public function deleteLiveSpotterDataById($id) |
| 809 | 809 | { |
| 810 | 810 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
| 811 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 811 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
| 812 | 812 | |
| 813 | 813 | try { |
| 814 | 814 | |
| 815 | 815 | $sth = $this->db->prepare($query); |
| 816 | 816 | $sth->execute(array(':id' => $id)); |
| 817 | - } catch(PDOException $e) { |
|
| 817 | + } catch (PDOException $e) { |
|
| 818 | 818 | return "error"; |
| 819 | 819 | } |
| 820 | 820 | |
@@ -832,13 +832,13 @@ discard block |
||
| 832 | 832 | { |
| 833 | 833 | global $globalDBdriver, $globalTimezone; |
| 834 | 834 | if ($globalDBdriver == 'mysql') { |
| 835 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 835 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
| 836 | 836 | WHERE spotter_live.ident = :ident |
| 837 | 837 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 838 | 838 | AND spotter_live.date < UTC_TIMESTAMP()'; |
| 839 | 839 | $query_data = array(':ident' => $ident); |
| 840 | 840 | } else { |
| 841 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 841 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
| 842 | 842 | WHERE spotter_live.ident = :ident |
| 843 | 843 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 844 | 844 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -847,8 +847,8 @@ discard block |
||
| 847 | 847 | |
| 848 | 848 | $sth = $this->db->prepare($query); |
| 849 | 849 | $sth->execute($query_data); |
| 850 | - $ident_result=''; |
|
| 851 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 850 | + $ident_result = ''; |
|
| 851 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 852 | 852 | { |
| 853 | 853 | $ident_result = $row['ident']; |
| 854 | 854 | } |
@@ -865,13 +865,13 @@ discard block |
||
| 865 | 865 | { |
| 866 | 866 | global $globalDBdriver, $globalTimezone; |
| 867 | 867 | if ($globalDBdriver == 'mysql') { |
| 868 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 868 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 869 | 869 | WHERE spotter_live.ident = :ident |
| 870 | 870 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 871 | 871 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 872 | 872 | $query_data = array(':ident' => $ident); |
| 873 | 873 | } else { |
| 874 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 874 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 875 | 875 | WHERE spotter_live.ident = :ident |
| 876 | 876 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
| 877 | 877 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -880,8 +880,8 @@ discard block |
||
| 880 | 880 | |
| 881 | 881 | $sth = $this->db->prepare($query); |
| 882 | 882 | $sth->execute($query_data); |
| 883 | - $ident_result=''; |
|
| 884 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 883 | + $ident_result = ''; |
|
| 884 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 885 | 885 | { |
| 886 | 886 | $ident_result = $row['flightaware_id']; |
| 887 | 887 | } |
@@ -898,13 +898,13 @@ discard block |
||
| 898 | 898 | { |
| 899 | 899 | global $globalDBdriver, $globalTimezone; |
| 900 | 900 | if ($globalDBdriver == 'mysql') { |
| 901 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 901 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 902 | 902 | WHERE spotter_live.flightaware_id = :id |
| 903 | 903 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
| 904 | 904 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 905 | 905 | $query_data = array(':id' => $id); |
| 906 | 906 | } else { |
| 907 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 907 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
| 908 | 908 | WHERE spotter_live.flightaware_id = :id |
| 909 | 909 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
| 910 | 910 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -913,8 +913,8 @@ discard block |
||
| 913 | 913 | |
| 914 | 914 | $sth = $this->db->prepare($query); |
| 915 | 915 | $sth->execute($query_data); |
| 916 | - $ident_result=''; |
|
| 917 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 916 | + $ident_result = ''; |
|
| 917 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 918 | 918 | { |
| 919 | 919 | $ident_result = $row['flightaware_id']; |
| 920 | 920 | } |
@@ -931,13 +931,13 @@ discard block |
||
| 931 | 931 | { |
| 932 | 932 | global $globalDBdriver, $globalTimezone; |
| 933 | 933 | if ($globalDBdriver == 'mysql') { |
| 934 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 934 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 935 | 935 | WHERE spotter_live.ModeS = :modes |
| 936 | 936 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
| 937 | 937 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
| 938 | 938 | $query_data = array(':modes' => $modes); |
| 939 | 939 | } else { |
| 940 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 940 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
| 941 | 941 | WHERE spotter_live.ModeS = :modes |
| 942 | 942 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
| 943 | 943 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -946,8 +946,8 @@ discard block |
||
| 946 | 946 | |
| 947 | 947 | $sth = $this->db->prepare($query); |
| 948 | 948 | $sth->execute($query_data); |
| 949 | - $ident_result=''; |
|
| 950 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 949 | + $ident_result = ''; |
|
| 950 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 951 | 951 | { |
| 952 | 952 | //$ident_result = $row['spotter_live_id']; |
| 953 | 953 | $ident_result = $row['flightaware_id']; |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | * @return String success or false |
| 967 | 967 | * |
| 968 | 968 | */ |
| 969 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
| 969 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
| 970 | 970 | { |
| 971 | 971 | global $globalURL, $globalArchive, $globalDebug; |
| 972 | 972 | $Common = new Common(); |
@@ -1066,27 +1066,27 @@ discard block |
||
| 1066 | 1066 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
| 1067 | 1067 | |
| 1068 | 1068 | |
| 1069 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
| 1070 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 1071 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 1072 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1073 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1074 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1075 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1076 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
| 1077 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1078 | - $altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1079 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 1080 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 1081 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
| 1082 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
| 1083 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
| 1084 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
| 1085 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 1086 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 1087 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
| 1088 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
| 1089 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
| 1069 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
| 1070 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 1071 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 1072 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1073 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1074 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1075 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1076 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
| 1077 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1078 | + $altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1079 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 1080 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 1081 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
| 1082 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
| 1083 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
| 1084 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
| 1085 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 1086 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 1087 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
| 1088 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
| 1089 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
| 1090 | 1090 | |
| 1091 | 1091 | $airline_name = ''; |
| 1092 | 1092 | $airline_icao = ''; |
@@ -1108,10 +1108,10 @@ discard block |
||
| 1108 | 1108 | $arrival_airport_country = ''; |
| 1109 | 1109 | |
| 1110 | 1110 | |
| 1111 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1112 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1113 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1114 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1111 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
| 1112 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
| 1113 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
| 1114 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
| 1115 | 1115 | |
| 1116 | 1116 | $query = ''; |
| 1117 | 1117 | if ($globalArchive) { |
@@ -1122,19 +1122,19 @@ discard block |
||
| 1122 | 1122 | $query .= 'INSERT INTO spotter_live (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, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country, real_altitude) |
| 1123 | 1123 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country, :real_altitude)'; |
| 1124 | 1124 | |
| 1125 | - $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_type' => $aircraft_type,':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,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country,':real_altitude' => $altitude_real); |
|
| 1125 | + $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_type' => $aircraft_type, ':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, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country, ':real_altitude' => $altitude_real); |
|
| 1126 | 1126 | try { |
| 1127 | 1127 | |
| 1128 | 1128 | $sth = $this->db->prepare($query); |
| 1129 | 1129 | $sth->execute($query_values); |
| 1130 | 1130 | $sth->closeCursor(); |
| 1131 | - } catch(PDOException $e) { |
|
| 1131 | + } catch (PDOException $e) { |
|
| 1132 | 1132 | return "error : ".$e->getMessage(); |
| 1133 | 1133 | } |
| 1134 | 1134 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1135 | 1135 | if ($globalDebug) echo '(Add to SBS archive : '; |
| 1136 | 1136 | $SpotterArchive = new SpotterArchive($this->db); |
| 1137 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
| 1137 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
| 1138 | 1138 | if ($globalDebug) echo $result.')'; |
| 1139 | 1139 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1140 | 1140 | echo '(Not adding to archive)'; |
@@ -1147,7 +1147,7 @@ discard block |
||
| 1147 | 1147 | |
| 1148 | 1148 | public function getOrderBy() |
| 1149 | 1149 | { |
| 1150 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 1150 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC")); |
|
| 1151 | 1151 | return $orderby; |
| 1152 | 1152 | } |
| 1153 | 1153 | |
@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | public function __construct($dbc = null) { |
| 9 | 9 | $Connection = new Connection($dbc); |
| 10 | 10 | $this->db = $Connection->db(); |
| 11 | - if ($this->db === null) die('Error: No DB connection.'); |
|
| 11 | + if ($this->db === null) { |
|
| 12 | + die('Error: No DB connection.'); |
|
| 13 | + } |
|
| 12 | 14 | } |
| 13 | 15 | |
| 14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
| 30 | 32 | if (isset($filter[0]['source'])) { |
| 31 | 33 | $filters = array_merge($filters,$filter); |
| 32 | 34 | } |
| 33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 35 | + if (is_array($globalFilter)) { |
|
| 36 | + $filter = array_merge($filter,$globalFilter); |
|
| 37 | + } |
|
| 34 | 38 | $filter_query_join = ''; |
| 35 | 39 | $filter_query_where = ''; |
| 36 | 40 | foreach($filters as $flt) { |
@@ -119,8 +123,11 @@ discard block |
||
| 119 | 123 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 120 | 124 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
| 121 | 125 | } |
| 122 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
| 123 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
| 126 | + if ($filter_query_where == '' && $where) { |
|
| 127 | + $filter_query_where = ' WHERE'; |
|
| 128 | + } elseif ($filter_query_where != '' && $and) { |
|
| 129 | + $filter_query_where .= ' AND'; |
|
| 130 | + } |
|
| 124 | 131 | if ($filter_query_where != '') { |
| 125 | 132 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
| 126 | 133 | } |
@@ -161,9 +168,13 @@ discard block |
||
| 161 | 168 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
| 162 | 169 | } |
| 163 | 170 | } |
| 164 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
| 171 | + if ($orderby_query == '') { |
|
| 172 | + $orderby_query = ' ORDER BY date DESC'; |
|
| 173 | + } |
|
| 165 | 174 | |
| 166 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 175 | + if (!isset($globalLiveInterval)) { |
|
| 176 | + $globalLiveInterval = '200'; |
|
| 177 | + } |
|
| 167 | 178 | if ($globalDBdriver == 'mysql') { |
| 168 | 179 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
| 169 | 180 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -186,7 +197,9 @@ discard block |
||
| 186 | 197 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 187 | 198 | date_default_timezone_set('UTC'); |
| 188 | 199 | $filter_query = $this->getFilter($filter,true,true); |
| 189 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 200 | + if (!isset($globalLiveInterval)) { |
|
| 201 | + $globalLiveInterval = '200'; |
|
| 202 | + } |
|
| 190 | 203 | if ($globalDBdriver == 'mysql') { |
| 191 | 204 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 192 | 205 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -236,8 +249,12 @@ discard block |
||
| 236 | 249 | } |
| 237 | 250 | $filter_query = $this->getFilter($filter,true,true); |
| 238 | 251 | |
| 239 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
| 240 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
| 252 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
| 253 | + $globalLiveInterval = '200'; |
|
| 254 | + } |
|
| 255 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
| 256 | + $globalMap3DAircraftsLimit = '300'; |
|
| 257 | + } |
|
| 241 | 258 | if ($globalDBdriver == 'mysql') { |
| 242 | 259 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 243 | 260 | /* |
@@ -248,22 +265,32 @@ discard block |
||
| 248 | 265 | */ |
| 249 | 266 | $query = 'SELECT * FROM (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, spotter_archive.date, spotter_archive.format_source |
| 250 | 267 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
| 251 | - if ($usecoord) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 268 | + if ($usecoord) { |
|
| 269 | + $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 270 | + } |
|
| 252 | 271 | $query .= "UNION |
| 253 | 272 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 254 | 273 | FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
| 255 | - if ($usecoord) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 274 | + if ($usecoord) { |
|
| 275 | + $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 276 | + } |
|
| 256 | 277 | $query .= ") AS spotter |
| 257 | 278 | WHERE latitude <> '0' AND longitude <> '0' |
| 258 | 279 | ORDER BY flightaware_id, date"; |
| 259 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 280 | + if ($limit) { |
|
| 281 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 282 | + } |
|
| 260 | 283 | } else { |
| 261 | 284 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 262 | 285 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
| 263 | - if ($usecoord) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 286 | + if ($usecoord) { |
|
| 287 | + $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 288 | + } |
|
| 264 | 289 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 265 | 290 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 266 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 291 | + if ($limit) { |
|
| 292 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 293 | + } |
|
| 267 | 294 | } |
| 268 | 295 | } else { |
| 269 | 296 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -275,21 +302,31 @@ discard block |
||
| 275 | 302 | */ |
| 276 | 303 | $query = "SELECT * FROM (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, spotter_archive.date, spotter_archive.format_source |
| 277 | 304 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
| 278 | - if ($usecoord) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 305 | + if ($usecoord) { |
|
| 306 | + $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 307 | + } |
|
| 279 | 308 | $query .= "UNION |
| 280 | 309 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 281 | 310 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
| 282 | - if ($usecoord) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 311 | + if ($usecoord) { |
|
| 312 | + $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
| 313 | + } |
|
| 283 | 314 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
| 284 | 315 | $query .= "ORDER BY flightaware_id, date"; |
| 285 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 316 | + if ($limit) { |
|
| 317 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 318 | + } |
|
| 286 | 319 | } else { |
| 287 | 320 | $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
| 288 | 321 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date "; |
| 289 | - if ($usecoord) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 322 | + if ($usecoord) { |
|
| 323 | + $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
| 324 | + } |
|
| 290 | 325 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
| 291 | 326 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
| 292 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 327 | + if ($limit) { |
|
| 328 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
| 329 | + } |
|
| 293 | 330 | } |
| 294 | 331 | } |
| 295 | 332 | try { |
@@ -314,7 +351,9 @@ discard block |
||
| 314 | 351 | global $globalDBdriver, $globalLiveInterval; |
| 315 | 352 | $filter_query = $this->getFilter($filter,true,true); |
| 316 | 353 | |
| 317 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 354 | + if (!isset($globalLiveInterval)) { |
|
| 355 | + $globalLiveInterval = '200'; |
|
| 356 | + } |
|
| 318 | 357 | if ($globalDBdriver == 'mysql') { |
| 319 | 358 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
| 320 | 359 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -344,7 +383,9 @@ discard block |
||
| 344 | 383 | { |
| 345 | 384 | global $globalDBdriver, $globalLiveInterval; |
| 346 | 385 | $Spotter = new Spotter($this->db); |
| 347 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 386 | + if (!isset($globalLiveInterval)) { |
|
| 387 | + $globalLiveInterval = '200'; |
|
| 388 | + } |
|
| 348 | 389 | $filter_query = $this->getFilter($filter); |
| 349 | 390 | |
| 350 | 391 | if (is_array($coord)) { |
@@ -352,7 +393,9 @@ discard block |
||
| 352 | 393 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 353 | 394 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 354 | 395 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 355 | - } else return array(); |
|
| 396 | + } else { |
|
| 397 | + return array(); |
|
| 398 | + } |
|
| 356 | 399 | if ($globalDBdriver == 'mysql') { |
| 357 | 400 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
| 358 | 401 | } else { |
@@ -373,7 +416,9 @@ discard block |
||
| 373 | 416 | { |
| 374 | 417 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
| 375 | 418 | $Spotter = new Spotter($this->db); |
| 376 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
| 419 | + if (!isset($globalLiveInterval)) { |
|
| 420 | + $globalLiveInterval = '200'; |
|
| 421 | + } |
|
| 377 | 422 | $filter_query = $this->getFilter($filter,true,true); |
| 378 | 423 | |
| 379 | 424 | if (is_array($coord)) { |
@@ -381,7 +426,9 @@ discard block |
||
| 381 | 426 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 382 | 427 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 383 | 428 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
| 384 | - } else return array(); |
|
| 429 | + } else { |
|
| 430 | + return array(); |
|
| 431 | + } |
|
| 385 | 432 | if ($globalDBdriver == 'mysql') { |
| 386 | 433 | if (isset($globalArchive) && $globalArchive === TRUE) { |
| 387 | 434 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -608,11 +655,15 @@ discard block |
||
| 608 | 655 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
| 609 | 656 | if ($globalDBdriver == 'mysql') { |
| 610 | 657 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 611 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 658 | + if ($liveinterval) { |
|
| 659 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
| 660 | + } |
|
| 612 | 661 | $query .= ' ORDER BY date'; |
| 613 | 662 | } else { |
| 614 | 663 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
| 615 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 664 | + if ($liveinterval) { |
|
| 665 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
| 666 | + } |
|
| 616 | 667 | $query .= ' ORDER BY date'; |
| 617 | 668 | } |
| 618 | 669 | |
@@ -707,7 +758,9 @@ discard block |
||
| 707 | 758 | $i++; |
| 708 | 759 | $j++; |
| 709 | 760 | if ($j == 30) { |
| 710 | - if ($globalDebug) echo "."; |
|
| 761 | + if ($globalDebug) { |
|
| 762 | + echo "."; |
|
| 763 | + } |
|
| 711 | 764 | try { |
| 712 | 765 | |
| 713 | 766 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -1014,7 +1067,9 @@ discard block |
||
| 1014 | 1067 | { |
| 1015 | 1068 | return false; |
| 1016 | 1069 | } |
| 1017 | - } else return ''; |
|
| 1070 | + } else { |
|
| 1071 | + return ''; |
|
| 1072 | + } |
|
| 1018 | 1073 | |
| 1019 | 1074 | if ($longitude != '') |
| 1020 | 1075 | { |
@@ -1022,7 +1077,9 @@ discard block |
||
| 1022 | 1077 | { |
| 1023 | 1078 | return false; |
| 1024 | 1079 | } |
| 1025 | - } else return ''; |
|
| 1080 | + } else { |
|
| 1081 | + return ''; |
|
| 1082 | + } |
|
| 1026 | 1083 | |
| 1027 | 1084 | if ($waypoints != '') |
| 1028 | 1085 | { |
@@ -1038,14 +1095,18 @@ discard block |
||
| 1038 | 1095 | { |
| 1039 | 1096 | return false; |
| 1040 | 1097 | } |
| 1041 | - } else $altitude = 0; |
|
| 1098 | + } else { |
|
| 1099 | + $altitude = 0; |
|
| 1100 | + } |
|
| 1042 | 1101 | if ($altitude_real != '') |
| 1043 | 1102 | { |
| 1044 | 1103 | if (!is_numeric($altitude_real)) |
| 1045 | 1104 | { |
| 1046 | 1105 | return false; |
| 1047 | 1106 | } |
| 1048 | - } else $altitude_real = 0; |
|
| 1107 | + } else { |
|
| 1108 | + $altitude_real = 0; |
|
| 1109 | + } |
|
| 1049 | 1110 | |
| 1050 | 1111 | if ($heading != '') |
| 1051 | 1112 | { |
@@ -1053,7 +1114,9 @@ discard block |
||
| 1053 | 1114 | { |
| 1054 | 1115 | return false; |
| 1055 | 1116 | } |
| 1056 | - } else $heading = 0; |
|
| 1117 | + } else { |
|
| 1118 | + $heading = 0; |
|
| 1119 | + } |
|
| 1057 | 1120 | |
| 1058 | 1121 | if ($groundspeed != '') |
| 1059 | 1122 | { |
@@ -1061,9 +1124,13 @@ discard block |
||
| 1061 | 1124 | { |
| 1062 | 1125 | return false; |
| 1063 | 1126 | } |
| 1064 | - } else $groundspeed = 0; |
|
| 1127 | + } else { |
|
| 1128 | + $groundspeed = 0; |
|
| 1129 | + } |
|
| 1065 | 1130 | date_default_timezone_set('UTC'); |
| 1066 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
| 1131 | + if ($date == '') { |
|
| 1132 | + $date = date("Y-m-d H:i:s", time()); |
|
| 1133 | + } |
|
| 1067 | 1134 | |
| 1068 | 1135 | |
| 1069 | 1136 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1108,14 +1175,24 @@ discard block |
||
| 1108 | 1175 | $arrival_airport_country = ''; |
| 1109 | 1176 | |
| 1110 | 1177 | |
| 1111 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
| 1112 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
| 1113 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
| 1114 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
| 1178 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
| 1179 | + $squawk = NULL; |
|
| 1180 | + } |
|
| 1181 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
| 1182 | + $verticalrate = NULL; |
|
| 1183 | + } |
|
| 1184 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
| 1185 | + $groundspeed = 0; |
|
| 1186 | + } |
|
| 1187 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
| 1188 | + $heading = 0; |
|
| 1189 | + } |
|
| 1115 | 1190 | |
| 1116 | 1191 | $query = ''; |
| 1117 | 1192 | if ($globalArchive) { |
| 1118 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
| 1193 | + if ($globalDebug) { |
|
| 1194 | + echo '-- Delete previous data -- '; |
|
| 1195 | + } |
|
| 1119 | 1196 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
| 1120 | 1197 | } |
| 1121 | 1198 | |
@@ -1132,10 +1209,14 @@ discard block |
||
| 1132 | 1209 | return "error : ".$e->getMessage(); |
| 1133 | 1210 | } |
| 1134 | 1211 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
| 1135 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
| 1212 | + if ($globalDebug) { |
|
| 1213 | + echo '(Add to SBS archive : '; |
|
| 1214 | + } |
|
| 1136 | 1215 | $SpotterArchive = new SpotterArchive($this->db); |
| 1137 | 1216 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
| 1138 | - if ($globalDebug) echo $result.')'; |
|
| 1217 | + if ($globalDebug) { |
|
| 1218 | + echo $result.')'; |
|
| 1219 | + } |
|
| 1139 | 1220 | } elseif ($globalDebug && $putinarchive !== true) { |
| 1140 | 1221 | echo '(Not adding to archive)'; |
| 1141 | 1222 | } elseif ($globalDebug && $noarchive === true) { |
@@ -40,8 +40,12 @@ discard block |
||
| 40 | 40 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
| 41 | 41 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
| 42 | 42 | $filter = array(); |
| 43 | - if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
| 44 | - if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
| 43 | + if ($year != '') { |
|
| 44 | + $filter = array_merge($filter,array('year' => $year)); |
|
| 45 | + } |
|
| 46 | + if ($month != '') { |
|
| 47 | + $filter = array_merge($filter,array('month' => $month)); |
|
| 48 | + } |
|
| 45 | 49 | if ($sort != '') |
| 46 | 50 | { |
| 47 | 51 | $spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter); |
@@ -59,8 +63,12 @@ discard block |
||
| 59 | 63 | { |
| 60 | 64 | $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']); |
| 61 | 65 | //$ident = $spotter_array[0]['ident']; |
| 62 | - if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
|
| 63 | - if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
|
| 66 | + if (isset($spotter_array[0]['latitude'])) { |
|
| 67 | + $latitude = $spotter_array[0]['latitude']; |
|
| 68 | + } |
|
| 69 | + if (isset($spotter_array[0]['longitude'])) { |
|
| 70 | + $longitude = $spotter_array[0]['longitude']; |
|
| 71 | + } |
|
| 64 | 72 | require_once('header.php'); |
| 65 | 73 | /* |
| 66 | 74 | if (isset($globalArchive) && $globalArchive) { |
@@ -115,9 +123,14 @@ discard block |
||
| 115 | 123 | print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>'; |
| 116 | 124 | //print '<div><span class="label">'._("Owner").'</span>'.$spotter_array[0]['aircraft_owner'].'</div>'; |
| 117 | 125 | $Stats = new Stats(); |
| 118 | - if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner); |
|
| 119 | - else $flights = 0; |
|
| 120 | - if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter); |
|
| 126 | + if ($year == '' && $month == '') { |
|
| 127 | + $flights = $Stats->getStatsOwner($owner); |
|
| 128 | + } else { |
|
| 129 | + $flights = 0; |
|
| 130 | + } |
|
| 131 | + if ($flights == 0) { |
|
| 132 | + $flights = $Spotter->countFlightsByOwner($owner,$filter); |
|
| 133 | + } |
|
| 121 | 134 | print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>'; |
| 122 | 135 | $aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter)); |
| 123 | 136 | print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>'; |
@@ -128,7 +141,9 @@ discard block |
||
| 128 | 141 | $airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter)); |
| 129 | 142 | print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>'; |
| 130 | 143 | $duration = $Spotter->getFlightDurationByOwner($owner,$filter); |
| 131 | - if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>'; |
|
| 144 | + if ($duration != '0') { |
|
| 145 | + print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>'; |
|
| 146 | + } |
|
| 132 | 147 | print '</div>'; |
| 133 | 148 | |
| 134 | 149 | include('owner-sub-menu.php'); |
@@ -7,14 +7,14 @@ discard block |
||
| 7 | 7 | //require_once('require/class.SpotterLive.php'); |
| 8 | 8 | require_once('require/class.SpotterArchive.php'); |
| 9 | 9 | |
| 10 | -if (!isset($_GET['owner'])){ |
|
| 10 | +if (!isset($_GET['owner'])) { |
|
| 11 | 11 | header('Location: '.$globalURL.''); |
| 12 | 12 | } else { |
| 13 | 13 | $Spotter = new Spotter(); |
| 14 | 14 | $SpotterArchive = new SpotterArchive(); |
| 15 | 15 | //$Translation = new Translation(); |
| 16 | 16 | //calculuation for the pagination |
| 17 | - if(!isset($_GET['limit'])) |
|
| 17 | + if (!isset($_GET['limit'])) |
|
| 18 | 18 | { |
| 19 | 19 | $limit_start = 0; |
| 20 | 20 | $limit_end = 25; |
@@ -35,23 +35,23 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | $page_url = $globalURL.'/owner/'.$_GET['owner']; |
| 37 | 37 | |
| 38 | - $owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING); |
|
| 39 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 40 | - $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
| 41 | - $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
| 38 | + $owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING); |
|
| 39 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 40 | + $year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
| 41 | + $month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
| 42 | 42 | $filter = array(); |
| 43 | - if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
| 44 | - if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
| 43 | + if ($year != '') $filter = array_merge($filter, array('year' => $year)); |
|
| 44 | + if ($month != '') $filter = array_merge($filter, array('month' => $month)); |
|
| 45 | 45 | if ($sort != '') |
| 46 | 46 | { |
| 47 | - $spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter); |
|
| 47 | + $spotter_array = $Spotter->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, $sort, $filter); |
|
| 48 | 48 | /* |
| 49 | 49 | if (empty($spotter_array)) { |
| 50 | 50 | $spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter); |
| 51 | 51 | } |
| 52 | 52 | */ |
| 53 | 53 | } else { |
| 54 | - $spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference,'',$filter); |
|
| 54 | + $spotter_array = $Spotter->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, '', $filter); |
|
| 55 | 55 | /* |
| 56 | 56 | if (empty($spotter_array)) { |
| 57 | 57 | $spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference,'',$filter); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | if (!empty($spotter_array)) |
| 63 | 63 | { |
| 64 | - $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']); |
|
| 64 | + $title = sprintf(_("Detailed View for %s"), $spotter_array[0]['aircraft_owner']); |
|
| 65 | 65 | //$ident = $spotter_array[0]['ident']; |
| 66 | 66 | if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
| 67 | 67 | if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
@@ -121,23 +121,23 @@ discard block |
||
| 121 | 121 | $Stats = new Stats(); |
| 122 | 122 | if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner); |
| 123 | 123 | else $flights = 0; |
| 124 | - if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter); |
|
| 124 | + if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner, $filter); |
|
| 125 | 125 | print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>'; |
| 126 | - $aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter)); |
|
| 126 | + $aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner, $filter)); |
|
| 127 | 127 | print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>'; |
| 128 | - $aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner,$filter)); |
|
| 128 | + $aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner, $filter)); |
|
| 129 | 129 | print '<div><span class="label">'._("Aircrafts").'</span>'.$aircraft_registration.'</div>'; |
| 130 | - $aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner,$filter)); |
|
| 130 | + $aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner, $filter)); |
|
| 131 | 131 | print '<div><span class="label">'._("Manufacturers").'</span>'.$aircraft_manufacturer.'</div>'; |
| 132 | - $airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter)); |
|
| 132 | + $airlines = count($Spotter->countAllAirlinesByOwner($owner, $filter)); |
|
| 133 | 133 | print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>'; |
| 134 | - $duration = $Spotter->getFlightDurationByOwner($owner,$filter); |
|
| 134 | + $duration = $Spotter->getFlightDurationByOwner($owner, $filter); |
|
| 135 | 135 | if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>'; |
| 136 | 136 | print '</div>'; |
| 137 | 137 | |
| 138 | 138 | include('owner-sub-menu.php'); |
| 139 | 139 | print '<div class="table column">'; |
| 140 | - print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the owner <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>'; |
|
| 140 | + print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the owner <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>'; |
|
| 141 | 141 | |
| 142 | 142 | include('table-output.php'); |
| 143 | 143 | print '<div class="pagination">'; |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | </span> |
| 4 | 4 | <div class="sub-menu sub-menu-container"> |
| 5 | 5 | <ul class="nav nav-pills"> |
| 6 | - <li><a href="<?php print $globalURL; ?>/flightid/<?php print $id; ?>" <?php if (strtolower($current_page) == "flightid-overview"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
| 6 | + <li><a href="<?php print $globalURL; ?>/flightid/<?php print $id; ?>" <?php if (strtolower($current_page) == "flightid-overview") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
| 7 | 7 | <?php if ($globalFlightAware) { ?> |
| 8 | 8 | <li><a href="http://flightaware.com/live/flight/id/<?php print $spotter_array[0]['flightaware_id']; ?>" target="_blank"><?php echo _("Flight Status"); ?>»</a></li> |
| 9 | 9 | <li><a href="http://flightaware.com/live/flight/id/<?php print $spotter_array[0]['flightaware_id']; ?>/tracklog" target="_blank"><?php echo _("Flight Log"); ?>»</a></li> |
@@ -3,10 +3,10 @@ discard block |
||
| 3 | 3 | </span> |
| 4 | 4 | <div class="sub-menu sub-menu-container"> |
| 5 | 5 | <ul class="nav nav-pills"> |
| 6 | - <li><a href="<?php print $globalURL; ?>/aircraft/<?php print $aircraft_type; ?>" <?php if (strtolower($current_page) == "aircraft-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
| 7 | - <li><a href="<?php print $globalURL; ?>/aircraft/statistics/registration/<?php print $aircraft_type; ?>" <?php if (strtolower($current_page) == "aircraft-statistics-registration"){ print 'class="active"'; } ?>><?php echo _("Registration"); ?></a></li> |
|
| 6 | + <li><a href="<?php print $globalURL; ?>/aircraft/<?php print $aircraft_type; ?>" <?php if (strtolower($current_page) == "aircraft-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li> |
|
| 7 | + <li><a href="<?php print $globalURL; ?>/aircraft/statistics/registration/<?php print $aircraft_type; ?>" <?php if (strtolower($current_page) == "aircraft-statistics-registration") { print 'class="active"'; } ?>><?php echo _("Registration"); ?></a></li> |
|
| 8 | 8 | <li class="dropdown"> |
| 9 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "aircraft-statistics-airline" || strtolower($current_page) == "aircraft-statistics-airline-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
| 9 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "aircraft-statistics-airline" || strtolower($current_page) == "aircraft-statistics-airline-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
| 10 | 10 | <?php echo _("Airline"); ?> <span class="caret"></span> |
| 11 | 11 | </a> |
| 12 | 12 | <ul class="dropdown-menu" role="menu"> |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | </ul> |
| 16 | 16 | </li> |
| 17 | 17 | <li class="dropdown"> |
| 18 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "aircraft-statistics-departure-airport" || strtolower($current_page) == "aircraft-statistics-departure-airport-country" || strtolower($current_page) == "aircraft-statistics-arrival-airport" || strtolower($current_page) == "aircraft-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
| 18 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "aircraft-statistics-departure-airport" || strtolower($current_page) == "aircraft-statistics-departure-airport-country" || strtolower($current_page) == "aircraft-statistics-arrival-airport" || strtolower($current_page) == "aircraft-statistics-arrival-airport-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
| 19 | 19 | <?php echo _("Airport"); ?> <span class="caret"></span> |
| 20 | 20 | </a> |
| 21 | 21 | <ul class="dropdown-menu" role="menu"> |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | <li><a href="<?php print $globalURL; ?>/aircraft/statistics/arrival-airport-country/<?php print $aircraft_type; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li> |
| 26 | 26 | </ul> |
| 27 | 27 | </li> |
| 28 | - <li><a href="<?php print $globalURL; ?>/aircraft/statistics/route/<?php print $aircraft_type; ?>" <?php if (strtolower($current_page) == "aircraft-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
| 29 | - <li><a href="<?php print $globalURL; ?>/aircraft/statistics/time/<?php print $aircraft_type; ?>" <?php if (strtolower($current_page) == "aircraft-statistics-time"){ print 'class="active"'; } ?>><?php echo ("Time"); ?></a></li> |
|
| 28 | + <li><a href="<?php print $globalURL; ?>/aircraft/statistics/route/<?php print $aircraft_type; ?>" <?php if (strtolower($current_page) == "aircraft-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li> |
|
| 29 | + <li><a href="<?php print $globalURL; ?>/aircraft/statistics/time/<?php print $aircraft_type; ?>" <?php if (strtolower($current_page) == "aircraft-statistics-time") { print 'class="active"'; } ?>><?php echo ("Time"); ?></a></li> |
|
| 30 | 30 | </ul> |
| 31 | 31 | </div> |
| 32 | 32 | \ No newline at end of file |
@@ -7,15 +7,15 @@ discard block |
||
| 7 | 7 | require_once('require/class.Connection.php'); |
| 8 | 8 | require_once('require/class.Spotter.php'); |
| 9 | 9 | require_once('require/class.Language.php'); |
| 10 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 11 | -$departure_airport = filter_input(INPUT_GET,'departure_airport',FILTER_SANITIZE_STRING); |
|
| 12 | -$arrival_airport = filter_input(INPUT_GET,'arrival_airport',FILTER_SANITIZE_STRING); |
|
| 10 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 11 | +$departure_airport = filter_input(INPUT_GET, 'departure_airport', FILTER_SANITIZE_STRING); |
|
| 12 | +$arrival_airport = filter_input(INPUT_GET, 'arrival_airport', FILTER_SANITIZE_STRING); |
|
| 13 | 13 | $Spotter = new Spotter(); |
| 14 | 14 | $spotter_array = $Spotter->getSpotterDataByRoute($departure_airport, $arrival_airport, "0,1", $sort); |
| 15 | 15 | |
| 16 | 16 | if (!empty($spotter_array)) |
| 17 | 17 | { |
| 18 | - $title = sprintf(_("Most Common Aircraft between %s (%s), %s - %s (%s), %s"),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']); |
|
| 18 | + $title = sprintf(_("Most Common Aircraft between %s (%s), %s - %s (%s), %s"), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']); |
|
| 19 | 19 | require_once('header.php'); |
| 20 | 20 | print '<div class="info column">'; |
| 21 | 21 | print '<h1>'._("Flights between").' '.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].' - '.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</h1>'; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | include('route-sub-menu.php'); |
| 27 | 27 | print '<div class="column">'; |
| 28 | 28 | print '<h2>'._("Most Common Aircraft").'</h2>'; |
| 29 | - print '<p>'.sprintf(_("The statistic below shows the most common aircrafts of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']).'</p>'; |
|
| 29 | + print '<p>'.sprintf(_("The statistic below shows the most common aircrafts of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']).'</p>'; |
|
| 30 | 30 | |
| 31 | 31 | $aircraft_array = $Spotter->countAllAircraftTypesByRoute($departure_airport, $arrival_airport); |
| 32 | 32 | if (!empty($aircraft_array)) |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | print '</thead>'; |
| 42 | 42 | print '<tbody>'; |
| 43 | 43 | $i = 1; |
| 44 | - foreach($aircraft_array as $aircraft_item) |
|
| 44 | + foreach ($aircraft_array as $aircraft_item) |
|
| 45 | 45 | { |
| 46 | 46 | print '<tr>'; |
| 47 | 47 | print '<td><strong>'.$i.'</strong></td>'; |