@@ -5,11 +5,15 @@ |
||
5 | 5 | $Stats = new Stats(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Departure Airport"); |
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 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
14 | 18 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
15 | 19 | require_once('header.php'); |
@@ -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 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
14 | 14 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
@@ -6,12 +6,12 @@ discard block |
||
6 | 6 | $title = _("Statistics").' - '._("Most common Departure Airport"); |
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 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
14 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
13 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
14 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
15 | 15 | require_once('header.php'); |
16 | 16 | |
17 | 17 | include('statistics-sub-menu.php'); |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | </div> |
24 | 24 | <p>'._("Below are the <strong>Top 10</strong> most common departure airports.").'</p>'; |
25 | 25 | |
26 | -$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month); |
|
26 | +$airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month); |
|
27 | 27 | print '<div id="chartAirport" class="chart" width="100%"></div>'; |
28 | 28 | print '<script>'; |
29 | 29 | print 'var series = ['; |
30 | 30 | $airport_data = ''; |
31 | -foreach($airport_airport_array as $airport_item) |
|
31 | +foreach ($airport_airport_array as $airport_item) |
|
32 | 32 | { |
33 | 33 | $airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],'; |
34 | 34 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | print '</thead>'; |
83 | 83 | print '<tbody>'; |
84 | 84 | $i = 1; |
85 | -foreach($airport_airport_array as $airport_item) |
|
85 | +foreach ($airport_airport_array as $airport_item) |
|
86 | 86 | { |
87 | 87 | print '<tr>'; |
88 | 88 | 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 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
@@ -5,11 +5,15 @@ |
||
5 | 5 | $Stats = new Stats(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Aircraft Manufacturer"); |
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 | |
14 | 18 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
15 | 19 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
@@ -6,13 +6,13 @@ discard block |
||
6 | 6 | $title = _("Statistics").' - '._("Most common Aircraft Manufacturer"); |
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 | 13 | |
14 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
15 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
14 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
15 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
16 | 16 | |
17 | 17 | require_once('header.php'); |
18 | 18 | include('statistics-sub-menu.php'); |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | </div> |
25 | 25 | <p>'._("Below are the <strong>Top 10</strong> most common aircraft manufacturers.").'</p>'; |
26 | 26 | |
27 | -$manufacturers_array = $Stats->countAllAircraftManufacturers(true,$airline_icao,$filter_name,$year,$month); |
|
27 | +$manufacturers_array = $Stats->countAllAircraftManufacturers(true, $airline_icao, $filter_name, $year, $month); |
|
28 | 28 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
29 | 29 | $manufacturer_data = ''; |
30 | -foreach($manufacturers_array as $manufacturer_item) |
|
30 | +foreach ($manufacturers_array as $manufacturer_item) |
|
31 | 31 | { |
32 | 32 | $manufacturer_data .= '[ "'.$manufacturer_item['aircraft_manufacturer'].'",'.$manufacturer_item['aircraft_manufacturer_count'].'],'; |
33 | 33 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | print '</thead>'; |
53 | 53 | print '<tbody>'; |
54 | 54 | $i = 1; |
55 | - foreach($manufacturers_array as $manufacturer_item) |
|
55 | + foreach ($manufacturers_array as $manufacturer_item) |
|
56 | 56 | { |
57 | 57 | print '<tr>'; |
58 | 58 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -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 | { |
@@ -12,8 +12,12 @@ |
||
12 | 12 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
13 | 13 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
14 | 14 | $filter = array(); |
15 | -if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
16 | -if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
15 | +if ($year != '') { |
|
16 | + $filter = array_merge($filter,array('year' => $year)); |
|
17 | +} |
|
18 | +if ($month != '') { |
|
19 | + $filter = array_merge($filter,array('month' => $month)); |
|
20 | +} |
|
17 | 21 | $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter); |
18 | 22 | |
19 | 23 | if (!empty($spotter_array)) |
@@ -3,8 +3,8 @@ |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | if (!isset($_GET['owner'])) { |
6 | - header('Location: '.$globalURL.'/owner'); |
|
7 | - die(); |
|
6 | + header('Location: '.$globalURL.'/owner'); |
|
7 | + die(); |
|
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | $owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING)); |
@@ -7,18 +7,18 @@ discard block |
||
7 | 7 | die(); |
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | -$owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING)); |
|
11 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
12 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
13 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
10 | +$owner = urldecode(filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING)); |
|
11 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
12 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
13 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
14 | 14 | $filter = array(); |
15 | -if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
16 | -if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
17 | -$spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter); |
|
15 | +if ($year != '') $filter = array_merge($filter, array('year' => $year)); |
|
16 | +if ($month != '') $filter = array_merge($filter, array('month' => $month)); |
|
17 | +$spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", $sort, $filter); |
|
18 | 18 | |
19 | 19 | if (!empty($spotter_array)) |
20 | 20 | { |
21 | - $title = sprintf(_("Most Common Aircraft by Registration of %s"),$spotter_array[0]['aircraft_owner']); |
|
21 | + $title = sprintf(_("Most Common Aircraft by Registration of %s"), $spotter_array[0]['aircraft_owner']); |
|
22 | 22 | require_once('header.php'); |
23 | 23 | print '<div class="info column">'; |
24 | 24 | print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>'; |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | include('owner-sub-menu.php'); |
30 | 30 | print '<div class="column">'; |
31 | 31 | print '<h2>'._("Most Common Aircraft by Registration").'</h2>'; |
32 | - print '<p>'.sprintf(_("The statistic below shows the most common aircraft by Registration of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>'; |
|
32 | + print '<p>'.sprintf(_("The statistic below shows the most common aircraft by Registration of flights owned by <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>'; |
|
33 | 33 | |
34 | - $aircraft_array = $Spotter->countAllAircraftRegistrationByOwner($owner,$filter); |
|
34 | + $aircraft_array = $Spotter->countAllAircraftRegistrationByOwner($owner, $filter); |
|
35 | 35 | |
36 | 36 | if (!empty($aircraft_array)) |
37 | 37 | { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | print '</thead>'; |
48 | 48 | print '<tbody>'; |
49 | 49 | $i = 1; |
50 | - foreach($aircraft_array as $aircraft_item) |
|
50 | + foreach ($aircraft_array as $aircraft_item) |
|
51 | 51 | { |
52 | 52 | print '<tr>'; |
53 | 53 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -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,13 +82,13 @@ 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 | 88 | if (count($filter['source']) == 1) { |
89 | 89 | $filter_query_where .= " AND format_source = '".$filter['source'][0]."'"; |
90 | 90 | } else { |
91 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
91 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
119 | 119 | } |
120 | 120 | } |
121 | - $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"; |
|
121 | + $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"; |
|
122 | 122 | } |
123 | 123 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
124 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
124 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
125 | 125 | } |
126 | 126 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
127 | 127 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
128 | 128 | if ($filter_query_where != '') { |
129 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
129 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
130 | 130 | } |
131 | 131 | $filter_query = $filter_query_join.$filter_query_where; |
132 | 132 | return $filter_query; |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | if ($limit != '') |
150 | 150 | { |
151 | 151 | $limit_array = explode(',', $limit); |
152 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
153 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
152 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
153 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
154 | 154 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
155 | 155 | { |
156 | 156 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | } else { |
175 | 175 | $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; |
176 | 176 | } |
177 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
177 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
178 | 178 | |
179 | 179 | return $spotter_array; |
180 | 180 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | { |
190 | 190 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
191 | 191 | date_default_timezone_set('UTC'); |
192 | - $filter_query = $this->getFilter($filter,true,true); |
|
192 | + $filter_query = $this->getFilter($filter, true, true); |
|
193 | 193 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
194 | 194 | if ($globalDBdriver == 'mysql') { |
195 | 195 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | $sth = $this->db->prepare($query); |
214 | 214 | $sth->execute(); |
215 | - } catch(PDOException $e) { |
|
215 | + } catch (PDOException $e) { |
|
216 | 216 | echo $e->getMessage(); |
217 | 217 | die; |
218 | 218 | } |
@@ -226,19 +226,19 @@ discard block |
||
226 | 226 | * @return Array the spotter information |
227 | 227 | * |
228 | 228 | */ |
229 | - public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false) |
|
229 | + public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = false) |
|
230 | 230 | { |
231 | 231 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit; |
232 | 232 | date_default_timezone_set('UTC'); |
233 | 233 | $usecoord = false; |
234 | 234 | if (is_array($coord) && !empty($coord)) { |
235 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
236 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
237 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
238 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
235 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
236 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
237 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
238 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
239 | 239 | $usecoord = true; |
240 | 240 | } |
241 | - $filter_query = $this->getFilter($filter,true,true); |
|
241 | + $filter_query = $this->getFilter($filter, true, true); |
|
242 | 242 | |
243 | 243 | if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
244 | 244 | if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | try { |
300 | 300 | $sth = $this->db->prepare($query); |
301 | 301 | $sth->execute(); |
302 | - } catch(PDOException $e) { |
|
302 | + } catch (PDOException $e) { |
|
303 | 303 | echo $e->getMessage(); |
304 | 304 | die; |
305 | 305 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | public function getLiveSpotterCount($filter = array()) |
317 | 317 | { |
318 | 318 | global $globalDBdriver, $globalLiveInterval; |
319 | - $filter_query = $this->getFilter($filter,true,true); |
|
319 | + $filter_query = $this->getFilter($filter, true, true); |
|
320 | 320 | |
321 | 321 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
322 | 322 | if ($globalDBdriver == 'mysql') { |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | try { |
330 | 330 | $sth = $this->db->prepare($query); |
331 | 331 | $sth->execute(); |
332 | - } catch(PDOException $e) { |
|
332 | + } catch (PDOException $e) { |
|
333 | 333 | echo $e->getMessage(); |
334 | 334 | die; |
335 | 335 | } |
@@ -352,10 +352,10 @@ discard block |
||
352 | 352 | $filter_query = $this->getFilter($filter); |
353 | 353 | |
354 | 354 | if (is_array($coord)) { |
355 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
356 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
357 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
358 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
355 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
356 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
357 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
358 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
359 | 359 | } else return array(); |
360 | 360 | if ($globalDBdriver == 'mysql') { |
361 | 361 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -378,23 +378,23 @@ discard block |
||
378 | 378 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
379 | 379 | $Spotter = new Spotter($this->db); |
380 | 380 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
381 | - $filter_query = $this->getFilter($filter,true,true); |
|
381 | + $filter_query = $this->getFilter($filter, true, true); |
|
382 | 382 | |
383 | 383 | if (is_array($coord)) { |
384 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
385 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
386 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
387 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
384 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
385 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
386 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
387 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
388 | 388 | } else return array(); |
389 | 389 | if ($globalDBdriver == 'mysql') { |
390 | 390 | if (isset($globalArchive) && $globalArchive === TRUE) { |
391 | - $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 |
|
391 | + $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 |
|
392 | 392 | FROM spotter_live |
393 | 393 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
394 | 394 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
395 | 395 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0'; |
396 | 396 | } else { |
397 | - $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 |
|
397 | + $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 |
|
398 | 398 | FROM spotter_live |
399 | 399 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
400 | 400 | FROM spotter_live l |
@@ -406,14 +406,14 @@ discard block |
||
406 | 406 | } |
407 | 407 | } else { |
408 | 408 | if (isset($globalArchive) && $globalArchive === TRUE) { |
409 | - $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 |
|
409 | + $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 |
|
410 | 410 | FROM spotter_live |
411 | 411 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
412 | 412 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
413 | 413 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
414 | 414 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
415 | 415 | } else { |
416 | - $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 |
|
416 | + $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 |
|
417 | 417 | FROM spotter_live |
418 | 418 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
419 | 419 | FROM spotter_live l |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | try { |
429 | 429 | $sth = $this->db->prepare($query); |
430 | 430 | $sth->execute(); |
431 | - } catch(PDOException $e) { |
|
431 | + } catch (PDOException $e) { |
|
432 | 432 | echo $e->getMessage(); |
433 | 433 | die; |
434 | 434 | } |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | if ($interval == '1m') |
478 | 478 | { |
479 | 479 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
480 | - } else if ($interval == '15m'){ |
|
480 | + } else if ($interval == '15m') { |
|
481 | 481 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
482 | 482 | } |
483 | 483 | } |
@@ -485,14 +485,14 @@ discard block |
||
485 | 485 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
486 | 486 | } |
487 | 487 | |
488 | - $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 |
|
488 | + $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 |
|
489 | 489 | WHERE spotter_live.latitude <> '' |
490 | 490 | AND spotter_live.longitude <> '' |
491 | 491 | ".$additional_query." |
492 | 492 | HAVING distance < :radius |
493 | 493 | ORDER BY distance"; |
494 | 494 | |
495 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
495 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
496 | 496 | |
497 | 497 | return $spotter_array; |
498 | 498 | } |
@@ -510,9 +510,9 @@ discard block |
||
510 | 510 | date_default_timezone_set('UTC'); |
511 | 511 | |
512 | 512 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
513 | - $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'; |
|
513 | + $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'; |
|
514 | 514 | |
515 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
515 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
516 | 516 | |
517 | 517 | return $spotter_array; |
518 | 518 | } |
@@ -523,16 +523,16 @@ discard block |
||
523 | 523 | * @return Array the spotter information |
524 | 524 | * |
525 | 525 | */ |
526 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
526 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
527 | 527 | { |
528 | 528 | $Spotter = new Spotter($this->db); |
529 | 529 | date_default_timezone_set('UTC'); |
530 | 530 | |
531 | 531 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
532 | - $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'; |
|
532 | + $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'; |
|
533 | 533 | |
534 | - $date = date('c',$date); |
|
535 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
534 | + $date = date('c', $date); |
|
535 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
536 | 536 | |
537 | 537 | return $spotter_array; |
538 | 538 | } |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | $Spotter = new Spotter($this->db); |
549 | 549 | date_default_timezone_set('UTC'); |
550 | 550 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
551 | - $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'; |
|
552 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
551 | + $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'; |
|
552 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
553 | 553 | return $spotter_array; |
554 | 554 | } |
555 | 555 | |
@@ -559,15 +559,15 @@ discard block |
||
559 | 559 | * @return Array the spotter information |
560 | 560 | * |
561 | 561 | */ |
562 | - public function getDateLiveSpotterDataById($id,$date) |
|
562 | + public function getDateLiveSpotterDataById($id, $date) |
|
563 | 563 | { |
564 | 564 | $Spotter = new Spotter($this->db); |
565 | 565 | date_default_timezone_set('UTC'); |
566 | 566 | |
567 | 567 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
568 | - $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'; |
|
569 | - $date = date('c',$date); |
|
570 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
568 | + $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'; |
|
569 | + $date = date('c', $date); |
|
570 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
571 | 571 | return $spotter_array; |
572 | 572 | } |
573 | 573 | |
@@ -583,13 +583,13 @@ discard block |
||
583 | 583 | date_default_timezone_set('UTC'); |
584 | 584 | |
585 | 585 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
586 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
586 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
587 | 587 | |
588 | 588 | try { |
589 | 589 | |
590 | 590 | $sth = $this->db->prepare($query); |
591 | 591 | $sth->execute(array(':ident' => $ident)); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | echo $e->getMessage(); |
594 | 594 | die; |
595 | 595 | } |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | * @return Array the spotter information |
605 | 605 | * |
606 | 606 | */ |
607 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
607 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
608 | 608 | { |
609 | 609 | global $globalDBdriver, $globalLiveInterval; |
610 | 610 | date_default_timezone_set('UTC'); |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | try { |
624 | 624 | $sth = $this->db->prepare($query); |
625 | 625 | $sth->execute(array(':id' => $id)); |
626 | - } catch(PDOException $e) { |
|
626 | + } catch (PDOException $e) { |
|
627 | 627 | echo $e->getMessage(); |
628 | 628 | die; |
629 | 629 | } |
@@ -641,12 +641,12 @@ discard block |
||
641 | 641 | { |
642 | 642 | date_default_timezone_set('UTC'); |
643 | 643 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
644 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
644 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
645 | 645 | try { |
646 | 646 | |
647 | 647 | $sth = $this->db->prepare($query); |
648 | 648 | $sth->execute(array(':ident' => $ident)); |
649 | - } catch(PDOException $e) { |
|
649 | + } catch (PDOException $e) { |
|
650 | 650 | echo $e->getMessage(); |
651 | 651 | die; |
652 | 652 | } |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | |
677 | 677 | $sth = $this->db->prepare($query); |
678 | 678 | $sth->execute(); |
679 | - } catch(PDOException $e) { |
|
679 | + } catch (PDOException $e) { |
|
680 | 680 | return "error"; |
681 | 681 | } |
682 | 682 | |
@@ -699,14 +699,14 @@ discard block |
||
699 | 699 | |
700 | 700 | $sth = $this->db->prepare($query); |
701 | 701 | $sth->execute(); |
702 | - } catch(PDOException $e) { |
|
702 | + } catch (PDOException $e) { |
|
703 | 703 | return "error"; |
704 | 704 | } |
705 | 705 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
706 | 706 | $i = 0; |
707 | - $j =0; |
|
707 | + $j = 0; |
|
708 | 708 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
709 | - foreach($all as $row) |
|
709 | + foreach ($all as $row) |
|
710 | 710 | { |
711 | 711 | $i++; |
712 | 712 | $j++; |
@@ -714,9 +714,9 @@ discard block |
||
714 | 714 | if ($globalDebug) echo "."; |
715 | 715 | try { |
716 | 716 | |
717 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
717 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
718 | 718 | $sth->execute(); |
719 | - } catch(PDOException $e) { |
|
719 | + } catch (PDOException $e) { |
|
720 | 720 | return "error"; |
721 | 721 | } |
722 | 722 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -727,9 +727,9 @@ discard block |
||
727 | 727 | if ($i > 0) { |
728 | 728 | try { |
729 | 729 | |
730 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
730 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
731 | 731 | $sth->execute(); |
732 | - } catch(PDOException $e) { |
|
732 | + } catch (PDOException $e) { |
|
733 | 733 | return "error"; |
734 | 734 | } |
735 | 735 | } |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | |
743 | 743 | $sth = $this->db->prepare($query); |
744 | 744 | $sth->execute(); |
745 | - } catch(PDOException $e) { |
|
745 | + } catch (PDOException $e) { |
|
746 | 746 | return "error"; |
747 | 747 | } |
748 | 748 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -790,13 +790,13 @@ discard block |
||
790 | 790 | public function deleteLiveSpotterDataByIdent($ident) |
791 | 791 | { |
792 | 792 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
793 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
793 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
794 | 794 | |
795 | 795 | try { |
796 | 796 | |
797 | 797 | $sth = $this->db->prepare($query); |
798 | 798 | $sth->execute(array(':ident' => $ident)); |
799 | - } catch(PDOException $e) { |
|
799 | + } catch (PDOException $e) { |
|
800 | 800 | return "error"; |
801 | 801 | } |
802 | 802 | |
@@ -812,13 +812,13 @@ discard block |
||
812 | 812 | public function deleteLiveSpotterDataById($id) |
813 | 813 | { |
814 | 814 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
815 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
815 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
816 | 816 | |
817 | 817 | try { |
818 | 818 | |
819 | 819 | $sth = $this->db->prepare($query); |
820 | 820 | $sth->execute(array(':id' => $id)); |
821 | - } catch(PDOException $e) { |
|
821 | + } catch (PDOException $e) { |
|
822 | 822 | return "error"; |
823 | 823 | } |
824 | 824 | |
@@ -836,13 +836,13 @@ discard block |
||
836 | 836 | { |
837 | 837 | global $globalDBdriver, $globalTimezone; |
838 | 838 | if ($globalDBdriver == 'mysql') { |
839 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
839 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
840 | 840 | WHERE spotter_live.ident = :ident |
841 | 841 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
842 | 842 | AND spotter_live.date < UTC_TIMESTAMP()'; |
843 | 843 | $query_data = array(':ident' => $ident); |
844 | 844 | } else { |
845 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
845 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
846 | 846 | WHERE spotter_live.ident = :ident |
847 | 847 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
848 | 848 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -851,8 +851,8 @@ discard block |
||
851 | 851 | |
852 | 852 | $sth = $this->db->prepare($query); |
853 | 853 | $sth->execute($query_data); |
854 | - $ident_result=''; |
|
855 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
854 | + $ident_result = ''; |
|
855 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
856 | 856 | { |
857 | 857 | $ident_result = $row['ident']; |
858 | 858 | } |
@@ -869,13 +869,13 @@ discard block |
||
869 | 869 | { |
870 | 870 | global $globalDBdriver, $globalTimezone; |
871 | 871 | if ($globalDBdriver == 'mysql') { |
872 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
872 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
873 | 873 | WHERE spotter_live.ident = :ident |
874 | 874 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
875 | 875 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
876 | 876 | $query_data = array(':ident' => $ident); |
877 | 877 | } else { |
878 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
878 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
879 | 879 | WHERE spotter_live.ident = :ident |
880 | 880 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
881 | 881 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -884,8 +884,8 @@ discard block |
||
884 | 884 | |
885 | 885 | $sth = $this->db->prepare($query); |
886 | 886 | $sth->execute($query_data); |
887 | - $ident_result=''; |
|
888 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
887 | + $ident_result = ''; |
|
888 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
889 | 889 | { |
890 | 890 | $ident_result = $row['flightaware_id']; |
891 | 891 | } |
@@ -902,13 +902,13 @@ discard block |
||
902 | 902 | { |
903 | 903 | global $globalDBdriver, $globalTimezone; |
904 | 904 | if ($globalDBdriver == 'mysql') { |
905 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
905 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
906 | 906 | WHERE spotter_live.flightaware_id = :id |
907 | 907 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
908 | 908 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
909 | 909 | $query_data = array(':id' => $id); |
910 | 910 | } else { |
911 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
911 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
912 | 912 | WHERE spotter_live.flightaware_id = :id |
913 | 913 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
914 | 914 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -917,8 +917,8 @@ discard block |
||
917 | 917 | |
918 | 918 | $sth = $this->db->prepare($query); |
919 | 919 | $sth->execute($query_data); |
920 | - $ident_result=''; |
|
921 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
920 | + $ident_result = ''; |
|
921 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
922 | 922 | { |
923 | 923 | $ident_result = $row['flightaware_id']; |
924 | 924 | } |
@@ -935,13 +935,13 @@ discard block |
||
935 | 935 | { |
936 | 936 | global $globalDBdriver, $globalTimezone; |
937 | 937 | if ($globalDBdriver == 'mysql') { |
938 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
938 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
939 | 939 | WHERE spotter_live.ModeS = :modes |
940 | 940 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
941 | 941 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
942 | 942 | $query_data = array(':modes' => $modes); |
943 | 943 | } else { |
944 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
944 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
945 | 945 | WHERE spotter_live.ModeS = :modes |
946 | 946 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
947 | 947 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -950,8 +950,8 @@ discard block |
||
950 | 950 | |
951 | 951 | $sth = $this->db->prepare($query); |
952 | 952 | $sth->execute($query_data); |
953 | - $ident_result=''; |
|
954 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
953 | + $ident_result = ''; |
|
954 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
955 | 955 | { |
956 | 956 | //$ident_result = $row['spotter_live_id']; |
957 | 957 | $ident_result = $row['flightaware_id']; |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | * @return String success or false |
971 | 971 | * |
972 | 972 | */ |
973 | - 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 = '') |
|
973 | + 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 = '') |
|
974 | 974 | { |
975 | 975 | global $globalURL, $globalArchive, $globalDebug; |
976 | 976 | $Common = new Common(); |
@@ -1070,27 +1070,27 @@ discard block |
||
1070 | 1070 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
1071 | 1071 | |
1072 | 1072 | |
1073 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
1074 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1075 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
1076 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
1077 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
1078 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1079 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1080 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
1081 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1082 | - $altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1083 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
1084 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1085 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
1086 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
1087 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
1088 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
1089 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
1090 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
1091 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
1092 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
1093 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
1073 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
1074 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1075 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
1076 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
1077 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
1078 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1079 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1080 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
1081 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1082 | + $altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1083 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
1084 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1085 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
1086 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
1087 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
1088 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
1089 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
1090 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
1091 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
1092 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
1093 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
1094 | 1094 | |
1095 | 1095 | $airline_name = ''; |
1096 | 1096 | $airline_icao = ''; |
@@ -1112,10 +1112,10 @@ discard block |
||
1112 | 1112 | $arrival_airport_country = ''; |
1113 | 1113 | |
1114 | 1114 | |
1115 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1116 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1117 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1118 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1115 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
1116 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
1117 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
1118 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1119 | 1119 | |
1120 | 1120 | $query = ''; |
1121 | 1121 | if ($globalArchive) { |
@@ -1126,19 +1126,19 @@ discard block |
||
1126 | 1126 | $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) |
1127 | 1127 | 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)'; |
1128 | 1128 | |
1129 | - $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); |
|
1129 | + $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); |
|
1130 | 1130 | try { |
1131 | 1131 | |
1132 | 1132 | $sth = $this->db->prepare($query); |
1133 | 1133 | $sth->execute($query_values); |
1134 | 1134 | $sth->closeCursor(); |
1135 | - } catch(PDOException $e) { |
|
1135 | + } catch (PDOException $e) { |
|
1136 | 1136 | return "error : ".$e->getMessage(); |
1137 | 1137 | } |
1138 | 1138 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1139 | 1139 | if ($globalDebug) echo '(Add to SBS archive : '; |
1140 | 1140 | $SpotterArchive = new SpotterArchive($this->db); |
1141 | - $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); |
|
1141 | + $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); |
|
1142 | 1142 | if ($globalDebug) echo $result.')'; |
1143 | 1143 | } elseif ($globalDebug && $putinarchive !== true) { |
1144 | 1144 | echo '(Not adding to archive)'; |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | |
1152 | 1152 | public function getOrderBy() |
1153 | 1153 | { |
1154 | - $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")); |
|
1154 | + $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")); |
|
1155 | 1155 | return $orderby; |
1156 | 1156 | } |
1157 | 1157 |
@@ -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. (SpotterLive)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (SpotterLive)'); |
|
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) { |
@@ -123,8 +127,11 @@ discard block |
||
123 | 127 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
124 | 128 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
125 | 129 | } |
126 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
127 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
130 | + if ($filter_query_where == '' && $where) { |
|
131 | + $filter_query_where = ' WHERE'; |
|
132 | + } elseif ($filter_query_where != '' && $and) { |
|
133 | + $filter_query_where .= ' AND'; |
|
134 | + } |
|
128 | 135 | if ($filter_query_where != '') { |
129 | 136 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
130 | 137 | } |
@@ -165,9 +172,13 @@ discard block |
||
165 | 172 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
166 | 173 | } |
167 | 174 | } |
168 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
175 | + if ($orderby_query == '') { |
|
176 | + $orderby_query = ' ORDER BY date DESC'; |
|
177 | + } |
|
169 | 178 | |
170 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
179 | + if (!isset($globalLiveInterval)) { |
|
180 | + $globalLiveInterval = '200'; |
|
181 | + } |
|
171 | 182 | if ($globalDBdriver == 'mysql') { |
172 | 183 | //$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"; |
173 | 184 | $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; |
@@ -190,7 +201,9 @@ discard block |
||
190 | 201 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
191 | 202 | date_default_timezone_set('UTC'); |
192 | 203 | $filter_query = $this->getFilter($filter,true,true); |
193 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
204 | + if (!isset($globalLiveInterval)) { |
|
205 | + $globalLiveInterval = '200'; |
|
206 | + } |
|
194 | 207 | if ($globalDBdriver == 'mysql') { |
195 | 208 | if (isset($globalArchive) && $globalArchive === TRUE) { |
196 | 209 | $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 |
@@ -240,8 +253,12 @@ discard block |
||
240 | 253 | } |
241 | 254 | $filter_query = $this->getFilter($filter,true,true); |
242 | 255 | |
243 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
244 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
256 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
257 | + $globalLiveInterval = '200'; |
|
258 | + } |
|
259 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
260 | + $globalMap3DAircraftsLimit = '300'; |
|
261 | + } |
|
245 | 262 | if ($globalDBdriver == 'mysql') { |
246 | 263 | if (isset($globalArchive) && $globalArchive === TRUE) { |
247 | 264 | /* |
@@ -252,22 +269,32 @@ discard block |
||
252 | 269 | */ |
253 | 270 | $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 |
254 | 271 | 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 "; |
255 | - if ($usecoord) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
272 | + if ($usecoord) { |
|
273 | + $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
274 | + } |
|
256 | 275 | $query .= "UNION |
257 | 276 | 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 |
258 | 277 | FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
259 | - if ($usecoord) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
278 | + if ($usecoord) { |
|
279 | + $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
280 | + } |
|
260 | 281 | $query .= ") AS spotter |
261 | 282 | WHERE latitude <> '0' AND longitude <> '0' |
262 | 283 | ORDER BY flightaware_id, date"; |
263 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
284 | + if ($limit) { |
|
285 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
286 | + } |
|
264 | 287 | } else { |
265 | 288 | $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 |
266 | 289 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
267 | - if ($usecoord) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
290 | + if ($usecoord) { |
|
291 | + $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
292 | + } |
|
268 | 293 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
269 | 294 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
270 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
295 | + if ($limit) { |
|
296 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
297 | + } |
|
271 | 298 | } |
272 | 299 | } else { |
273 | 300 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -279,21 +306,31 @@ discard block |
||
279 | 306 | */ |
280 | 307 | $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 |
281 | 308 | 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 "; |
282 | - if ($usecoord) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
309 | + if ($usecoord) { |
|
310 | + $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
311 | + } |
|
283 | 312 | $query .= "UNION |
284 | 313 | 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 |
285 | 314 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
286 | - if ($usecoord) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
315 | + if ($usecoord) { |
|
316 | + $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
317 | + } |
|
287 | 318 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
288 | 319 | $query .= "ORDER BY flightaware_id, date"; |
289 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
320 | + if ($limit) { |
|
321 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
322 | + } |
|
290 | 323 | } else { |
291 | 324 | $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 |
292 | 325 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date "; |
293 | - if ($usecoord) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
326 | + if ($usecoord) { |
|
327 | + $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
328 | + } |
|
294 | 329 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
295 | 330 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
296 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
331 | + if ($limit) { |
|
332 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
333 | + } |
|
297 | 334 | } |
298 | 335 | } |
299 | 336 | try { |
@@ -318,7 +355,9 @@ discard block |
||
318 | 355 | global $globalDBdriver, $globalLiveInterval; |
319 | 356 | $filter_query = $this->getFilter($filter,true,true); |
320 | 357 | |
321 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
358 | + if (!isset($globalLiveInterval)) { |
|
359 | + $globalLiveInterval = '200'; |
|
360 | + } |
|
322 | 361 | if ($globalDBdriver == 'mysql') { |
323 | 362 | //$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; |
324 | 363 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -348,7 +387,9 @@ discard block |
||
348 | 387 | { |
349 | 388 | global $globalDBdriver, $globalLiveInterval; |
350 | 389 | $Spotter = new Spotter($this->db); |
351 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
390 | + if (!isset($globalLiveInterval)) { |
|
391 | + $globalLiveInterval = '200'; |
|
392 | + } |
|
352 | 393 | $filter_query = $this->getFilter($filter); |
353 | 394 | |
354 | 395 | if (is_array($coord)) { |
@@ -356,7 +397,9 @@ discard block |
||
356 | 397 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
357 | 398 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
358 | 399 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
359 | - } else return array(); |
|
400 | + } else { |
|
401 | + return array(); |
|
402 | + } |
|
360 | 403 | if ($globalDBdriver == 'mysql') { |
361 | 404 | $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; |
362 | 405 | } else { |
@@ -377,7 +420,9 @@ discard block |
||
377 | 420 | { |
378 | 421 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
379 | 422 | $Spotter = new Spotter($this->db); |
380 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
423 | + if (!isset($globalLiveInterval)) { |
|
424 | + $globalLiveInterval = '200'; |
|
425 | + } |
|
381 | 426 | $filter_query = $this->getFilter($filter,true,true); |
382 | 427 | |
383 | 428 | if (is_array($coord)) { |
@@ -385,7 +430,9 @@ discard block |
||
385 | 430 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
386 | 431 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
387 | 432 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
388 | - } else return array(); |
|
433 | + } else { |
|
434 | + return array(); |
|
435 | + } |
|
389 | 436 | if ($globalDBdriver == 'mysql') { |
390 | 437 | if (isset($globalArchive) && $globalArchive === TRUE) { |
391 | 438 | $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 |
@@ -612,11 +659,15 @@ discard block |
||
612 | 659 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
613 | 660 | if ($globalDBdriver == 'mysql') { |
614 | 661 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
615 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
662 | + if ($liveinterval) { |
|
663 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
664 | + } |
|
616 | 665 | $query .= ' ORDER BY date'; |
617 | 666 | } else { |
618 | 667 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
619 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
668 | + if ($liveinterval) { |
|
669 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
670 | + } |
|
620 | 671 | $query .= ' ORDER BY date'; |
621 | 672 | } |
622 | 673 | |
@@ -711,7 +762,9 @@ discard block |
||
711 | 762 | $i++; |
712 | 763 | $j++; |
713 | 764 | if ($j == 30) { |
714 | - if ($globalDebug) echo "."; |
|
765 | + if ($globalDebug) { |
|
766 | + echo "."; |
|
767 | + } |
|
715 | 768 | try { |
716 | 769 | |
717 | 770 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -1018,7 +1071,9 @@ discard block |
||
1018 | 1071 | { |
1019 | 1072 | return false; |
1020 | 1073 | } |
1021 | - } else return ''; |
|
1074 | + } else { |
|
1075 | + return ''; |
|
1076 | + } |
|
1022 | 1077 | |
1023 | 1078 | if ($longitude != '') |
1024 | 1079 | { |
@@ -1026,7 +1081,9 @@ discard block |
||
1026 | 1081 | { |
1027 | 1082 | return false; |
1028 | 1083 | } |
1029 | - } else return ''; |
|
1084 | + } else { |
|
1085 | + return ''; |
|
1086 | + } |
|
1030 | 1087 | |
1031 | 1088 | if ($waypoints != '') |
1032 | 1089 | { |
@@ -1042,14 +1099,18 @@ discard block |
||
1042 | 1099 | { |
1043 | 1100 | return false; |
1044 | 1101 | } |
1045 | - } else $altitude = 0; |
|
1102 | + } else { |
|
1103 | + $altitude = 0; |
|
1104 | + } |
|
1046 | 1105 | if ($altitude_real != '') |
1047 | 1106 | { |
1048 | 1107 | if (!is_numeric($altitude_real)) |
1049 | 1108 | { |
1050 | 1109 | return false; |
1051 | 1110 | } |
1052 | - } else $altitude_real = 0; |
|
1111 | + } else { |
|
1112 | + $altitude_real = 0; |
|
1113 | + } |
|
1053 | 1114 | |
1054 | 1115 | if ($heading != '') |
1055 | 1116 | { |
@@ -1057,7 +1118,9 @@ discard block |
||
1057 | 1118 | { |
1058 | 1119 | return false; |
1059 | 1120 | } |
1060 | - } else $heading = 0; |
|
1121 | + } else { |
|
1122 | + $heading = 0; |
|
1123 | + } |
|
1061 | 1124 | |
1062 | 1125 | if ($groundspeed != '') |
1063 | 1126 | { |
@@ -1065,9 +1128,13 @@ discard block |
||
1065 | 1128 | { |
1066 | 1129 | return false; |
1067 | 1130 | } |
1068 | - } else $groundspeed = 0; |
|
1131 | + } else { |
|
1132 | + $groundspeed = 0; |
|
1133 | + } |
|
1069 | 1134 | date_default_timezone_set('UTC'); |
1070 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1135 | + if ($date == '') { |
|
1136 | + $date = date("Y-m-d H:i:s", time()); |
|
1137 | + } |
|
1071 | 1138 | |
1072 | 1139 | |
1073 | 1140 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1112,14 +1179,24 @@ discard block |
||
1112 | 1179 | $arrival_airport_country = ''; |
1113 | 1180 | |
1114 | 1181 | |
1115 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1116 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1117 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1118 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1182 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
1183 | + $squawk = NULL; |
|
1184 | + } |
|
1185 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
1186 | + $verticalrate = NULL; |
|
1187 | + } |
|
1188 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1189 | + $groundspeed = 0; |
|
1190 | + } |
|
1191 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1192 | + $heading = 0; |
|
1193 | + } |
|
1119 | 1194 | |
1120 | 1195 | $query = ''; |
1121 | 1196 | if ($globalArchive) { |
1122 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1197 | + if ($globalDebug) { |
|
1198 | + echo '-- Delete previous data -- '; |
|
1199 | + } |
|
1123 | 1200 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
1124 | 1201 | } |
1125 | 1202 | |
@@ -1136,10 +1213,14 @@ discard block |
||
1136 | 1213 | return "error : ".$e->getMessage(); |
1137 | 1214 | } |
1138 | 1215 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1139 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1216 | + if ($globalDebug) { |
|
1217 | + echo '(Add to SBS archive : '; |
|
1218 | + } |
|
1140 | 1219 | $SpotterArchive = new SpotterArchive($this->db); |
1141 | 1220 | $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); |
1142 | - if ($globalDebug) echo $result.')'; |
|
1221 | + if ($globalDebug) { |
|
1222 | + echo $result.')'; |
|
1223 | + } |
|
1143 | 1224 | } elseif ($globalDebug && $putinarchive !== true) { |
1144 | 1225 | echo '(Not adding to archive)'; |
1145 | 1226 | } 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,29 +35,29 @@ discard block |
||
35 | 35 | |
36 | 36 | $page_url = $globalURL.'/owner/'.$_GET['owner']; |
37 | 37 | |
38 | - $owner = urldecode(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 = urldecode(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 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
49 | - $spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter); |
|
49 | + $spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, $sort, $filter); |
|
50 | 50 | } |
51 | 51 | } else { |
52 | - $spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference,'',$filter); |
|
52 | + $spotter_array = $Spotter->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, '', $filter); |
|
53 | 53 | if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) { |
54 | - $spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference,'',$filter); |
|
54 | + $spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, '', $filter); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | 58 | if (!empty($spotter_array)) |
59 | 59 | { |
60 | - $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']); |
|
60 | + $title = sprintf(_("Detailed View for %s"), $spotter_array[0]['aircraft_owner']); |
|
61 | 61 | //$ident = $spotter_array[0]['ident']; |
62 | 62 | if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
63 | 63 | if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
@@ -117,23 +117,23 @@ discard block |
||
117 | 117 | $Stats = new Stats(); |
118 | 118 | if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner); |
119 | 119 | else $flights = 0; |
120 | - if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter); |
|
120 | + if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner, $filter); |
|
121 | 121 | print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>'; |
122 | - $aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter)); |
|
122 | + $aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner, $filter)); |
|
123 | 123 | print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>'; |
124 | - $aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner,$filter)); |
|
124 | + $aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner, $filter)); |
|
125 | 125 | print '<div><span class="label">'._("Aircrafts").'</span>'.$aircraft_registration.'</div>'; |
126 | - $aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner,$filter)); |
|
126 | + $aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner, $filter)); |
|
127 | 127 | print '<div><span class="label">'._("Manufacturers").'</span>'.$aircraft_manufacturer.'</div>'; |
128 | - $airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter)); |
|
128 | + $airlines = count($Spotter->countAllAirlinesByOwner($owner, $filter)); |
|
129 | 129 | print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>'; |
130 | - $duration = $Spotter->getFlightDurationByOwner($owner,$filter); |
|
130 | + $duration = $Spotter->getFlightDurationByOwner($owner, $filter); |
|
131 | 131 | if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>'; |
132 | 132 | print '</div>'; |
133 | 133 | |
134 | 134 | include('owner-sub-menu.php'); |
135 | 135 | print '<div class="table column">'; |
136 | - 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>'; |
|
136 | + 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>'; |
|
137 | 137 | |
138 | 138 | include('table-output.php'); |
139 | 139 | print '<div class="pagination">'; |