@@ -5,11 +5,15 @@ |
||
5 | 5 | $Stats = new Stats(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Departure Airport by Country"); |
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 |
@@ -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 by Country"); |
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 | |
16 | 16 | require_once('header.php'); |
17 | 17 | include('statistics-sub-menu.php'); |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | <p>'._("Below are the <strong>Top 10</strong> most common countries of all the departure airports.").'</p>'; |
26 | 26 | print '<div id="chartCountry" class="chart" width="100%"></div>'; |
27 | 27 | |
28 | -$airport_country_array = $Stats->countAllDepartureCountries(true,$airline_icao,$filter_name,$year,$month); |
|
28 | +$airport_country_array = $Stats->countAllDepartureCountries(true, $airline_icao, $filter_name, $year, $month); |
|
29 | 29 | print '<script>'; |
30 | 30 | print 'var series = ['; |
31 | 31 | $country_data = ''; |
32 | -foreach($airport_country_array as $airport_item) |
|
32 | +foreach ($airport_country_array as $airport_item) |
|
33 | 33 | { |
34 | 34 | $country_data .= '[ "'.$airport_item['airport_departure_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],'; |
35 | 35 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | print '</thead>'; |
75 | 75 | print '<tbody>'; |
76 | 76 | $i = 1; |
77 | -foreach($airport_country_array as $airport_item) |
|
77 | +foreach ($airport_country_array as $airport_item) |
|
78 | 78 | { |
79 | 79 | print '<tr>'; |
80 | 80 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -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>'; |
@@ -5,11 +5,15 @@ |
||
5 | 5 | $Stats = new Stats(); |
6 | 6 | $title = _("Statistics").' - '._("Busiest Month of Last Year"); |
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 | require_once('header.php'); |
15 | 19 | include('statistics-sub-menu.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 | |
14 | 14 | require_once('header.php'); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | $title = _("Statistics").' - '._("Busiest Month of Last Year"); |
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 | } |
@@ -21,17 +21,17 @@ discard block |
||
21 | 21 | </div> |
22 | 22 | <p>'._("Below is a chart that plots the busiest month during the <strong>last year</strong>.").'</p>'; |
23 | 23 | |
24 | -$date_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
|
24 | +$date_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name); |
|
25 | 25 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
26 | 26 | $year_data = ''; |
27 | 27 | $year_cnt = ''; |
28 | -foreach($date_array as $year_item) |
|
28 | +foreach ($date_array as $year_item) |
|
29 | 29 | { |
30 | 30 | $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",'; |
31 | 31 | $year_cnt .= $year_item['date_count'].','; |
32 | 32 | } |
33 | 33 | $year_data = "['x',".substr($year_data, 0, -1)."]"; |
34 | -$year_cnt = "['flights',".substr($year_cnt,0,-1)."]"; |
|
34 | +$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]"; |
|
35 | 35 | print 'c3.generate({ |
36 | 36 | bindto: "#chart", |
37 | 37 | data: { x: "x", |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | print '</thead>'; |
52 | 52 | print '<tbody>'; |
53 | 53 | $i = 1; |
54 | - foreach($date_array as $date_item) |
|
54 | + foreach ($date_array as $date_item) |
|
55 | 55 | { |
56 | 56 | print '<tr>'; |
57 | 57 | 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").' - '._("Busiest Time of the Day"); |
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 | require_once('header.php'); |
15 | 19 | include('statistics-sub-menu.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 | |
14 | 14 | require_once('header.php'); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | $title = _("Statistics").' - '._("Busiest Time of the Day"); |
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 | } |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | </div> |
23 | 23 | <p>'._("Below is a list of the most common <strong>time of day</strong>.").'</p>'; |
24 | 24 | |
25 | -$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
|
25 | +$hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name); |
|
26 | 26 | print '<div id="chartHour" class="chart" width="100%"></div><script>'; |
27 | 27 | $hour_data = ''; |
28 | 28 | $hour_cnt = ''; |
29 | -foreach($hour_array as $hour_item) |
|
29 | +foreach ($hour_array as $hour_item) |
|
30 | 30 | { |
31 | 31 | $hour_data .= '"'.$hour_item['hour_name'].':00",'; |
32 | 32 | $hour_cnt .= $hour_item['hour_count'].','; |
33 | 33 | } |
34 | 34 | $hour_data = "[".substr($hour_data, 0, -1)."]"; |
35 | -$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]"; |
|
35 | +$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]"; |
|
36 | 36 | print 'c3.generate({ |
37 | 37 | bindto: "#chartHour", |
38 | 38 | data: { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});'; |
41 | 41 | print '</script>'; |
42 | 42 | |
43 | -$hour_array = $Stats->countAllHours('count',true,$airline_icao,$filter_name); |
|
43 | +$hour_array = $Stats->countAllHours('count', true, $airline_icao, $filter_name); |
|
44 | 44 | if (!empty($hour_array)) |
45 | 45 | { |
46 | 46 | print '<div class="table-responsive">'; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | print '</thead>'; |
53 | 53 | print '<tbody>'; |
54 | 54 | $i = 1; |
55 | - foreach($hour_array as $hour_item) |
|
55 | + foreach ($hour_array as $hour_item) |
|
56 | 56 | { |
57 | 57 | print '<tr>'; |
58 | 58 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | </form> |
33 | 33 | </div> |
34 | 34 | <?php |
35 | - if (!isset($year) || (isset($year) && $year == '') && !isset($month) || (isset($month) && $month == '')) { |
|
35 | + if (!isset($year) || (isset($year) && $year == '') && !isset($month) || (isset($month) && $month == '')) { |
|
36 | 36 | ?> |
37 | 37 | <div class="sub-menu sub-menu-container"> |
38 | 38 | <ul class="nav"> |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | </ul> |
88 | 88 | </li> |
89 | 89 | <?php |
90 | - if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) { |
|
90 | + if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) { |
|
91 | 91 | ?> |
92 | 92 | <li class="dropdown"> |
93 | 93 | <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | </ul> |
100 | 100 | </li> |
101 | 101 | <?php |
102 | - } |
|
102 | + } |
|
103 | 103 | ?> |
104 | 104 | </ul> |
105 | 105 | </div> |
106 | 106 | <?php |
107 | - } else { |
|
107 | + } else { |
|
108 | 108 | ?> |
109 | 109 | <div class="sub-menu sub-menu-container"> |
110 | 110 | <ul class="nav"> |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | </li> |
164 | 164 | --> |
165 | 165 | <?php |
166 | - if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) { |
|
166 | + if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) { |
|
167 | 167 | ?> |
168 | 168 | <!-- |
169 | 169 | <li class="dropdown"> |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | </li> |
178 | 178 | --> |
179 | 179 | <?php |
180 | - } |
|
180 | + } |
|
181 | 181 | ?> |
182 | 182 | </ul> |
183 | 183 | </div> |
184 | 184 | <?php |
185 | - } |
|
185 | + } |
|
186 | 186 | ?> |
187 | 187 | \ No newline at end of file |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | } else { |
21 | 21 | print '<option value="all">All</option>'; |
22 | 22 | } |
23 | - foreach($airlines as $airline) { |
|
23 | + foreach ($airlines as $airline) { |
|
24 | 24 | if (isset($airline_icao) && $airline_icao == $airline['airline_icao']) { |
25 | 25 | print '<option value="'.$airline['airline_icao'].'" selected>'.$airline['airline_name'].'</option>'; |
26 | 26 | } else { |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | <div class="sub-menu sub-menu-container"> |
38 | 38 | <ul class="nav"> |
39 | 39 | <li class="dropdown"> |
40 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" > |
|
40 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" > |
|
41 | 41 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
42 | 42 | </a> |
43 | 43 | <ul class="dropdown-menu"> |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | </ul> |
49 | 49 | </li> |
50 | 50 | <li class="dropdown"> |
51 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
51 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
52 | 52 | <?php echo _("Airline"); ?> <span class="caret"></span> |
53 | 53 | </a> |
54 | 54 | <ul class="dropdown-menu" role="menu"> |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | </ul> |
59 | 59 | </li> |
60 | 60 | <li class="dropdown"> |
61 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
61 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
62 | 62 | <?php echo _("Airport"); ?> <span class="caret"></span> |
63 | 63 | </a> |
64 | 64 | <ul class="dropdown-menu" role="menu"> |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | </ul> |
70 | 70 | </li> |
71 | 71 | <li class="dropdown"> |
72 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
72 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
73 | 73 | <?php echo _("Route"); ?> <span class="caret"></span> |
74 | 74 | </a> |
75 | 75 | <ul class="dropdown-menu" role="menu"> |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | </ul> |
79 | 79 | </li> |
80 | 80 | <li class="dropdown"> |
81 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
81 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
82 | 82 | <?php echo _("Date & Time"); ?> <span class="caret"></span> |
83 | 83 | </a> |
84 | 84 | <ul class="dropdown-menu" role="menu"> |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) { |
91 | 91 | ?> |
92 | 92 | <li class="dropdown"> |
93 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
93 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
94 | 94 | <?php echo _("Fatalities"); ?> <span class="caret"></span> |
95 | 95 | </a> |
96 | 96 | <ul class="dropdown-menu" role="menu"> |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | <div class="sub-menu sub-menu-container"> |
110 | 110 | <ul class="nav"> |
111 | 111 | <li class="dropdown"> |
112 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer"){ print 'active'; } ?>" data-toggle="dropdown" href="#" > |
|
112 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-aircraft" || strtolower($current_page) == "statistics-registration" || strtolower($current_page) == "statistics-manufacturer") { print 'active'; } ?>" data-toggle="dropdown" href="#" > |
|
113 | 113 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
114 | 114 | </a> |
115 | 115 | <ul class="dropdown-menu"> |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | </ul> |
121 | 121 | </li> |
122 | 122 | <li class="dropdown"> |
123 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
123 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airline" || strtolower($current_page) == "statistics-airline-country" || strtolower($current_page) == "statistics-callsign") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
124 | 124 | <?php echo _("Airline"); ?> <span class="caret"></span> |
125 | 125 | </a> |
126 | 126 | <ul class="dropdown-menu" role="menu"> |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | </ul> |
131 | 131 | </li> |
132 | 132 | <li class="dropdown"> |
133 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
133 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-airport-departure" || strtolower($current_page) == "statistics-airport-departure-country" || strtolower($current_page) == "statistics-airport-arrival" || strtolower($current_page) == "statistics-airport-arrival-country") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
134 | 134 | <?php echo _("Airport"); ?> <span class="caret"></span> |
135 | 135 | </a> |
136 | 136 | <ul class="dropdown-menu" role="menu"> |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | </li> |
143 | 143 | <!-- |
144 | 144 | <li class="dropdown"> |
145 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
145 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-route-airport" || strtolower($current_page) == "statistics-route-waypoint") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
146 | 146 | <?php echo _("Route"); ?> <span class="caret"></span> |
147 | 147 | </a> |
148 | 148 | <ul class="dropdown-menu" role="menu"> |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | --> |
154 | 154 | <!-- |
155 | 155 | <li class="dropdown"> |
156 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
156 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-date" || strtolower($current_page) == "statistics-time") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
157 | 157 | <?php echo _("Date & Time"); ?> <span class="caret"></span> |
158 | 158 | </a> |
159 | 159 | <ul class="dropdown-menu" role="menu"> |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | ?> |
168 | 168 | <!-- |
169 | 169 | <li class="dropdown"> |
170 | - <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
170 | + <a class="dropdown-toggle <?php if (strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month") { print 'active'; } ?>" data-toggle="dropdown" href="#"> |
|
171 | 171 | <?php echo _("Fatalities"); ?> <span class="caret"></span> |
172 | 172 | </a> |
173 | 173 | <ul class="dropdown-menu" role="menu"> |
@@ -4,7 +4,13 @@ discard block |
||
4 | 4 | <div class="stats_airline"> |
5 | 5 | |
6 | 6 | <form id="changedate" method="post"> |
7 | - <input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') echo $year.'-'; ?><?php if (isset($month) && $month != '') echo $month; ?>" /> |
|
7 | + <input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') { |
|
8 | + echo $year.'-'; |
|
9 | +} |
|
10 | +?><?php if (isset($month) && $month != '') { |
|
11 | + echo $month; |
|
12 | +} |
|
13 | +?>" /> |
|
8 | 14 | </form> |
9 | 15 | |
10 | 16 | <form id="changeairline" method="post"> |
@@ -13,7 +19,9 @@ discard block |
||
13 | 19 | <?php |
14 | 20 | require_once('require/class.Stats.php'); |
15 | 21 | $Stats = new Stats(); |
16 | - if (!isset($filter_name)) $filter_name = ''; |
|
22 | + if (!isset($filter_name)) { |
|
23 | + $filter_name = ''; |
|
24 | + } |
|
17 | 25 | $airlines = $Stats->getAllAirlineNames($filter_name); |
18 | 26 | if (isset($airline_icao) && ($airline_icao == '' || $airline_icao == 'all')) { |
19 | 27 | print '<option value="all" selected>All</option>'; |
@@ -41,10 +49,22 @@ discard block |
||
41 | 49 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
42 | 50 | </a> |
43 | 51 | <ul class="dropdown-menu"> |
44 | - <li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Aircraft"); ?></a></li> |
|
45 | - <li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Registration"); ?></a></li> |
|
46 | - <li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Manufacturer"); ?></a></li> |
|
47 | - <li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Country"); ?></a></li> |
|
52 | + <li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
53 | + echo '/'.$airline_icao; |
|
54 | +} |
|
55 | +?>"><?php echo _("Aircraft"); ?></a></li> |
|
56 | + <li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
57 | + echo '/'.$airline_icao; |
|
58 | +} |
|
59 | +?>"><?php echo _("Registration"); ?></a></li> |
|
60 | + <li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
61 | + echo '/'.$airline_icao; |
|
62 | +} |
|
63 | +?>"><?php echo _("Manufacturer"); ?></a></li> |
|
64 | + <li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
65 | + echo '/'.$airline_icao; |
|
66 | +} |
|
67 | +?>"><?php echo _("Country"); ?></a></li> |
|
48 | 68 | </ul> |
49 | 69 | </li> |
50 | 70 | <li class="dropdown"> |
@@ -52,9 +72,18 @@ discard block |
||
52 | 72 | <?php echo _("Airline"); ?> <span class="caret"></span> |
53 | 73 | </a> |
54 | 74 | <ul class="dropdown-menu" role="menu"> |
55 | - <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Airline"); ?></a></li> |
|
56 | - <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Airline by Country"); ?></a></li> |
|
57 | - <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Callsign"); ?></a></li> |
|
75 | + <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
76 | + echo '/'.$airline_icao; |
|
77 | +} |
|
78 | +?>"><?php echo _("Airline"); ?></a></li> |
|
79 | + <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
80 | + echo '/'.$airline_icao; |
|
81 | +} |
|
82 | +?>"><?php echo _("Airline by Country"); ?></a></li> |
|
83 | + <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
84 | + echo '/'.$airline_icao; |
|
85 | +} |
|
86 | +?>"><?php echo _("Callsign"); ?></a></li> |
|
58 | 87 | </ul> |
59 | 88 | </li> |
60 | 89 | <li class="dropdown"> |
@@ -62,10 +91,22 @@ discard block |
||
62 | 91 | <?php echo _("Airport"); ?> <span class="caret"></span> |
63 | 92 | </a> |
64 | 93 | <ul class="dropdown-menu" role="menu"> |
65 | - <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Departure Airport"); ?></a></li> |
|
66 | - <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Departure Airport by Country"); ?></a></li> |
|
67 | - <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Arrival Airport"); ?></a></li> |
|
68 | - <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li> |
|
94 | + <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
95 | + echo '/'.$airline_icao; |
|
96 | +} |
|
97 | +?>"><?php echo _("Departure Airport"); ?></a></li> |
|
98 | + <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
99 | + echo '/'.$airline_icao; |
|
100 | +} |
|
101 | +?>"><?php echo _("Departure Airport by Country"); ?></a></li> |
|
102 | + <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
103 | + echo '/'.$airline_icao; |
|
104 | +} |
|
105 | +?>"><?php echo _("Arrival Airport"); ?></a></li> |
|
106 | + <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
107 | + echo '/'.$airline_icao; |
|
108 | +} |
|
109 | +?>"><?php echo _("Arrival Airport by Country"); ?></a></li> |
|
69 | 110 | </ul> |
70 | 111 | </li> |
71 | 112 | <li class="dropdown"> |
@@ -73,8 +114,14 @@ discard block |
||
73 | 114 | <?php echo _("Route"); ?> <span class="caret"></span> |
74 | 115 | </a> |
75 | 116 | <ul class="dropdown-menu" role="menu"> |
76 | - <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Route by Airport"); ?></a></li> |
|
77 | - <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Route by Waypoint"); ?></a></li> |
|
117 | + <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
118 | + echo '/'.$airline_icao; |
|
119 | +} |
|
120 | +?>"><?php echo _("Route by Airport"); ?></a></li> |
|
121 | + <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
122 | + echo '/'.$airline_icao; |
|
123 | +} |
|
124 | +?>"><?php echo _("Route by Waypoint"); ?></a></li> |
|
78 | 125 | </ul> |
79 | 126 | </li> |
80 | 127 | <li class="dropdown"> |
@@ -82,8 +129,14 @@ discard block |
||
82 | 129 | <?php echo _("Date & Time"); ?> <span class="caret"></span> |
83 | 130 | </a> |
84 | 131 | <ul class="dropdown-menu" role="menu"> |
85 | - <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Date"); ?></a></li> |
|
86 | - <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Time"); ?></a></li> |
|
132 | + <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
133 | + echo '/'.$airline_icao; |
|
134 | +} |
|
135 | +?>"><?php echo _("Date"); ?></a></li> |
|
136 | + <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
137 | + echo '/'.$airline_icao; |
|
138 | +} |
|
139 | +?>"><?php echo _("Time"); ?></a></li> |
|
87 | 140 | </ul> |
88 | 141 | </li> |
89 | 142 | <?php |
@@ -113,9 +166,18 @@ discard block |
||
113 | 166 | <?php echo _("Aircraft"); ?> <span class="caret"></span> |
114 | 167 | </a> |
115 | 168 | <ul class="dropdown-menu"> |
116 | - <li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li> |
|
117 | - <li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li> |
|
118 | - <li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li> |
|
169 | + <li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
170 | + echo '/'.$airline_icao; |
|
171 | +} |
|
172 | +?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li> |
|
173 | + <li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
174 | + echo '/'.$airline_icao; |
|
175 | +} |
|
176 | +?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li> |
|
177 | + <li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
178 | + echo '/'.$airline_icao; |
|
179 | +} |
|
180 | +?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li> |
|
119 | 181 | <!-- <li><a href="<?php print $globalURL; ?>/statistics/country"><?php echo _("Country"); ?></a></li> --> |
120 | 182 | </ul> |
121 | 183 | </li> |
@@ -124,9 +186,18 @@ discard block |
||
124 | 186 | <?php echo _("Airline"); ?> <span class="caret"></span> |
125 | 187 | </a> |
126 | 188 | <ul class="dropdown-menu" role="menu"> |
127 | - <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li> |
|
128 | - <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li> |
|
129 | - <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li> |
|
189 | + <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
190 | + echo '/'.$airline_icao; |
|
191 | +} |
|
192 | +?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li> |
|
193 | + <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
194 | + echo '/'.$airline_icao; |
|
195 | +} |
|
196 | +?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li> |
|
197 | + <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
198 | + echo '/'.$airline_icao; |
|
199 | +} |
|
200 | +?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li> |
|
130 | 201 | </ul> |
131 | 202 | </li> |
132 | 203 | <li class="dropdown"> |
@@ -134,10 +205,22 @@ discard block |
||
134 | 205 | <?php echo _("Airport"); ?> <span class="caret"></span> |
135 | 206 | </a> |
136 | 207 | <ul class="dropdown-menu" role="menu"> |
137 | - <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li> |
|
138 | - <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li> |
|
139 | - <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li> |
|
140 | - <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li> |
|
208 | + <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
209 | + echo '/'.$airline_icao; |
|
210 | +} |
|
211 | +?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li> |
|
212 | + <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
213 | + echo '/'.$airline_icao; |
|
214 | +} |
|
215 | +?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li> |
|
216 | + <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
217 | + echo '/'.$airline_icao; |
|
218 | +} |
|
219 | +?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li> |
|
220 | + <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
221 | + echo '/'.$airline_icao; |
|
222 | +} |
|
223 | +?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li> |
|
141 | 224 | </ul> |
142 | 225 | </li> |
143 | 226 | <!-- |
@@ -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>'; |
@@ -7,109 +7,109 @@ discard block |
||
7 | 7 | public $db; |
8 | 8 | |
9 | 9 | protected $texts = Array( |
10 | - 'MI' => 'Shallow', |
|
11 | - 'PR' => 'Partial', |
|
12 | - 'BC' => 'Low drifting', |
|
13 | - 'BL' => 'Blowing', |
|
14 | - 'SH' => 'Showers', |
|
15 | - 'TS' => 'Thunderstorm', |
|
16 | - 'FZ' => 'Freezing', |
|
17 | - 'DZ' => 'Drizzle', |
|
18 | - 'RA' => 'Rain', |
|
19 | - 'SN' => 'Snow', |
|
20 | - 'SG' => 'Snow Grains', |
|
21 | - 'IC' => 'Ice crystals', |
|
22 | - 'PL' => 'Ice pellets', |
|
23 | - 'GR' => 'Hail', |
|
24 | - 'GS' => 'Small hail', |
|
25 | - 'UP' => 'Unknown', |
|
26 | - 'BR' => 'Mist', |
|
27 | - 'FG' => 'Fog', |
|
28 | - 'FU' => 'Smoke', |
|
29 | - 'VA' => 'Volcanic ash', |
|
30 | - 'DU' => 'Widespread dust', |
|
31 | - 'SA' => 'Sand', |
|
32 | - 'HZ' => 'Haze', |
|
33 | - 'PY' => 'Spray', |
|
34 | - 'PO' => 'Well developed dust / sand whirls', |
|
35 | - 'SQ' => 'Squalls', |
|
36 | - 'FC' => 'Funnel clouds inc tornadoes or waterspouts', |
|
37 | - 'SS' => 'Sandstorm', |
|
38 | - 'DS' => 'Duststorm' |
|
10 | + 'MI' => 'Shallow', |
|
11 | + 'PR' => 'Partial', |
|
12 | + 'BC' => 'Low drifting', |
|
13 | + 'BL' => 'Blowing', |
|
14 | + 'SH' => 'Showers', |
|
15 | + 'TS' => 'Thunderstorm', |
|
16 | + 'FZ' => 'Freezing', |
|
17 | + 'DZ' => 'Drizzle', |
|
18 | + 'RA' => 'Rain', |
|
19 | + 'SN' => 'Snow', |
|
20 | + 'SG' => 'Snow Grains', |
|
21 | + 'IC' => 'Ice crystals', |
|
22 | + 'PL' => 'Ice pellets', |
|
23 | + 'GR' => 'Hail', |
|
24 | + 'GS' => 'Small hail', |
|
25 | + 'UP' => 'Unknown', |
|
26 | + 'BR' => 'Mist', |
|
27 | + 'FG' => 'Fog', |
|
28 | + 'FU' => 'Smoke', |
|
29 | + 'VA' => 'Volcanic ash', |
|
30 | + 'DU' => 'Widespread dust', |
|
31 | + 'SA' => 'Sand', |
|
32 | + 'HZ' => 'Haze', |
|
33 | + 'PY' => 'Spray', |
|
34 | + 'PO' => 'Well developed dust / sand whirls', |
|
35 | + 'SQ' => 'Squalls', |
|
36 | + 'FC' => 'Funnel clouds inc tornadoes or waterspouts', |
|
37 | + 'SS' => 'Sandstorm', |
|
38 | + 'DS' => 'Duststorm' |
|
39 | 39 | ); |
40 | 40 | |
41 | 41 | public function __construct($dbc = null) { |
42 | - $Connection = new Connection($dbc); |
|
43 | - $this->db = $Connection->db; |
|
44 | - } |
|
42 | + $Connection = new Connection($dbc); |
|
43 | + $this->db = $Connection->db; |
|
44 | + } |
|
45 | 45 | |
46 | - public static function check_last_update() { |
|
47 | - global $globalDBdriver; |
|
48 | - if ($globalDBdriver == 'mysql') { |
|
46 | + public static function check_last_update() { |
|
47 | + global $globalDBdriver; |
|
48 | + if ($globalDBdriver == 'mysql') { |
|
49 | 49 | $query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value > DATE_SUB(NOW(), INTERVAL 20 MINUTE)"; |
50 | 50 | } else { |
51 | 51 | $query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '20 MINUTES'"; |
52 | 52 | } |
53 | - try { |
|
54 | - $Connection = new Connection(); |
|
55 | - $sth = $Connection->db->prepare($query); |
|
56 | - $sth->execute(); |
|
57 | - } catch(PDOException $e) { |
|
58 | - return "error : ".$e->getMessage(); |
|
59 | - } |
|
60 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
61 | - $sth->closeCursor(); |
|
62 | - if ($row['nb'] > 0) return false; |
|
63 | - else return true; |
|
64 | - } |
|
53 | + try { |
|
54 | + $Connection = new Connection(); |
|
55 | + $sth = $Connection->db->prepare($query); |
|
56 | + $sth->execute(); |
|
57 | + } catch(PDOException $e) { |
|
58 | + return "error : ".$e->getMessage(); |
|
59 | + } |
|
60 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
61 | + $sth->closeCursor(); |
|
62 | + if ($row['nb'] > 0) return false; |
|
63 | + else return true; |
|
64 | + } |
|
65 | 65 | |
66 | - public static function insert_last_update() { |
|
67 | - $query = "DELETE FROM config WHERE name = 'last_update_metar'; |
|
66 | + public static function insert_last_update() { |
|
67 | + $query = "DELETE FROM config WHERE name = 'last_update_metar'; |
|
68 | 68 | INSERT INTO config (name,value) VALUES ('last_update_metar',NOW());"; |
69 | - try { |
|
70 | - $Connection = new Connection(); |
|
71 | - $sth = $Connection->db->prepare($query); |
|
72 | - $sth->execute(); |
|
73 | - } catch(PDOException $e) { |
|
74 | - return "error : ".$e->getMessage(); |
|
75 | - } |
|
76 | - } |
|
69 | + try { |
|
70 | + $Connection = new Connection(); |
|
71 | + $sth = $Connection->db->prepare($query); |
|
72 | + $sth->execute(); |
|
73 | + } catch(PDOException $e) { |
|
74 | + return "error : ".$e->getMessage(); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | 79 | |
80 | - public function parse($data) { |
|
81 | - //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
|
82 | - $codes = implode('|', array_keys($this->texts)); |
|
83 | - $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
84 | - //$pieces = explode(' ',$data); |
|
85 | - $pieces = preg_split('/\s/',$data); |
|
86 | - $pos = 0; |
|
87 | - if ($pieces[0] == 'METAR') $pos++; |
|
88 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
89 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
90 | - $result = array(); |
|
91 | - $result['location'] = $pieces[$pos]; |
|
92 | - $pos++; |
|
93 | - $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
94 | - $result['time'] = substr($pieces[$pos],2,4); |
|
95 | - $c = count($pieces); |
|
96 | - for($pos++; $pos < $c; $pos++) { |
|
97 | - $piece = $pieces[$pos]; |
|
98 | - if ($piece == 'RMK') break; |
|
99 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
100 | - if ($piece == 'COR') $result['correction'] = true; |
|
101 | - // Wind Speed |
|
102 | - if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
|
103 | - $result['wind']['direction'] = (float)$matches[1]; |
|
80 | + public function parse($data) { |
|
81 | + //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
|
82 | + $codes = implode('|', array_keys($this->texts)); |
|
83 | + $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
84 | + //$pieces = explode(' ',$data); |
|
85 | + $pieces = preg_split('/\s/',$data); |
|
86 | + $pos = 0; |
|
87 | + if ($pieces[0] == 'METAR') $pos++; |
|
88 | + elseif ($pieces[0] == 'SPECI') $pos++; |
|
89 | + if (strlen($pieces[$pos]) != 4) $pos++; |
|
90 | + $result = array(); |
|
91 | + $result['location'] = $pieces[$pos]; |
|
92 | + $pos++; |
|
93 | + $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
94 | + $result['time'] = substr($pieces[$pos],2,4); |
|
95 | + $c = count($pieces); |
|
96 | + for($pos++; $pos < $c; $pos++) { |
|
97 | + $piece = $pieces[$pos]; |
|
98 | + if ($piece == 'RMK') break; |
|
99 | + if ($piece == 'AUTO') $result['auto'] = true; |
|
100 | + if ($piece == 'COR') $result['correction'] = true; |
|
101 | + // Wind Speed |
|
102 | + if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
|
103 | + $result['wind']['direction'] = (float)$matches[1]; |
|
104 | 104 | $result['wind']['unit'] = $matches[4]; |
105 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
106 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
107 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
105 | + if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
106 | + elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
107 | + elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
108 | 108 | $result['wind']['gust'] = (float)$matches[3]; |
109 | 109 | $result['wind']['unit'] = $matches[4]; |
110 | 110 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
111 | 111 | $result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0; |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | 114 | /* if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) { |
115 | 115 | $result['wind_direction'] = (float)$matches[1]; |
@@ -126,35 +126,35 @@ discard block |
||
126 | 126 | } |
127 | 127 | } |
128 | 128 | */ |
129 | - // Temperature |
|
130 | - if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
|
131 | - $temp = (float)$matches[1]; |
|
129 | + // Temperature |
|
130 | + if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
|
131 | + $temp = (float)$matches[1]; |
|
132 | 132 | if ($matches[1]{0} == 'M') { |
133 | 133 | $temp = ((float)substr($matches[1], 1)) * -1; |
134 | 134 | } |
135 | - $result['temperature'] = $temp; |
|
136 | - $dew = (float)$matches[2]; |
|
135 | + $result['temperature'] = $temp; |
|
136 | + $dew = (float)$matches[2]; |
|
137 | 137 | if ($matches[2]{0} == 'M') { |
138 | 138 | $dew = ((float)substr($matches[2], 1)) * -1; |
139 | 139 | } |
140 | 140 | $result['dew'] = $dew; |
141 | - } |
|
142 | - // QNH |
|
143 | - if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) { |
|
144 | - // #^(Q|A)(////|[0-9]{4})( )# |
|
145 | - if ($matches[1] == 'Q') { |
|
146 | - // hPa |
|
147 | - $result['QNH'] = $matches[2]; |
|
148 | - } else { |
|
149 | - // inHg |
|
150 | - $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
151 | 141 | } |
152 | - /* |
|
142 | + // QNH |
|
143 | + if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) { |
|
144 | + // #^(Q|A)(////|[0-9]{4})( )# |
|
145 | + if ($matches[1] == 'Q') { |
|
146 | + // hPa |
|
147 | + $result['QNH'] = $matches[2]; |
|
148 | + } else { |
|
149 | + // inHg |
|
150 | + $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
151 | + } |
|
152 | + /* |
|
153 | 153 | $result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100); |
154 | 154 | $result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg'; |
155 | 155 | */ |
156 | - } |
|
157 | - /* |
|
156 | + } |
|
157 | + /* |
|
158 | 158 | // Wind Direction |
159 | 159 | if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) { |
160 | 160 | $result['wind_direction'] = $matches[1]; |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | $result['speed_variable'] = $matches[1]; |
166 | 166 | } |
167 | 167 | */ |
168 | - // Visibility |
|
169 | - if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
|
170 | - if (isset($matches[3]) && strlen($matches[3]) > 0) { |
|
168 | + // Visibility |
|
169 | + if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
|
170 | + if (isset($matches[3]) && strlen($matches[3]) > 0) { |
|
171 | 171 | $result['visibility'] = (float)$matches[3] * 1609.34; |
172 | 172 | } else { |
173 | 173 | if ($matches[1] == '9999') { |
@@ -180,28 +180,28 @@ discard block |
||
180 | 180 | $result['visibility'] = '> 10000'; |
181 | 181 | $result['weather'] = "CAVOK"; |
182 | 182 | } |
183 | - } |
|
184 | - // Cloud Coverage |
|
185 | - if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) { |
|
186 | - //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
|
187 | - $type = $matches[1]; |
|
188 | - $cloud = array(); |
|
189 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
190 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
191 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
192 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
193 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
194 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
195 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
196 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
197 | - $cloud['type_code'] = $type; |
|
198 | - $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
199 | - $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
|
200 | - $result['cloud'][] = $cloud; |
|
201 | - } |
|
202 | - // RVR |
|
203 | - if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) { |
|
204 | - $rvr = array(); |
|
183 | + } |
|
184 | + // Cloud Coverage |
|
185 | + if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) { |
|
186 | + //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
|
187 | + $type = $matches[1]; |
|
188 | + $cloud = array(); |
|
189 | + if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
190 | + elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
191 | + elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
192 | + elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
193 | + elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
194 | + elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
195 | + elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
196 | + elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
197 | + $cloud['type_code'] = $type; |
|
198 | + $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
199 | + $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
|
200 | + $result['cloud'][] = $cloud; |
|
201 | + } |
|
202 | + // RVR |
|
203 | + if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) { |
|
204 | + $rvr = array(); |
|
205 | 205 | $rvr['runway'] = $matches[1]; |
206 | 206 | $rvr['assessment'] = $matches[2]; |
207 | 207 | $rvr['rvr'] = $matches[3]; |
@@ -210,33 +210,33 @@ discard block |
||
210 | 210 | $result['RVR'] = $rvr; |
211 | 211 | } |
212 | 212 | |
213 | - //if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
214 | - if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) { |
|
215 | - //print_r($matches); |
|
216 | - // https://github.com/davidmegginson/metar-taf/blob/master/Metar.php |
|
217 | - $result['RVR']['runway'] = $matches[1]; |
|
218 | - $result['RVR']['deposits'] = $matches[2]; |
|
219 | - $result['RVR']['extent'] = $matches[3]; |
|
220 | - $result['RVR']['depth'] = $matches[4]; |
|
221 | - $result['RVR']['friction'] = $matches[5]; |
|
222 | - } |
|
223 | - if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
224 | - //echo $piece; |
|
225 | - //print_r($matches); |
|
226 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
213 | + //if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
214 | + if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) { |
|
215 | + //print_r($matches); |
|
216 | + // https://github.com/davidmegginson/metar-taf/blob/master/Metar.php |
|
217 | + $result['RVR']['runway'] = $matches[1]; |
|
218 | + $result['RVR']['deposits'] = $matches[2]; |
|
219 | + $result['RVR']['extent'] = $matches[3]; |
|
220 | + $result['RVR']['depth'] = $matches[4]; |
|
221 | + $result['RVR']['friction'] = $matches[5]; |
|
222 | + } |
|
223 | + if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
|
224 | + //echo $piece; |
|
225 | + //print_r($matches); |
|
226 | + if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | + else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
228 | 228 | if (isset($matches[3])) { |
229 | 229 | $range = Array( |
230 | - 'from' => (float)$matches[2], |
|
231 | - 'to' => (float)$matches[4], |
|
232 | - 'unit' => $matches[5] ? 'FT' : 'M' |
|
230 | + 'from' => (float)$matches[2], |
|
231 | + 'to' => (float)$matches[4], |
|
232 | + 'unit' => $matches[5] ? 'FT' : 'M' |
|
233 | 233 | ); |
234 | 234 | } |
235 | 235 | $result['RVR'] = $matches[1]; |
236 | 236 | $result['RVR_range'] = $range; |
237 | - } |
|
238 | - // Weather |
|
239 | - if (preg_match($regWeather, $piece, $matches)) { |
|
237 | + } |
|
238 | + // Weather |
|
239 | + if (preg_match($regWeather, $piece, $matches)) { |
|
240 | 240 | $text = Array(); |
241 | 241 | switch ($matches[1]) { |
242 | 242 | case '+': |
@@ -259,35 +259,35 @@ discard block |
||
259 | 259 | } |
260 | 260 | if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
261 | 261 | else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
262 | - } |
|
263 | - } |
|
264 | - return $result; |
|
262 | + } |
|
263 | + } |
|
264 | + return $result; |
|
265 | 265 | |
266 | - } |
|
266 | + } |
|
267 | 267 | |
268 | 268 | public function getMETAR($icao) { |
269 | - global $globalMETARcycle, $globalDBdriver; |
|
270 | - if (isset($globalMETARcycle) && $globalMETARcycle) { |
|
271 | - $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
|
272 | - } else { |
|
273 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
274 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
275 | - } |
|
276 | - $query_values = array(':icao' => $icao); |
|
277 | - try { |
|
278 | - $sth = $this->db->prepare($query); |
|
279 | - $sth->execute($query_values); |
|
280 | - } catch(PDOException $e) { |
|
281 | - return "error : ".$e->getMessage(); |
|
282 | - } |
|
283 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
284 | - if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) { |
|
285 | - $all = $this->downloadMETAR($icao); |
|
286 | - } |
|
287 | - return $all; |
|
288 | - } |
|
269 | + global $globalMETARcycle, $globalDBdriver; |
|
270 | + if (isset($globalMETARcycle) && $globalMETARcycle) { |
|
271 | + $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
|
272 | + } else { |
|
273 | + if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
274 | + else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
275 | + } |
|
276 | + $query_values = array(':icao' => $icao); |
|
277 | + try { |
|
278 | + $sth = $this->db->prepare($query); |
|
279 | + $sth->execute($query_values); |
|
280 | + } catch(PDOException $e) { |
|
281 | + return "error : ".$e->getMessage(); |
|
282 | + } |
|
283 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
284 | + if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) { |
|
285 | + $all = $this->downloadMETAR($icao); |
|
286 | + } |
|
287 | + return $all; |
|
288 | + } |
|
289 | 289 | |
290 | - public function addMETAR($location,$metar,$date) { |
|
290 | + public function addMETAR($location,$metar,$date) { |
|
291 | 291 | global $globalDBdriver; |
292 | 292 | $date = date('Y-m-d H:i:s',strtotime($date)); |
293 | 293 | if ($globalDBdriver == 'mysql') { |
@@ -295,106 +295,106 @@ discard block |
||
295 | 295 | } else { |
296 | 296 | $query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);"; |
297 | 297 | } |
298 | - $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
299 | - try { |
|
300 | - $sth = $this->db->prepare($query); |
|
301 | - $sth->execute($query_values); |
|
302 | - } catch(PDOException $e) { |
|
303 | - return "error : ".$e->getMessage(); |
|
304 | - } |
|
305 | - } |
|
298 | + $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
299 | + try { |
|
300 | + $sth = $this->db->prepare($query); |
|
301 | + $sth->execute($query_values); |
|
302 | + } catch(PDOException $e) { |
|
303 | + return "error : ".$e->getMessage(); |
|
304 | + } |
|
305 | + } |
|
306 | 306 | |
307 | - public function deleteMETAR($id) { |
|
308 | - $query = "DELETE FROM metar WHERE id = :id"; |
|
309 | - $query_values = array(':id' => $id); |
|
310 | - try { |
|
311 | - $sth = $this->db->prepare($query); |
|
312 | - $sth->execute($query_values); |
|
313 | - } catch(PDOException $e) { |
|
314 | - return "error : ".$e->getMessage(); |
|
315 | - } |
|
316 | - } |
|
317 | - public function deleteAllMETARLocation() { |
|
318 | - $query = "DELETE FROM metar"; |
|
319 | - try { |
|
320 | - $sth = $this->db->prepare($query); |
|
321 | - $sth->execute(); |
|
322 | - } catch(PDOException $e) { |
|
323 | - return "error : ".$e->getMessage(); |
|
324 | - } |
|
325 | - } |
|
307 | + public function deleteMETAR($id) { |
|
308 | + $query = "DELETE FROM metar WHERE id = :id"; |
|
309 | + $query_values = array(':id' => $id); |
|
310 | + try { |
|
311 | + $sth = $this->db->prepare($query); |
|
312 | + $sth->execute($query_values); |
|
313 | + } catch(PDOException $e) { |
|
314 | + return "error : ".$e->getMessage(); |
|
315 | + } |
|
316 | + } |
|
317 | + public function deleteAllMETARLocation() { |
|
318 | + $query = "DELETE FROM metar"; |
|
319 | + try { |
|
320 | + $sth = $this->db->prepare($query); |
|
321 | + $sth->execute(); |
|
322 | + } catch(PDOException $e) { |
|
323 | + return "error : ".$e->getMessage(); |
|
324 | + } |
|
325 | + } |
|
326 | 326 | |
327 | - public function addMETARCycle() { |
|
328 | - global $globalDebug, $globalIVAO, $globalTransaction; |
|
329 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
330 | - date_default_timezone_set("UTC"); |
|
331 | - $Common = new Common(); |
|
332 | - if (isset($globalIVAO) && $globalIVAO) { |
|
333 | - //$cycle = $Common->getData('http://wx.ivao.aero/metar.php'); |
|
327 | + public function addMETARCycle() { |
|
328 | + global $globalDebug, $globalIVAO, $globalTransaction; |
|
329 | + if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
330 | + date_default_timezone_set("UTC"); |
|
331 | + $Common = new Common(); |
|
332 | + if (isset($globalIVAO) && $globalIVAO) { |
|
333 | + //$cycle = $Common->getData('http://wx.ivao.aero/metar.php'); |
|
334 | 334 | $Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
335 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
336 | - } else { |
|
335 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
336 | + } else { |
|
337 | 337 | //$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT'); |
338 | 338 | $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
339 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
340 | - } |
|
341 | - if ($handle) { |
|
339 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
340 | + } |
|
341 | + if ($handle) { |
|
342 | 342 | if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
343 | 343 | $date = ''; |
344 | - //foreach(explode("\n",$cycle) as $line) { |
|
345 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
346 | - while(($line = fgets($handle,4096)) !== false) { |
|
344 | + //foreach(explode("\n",$cycle) as $line) { |
|
345 | + if ($globalTransaction) $this->db->beginTransaction(); |
|
346 | + while(($line = fgets($handle,4096)) !== false) { |
|
347 | 347 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
348 | 348 | $date = $line; |
349 | - } elseif ($line != '') { |
|
350 | - //$this->parse($line); |
|
351 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
352 | - $pos = 0; |
|
353 | - $pieces = preg_split('/\s/',$line); |
|
354 | - if ($pieces[0] == 'METAR') $pos++; |
|
355 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
356 | - $location = $pieces[$pos]; |
|
357 | - echo $this->addMETAR($location,$line,$date); |
|
358 | - } |
|
359 | - } |
|
360 | - fclose($handle); |
|
361 | - if ($globalTransaction) $this->db->commit(); |
|
362 | - } |
|
363 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
349 | + } elseif ($line != '') { |
|
350 | + //$this->parse($line); |
|
351 | + if ($date == '') $date = date('Y/m/d H:m'); |
|
352 | + $pos = 0; |
|
353 | + $pieces = preg_split('/\s/',$line); |
|
354 | + if ($pieces[0] == 'METAR') $pos++; |
|
355 | + if (strlen($pieces[$pos]) != 4) $pos++; |
|
356 | + $location = $pieces[$pos]; |
|
357 | + echo $this->addMETAR($location,$line,$date); |
|
358 | + } |
|
359 | + } |
|
360 | + fclose($handle); |
|
361 | + if ($globalTransaction) $this->db->commit(); |
|
362 | + } |
|
363 | + if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
364 | 364 | |
365 | - } |
|
366 | - public function downloadMETAR($icao) { |
|
367 | - global $globalMETARurl; |
|
368 | - if ($globalMETARurl == '') return array(); |
|
369 | - date_default_timezone_set("UTC"); |
|
370 | - $Common = new Common(); |
|
371 | - $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
372 | - $cycle = $Common->getData($url); |
|
373 | - $date = ''; |
|
374 | - foreach(explode("\n",$cycle) as $line) { |
|
375 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
376 | - //echo "date : ".$line."\n"; |
|
377 | - $date = $line; |
|
378 | - } |
|
379 | - if ($line != '') { |
|
380 | - //$this->parse($line); |
|
381 | - //echo $line; |
|
382 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
383 | - $pos = 0; |
|
384 | - $pieces = preg_split('/\s/',$line); |
|
385 | - if ($pieces[0] == 'METAR') $pos++; |
|
386 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
387 | - $location = $pieces[$pos]; |
|
388 | - if (strlen($location == 4)) { |
|
389 | - $this->addMETAR($location,$line,$date); |
|
390 | - return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
|
391 | - } else return array(); |
|
392 | - } |
|
393 | - //echo $line."\n"; |
|
394 | - } |
|
395 | - return array(); |
|
365 | + } |
|
366 | + public function downloadMETAR($icao) { |
|
367 | + global $globalMETARurl; |
|
368 | + if ($globalMETARurl == '') return array(); |
|
369 | + date_default_timezone_set("UTC"); |
|
370 | + $Common = new Common(); |
|
371 | + $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
372 | + $cycle = $Common->getData($url); |
|
373 | + $date = ''; |
|
374 | + foreach(explode("\n",$cycle) as $line) { |
|
375 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
376 | + //echo "date : ".$line."\n"; |
|
377 | + $date = $line; |
|
378 | + } |
|
379 | + if ($line != '') { |
|
380 | + //$this->parse($line); |
|
381 | + //echo $line; |
|
382 | + if ($date == '') $date = date('Y/m/d H:m'); |
|
383 | + $pos = 0; |
|
384 | + $pieces = preg_split('/\s/',$line); |
|
385 | + if ($pieces[0] == 'METAR') $pos++; |
|
386 | + if (strlen($pieces[$pos]) != 4) $pos++; |
|
387 | + $location = $pieces[$pos]; |
|
388 | + if (strlen($location == 4)) { |
|
389 | + $this->addMETAR($location,$line,$date); |
|
390 | + return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
|
391 | + } else return array(); |
|
392 | + } |
|
393 | + //echo $line."\n"; |
|
394 | + } |
|
395 | + return array(); |
|
396 | 396 | |
397 | - } |
|
397 | + } |
|
398 | 398 | } |
399 | 399 | /* |
400 | 400 | $METAR = new METAR(); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $Connection = new Connection(); |
55 | 55 | $sth = $Connection->db->prepare($query); |
56 | 56 | $sth->execute(); |
57 | - } catch(PDOException $e) { |
|
57 | + } catch (PDOException $e) { |
|
58 | 58 | return "error : ".$e->getMessage(); |
59 | 59 | } |
60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $Connection = new Connection(); |
71 | 71 | $sth = $Connection->db->prepare($query); |
72 | 72 | $sth->execute(); |
73 | - } catch(PDOException $e) { |
|
73 | + } catch (PDOException $e) { |
|
74 | 74 | return "error : ".$e->getMessage(); |
75 | 75 | } |
76 | 76 | } |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | public function parse($data) { |
81 | 81 | //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
82 | 82 | $codes = implode('|', array_keys($this->texts)); |
83 | - $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
83 | + $regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#'; |
|
84 | 84 | //$pieces = explode(' ',$data); |
85 | - $pieces = preg_split('/\s/',$data); |
|
85 | + $pieces = preg_split('/\s/', $data); |
|
86 | 86 | $pos = 0; |
87 | 87 | if ($pieces[0] == 'METAR') $pos++; |
88 | 88 | elseif ($pieces[0] == 'SPECI') $pos++; |
@@ -90,25 +90,25 @@ discard block |
||
90 | 90 | $result = array(); |
91 | 91 | $result['location'] = $pieces[$pos]; |
92 | 92 | $pos++; |
93 | - $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
94 | - $result['time'] = substr($pieces[$pos],2,4); |
|
93 | + $result['dayofmonth'] = substr($pieces[$pos], 0, 2); |
|
94 | + $result['time'] = substr($pieces[$pos], 2, 4); |
|
95 | 95 | $c = count($pieces); |
96 | - for($pos++; $pos < $c; $pos++) { |
|
96 | + for ($pos++; $pos < $c; $pos++) { |
|
97 | 97 | $piece = $pieces[$pos]; |
98 | 98 | if ($piece == 'RMK') break; |
99 | 99 | if ($piece == 'AUTO') $result['auto'] = true; |
100 | 100 | if ($piece == 'COR') $result['correction'] = true; |
101 | 101 | // Wind Speed |
102 | 102 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
103 | - $result['wind']['direction'] = (float)$matches[1]; |
|
103 | + $result['wind']['direction'] = (float) $matches[1]; |
|
104 | 104 | $result['wind']['unit'] = $matches[4]; |
105 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
106 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
107 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
108 | - $result['wind']['gust'] = (float)$matches[3]; |
|
105 | + if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2); |
|
106 | + elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2); |
|
107 | + elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2); |
|
108 | + $result['wind']['gust'] = (float) $matches[3]; |
|
109 | 109 | $result['wind']['unit'] = $matches[4]; |
110 | - $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
|
111 | - $result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0; |
|
110 | + $result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0; |
|
111 | + $result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /* if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) { |
@@ -128,14 +128,14 @@ discard block |
||
128 | 128 | */ |
129 | 129 | // Temperature |
130 | 130 | if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
131 | - $temp = (float)$matches[1]; |
|
131 | + $temp = (float) $matches[1]; |
|
132 | 132 | if ($matches[1]{0} == 'M') { |
133 | - $temp = ((float)substr($matches[1], 1)) * -1; |
|
133 | + $temp = ((float) substr($matches[1], 1))*-1; |
|
134 | 134 | } |
135 | 135 | $result['temperature'] = $temp; |
136 | - $dew = (float)$matches[2]; |
|
136 | + $dew = (float) $matches[2]; |
|
137 | 137 | if ($matches[2]{0} == 'M') { |
138 | - $dew = ((float)substr($matches[2], 1)) * -1; |
|
138 | + $dew = ((float) substr($matches[2], 1))*-1; |
|
139 | 139 | } |
140 | 140 | $result['dew'] = $dew; |
141 | 141 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $result['QNH'] = $matches[2]; |
148 | 148 | } else { |
149 | 149 | // inHg |
150 | - $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
150 | + $result['QNH'] = round(($matches[2]/100)*33.86389, 2); |
|
151 | 151 | } |
152 | 152 | /* |
153 | 153 | $result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100); |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | // Visibility |
169 | 169 | if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
170 | 170 | if (isset($matches[3]) && strlen($matches[3]) > 0) { |
171 | - $result['visibility'] = (float)$matches[3] * 1609.34; |
|
171 | + $result['visibility'] = (float) $matches[3]*1609.34; |
|
172 | 172 | } else { |
173 | 173 | if ($matches[1] == '9999') { |
174 | 174 | $result['visibility'] = '> 10000'; |
175 | 175 | } else { |
176 | - $result['visibility'] = (float)$matches[1]; |
|
176 | + $result['visibility'] = (float) $matches[1]; |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | if (preg_match('#^CAVOK$#', $piece, $matches)) { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
196 | 196 | elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
197 | 197 | $cloud['type_code'] = $type; |
198 | - $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
198 | + $cloud['level'] = round(((float) $matches[2])*100*0.3048); |
|
199 | 199 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
200 | 200 | $result['cloud'][] = $cloud; |
201 | 201 | } |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | $rvr['runway'] = $matches[1]; |
206 | 206 | $rvr['assessment'] = $matches[2]; |
207 | 207 | $rvr['rvr'] = $matches[3]; |
208 | - $rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0; |
|
209 | - $rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : ''; |
|
208 | + $rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0; |
|
209 | + $rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : ''; |
|
210 | 210 | $result['RVR'] = $rvr; |
211 | 211 | } |
212 | 212 | |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
224 | 224 | //echo $piece; |
225 | 225 | //print_r($matches); |
226 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
226 | + if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | + else $range = array('exact' => (float) $matches[2], 'unit' => 'M'); |
|
228 | 228 | if (isset($matches[3])) { |
229 | 229 | $range = Array( |
230 | - 'from' => (float)$matches[2], |
|
231 | - 'to' => (float)$matches[4], |
|
230 | + 'from' => (float) $matches[2], |
|
231 | + 'to' => (float) $matches[4], |
|
232 | 232 | 'unit' => $matches[5] ? 'FT' : 'M' |
233 | 233 | ); |
234 | 234 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | try { |
278 | 278 | $sth = $this->db->prepare($query); |
279 | 279 | $sth->execute($query_values); |
280 | - } catch(PDOException $e) { |
|
280 | + } catch (PDOException $e) { |
|
281 | 281 | return "error : ".$e->getMessage(); |
282 | 282 | } |
283 | 283 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -287,19 +287,19 @@ discard block |
||
287 | 287 | return $all; |
288 | 288 | } |
289 | 289 | |
290 | - public function addMETAR($location,$metar,$date) { |
|
290 | + public function addMETAR($location, $metar, $date) { |
|
291 | 291 | global $globalDBdriver; |
292 | - $date = date('Y-m-d H:i:s',strtotime($date)); |
|
292 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
293 | 293 | if ($globalDBdriver == 'mysql') { |
294 | 294 | $query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar"; |
295 | 295 | } else { |
296 | 296 | $query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);"; |
297 | 297 | } |
298 | - $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
298 | + $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar)); |
|
299 | 299 | try { |
300 | 300 | $sth = $this->db->prepare($query); |
301 | 301 | $sth->execute($query_values); |
302 | - } catch(PDOException $e) { |
|
302 | + } catch (PDOException $e) { |
|
303 | 303 | return "error : ".$e->getMessage(); |
304 | 304 | } |
305 | 305 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | try { |
311 | 311 | $sth = $this->db->prepare($query); |
312 | 312 | $sth->execute($query_values); |
313 | - } catch(PDOException $e) { |
|
313 | + } catch (PDOException $e) { |
|
314 | 314 | return "error : ".$e->getMessage(); |
315 | 315 | } |
316 | 316 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | try { |
320 | 320 | $sth = $this->db->prepare($query); |
321 | 321 | $sth->execute(); |
322 | - } catch(PDOException $e) { |
|
322 | + } catch (PDOException $e) { |
|
323 | 323 | return "error : ".$e->getMessage(); |
324 | 324 | } |
325 | 325 | } |
@@ -331,30 +331,30 @@ discard block |
||
331 | 331 | $Common = new Common(); |
332 | 332 | if (isset($globalIVAO) && $globalIVAO) { |
333 | 333 | //$cycle = $Common->getData('http://wx.ivao.aero/metar.php'); |
334 | - $Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
335 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
334 | + $Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
335 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r"); |
|
336 | 336 | } else { |
337 | 337 | //$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT'); |
338 | - $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
339 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
338 | + $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
339 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r"); |
|
340 | 340 | } |
341 | 341 | if ($handle) { |
342 | 342 | if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
343 | 343 | $date = ''; |
344 | 344 | //foreach(explode("\n",$cycle) as $line) { |
345 | 345 | if ($globalTransaction) $this->db->beginTransaction(); |
346 | - while(($line = fgets($handle,4096)) !== false) { |
|
347 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
346 | + while (($line = fgets($handle, 4096)) !== false) { |
|
347 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
348 | 348 | $date = $line; |
349 | 349 | } elseif ($line != '') { |
350 | 350 | //$this->parse($line); |
351 | 351 | if ($date == '') $date = date('Y/m/d H:m'); |
352 | 352 | $pos = 0; |
353 | - $pieces = preg_split('/\s/',$line); |
|
353 | + $pieces = preg_split('/\s/', $line); |
|
354 | 354 | if ($pieces[0] == 'METAR') $pos++; |
355 | 355 | if (strlen($pieces[$pos]) != 4) $pos++; |
356 | 356 | $location = $pieces[$pos]; |
357 | - echo $this->addMETAR($location,$line,$date); |
|
357 | + echo $this->addMETAR($location, $line, $date); |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | fclose($handle); |
@@ -368,11 +368,11 @@ discard block |
||
368 | 368 | if ($globalMETARurl == '') return array(); |
369 | 369 | date_default_timezone_set("UTC"); |
370 | 370 | $Common = new Common(); |
371 | - $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
371 | + $url = str_replace('{icao}', $icao, $globalMETARurl); |
|
372 | 372 | $cycle = $Common->getData($url); |
373 | 373 | $date = ''; |
374 | - foreach(explode("\n",$cycle) as $line) { |
|
375 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
374 | + foreach (explode("\n", $cycle) as $line) { |
|
375 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
376 | 376 | //echo "date : ".$line."\n"; |
377 | 377 | $date = $line; |
378 | 378 | } |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | //echo $line; |
382 | 382 | if ($date == '') $date = date('Y/m/d H:m'); |
383 | 383 | $pos = 0; |
384 | - $pieces = preg_split('/\s/',$line); |
|
384 | + $pieces = preg_split('/\s/', $line); |
|
385 | 385 | if ($pieces[0] == 'METAR') $pos++; |
386 | 386 | if (strlen($pieces[$pos]) != 4) $pos++; |
387 | 387 | $location = $pieces[$pos]; |
388 | 388 | if (strlen($location == 4)) { |
389 | - $this->addMETAR($location,$line,$date); |
|
389 | + $this->addMETAR($location, $line, $date); |
|
390 | 390 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
391 | 391 | } else return array(); |
392 | 392 | } |
@@ -59,8 +59,11 @@ discard block |
||
59 | 59 | } |
60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
61 | 61 | $sth->closeCursor(); |
62 | - if ($row['nb'] > 0) return false; |
|
63 | - else return true; |
|
62 | + if ($row['nb'] > 0) { |
|
63 | + return false; |
|
64 | + } else { |
|
65 | + return true; |
|
66 | + } |
|
64 | 67 | } |
65 | 68 | |
66 | 69 | public static function insert_last_update() { |
@@ -84,9 +87,14 @@ discard block |
||
84 | 87 | //$pieces = explode(' ',$data); |
85 | 88 | $pieces = preg_split('/\s/',$data); |
86 | 89 | $pos = 0; |
87 | - if ($pieces[0] == 'METAR') $pos++; |
|
88 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
89 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
90 | + if ($pieces[0] == 'METAR') { |
|
91 | + $pos++; |
|
92 | + } elseif ($pieces[0] == 'SPECI') { |
|
93 | + $pos++; |
|
94 | + } |
|
95 | + if (strlen($pieces[$pos]) != 4) { |
|
96 | + $pos++; |
|
97 | + } |
|
90 | 98 | $result = array(); |
91 | 99 | $result['location'] = $pieces[$pos]; |
92 | 100 | $pos++; |
@@ -95,16 +103,26 @@ discard block |
||
95 | 103 | $c = count($pieces); |
96 | 104 | for($pos++; $pos < $c; $pos++) { |
97 | 105 | $piece = $pieces[$pos]; |
98 | - if ($piece == 'RMK') break; |
|
99 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
100 | - if ($piece == 'COR') $result['correction'] = true; |
|
106 | + if ($piece == 'RMK') { |
|
107 | + break; |
|
108 | + } |
|
109 | + if ($piece == 'AUTO') { |
|
110 | + $result['auto'] = true; |
|
111 | + } |
|
112 | + if ($piece == 'COR') { |
|
113 | + $result['correction'] = true; |
|
114 | + } |
|
101 | 115 | // Wind Speed |
102 | 116 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
103 | 117 | $result['wind']['direction'] = (float)$matches[1]; |
104 | 118 | $result['wind']['unit'] = $matches[4]; |
105 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
106 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
107 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
119 | + if ($result['wind']['unit'] == 'KT') { |
|
120 | + $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
121 | + } elseif ($result['wind']['unit'] == 'KPH') { |
|
122 | + $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
123 | + } elseif ($result['wind']['unit'] == 'MPS') { |
|
124 | + $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
125 | + } |
|
108 | 126 | $result['wind']['gust'] = (float)$matches[3]; |
109 | 127 | $result['wind']['unit'] = $matches[4]; |
110 | 128 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
@@ -186,14 +204,23 @@ discard block |
||
186 | 204 | //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
187 | 205 | $type = $matches[1]; |
188 | 206 | $cloud = array(); |
189 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
190 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
191 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
192 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
193 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
194 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
195 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
196 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
207 | + if ($type == 'SKC') { |
|
208 | + $cloud['type'] = 'No cloud/Sky clear'; |
|
209 | + } elseif ($type == 'CLR') { |
|
210 | + $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
211 | + } elseif ($type == 'NSC') { |
|
212 | + $cloud['type'] = 'No significant cloud'; |
|
213 | + } elseif ($type == 'FEW') { |
|
214 | + $cloud['type'] = 'Few'; |
|
215 | + } elseif ($type == 'SCT') { |
|
216 | + $cloud['type'] = 'Scattered'; |
|
217 | + } elseif ($type == 'BKN') { |
|
218 | + $cloud['type'] = 'Broken'; |
|
219 | + } elseif ($type == 'OVC') { |
|
220 | + $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
221 | + } elseif ($type == 'VV') { |
|
222 | + $cloud['type'] = 'Vertical visibility'; |
|
223 | + } |
|
197 | 224 | $cloud['type_code'] = $type; |
198 | 225 | $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
199 | 226 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
@@ -223,8 +250,11 @@ discard block |
||
223 | 250 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
224 | 251 | //echo $piece; |
225 | 252 | //print_r($matches); |
226 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
253 | + if (isset($matches[5])) { |
|
254 | + $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
255 | + } else { |
|
256 | + $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
257 | + } |
|
228 | 258 | if (isset($matches[3])) { |
229 | 259 | $range = Array( |
230 | 260 | 'from' => (float)$matches[2], |
@@ -257,8 +287,11 @@ discard block |
||
257 | 287 | if (isset($matches[3])) { |
258 | 288 | $text[] = $this->texts[$matches[3]]; |
259 | 289 | } |
260 | - if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
|
261 | - else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
290 | + if (!isset($result['weather'])) { |
|
291 | + $result['weather'] = implode(' ', $text); |
|
292 | + } else { |
|
293 | + $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
294 | + } |
|
262 | 295 | } |
263 | 296 | } |
264 | 297 | return $result; |
@@ -270,8 +303,11 @@ discard block |
||
270 | 303 | if (isset($globalMETARcycle) && $globalMETARcycle) { |
271 | 304 | $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
272 | 305 | } else { |
273 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
274 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
306 | + if ($globalDBdriver == 'mysql') { |
|
307 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
308 | + } else { |
|
309 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
310 | + } |
|
275 | 311 | } |
276 | 312 | $query_values = array(':icao' => $icao); |
277 | 313 | try { |
@@ -326,7 +362,9 @@ discard block |
||
326 | 362 | |
327 | 363 | public function addMETARCycle() { |
328 | 364 | global $globalDebug, $globalIVAO, $globalTransaction; |
329 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
365 | + if (isset($globalDebug) && $globalDebug) { |
|
366 | + echo "Downloading METAR cycle..."; |
|
367 | + } |
|
330 | 368 | date_default_timezone_set("UTC"); |
331 | 369 | $Common = new Common(); |
332 | 370 | if (isset($globalIVAO) && $globalIVAO) { |
@@ -339,33 +377,49 @@ discard block |
||
339 | 377 | $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
340 | 378 | } |
341 | 379 | if ($handle) { |
342 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
380 | + if (isset($globalDebug) && $globalDebug) { |
|
381 | + echo "Done - Updating DB..."; |
|
382 | + } |
|
343 | 383 | $date = ''; |
344 | 384 | //foreach(explode("\n",$cycle) as $line) { |
345 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
385 | + if ($globalTransaction) { |
|
386 | + $this->db->beginTransaction(); |
|
387 | + } |
|
346 | 388 | while(($line = fgets($handle,4096)) !== false) { |
347 | 389 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
348 | 390 | $date = $line; |
349 | 391 | } elseif ($line != '') { |
350 | 392 | //$this->parse($line); |
351 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
393 | + if ($date == '') { |
|
394 | + $date = date('Y/m/d H:m'); |
|
395 | + } |
|
352 | 396 | $pos = 0; |
353 | 397 | $pieces = preg_split('/\s/',$line); |
354 | - if ($pieces[0] == 'METAR') $pos++; |
|
355 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
398 | + if ($pieces[0] == 'METAR') { |
|
399 | + $pos++; |
|
400 | + } |
|
401 | + if (strlen($pieces[$pos]) != 4) { |
|
402 | + $pos++; |
|
403 | + } |
|
356 | 404 | $location = $pieces[$pos]; |
357 | 405 | echo $this->addMETAR($location,$line,$date); |
358 | 406 | } |
359 | 407 | } |
360 | 408 | fclose($handle); |
361 | - if ($globalTransaction) $this->db->commit(); |
|
409 | + if ($globalTransaction) { |
|
410 | + $this->db->commit(); |
|
411 | + } |
|
412 | + } |
|
413 | + if (isset($globalDebug) && $globalDebug) { |
|
414 | + echo "Done\n"; |
|
362 | 415 | } |
363 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
364 | 416 | |
365 | 417 | } |
366 | 418 | public function downloadMETAR($icao) { |
367 | 419 | global $globalMETARurl; |
368 | - if ($globalMETARurl == '') return array(); |
|
420 | + if ($globalMETARurl == '') { |
|
421 | + return array(); |
|
422 | + } |
|
369 | 423 | date_default_timezone_set("UTC"); |
370 | 424 | $Common = new Common(); |
371 | 425 | $url = str_replace('{icao}',$icao,$globalMETARurl); |
@@ -379,16 +433,24 @@ discard block |
||
379 | 433 | if ($line != '') { |
380 | 434 | //$this->parse($line); |
381 | 435 | //echo $line; |
382 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
436 | + if ($date == '') { |
|
437 | + $date = date('Y/m/d H:m'); |
|
438 | + } |
|
383 | 439 | $pos = 0; |
384 | 440 | $pieces = preg_split('/\s/',$line); |
385 | - if ($pieces[0] == 'METAR') $pos++; |
|
386 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
441 | + if ($pieces[0] == 'METAR') { |
|
442 | + $pos++; |
|
443 | + } |
|
444 | + if (strlen($pieces[$pos]) != 4) { |
|
445 | + $pos++; |
|
446 | + } |
|
387 | 447 | $location = $pieces[$pos]; |
388 | 448 | if (strlen($location == 4)) { |
389 | 449 | $this->addMETAR($location,$line,$date); |
390 | 450 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
391 | - } else return array(); |
|
451 | + } else { |
|
452 | + return array(); |
|
453 | + } |
|
392 | 454 | } |
393 | 455 | //echo $line."\n"; |
394 | 456 | } |
@@ -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; |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * Gets all the spotter information based on the latest data entry |
|
132 | - * |
|
133 | - * @return Array the spotter information |
|
134 | - * |
|
135 | - */ |
|
131 | + * Gets all the spotter information based on the latest data entry |
|
132 | + * |
|
133 | + * @return Array the spotter information |
|
134 | + * |
|
135 | + */ |
|
136 | 136 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
137 | 137 | { |
138 | 138 | global $globalDBdriver, $globalLiveInterval; |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
177 | - * Gets Minimal Live Spotter data |
|
178 | - * |
|
179 | - * @return Array the spotter information |
|
180 | - * |
|
181 | - */ |
|
177 | + * Gets Minimal Live Spotter data |
|
178 | + * |
|
179 | + * @return Array the spotter information |
|
180 | + * |
|
181 | + */ |
|
182 | 182 | public function getMinLiveSpotterData($filter = array()) |
183 | 183 | { |
184 | 184 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
218 | - * Gets Minimal Live Spotter data since xx seconds |
|
219 | - * |
|
220 | - * @return Array the spotter information |
|
221 | - * |
|
222 | - */ |
|
218 | + * Gets Minimal Live Spotter data since xx seconds |
|
219 | + * |
|
220 | + * @return Array the spotter information |
|
221 | + * |
|
222 | + */ |
|
223 | 223 | public function getMinLastLiveSpotterData($filter = array()) |
224 | 224 | { |
225 | 225 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
239 | 239 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
240 | 240 | } |
241 | - } else { |
|
241 | + } else { |
|
242 | 242 | if (isset($globalArchive) && $globalArchive === TRUE) { |
243 | 243 | $query = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
244 | 244 | 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 WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | - try { |
|
253 | + try { |
|
254 | 254 | $sth = $this->db->prepare($query); |
255 | 255 | $sth->execute(); |
256 | 256 | } catch(PDOException $e) { |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | - * Gets number of latest data entry |
|
266 | - * |
|
267 | - * @return String number of entry |
|
268 | - * |
|
269 | - */ |
|
265 | + * Gets number of latest data entry |
|
266 | + * |
|
267 | + * @return String number of entry |
|
268 | + * |
|
269 | + */ |
|
270 | 270 | public function getLiveSpotterCount($filter = array()) |
271 | 271 | { |
272 | 272 | global $globalDBdriver, $globalLiveInterval; |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
296 | - * Gets all the spotter information based on the latest data entry and coord |
|
297 | - * |
|
298 | - * @return Array the spotter information |
|
299 | - * |
|
300 | - */ |
|
296 | + * Gets all the spotter information based on the latest data entry and coord |
|
297 | + * |
|
298 | + * @return Array the spotter information |
|
299 | + * |
|
300 | + */ |
|
301 | 301 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
302 | 302 | { |
303 | 303 | global $globalDBdriver, $globalLiveInterval; |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
325 | - * Gets all the spotter information based on the latest data entry and coord |
|
326 | - * |
|
327 | - * @return Array the spotter information |
|
328 | - * |
|
329 | - */ |
|
325 | + * Gets all the spotter information based on the latest data entry and coord |
|
326 | + * |
|
327 | + * @return Array the spotter information |
|
328 | + * |
|
329 | + */ |
|
330 | 330 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
331 | 331 | { |
332 | 332 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
394 | - * Gets all the spotter information based on a user's latitude and longitude |
|
395 | - * |
|
396 | - * @return Array the spotter information |
|
397 | - * |
|
398 | - */ |
|
394 | + * Gets all the spotter information based on a user's latitude and longitude |
|
395 | + * |
|
396 | + * @return Array the spotter information |
|
397 | + * |
|
398 | + */ |
|
399 | 399 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
400 | 400 | { |
401 | 401 | $Spotter = new Spotter($this->db); |
@@ -405,145 +405,145 @@ discard block |
||
405 | 405 | return false; |
406 | 406 | } |
407 | 407 | } |
408 | - if ($lng != '') |
|
409 | - { |
|
410 | - if (!is_numeric($lng)) |
|
411 | - { |
|
412 | - return false; |
|
413 | - } |
|
414 | - } |
|
415 | - |
|
416 | - if ($radius != '') |
|
417 | - { |
|
418 | - if (!is_numeric($radius)) |
|
419 | - { |
|
420 | - return false; |
|
421 | - } |
|
422 | - } |
|
408 | + if ($lng != '') |
|
409 | + { |
|
410 | + if (!is_numeric($lng)) |
|
411 | + { |
|
412 | + return false; |
|
413 | + } |
|
414 | + } |
|
415 | + |
|
416 | + if ($radius != '') |
|
417 | + { |
|
418 | + if (!is_numeric($radius)) |
|
419 | + { |
|
420 | + return false; |
|
421 | + } |
|
422 | + } |
|
423 | 423 | $additional_query = ''; |
424 | - if ($interval != '') |
|
425 | - { |
|
426 | - if (!is_string($interval)) |
|
427 | - { |
|
428 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
429 | - return false; |
|
430 | - } else { |
|
431 | - if ($interval == '1m') |
|
432 | - { |
|
433 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
434 | - } else if ($interval == '15m'){ |
|
435 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
436 | - } |
|
437 | - } |
|
438 | - } else { |
|
439 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
440 | - } |
|
441 | - |
|
442 | - $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 |
|
424 | + if ($interval != '') |
|
425 | + { |
|
426 | + if (!is_string($interval)) |
|
427 | + { |
|
428 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
429 | + return false; |
|
430 | + } else { |
|
431 | + if ($interval == '1m') |
|
432 | + { |
|
433 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
434 | + } else if ($interval == '15m'){ |
|
435 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
436 | + } |
|
437 | + } |
|
438 | + } else { |
|
439 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
440 | + } |
|
441 | + |
|
442 | + $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 |
|
443 | 443 | WHERE spotter_live.latitude <> '' |
444 | 444 | AND spotter_live.longitude <> '' |
445 | 445 | ".$additional_query." |
446 | 446 | HAVING distance < :radius |
447 | 447 | ORDER BY distance"; |
448 | 448 | |
449 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
449 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
450 | 450 | |
451 | - return $spotter_array; |
|
452 | - } |
|
451 | + return $spotter_array; |
|
452 | + } |
|
453 | 453 | |
454 | 454 | |
455 | - /** |
|
456 | - * Gets all the spotter information based on a particular callsign |
|
457 | - * |
|
458 | - * @return Array the spotter information |
|
459 | - * |
|
460 | - */ |
|
455 | + /** |
|
456 | + * Gets all the spotter information based on a particular callsign |
|
457 | + * |
|
458 | + * @return Array the spotter information |
|
459 | + * |
|
460 | + */ |
|
461 | 461 | public function getLastLiveSpotterDataByIdent($ident) |
462 | 462 | { |
463 | 463 | $Spotter = new Spotter($this->db); |
464 | 464 | date_default_timezone_set('UTC'); |
465 | 465 | |
466 | 466 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
467 | - $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'; |
|
467 | + $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'; |
|
468 | 468 | |
469 | 469 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
470 | 470 | |
471 | 471 | return $spotter_array; |
472 | 472 | } |
473 | 473 | |
474 | - /** |
|
475 | - * Gets all the spotter information based on a particular callsign |
|
476 | - * |
|
477 | - * @return Array the spotter information |
|
478 | - * |
|
479 | - */ |
|
474 | + /** |
|
475 | + * Gets all the spotter information based on a particular callsign |
|
476 | + * |
|
477 | + * @return Array the spotter information |
|
478 | + * |
|
479 | + */ |
|
480 | 480 | public function getDateLiveSpotterDataByIdent($ident,$date) |
481 | 481 | { |
482 | 482 | $Spotter = new Spotter($this->db); |
483 | 483 | date_default_timezone_set('UTC'); |
484 | 484 | |
485 | 485 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
486 | - $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'; |
|
486 | + $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'; |
|
487 | 487 | |
488 | - $date = date('c',$date); |
|
488 | + $date = date('c',$date); |
|
489 | 489 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
490 | 490 | |
491 | 491 | return $spotter_array; |
492 | 492 | } |
493 | 493 | |
494 | - /** |
|
495 | - * Gets last spotter information based on a particular callsign |
|
496 | - * |
|
497 | - * @return Array the spotter information |
|
498 | - * |
|
499 | - */ |
|
494 | + /** |
|
495 | + * Gets last spotter information based on a particular callsign |
|
496 | + * |
|
497 | + * @return Array the spotter information |
|
498 | + * |
|
499 | + */ |
|
500 | 500 | public function getLastLiveSpotterDataById($id) |
501 | 501 | { |
502 | 502 | $Spotter = new Spotter($this->db); |
503 | 503 | date_default_timezone_set('UTC'); |
504 | 504 | |
505 | 505 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
506 | - $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'; |
|
506 | + $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'; |
|
507 | 507 | |
508 | 508 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
509 | 509 | |
510 | 510 | return $spotter_array; |
511 | 511 | } |
512 | 512 | |
513 | - /** |
|
514 | - * Gets last spotter information based on a particular callsign |
|
515 | - * |
|
516 | - * @return Array the spotter information |
|
517 | - * |
|
518 | - */ |
|
513 | + /** |
|
514 | + * Gets last spotter information based on a particular callsign |
|
515 | + * |
|
516 | + * @return Array the spotter information |
|
517 | + * |
|
518 | + */ |
|
519 | 519 | public function getDateLiveSpotterDataById($id,$date) |
520 | 520 | { |
521 | 521 | $Spotter = new Spotter($this->db); |
522 | 522 | date_default_timezone_set('UTC'); |
523 | 523 | |
524 | 524 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
525 | - $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'; |
|
526 | - $date = date('c',$date); |
|
525 | + $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'; |
|
526 | + $date = date('c',$date); |
|
527 | 527 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
528 | 528 | |
529 | 529 | return $spotter_array; |
530 | 530 | } |
531 | 531 | |
532 | - /** |
|
533 | - * Gets altitude information based on a particular callsign |
|
534 | - * |
|
535 | - * @return Array the spotter information |
|
536 | - * |
|
537 | - */ |
|
532 | + /** |
|
533 | + * Gets altitude information based on a particular callsign |
|
534 | + * |
|
535 | + * @return Array the spotter information |
|
536 | + * |
|
537 | + */ |
|
538 | 538 | public function getAltitudeLiveSpotterDataByIdent($ident) |
539 | 539 | { |
540 | 540 | |
541 | 541 | date_default_timezone_set('UTC'); |
542 | 542 | |
543 | 543 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
544 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
544 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
545 | 545 | |
546 | - try { |
|
546 | + try { |
|
547 | 547 | |
548 | 548 | $sth = $this->db->prepare($query); |
549 | 549 | $sth->execute(array(':ident' => $ident)); |
@@ -556,12 +556,12 @@ discard block |
||
556 | 556 | return $spotter_array; |
557 | 557 | } |
558 | 558 | |
559 | - /** |
|
560 | - * Gets all the spotter information based on a particular id |
|
561 | - * |
|
562 | - * @return Array the spotter information |
|
563 | - * |
|
564 | - */ |
|
559 | + /** |
|
560 | + * Gets all the spotter information based on a particular id |
|
561 | + * |
|
562 | + * @return Array the spotter information |
|
563 | + * |
|
564 | + */ |
|
565 | 565 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
566 | 566 | { |
567 | 567 | global $globalDBdriver, $globalLiveInterval; |
@@ -589,18 +589,18 @@ discard block |
||
589 | 589 | return $spotter_array; |
590 | 590 | } |
591 | 591 | |
592 | - /** |
|
593 | - * Gets all the spotter information based on a particular ident |
|
594 | - * |
|
595 | - * @return Array the spotter information |
|
596 | - * |
|
597 | - */ |
|
592 | + /** |
|
593 | + * Gets all the spotter information based on a particular ident |
|
594 | + * |
|
595 | + * @return Array the spotter information |
|
596 | + * |
|
597 | + */ |
|
598 | 598 | public function getAllLiveSpotterDataByIdent($ident) |
599 | 599 | { |
600 | 600 | date_default_timezone_set('UTC'); |
601 | 601 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
602 | 602 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
603 | - try { |
|
603 | + try { |
|
604 | 604 | |
605 | 605 | $sth = $this->db->prepare($query); |
606 | 606 | $sth->execute(array(':ident' => $ident)); |
@@ -614,23 +614,23 @@ discard block |
||
614 | 614 | |
615 | 615 | |
616 | 616 | /** |
617 | - * Deletes all info in the table |
|
618 | - * |
|
619 | - * @return String success or false |
|
620 | - * |
|
621 | - */ |
|
617 | + * Deletes all info in the table |
|
618 | + * |
|
619 | + * @return String success or false |
|
620 | + * |
|
621 | + */ |
|
622 | 622 | public function deleteLiveSpotterData() |
623 | 623 | { |
624 | 624 | global $globalDBdriver; |
625 | 625 | if ($globalDBdriver == 'mysql') { |
626 | 626 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
627 | 627 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
628 | - //$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)"; |
|
628 | + //$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)"; |
|
629 | 629 | } else { |
630 | 630 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
631 | 631 | } |
632 | 632 | |
633 | - try { |
|
633 | + try { |
|
634 | 634 | |
635 | 635 | $sth = $this->db->prepare($query); |
636 | 636 | $sth->execute(); |
@@ -642,18 +642,18 @@ discard block |
||
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
645 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
646 | - * |
|
647 | - * @return String success or false |
|
648 | - * |
|
649 | - */ |
|
645 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
646 | + * |
|
647 | + * @return String success or false |
|
648 | + * |
|
649 | + */ |
|
650 | 650 | public function deleteLiveSpotterDataNotUpdated() |
651 | 651 | { |
652 | 652 | global $globalDBdriver, $globalDebug; |
653 | 653 | if ($globalDBdriver == 'mysql') { |
654 | 654 | //$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'; |
655 | - $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"; |
|
656 | - try { |
|
655 | + $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"; |
|
656 | + try { |
|
657 | 657 | |
658 | 658 | $sth = $this->db->prepare($query); |
659 | 659 | $sth->execute(); |
@@ -661,8 +661,8 @@ discard block |
||
661 | 661 | return "error"; |
662 | 662 | } |
663 | 663 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
664 | - $i = 0; |
|
665 | - $j =0; |
|
664 | + $i = 0; |
|
665 | + $j =0; |
|
666 | 666 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
667 | 667 | foreach($all as $row) |
668 | 668 | { |
@@ -670,20 +670,20 @@ discard block |
||
670 | 670 | $j++; |
671 | 671 | if ($j == 30) { |
672 | 672 | if ($globalDebug) echo "."; |
673 | - try { |
|
673 | + try { |
|
674 | 674 | |
675 | 675 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
676 | 676 | $sth->execute(); |
677 | 677 | } catch(PDOException $e) { |
678 | 678 | return "error"; |
679 | 679 | } |
680 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
681 | - $j = 0; |
|
680 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
681 | + $j = 0; |
|
682 | 682 | } |
683 | 683 | $query_delete .= "'".$row['flightaware_id']."',"; |
684 | 684 | } |
685 | 685 | if ($i > 0) { |
686 | - try { |
|
686 | + try { |
|
687 | 687 | |
688 | 688 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
689 | 689 | $sth->execute(); |
@@ -694,9 +694,9 @@ discard block |
||
694 | 694 | return "success"; |
695 | 695 | } elseif ($globalDBdriver == 'pgsql') { |
696 | 696 | //$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"; |
697 | - //$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"; |
|
698 | - $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)"; |
|
699 | - try { |
|
697 | + //$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"; |
|
698 | + $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)"; |
|
699 | + try { |
|
700 | 700 | |
701 | 701 | $sth = $this->db->prepare($query); |
702 | 702 | $sth->execute(); |
@@ -740,17 +740,17 @@ discard block |
||
740 | 740 | } |
741 | 741 | |
742 | 742 | /** |
743 | - * Deletes all info in the table for an ident |
|
744 | - * |
|
745 | - * @return String success or false |
|
746 | - * |
|
747 | - */ |
|
743 | + * Deletes all info in the table for an ident |
|
744 | + * |
|
745 | + * @return String success or false |
|
746 | + * |
|
747 | + */ |
|
748 | 748 | public function deleteLiveSpotterDataByIdent($ident) |
749 | 749 | { |
750 | 750 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
751 | 751 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
752 | 752 | |
753 | - try { |
|
753 | + try { |
|
754 | 754 | |
755 | 755 | $sth = $this->db->prepare($query); |
756 | 756 | $sth->execute(array(':ident' => $ident)); |
@@ -762,17 +762,17 @@ discard block |
||
762 | 762 | } |
763 | 763 | |
764 | 764 | /** |
765 | - * Deletes all info in the table for an id |
|
766 | - * |
|
767 | - * @return String success or false |
|
768 | - * |
|
769 | - */ |
|
765 | + * Deletes all info in the table for an id |
|
766 | + * |
|
767 | + * @return String success or false |
|
768 | + * |
|
769 | + */ |
|
770 | 770 | public function deleteLiveSpotterDataById($id) |
771 | 771 | { |
772 | 772 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
773 | 773 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
774 | 774 | |
775 | - try { |
|
775 | + try { |
|
776 | 776 | |
777 | 777 | $sth = $this->db->prepare($query); |
778 | 778 | $sth->execute(array(':id' => $id)); |
@@ -785,11 +785,11 @@ discard block |
||
785 | 785 | |
786 | 786 | |
787 | 787 | /** |
788 | - * Gets the aircraft ident within the last hour |
|
789 | - * |
|
790 | - * @return String the ident |
|
791 | - * |
|
792 | - */ |
|
788 | + * Gets the aircraft ident within the last hour |
|
789 | + * |
|
790 | + * @return String the ident |
|
791 | + * |
|
792 | + */ |
|
793 | 793 | public function getIdentFromLastHour($ident) |
794 | 794 | { |
795 | 795 | global $globalDBdriver, $globalTimezone; |
@@ -815,14 +815,14 @@ discard block |
||
815 | 815 | $ident_result = $row['ident']; |
816 | 816 | } |
817 | 817 | return $ident_result; |
818 | - } |
|
818 | + } |
|
819 | 819 | |
820 | 820 | /** |
821 | - * Check recent aircraft |
|
822 | - * |
|
823 | - * @return String the ident |
|
824 | - * |
|
825 | - */ |
|
821 | + * Check recent aircraft |
|
822 | + * |
|
823 | + * @return String the ident |
|
824 | + * |
|
825 | + */ |
|
826 | 826 | public function checkIdentRecent($ident) |
827 | 827 | { |
828 | 828 | global $globalDBdriver, $globalTimezone; |
@@ -848,14 +848,14 @@ discard block |
||
848 | 848 | $ident_result = $row['flightaware_id']; |
849 | 849 | } |
850 | 850 | return $ident_result; |
851 | - } |
|
851 | + } |
|
852 | 852 | |
853 | 853 | /** |
854 | - * Check recent aircraft by id |
|
855 | - * |
|
856 | - * @return String the ident |
|
857 | - * |
|
858 | - */ |
|
854 | + * Check recent aircraft by id |
|
855 | + * |
|
856 | + * @return String the ident |
|
857 | + * |
|
858 | + */ |
|
859 | 859 | public function checkIdRecent($id) |
860 | 860 | { |
861 | 861 | global $globalDBdriver, $globalTimezone; |
@@ -881,14 +881,14 @@ discard block |
||
881 | 881 | $ident_result = $row['flightaware_id']; |
882 | 882 | } |
883 | 883 | return $ident_result; |
884 | - } |
|
884 | + } |
|
885 | 885 | |
886 | 886 | /** |
887 | - * Check recent aircraft by ModeS |
|
888 | - * |
|
889 | - * @return String the ModeS |
|
890 | - * |
|
891 | - */ |
|
887 | + * Check recent aircraft by ModeS |
|
888 | + * |
|
889 | + * @return String the ModeS |
|
890 | + * |
|
891 | + */ |
|
892 | 892 | public function checkModeSRecent($modes) |
893 | 893 | { |
894 | 894 | global $globalDBdriver, $globalTimezone; |
@@ -915,19 +915,19 @@ discard block |
||
915 | 915 | $ident_result = $row['flightaware_id']; |
916 | 916 | } |
917 | 917 | return $ident_result; |
918 | - } |
|
918 | + } |
|
919 | 919 | |
920 | 920 | /** |
921 | - * Adds a new spotter data |
|
922 | - * |
|
923 | - * @param String $flightaware_id the ID from flightaware |
|
924 | - * @param String $ident the flight ident |
|
925 | - * @param String $aircraft_icao the aircraft type |
|
926 | - * @param String $departure_airport_icao the departure airport |
|
927 | - * @param String $arrival_airport_icao the arrival airport |
|
928 | - * @return String success or false |
|
929 | - * |
|
930 | - */ |
|
921 | + * Adds a new spotter data |
|
922 | + * |
|
923 | + * @param String $flightaware_id the ID from flightaware |
|
924 | + * @param String $ident the flight ident |
|
925 | + * @param String $aircraft_icao the aircraft type |
|
926 | + * @param String $departure_airport_icao the departure airport |
|
927 | + * @param String $arrival_airport_icao the arrival airport |
|
928 | + * @return String success or false |
|
929 | + * |
|
930 | + */ |
|
931 | 931 | 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 = '') |
932 | 932 | { |
933 | 933 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1062,10 +1062,10 @@ discard block |
||
1062 | 1062 | $arrival_airport_country = ''; |
1063 | 1063 | |
1064 | 1064 | |
1065 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1066 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1067 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1068 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1065 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1066 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1067 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1068 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1069 | 1069 | |
1070 | 1070 | $query = ''; |
1071 | 1071 | if ($globalArchive) { |
@@ -1086,10 +1086,10 @@ discard block |
||
1086 | 1086 | return "error : ".$e->getMessage(); |
1087 | 1087 | } |
1088 | 1088 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1089 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1090 | - $SpotterArchive = new SpotterArchive($this->db); |
|
1091 | - $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1092 | - if ($globalDebug) echo $result.')'; |
|
1089 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
1090 | + $SpotterArchive = new SpotterArchive($this->db); |
|
1091 | + $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1092 | + if ($globalDebug) echo $result.')'; |
|
1093 | 1093 | } |
1094 | 1094 | return "success"; |
1095 | 1095 |
@@ -16,62 +16,62 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($filter[0]['source'])) { |
30 | - $filters = array_merge($filters,$filter); |
|
30 | + $filters = array_merge($filters, $filter); |
|
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
33 | 33 | $filter_query_join = ''; |
34 | 34 | $filter_query_where = ''; |
35 | - foreach($filters as $flt) { |
|
35 | + foreach ($filters as $flt) { |
|
36 | 36 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
37 | 37 | if ($flt['airlines'][0] != '') { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $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"; |
|
39 | + $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 | 40 | } else { |
41 | - $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"; |
|
41 | + $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 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
46 | 46 | if (isset($flt['source'])) { |
47 | - $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"; |
|
47 | + $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 | 48 | } else { |
49 | - $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"; |
|
49 | + $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 | 50 | } |
51 | 51 | } |
52 | 52 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
53 | 53 | if (isset($flt['source'])) { |
54 | - $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"; |
|
54 | + $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 | 55 | } else { |
56 | - $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"; |
|
56 | + $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 | 57 | } |
58 | 58 | } |
59 | 59 | if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
60 | 60 | if (isset($flt['source'])) { |
61 | - $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"; |
|
61 | + $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 | 62 | } else { |
63 | - $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"; |
|
63 | + $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 | 64 | } |
65 | 65 | } |
66 | 66 | 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']))) { |
67 | 67 | if (isset($flt['source'])) { |
68 | - $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"; |
|
68 | + $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 | 69 | } |
70 | 70 | } |
71 | 71 | } |
72 | 72 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
73 | 73 | if ($filter['airlines'][0] != '') { |
74 | - $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"; |
|
74 | + $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 | 75 | } |
76 | 76 | } |
77 | 77 | if (isset($filter['alliance']) && !empty($filter['alliance'])) { |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | $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 "; |
82 | 82 | } |
83 | 83 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
84 | - $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"; |
|
84 | + $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 | 85 | } |
86 | 86 | if (isset($filter['source']) && !empty($filter['source'])) { |
87 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
87 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
88 | 88 | } |
89 | 89 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
90 | 90 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'"; |
114 | 114 | } |
115 | 115 | } |
116 | - $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"; |
|
116 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id"; |
|
117 | 117 | } |
118 | 118 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
119 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
119 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
120 | 120 | } |
121 | 121 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
122 | 122 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
123 | 123 | if ($filter_query_where != '') { |
124 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
124 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
125 | 125 | } |
126 | 126 | $filter_query = $filter_query_join.$filter_query_where; |
127 | 127 | return $filter_query; |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | if ($limit != '') |
145 | 145 | { |
146 | 146 | $limit_array = explode(',', $limit); |
147 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
148 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
147 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
148 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
149 | 149 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
150 | 150 | { |
151 | 151 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | } else { |
169 | 169 | $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; |
170 | 170 | } |
171 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
171 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
172 | 172 | |
173 | 173 | return $spotter_array; |
174 | 174 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | { |
184 | 184 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
185 | 185 | date_default_timezone_set('UTC'); |
186 | - $filter_query = $this->getFilter($filter,true,true); |
|
186 | + $filter_query = $this->getFilter($filter, true, true); |
|
187 | 187 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
188 | 188 | if ($globalDBdriver == 'mysql') { |
189 | 189 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | try { |
207 | 207 | $sth = $this->db->prepare($query); |
208 | 208 | $sth->execute(); |
209 | - } catch(PDOException $e) { |
|
209 | + } catch (PDOException $e) { |
|
210 | 210 | echo $e->getMessage(); |
211 | 211 | die; |
212 | 212 | } |
@@ -225,26 +225,26 @@ discard block |
||
225 | 225 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
226 | 226 | date_default_timezone_set('UTC'); |
227 | 227 | |
228 | - $filter_query = $this->getFilter($filter,true,true); |
|
228 | + $filter_query = $this->getFilter($filter, true, true); |
|
229 | 229 | |
230 | 230 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
231 | 231 | if ($globalDBdriver == 'mysql') { |
232 | 232 | if (isset($globalArchive) && $globalArchive === TRUE) { |
233 | - $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
233 | + $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
234 | 234 | 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 AND spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
235 | 235 | ORDER BY spotter_archive.flightaware_id, spotter_archive.date"; |
236 | 236 | } else { |
237 | - $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 |
|
237 | + $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 |
|
238 | 238 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
239 | 239 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
240 | 240 | } |
241 | 241 | } else { |
242 | 242 | if (isset($globalArchive) && $globalArchive === TRUE) { |
243 | - $query = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
243 | + $query = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
|
244 | 244 | 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 WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
245 | 245 | ORDER BY spotter_archive.flightaware_id, spotter_archive.date"; |
246 | 246 | } else { |
247 | - $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 |
|
247 | + $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 |
|
248 | 248 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
249 | 249 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
250 | 250 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | try { |
254 | 254 | $sth = $this->db->prepare($query); |
255 | 255 | $sth->execute(); |
256 | - } catch(PDOException $e) { |
|
256 | + } catch (PDOException $e) { |
|
257 | 257 | echo $e->getMessage(); |
258 | 258 | die; |
259 | 259 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | public function getLiveSpotterCount($filter = array()) |
271 | 271 | { |
272 | 272 | global $globalDBdriver, $globalLiveInterval; |
273 | - $filter_query = $this->getFilter($filter,true,true); |
|
273 | + $filter_query = $this->getFilter($filter, true, true); |
|
274 | 274 | |
275 | 275 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
276 | 276 | if ($globalDBdriver == 'mysql') { |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | try { |
284 | 284 | $sth = $this->db->prepare($query); |
285 | 285 | $sth->execute(); |
286 | - } catch(PDOException $e) { |
|
286 | + } catch (PDOException $e) { |
|
287 | 287 | echo $e->getMessage(); |
288 | 288 | die; |
289 | 289 | } |
@@ -306,10 +306,10 @@ discard block |
||
306 | 306 | $filter_query = $this->getFilter($filter); |
307 | 307 | |
308 | 308 | if (is_array($coord)) { |
309 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
310 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
311 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
312 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
309 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
310 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
311 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
312 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
313 | 313 | } else return array(); |
314 | 314 | if ($globalDBdriver == 'mysql') { |
315 | 315 | $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; |
@@ -332,23 +332,23 @@ discard block |
||
332 | 332 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
333 | 333 | $Spotter = new Spotter($this->db); |
334 | 334 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
335 | - $filter_query = $this->getFilter($filter,true,true); |
|
335 | + $filter_query = $this->getFilter($filter, true, true); |
|
336 | 336 | |
337 | 337 | if (is_array($coord)) { |
338 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
339 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
340 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
341 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
338 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
339 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
340 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
341 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
342 | 342 | } else return array(); |
343 | 343 | if ($globalDBdriver == 'mysql') { |
344 | 344 | if (isset($globalArchive) && $globalArchive === TRUE) { |
345 | - $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 |
|
345 | + $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 |
|
346 | 346 | FROM spotter_live |
347 | 347 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date |
348 | 348 | AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
349 | 349 | AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0'; |
350 | 350 | } else { |
351 | - $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 |
|
351 | + $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 |
|
352 | 352 | FROM spotter_live |
353 | 353 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
354 | 354 | FROM spotter_live l |
@@ -360,14 +360,14 @@ discard block |
||
360 | 360 | } |
361 | 361 | } else { |
362 | 362 | if (isset($globalArchive) && $globalArchive === TRUE) { |
363 | - $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 |
|
363 | + $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 |
|
364 | 364 | FROM spotter_live |
365 | 365 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
366 | 366 | AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
367 | 367 | AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
368 | 368 | AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
369 | 369 | } else { |
370 | - $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 |
|
370 | + $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 |
|
371 | 371 | FROM spotter_live |
372 | 372 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate |
373 | 373 | FROM spotter_live l |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | try { |
383 | 383 | $sth = $this->db->prepare($query); |
384 | 384 | $sth->execute(); |
385 | - } catch(PDOException $e) { |
|
385 | + } catch (PDOException $e) { |
|
386 | 386 | echo $e->getMessage(); |
387 | 387 | die; |
388 | 388 | } |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | if ($interval == '1m') |
432 | 432 | { |
433 | 433 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
434 | - } else if ($interval == '15m'){ |
|
434 | + } else if ($interval == '15m') { |
|
435 | 435 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
436 | 436 | } |
437 | 437 | } |
@@ -439,14 +439,14 @@ discard block |
||
439 | 439 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
440 | 440 | } |
441 | 441 | |
442 | - $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 |
|
442 | + $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 |
|
443 | 443 | WHERE spotter_live.latitude <> '' |
444 | 444 | AND spotter_live.longitude <> '' |
445 | 445 | ".$additional_query." |
446 | 446 | HAVING distance < :radius |
447 | 447 | ORDER BY distance"; |
448 | 448 | |
449 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
449 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
450 | 450 | |
451 | 451 | return $spotter_array; |
452 | 452 | } |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | date_default_timezone_set('UTC'); |
465 | 465 | |
466 | 466 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
467 | - $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'; |
|
467 | + $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'; |
|
468 | 468 | |
469 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
469 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
470 | 470 | |
471 | 471 | return $spotter_array; |
472 | 472 | } |
@@ -477,16 +477,16 @@ discard block |
||
477 | 477 | * @return Array the spotter information |
478 | 478 | * |
479 | 479 | */ |
480 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
480 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
481 | 481 | { |
482 | 482 | $Spotter = new Spotter($this->db); |
483 | 483 | date_default_timezone_set('UTC'); |
484 | 484 | |
485 | 485 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
486 | - $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'; |
|
486 | + $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'; |
|
487 | 487 | |
488 | - $date = date('c',$date); |
|
489 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
488 | + $date = date('c', $date); |
|
489 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
490 | 490 | |
491 | 491 | return $spotter_array; |
492 | 492 | } |
@@ -503,9 +503,9 @@ discard block |
||
503 | 503 | date_default_timezone_set('UTC'); |
504 | 504 | |
505 | 505 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
506 | - $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'; |
|
506 | + $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'; |
|
507 | 507 | |
508 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
508 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
509 | 509 | |
510 | 510 | return $spotter_array; |
511 | 511 | } |
@@ -516,15 +516,15 @@ discard block |
||
516 | 516 | * @return Array the spotter information |
517 | 517 | * |
518 | 518 | */ |
519 | - public function getDateLiveSpotterDataById($id,$date) |
|
519 | + public function getDateLiveSpotterDataById($id, $date) |
|
520 | 520 | { |
521 | 521 | $Spotter = new Spotter($this->db); |
522 | 522 | date_default_timezone_set('UTC'); |
523 | 523 | |
524 | 524 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
525 | - $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'; |
|
526 | - $date = date('c',$date); |
|
527 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
525 | + $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'; |
|
526 | + $date = date('c', $date); |
|
527 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
528 | 528 | |
529 | 529 | return $spotter_array; |
530 | 530 | } |
@@ -541,13 +541,13 @@ discard block |
||
541 | 541 | date_default_timezone_set('UTC'); |
542 | 542 | |
543 | 543 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
544 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
544 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
545 | 545 | |
546 | 546 | try { |
547 | 547 | |
548 | 548 | $sth = $this->db->prepare($query); |
549 | 549 | $sth->execute(array(':ident' => $ident)); |
550 | - } catch(PDOException $e) { |
|
550 | + } catch (PDOException $e) { |
|
551 | 551 | echo $e->getMessage(); |
552 | 552 | die; |
553 | 553 | } |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | * @return Array the spotter information |
563 | 563 | * |
564 | 564 | */ |
565 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
565 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
566 | 566 | { |
567 | 567 | global $globalDBdriver, $globalLiveInterval; |
568 | 568 | date_default_timezone_set('UTC'); |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | try { |
582 | 582 | $sth = $this->db->prepare($query); |
583 | 583 | $sth->execute(array(':id' => $id)); |
584 | - } catch(PDOException $e) { |
|
584 | + } catch (PDOException $e) { |
|
585 | 585 | echo $e->getMessage(); |
586 | 586 | die; |
587 | 587 | } |
@@ -599,12 +599,12 @@ discard block |
||
599 | 599 | { |
600 | 600 | date_default_timezone_set('UTC'); |
601 | 601 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
602 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
602 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
603 | 603 | try { |
604 | 604 | |
605 | 605 | $sth = $this->db->prepare($query); |
606 | 606 | $sth->execute(array(':ident' => $ident)); |
607 | - } catch(PDOException $e) { |
|
607 | + } catch (PDOException $e) { |
|
608 | 608 | echo $e->getMessage(); |
609 | 609 | die; |
610 | 610 | } |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | |
635 | 635 | $sth = $this->db->prepare($query); |
636 | 636 | $sth->execute(); |
637 | - } catch(PDOException $e) { |
|
637 | + } catch (PDOException $e) { |
|
638 | 638 | return "error"; |
639 | 639 | } |
640 | 640 | |
@@ -657,14 +657,14 @@ discard block |
||
657 | 657 | |
658 | 658 | $sth = $this->db->prepare($query); |
659 | 659 | $sth->execute(); |
660 | - } catch(PDOException $e) { |
|
660 | + } catch (PDOException $e) { |
|
661 | 661 | return "error"; |
662 | 662 | } |
663 | 663 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
664 | 664 | $i = 0; |
665 | - $j =0; |
|
665 | + $j = 0; |
|
666 | 666 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
667 | - foreach($all as $row) |
|
667 | + foreach ($all as $row) |
|
668 | 668 | { |
669 | 669 | $i++; |
670 | 670 | $j++; |
@@ -672,9 +672,9 @@ discard block |
||
672 | 672 | if ($globalDebug) echo "."; |
673 | 673 | try { |
674 | 674 | |
675 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
675 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
676 | 676 | $sth->execute(); |
677 | - } catch(PDOException $e) { |
|
677 | + } catch (PDOException $e) { |
|
678 | 678 | return "error"; |
679 | 679 | } |
680 | 680 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -685,9 +685,9 @@ discard block |
||
685 | 685 | if ($i > 0) { |
686 | 686 | try { |
687 | 687 | |
688 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
688 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
689 | 689 | $sth->execute(); |
690 | - } catch(PDOException $e) { |
|
690 | + } catch (PDOException $e) { |
|
691 | 691 | return "error"; |
692 | 692 | } |
693 | 693 | } |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | |
701 | 701 | $sth = $this->db->prepare($query); |
702 | 702 | $sth->execute(); |
703 | - } catch(PDOException $e) { |
|
703 | + } catch (PDOException $e) { |
|
704 | 704 | return "error"; |
705 | 705 | } |
706 | 706 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -748,13 +748,13 @@ discard block |
||
748 | 748 | public function deleteLiveSpotterDataByIdent($ident) |
749 | 749 | { |
750 | 750 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
751 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
751 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
752 | 752 | |
753 | 753 | try { |
754 | 754 | |
755 | 755 | $sth = $this->db->prepare($query); |
756 | 756 | $sth->execute(array(':ident' => $ident)); |
757 | - } catch(PDOException $e) { |
|
757 | + } catch (PDOException $e) { |
|
758 | 758 | return "error"; |
759 | 759 | } |
760 | 760 | |
@@ -770,13 +770,13 @@ discard block |
||
770 | 770 | public function deleteLiveSpotterDataById($id) |
771 | 771 | { |
772 | 772 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
773 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
773 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
774 | 774 | |
775 | 775 | try { |
776 | 776 | |
777 | 777 | $sth = $this->db->prepare($query); |
778 | 778 | $sth->execute(array(':id' => $id)); |
779 | - } catch(PDOException $e) { |
|
779 | + } catch (PDOException $e) { |
|
780 | 780 | return "error"; |
781 | 781 | } |
782 | 782 | |
@@ -794,13 +794,13 @@ discard block |
||
794 | 794 | { |
795 | 795 | global $globalDBdriver, $globalTimezone; |
796 | 796 | if ($globalDBdriver == 'mysql') { |
797 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
797 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
798 | 798 | WHERE spotter_live.ident = :ident |
799 | 799 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
800 | 800 | AND spotter_live.date < UTC_TIMESTAMP()'; |
801 | 801 | $query_data = array(':ident' => $ident); |
802 | 802 | } else { |
803 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
803 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
804 | 804 | WHERE spotter_live.ident = :ident |
805 | 805 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
806 | 806 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -809,8 +809,8 @@ discard block |
||
809 | 809 | |
810 | 810 | $sth = $this->db->prepare($query); |
811 | 811 | $sth->execute($query_data); |
812 | - $ident_result=''; |
|
813 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
812 | + $ident_result = ''; |
|
813 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
814 | 814 | { |
815 | 815 | $ident_result = $row['ident']; |
816 | 816 | } |
@@ -827,13 +827,13 @@ discard block |
||
827 | 827 | { |
828 | 828 | global $globalDBdriver, $globalTimezone; |
829 | 829 | if ($globalDBdriver == 'mysql') { |
830 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
830 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
831 | 831 | WHERE spotter_live.ident = :ident |
832 | 832 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
833 | 833 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
834 | 834 | $query_data = array(':ident' => $ident); |
835 | 835 | } else { |
836 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
836 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
837 | 837 | WHERE spotter_live.ident = :ident |
838 | 838 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
839 | 839 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -842,8 +842,8 @@ discard block |
||
842 | 842 | |
843 | 843 | $sth = $this->db->prepare($query); |
844 | 844 | $sth->execute($query_data); |
845 | - $ident_result=''; |
|
846 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
845 | + $ident_result = ''; |
|
846 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
847 | 847 | { |
848 | 848 | $ident_result = $row['flightaware_id']; |
849 | 849 | } |
@@ -860,13 +860,13 @@ discard block |
||
860 | 860 | { |
861 | 861 | global $globalDBdriver, $globalTimezone; |
862 | 862 | if ($globalDBdriver == 'mysql') { |
863 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
863 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
864 | 864 | WHERE spotter_live.flightaware_id = :id |
865 | 865 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
866 | 866 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
867 | 867 | $query_data = array(':id' => $id); |
868 | 868 | } else { |
869 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
869 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
870 | 870 | WHERE spotter_live.flightaware_id = :id |
871 | 871 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
872 | 872 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -875,8 +875,8 @@ discard block |
||
875 | 875 | |
876 | 876 | $sth = $this->db->prepare($query); |
877 | 877 | $sth->execute($query_data); |
878 | - $ident_result=''; |
|
879 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
878 | + $ident_result = ''; |
|
879 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
880 | 880 | { |
881 | 881 | $ident_result = $row['flightaware_id']; |
882 | 882 | } |
@@ -893,13 +893,13 @@ discard block |
||
893 | 893 | { |
894 | 894 | global $globalDBdriver, $globalTimezone; |
895 | 895 | if ($globalDBdriver == 'mysql') { |
896 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
896 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
897 | 897 | WHERE spotter_live.ModeS = :modes |
898 | 898 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
899 | 899 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
900 | 900 | $query_data = array(':modes' => $modes); |
901 | 901 | } else { |
902 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
902 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
903 | 903 | WHERE spotter_live.ModeS = :modes |
904 | 904 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
905 | 905 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -908,8 +908,8 @@ discard block |
||
908 | 908 | |
909 | 909 | $sth = $this->db->prepare($query); |
910 | 910 | $sth->execute($query_data); |
911 | - $ident_result=''; |
|
912 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
911 | + $ident_result = ''; |
|
912 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
913 | 913 | { |
914 | 914 | //$ident_result = $row['spotter_live_id']; |
915 | 915 | $ident_result = $row['flightaware_id']; |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | * @return String success or false |
929 | 929 | * |
930 | 930 | */ |
931 | - 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 = '') |
|
931 | + 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 = '') |
|
932 | 932 | { |
933 | 933 | global $globalURL, $globalArchive, $globalDebug; |
934 | 934 | $Common = new Common(); |
@@ -1021,26 +1021,26 @@ discard block |
||
1021 | 1021 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
1022 | 1022 | |
1023 | 1023 | |
1024 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
1025 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1026 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
1027 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
1028 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
1029 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1030 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1031 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
1032 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1033 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
1034 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1035 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
1036 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
1037 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
1038 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
1039 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
1040 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
1041 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
1042 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
1043 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
1024 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
1025 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1026 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
1027 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
1028 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
1029 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1030 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1031 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
1032 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1033 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
1034 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1035 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
1036 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
1037 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
1038 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
1039 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
1040 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
1041 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
1042 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
1043 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
1044 | 1044 | |
1045 | 1045 | $airline_name = ''; |
1046 | 1046 | $airline_icao = ''; |
@@ -1062,10 +1062,10 @@ discard block |
||
1062 | 1062 | $arrival_airport_country = ''; |
1063 | 1063 | |
1064 | 1064 | |
1065 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1066 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1067 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1068 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1065 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
1066 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
1067 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
1068 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
1069 | 1069 | |
1070 | 1070 | $query = ''; |
1071 | 1071 | if ($globalArchive) { |
@@ -1076,19 +1076,19 @@ discard block |
||
1076 | 1076 | $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) |
1077 | 1077 | 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)'; |
1078 | 1078 | |
1079 | - $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); |
|
1079 | + $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); |
|
1080 | 1080 | try { |
1081 | 1081 | |
1082 | 1082 | $sth = $this->db->prepare($query); |
1083 | 1083 | $sth->execute($query_values); |
1084 | 1084 | $sth->closeCursor(); |
1085 | - } catch(PDOException $e) { |
|
1085 | + } catch (PDOException $e) { |
|
1086 | 1086 | return "error : ".$e->getMessage(); |
1087 | 1087 | } |
1088 | 1088 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1089 | 1089 | if ($globalDebug) echo '(Add to SBS archive : '; |
1090 | 1090 | $SpotterArchive = new SpotterArchive($this->db); |
1091 | - $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1091 | + $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
1092 | 1092 | if ($globalDebug) echo $result.')'; |
1093 | 1093 | } |
1094 | 1094 | return "success"; |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | |
1098 | 1098 | public function getOrderBy() |
1099 | 1099 | { |
1100 | - $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")); |
|
1100 | + $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")); |
|
1101 | 1101 | return $orderby; |
1102 | 1102 | } |
1103 | 1103 |
@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | if (isset($filter[0]['source'])) { |
30 | 30 | $filters = array_merge($filters,$filter); |
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
33 | 35 | $filter_query_join = ''; |
34 | 36 | $filter_query_where = ''; |
35 | 37 | foreach($filters as $flt) { |
@@ -118,8 +120,11 @@ discard block |
||
118 | 120 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
119 | 121 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
120 | 122 | } |
121 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
122 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
123 | + if ($filter_query_where == '' && $where) { |
|
124 | + $filter_query_where = ' WHERE'; |
|
125 | + } elseif ($filter_query_where != '' && $and) { |
|
126 | + $filter_query_where .= ' AND'; |
|
127 | + } |
|
123 | 128 | if ($filter_query_where != '') { |
124 | 129 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
125 | 130 | } |
@@ -160,9 +165,13 @@ discard block |
||
160 | 165 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
161 | 166 | } |
162 | 167 | } |
163 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
168 | + if ($orderby_query == '') { |
|
169 | + $orderby_query = ' ORDER BY date DESC'; |
|
170 | + } |
|
164 | 171 | |
165 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
172 | + if (!isset($globalLiveInterval)) { |
|
173 | + $globalLiveInterval = '200'; |
|
174 | + } |
|
166 | 175 | if ($globalDBdriver == 'mysql') { |
167 | 176 | //$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"; |
168 | 177 | $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; |
@@ -185,7 +194,9 @@ discard block |
||
185 | 194 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
186 | 195 | date_default_timezone_set('UTC'); |
187 | 196 | $filter_query = $this->getFilter($filter,true,true); |
188 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
197 | + if (!isset($globalLiveInterval)) { |
|
198 | + $globalLiveInterval = '200'; |
|
199 | + } |
|
189 | 200 | if ($globalDBdriver == 'mysql') { |
190 | 201 | if (isset($globalArchive) && $globalArchive === TRUE) { |
191 | 202 | $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 |
@@ -228,7 +239,9 @@ discard block |
||
228 | 239 | |
229 | 240 | $filter_query = $this->getFilter($filter,true,true); |
230 | 241 | |
231 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
242 | + if (!isset($globalLiveInterval)) { |
|
243 | + $globalLiveInterval = '200'; |
|
244 | + } |
|
232 | 245 | if ($globalDBdriver == 'mysql') { |
233 | 246 | if (isset($globalArchive) && $globalArchive === TRUE) { |
234 | 247 | $query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
@@ -273,7 +286,9 @@ discard block |
||
273 | 286 | global $globalDBdriver, $globalLiveInterval; |
274 | 287 | $filter_query = $this->getFilter($filter,true,true); |
275 | 288 | |
276 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
289 | + if (!isset($globalLiveInterval)) { |
|
290 | + $globalLiveInterval = '200'; |
|
291 | + } |
|
277 | 292 | if ($globalDBdriver == 'mysql') { |
278 | 293 | //$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; |
279 | 294 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -303,7 +318,9 @@ discard block |
||
303 | 318 | { |
304 | 319 | global $globalDBdriver, $globalLiveInterval; |
305 | 320 | $Spotter = new Spotter($this->db); |
306 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
321 | + if (!isset($globalLiveInterval)) { |
|
322 | + $globalLiveInterval = '200'; |
|
323 | + } |
|
307 | 324 | $filter_query = $this->getFilter($filter); |
308 | 325 | |
309 | 326 | if (is_array($coord)) { |
@@ -311,7 +328,9 @@ discard block |
||
311 | 328 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
312 | 329 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
313 | 330 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
314 | - } else return array(); |
|
331 | + } else { |
|
332 | + return array(); |
|
333 | + } |
|
315 | 334 | if ($globalDBdriver == 'mysql') { |
316 | 335 | $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; |
317 | 336 | } else { |
@@ -332,7 +351,9 @@ discard block |
||
332 | 351 | { |
333 | 352 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
334 | 353 | $Spotter = new Spotter($this->db); |
335 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
354 | + if (!isset($globalLiveInterval)) { |
|
355 | + $globalLiveInterval = '200'; |
|
356 | + } |
|
336 | 357 | $filter_query = $this->getFilter($filter,true,true); |
337 | 358 | |
338 | 359 | if (is_array($coord)) { |
@@ -340,7 +361,9 @@ discard block |
||
340 | 361 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
341 | 362 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
342 | 363 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
343 | - } else return array(); |
|
364 | + } else { |
|
365 | + return array(); |
|
366 | + } |
|
344 | 367 | if ($globalDBdriver == 'mysql') { |
345 | 368 | if (isset($globalArchive) && $globalArchive === TRUE) { |
346 | 369 | $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 |
@@ -571,11 +594,15 @@ discard block |
||
571 | 594 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
572 | 595 | if ($globalDBdriver == 'mysql') { |
573 | 596 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
574 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
597 | + if ($liveinterval) { |
|
598 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
599 | + } |
|
575 | 600 | $query .= ' ORDER BY date'; |
576 | 601 | } else { |
577 | 602 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
578 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
603 | + if ($liveinterval) { |
|
604 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
605 | + } |
|
579 | 606 | $query .= ' ORDER BY date'; |
580 | 607 | } |
581 | 608 | |
@@ -670,7 +697,9 @@ discard block |
||
670 | 697 | $i++; |
671 | 698 | $j++; |
672 | 699 | if ($j == 30) { |
673 | - if ($globalDebug) echo "."; |
|
700 | + if ($globalDebug) { |
|
701 | + echo "."; |
|
702 | + } |
|
674 | 703 | try { |
675 | 704 | |
676 | 705 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -977,7 +1006,9 @@ discard block |
||
977 | 1006 | { |
978 | 1007 | return false; |
979 | 1008 | } |
980 | - } else return ''; |
|
1009 | + } else { |
|
1010 | + return ''; |
|
1011 | + } |
|
981 | 1012 | |
982 | 1013 | if ($longitude != '') |
983 | 1014 | { |
@@ -985,7 +1016,9 @@ discard block |
||
985 | 1016 | { |
986 | 1017 | return false; |
987 | 1018 | } |
988 | - } else return ''; |
|
1019 | + } else { |
|
1020 | + return ''; |
|
1021 | + } |
|
989 | 1022 | |
990 | 1023 | if ($waypoints != '') |
991 | 1024 | { |
@@ -1001,7 +1034,9 @@ discard block |
||
1001 | 1034 | { |
1002 | 1035 | return false; |
1003 | 1036 | } |
1004 | - } else $altitude = 0; |
|
1037 | + } else { |
|
1038 | + $altitude = 0; |
|
1039 | + } |
|
1005 | 1040 | |
1006 | 1041 | if ($heading != '') |
1007 | 1042 | { |
@@ -1009,7 +1044,9 @@ discard block |
||
1009 | 1044 | { |
1010 | 1045 | return false; |
1011 | 1046 | } |
1012 | - } else $heading = 0; |
|
1047 | + } else { |
|
1048 | + $heading = 0; |
|
1049 | + } |
|
1013 | 1050 | |
1014 | 1051 | if ($groundspeed != '') |
1015 | 1052 | { |
@@ -1017,9 +1054,13 @@ discard block |
||
1017 | 1054 | { |
1018 | 1055 | return false; |
1019 | 1056 | } |
1020 | - } else $groundspeed = 0; |
|
1057 | + } else { |
|
1058 | + $groundspeed = 0; |
|
1059 | + } |
|
1021 | 1060 | date_default_timezone_set('UTC'); |
1022 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1061 | + if ($date == '') { |
|
1062 | + $date = date("Y-m-d H:i:s", time()); |
|
1063 | + } |
|
1023 | 1064 | |
1024 | 1065 | |
1025 | 1066 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1063,14 +1104,24 @@ discard block |
||
1063 | 1104 | $arrival_airport_country = ''; |
1064 | 1105 | |
1065 | 1106 | |
1066 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1067 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1068 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1069 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1107 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
1108 | + $squawk = NULL; |
|
1109 | + } |
|
1110 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
1111 | + $verticalrate = NULL; |
|
1112 | + } |
|
1113 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1114 | + $groundspeed = 0; |
|
1115 | + } |
|
1116 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1117 | + $heading = 0; |
|
1118 | + } |
|
1070 | 1119 | |
1071 | 1120 | $query = ''; |
1072 | 1121 | if ($globalArchive) { |
1073 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1122 | + if ($globalDebug) { |
|
1123 | + echo '-- Delete previous data -- '; |
|
1124 | + } |
|
1074 | 1125 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
1075 | 1126 | } |
1076 | 1127 | |
@@ -1087,10 +1138,14 @@ discard block |
||
1087 | 1138 | return "error : ".$e->getMessage(); |
1088 | 1139 | } |
1089 | 1140 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1090 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1141 | + if ($globalDebug) { |
|
1142 | + echo '(Add to SBS archive : '; |
|
1143 | + } |
|
1091 | 1144 | $SpotterArchive = new SpotterArchive($this->db); |
1092 | 1145 | $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
1093 | - if ($globalDebug) echo $result.')'; |
|
1146 | + if ($globalDebug) { |
|
1147 | + echo $result.')'; |
|
1148 | + } |
|
1094 | 1149 | } |
1095 | 1150 | return "success"; |
1096 | 1151 |