@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | header('Content-disposition: attachment; filename="atc.geojson"'); |
8 | 8 | } |
9 | 9 | header('Content-Type: text/javascript'); |
10 | -$ATC=new ATC(); |
|
10 | +$ATC = new ATC(); |
|
11 | 11 | if (isset($_GET['coord'])) |
12 | 12 | { |
13 | 13 | //$coords = explode(',',$_GET['coord']); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $output = '{"type": "FeatureCollection","features": ['; |
20 | 20 | if (!empty($spotter_array)) |
21 | 21 | { |
22 | - foreach($spotter_array as $spotter_item) |
|
22 | + foreach ($spotter_array as $spotter_item) |
|
23 | 23 | { |
24 | 24 | date_default_timezone_set('UTC'); |
25 | 25 | //waypoint plotting |
@@ -16,14 +16,14 @@ discard block |
||
16 | 16 | |
17 | 17 | if (isset($_GET['start_date'])) { |
18 | 18 | //for the date manipulation into the query |
19 | - if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
19 | + if ($_GET['start_date'] != "" && $_GET['end_date'] != "") { |
|
20 | 20 | $start_date = $_GET['start_date']." 00:00:00"; |
21 | 21 | $end_date = $_GET['end_date']." 00:00:00"; |
22 | 22 | $sql_date = $start_date.",".$end_date; |
23 | - } else if($_GET['start_date'] != ""){ |
|
23 | + } else if ($_GET['start_date'] != "") { |
|
24 | 24 | $start_date = $_GET['start_date']." 00:00:00"; |
25 | 25 | $sql_date = $start_date; |
26 | - } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
26 | + } else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") { |
|
27 | 27 | $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date']." 00:00:00"; |
28 | 28 | $sql_date = $end_date; |
29 | 29 | } else $sql_date = ''; |
@@ -31,21 +31,21 @@ discard block |
||
31 | 31 | |
32 | 32 | if (isset($_GET['highest_altitude'])) { |
33 | 33 | //for altitude manipulation |
34 | - if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
34 | + if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") { |
|
35 | 35 | $end_altitude = $_GET['highest_altitude']; |
36 | 36 | $start_altitude = $_GET['lowest_altitude']; |
37 | 37 | $sql_altitude = $start_altitude.",".$end_altitude; |
38 | - } else if($_GET['highest_altitude'] != ""){ |
|
38 | + } else if ($_GET['highest_altitude'] != "") { |
|
39 | 39 | $end_altitude = $_GET['highest_altitude']; |
40 | 40 | $sql_altitude = $end_altitude; |
41 | - } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
41 | + } else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") { |
|
42 | 42 | $start_altitude = $_GET['lowest_altitude'].",60000"; |
43 | 43 | $sql_altitude = $start_altitude; |
44 | 44 | } else $sql_altitude = ''; |
45 | 45 | } else $sql_altitude = ''; |
46 | 46 | |
47 | 47 | //calculuation for the pagination |
48 | -if(!isset($_GET['limit'])) |
|
48 | +if (!isset($_GET['limit'])) |
|
49 | 49 | { |
50 | 50 | if (!isset($_GET['number_results'])) |
51 | 51 | { |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | $limit_end = 25; |
54 | 54 | $absolute_difference = 25; |
55 | 55 | } else { |
56 | - if ($_GET['number_results'] > 1000){ |
|
56 | + if ($_GET['number_results'] > 1000) { |
|
57 | 57 | $_GET['number_results'] = 1000; |
58 | 58 | } |
59 | 59 | $limit_start = 0; |
60 | 60 | $limit_end = $_GET['number_results']; |
61 | 61 | $absolute_difference = $_GET['number_results']; |
62 | 62 | } |
63 | -} else { |
|
63 | +} else { |
|
64 | 64 | $limit_explode = explode(",", $_GET['limit']); |
65 | 65 | $limit_start = $limit_explode[0]; |
66 | 66 | $limit_end = $limit_explode[1]; |
@@ -70,28 +70,28 @@ discard block |
||
70 | 70 | $limit_previous_1 = $limit_start - $absolute_difference; |
71 | 71 | $limit_previous_2 = $limit_end - $absolute_difference; |
72 | 72 | |
73 | -if (!empty($_GET)){ |
|
74 | - $q = filter_input(INPUT_GET, 'q',FILTER_SANITIZE_STRING); |
|
75 | - $registration = filter_input(INPUT_GET, 'registration',FILTER_SANITIZE_STRING); |
|
76 | - $aircraft = filter_input(INPUT_GET, 'aircraft',FILTER_SANITIZE_STRING); |
|
77 | - $manufacturer = filter_input(INPUT_GET, 'manufacturer',FILTER_SANITIZE_STRING); |
|
78 | - $highlights = filter_input(INPUT_GET, 'highlights',FILTER_SANITIZE_STRING); |
|
79 | - $airline = filter_input(INPUT_GET, 'airline',FILTER_SANITIZE_STRING); |
|
80 | - $airline_country = filter_input(INPUT_GET, 'airline_country',FILTER_SANITIZE_STRING); |
|
81 | - $airline_type = filter_input(INPUT_GET, 'airline_type',FILTER_SANITIZE_STRING); |
|
82 | - $airport = filter_input(INPUT_GET, 'airport',FILTER_SANITIZE_STRING); |
|
83 | - $airport_country = filter_input(INPUT_GET, 'airport_country',FILTER_SANITIZE_STRING); |
|
84 | - $callsign = filter_input(INPUT_GET, 'callsign',FILTER_SANITIZE_STRING); |
|
85 | - $owner = filter_input(INPUT_GET, 'owner',FILTER_SANITIZE_STRING); |
|
86 | - $pilot_name = filter_input(INPUT_GET, 'pilot_name',FILTER_SANITIZE_STRING); |
|
87 | - $pilot_id = filter_input(INPUT_GET, 'pilot_id',FILTER_SANITIZE_STRING); |
|
88 | - $departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route',FILTER_SANITIZE_STRING); |
|
89 | - $arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route',FILTER_SANITIZE_STRING); |
|
90 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
91 | - $archive = filter_input(INPUT_GET,'archive',FILTER_SANITIZE_NUMBER_INT); |
|
92 | - $origlat = filter_input(INPUT_GET,'origlat',FILTER_SANITIZE_STRING); |
|
93 | - $origlon = filter_input(INPUT_GET,'origlon',FILTER_SANITIZE_STRING); |
|
94 | - $dist = filter_input(INPUT_GET,'dist',FILTER_SANITIZE_NUMBER_INT); |
|
73 | +if (!empty($_GET)) { |
|
74 | + $q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING); |
|
75 | + $registration = filter_input(INPUT_GET, 'registration', FILTER_SANITIZE_STRING); |
|
76 | + $aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING); |
|
77 | + $manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING); |
|
78 | + $highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING); |
|
79 | + $airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
80 | + $airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING); |
|
81 | + $airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING); |
|
82 | + $airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING); |
|
83 | + $airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING); |
|
84 | + $callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING); |
|
85 | + $owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING); |
|
86 | + $pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING); |
|
87 | + $pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING); |
|
88 | + $departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING); |
|
89 | + $arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING); |
|
90 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
91 | + $archive = filter_input(INPUT_GET, 'archive', FILTER_SANITIZE_NUMBER_INT); |
|
92 | + $origlat = filter_input(INPUT_GET, 'origlat', FILTER_SANITIZE_STRING); |
|
93 | + $origlon = filter_input(INPUT_GET, 'origlon', FILTER_SANITIZE_STRING); |
|
94 | + $dist = filter_input(INPUT_GET, 'dist', FILTER_SANITIZE_NUMBER_INT); |
|
95 | 95 | if ($dist != '') { |
96 | 96 | if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') $dist = $dist*1.60934; |
97 | 97 | elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') $dist = $dist*1.852; |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | if (!isset($sql_date)) $sql_date = ''; |
100 | 100 | if ($archive == 1) { |
101 | 101 | $SpotterArchive = new SpotterArchive(); |
102 | - $spotter_array = $SpotterArchive->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist); |
|
102 | + $spotter_array = $SpotterArchive->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '', $origlat, $origlon, $dist); |
|
103 | 103 | } else { |
104 | - $spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist); |
|
104 | + $spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '', $origlat, $origlon, $dist); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | print '<span class="sub-menu-statistic column mobile">'; |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | //remove 3D=true parameter |
135 | 135 | $no3D = str_replace("&3D=true", "", $_SERVER['QUERY_STRING']); |
136 | 136 | $kmlURL = str_replace("http://", "kml://", $globalURL); |
137 | - if (!isset($_GET['3D'])){ |
|
137 | + if (!isset($_GET['3D'])) { |
|
138 | 138 | print '<li><a href="'.$globalURL.'/search?'.$no3D.'" class="active"><i class="fa fa-table"></i> '._("Table").'</a></li>'; |
139 | 139 | } else { |
140 | 140 | print '<li><span class="notablet"><a href="'.$globalURL.'/search?'.$no3D.'"><i class="fa fa-table"></i> '._("Table").'</a></span></li>'; |
141 | 141 | } |
142 | - if (isset($_GET['3D'])){ |
|
142 | + if (isset($_GET['3D'])) { |
|
143 | 143 | print '<li><a href="'.$globalURL.'/search?'.$no3D.'&3D=true" class="active"><i class="fa fa-globe"></i> '._("3D Map").'</a></li>'; |
144 | 144 | } else { |
145 | 145 | print '<li ><a href="'.$globalURL.'/search?'.$no3D.'&3D=true" class="notablet nomobile"><i class="fa fa-globe"></i> '._("3D Map").'</a><a href="'.$kmlURL.'/search/kml?'.htmlentities($_SERVER['QUERY_STRING']).'" class="tablet mobile"><i class="fa fa-globe"></i> 3D Map</a></li>'; |
@@ -160,30 +160,30 @@ discard block |
||
160 | 160 | print '<div class="column">'; |
161 | 161 | print '<div class="info">'; |
162 | 162 | print '<h1>'._("Search Results for").' '; |
163 | - if (isset($_GET['q']) && $_GET['q'] != ""){ print _("Keyword:").' <span>'.$_GET['q'].'</span> '; } |
|
164 | - if (isset($_GET['aircraft']) && $_GET['aircraft'] != ""){ print _("Aircraft:").' <span>'.$_GET['aircraft'].'</span> '; } |
|
165 | - if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != ""){ print _("Manufacturer:").' <span>'.$_GET['manufacturer'].'</span> '; } |
|
166 | - if (isset($_GET['registration']) && $_GET['registration'] != ""){ print _("Registration:").' <span>'.$_GET['registration'].'</span> '; } |
|
167 | - if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$_GET['highlights'].'</span> '; } |
|
168 | - if (isset($_GET['airline']) && $_GET['airline'] != ""){ print _("Airline:").' <span>'.$_GET['airline'].'</span> '; } |
|
169 | - if (isset($_GET['airline_country']) && $_GET['airline_country'] != ""){ print _("Airline country:").' <span>'.$_GET['airline_country'].'</span> '; } |
|
170 | - if (isset($_GET['airline_type']) && $_GET['airline_type'] != ""){ print _("Airline type:").' <span>'.$_GET['airline_type'].'</span> '; } |
|
171 | - if (isset($_GET['airport']) && $_GET['airport'] != ""){ print _("Airport:").' <span>'.$_GET['airport'].'</span> '; } |
|
172 | - if (isset($_GET['airport_country']) && $_GET['airport_country'] != ""){ print _("Airport country:").' <span>'.$_GET['airport_country'].'</span> '; } |
|
173 | - if (isset($_GET['callsign']) && $_GET['callsign'] != ""){ print _("Callsign:").' <span>'.$_GET['callsign'].'</span> '; } |
|
174 | - if (isset($_GET['owner']) && $_GET['owner'] != ""){ print _("Owner:").' <span>'.$_GET['owner'].'</span> '; } |
|
175 | - if (isset($_GET['pilot_id']) && $_GET['pilot_id'] != ""){ print _("Pilot id:").' <span>'.$_GET['pilot_id'].'</span> '; } |
|
176 | - if (isset($_GET['pilot_name']) && $_GET['pilot_name'] != ""){ print _("Pilot name:").' <span>'.$_GET['pilot_name'].'</span> '; } |
|
177 | - if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && (!isset($_GET['arrival_airport_route']) || $_GET['arrival_airport_route'] == "")){ print _("Route out of:").' <span>'.$_GET['departure_airport_route'].'</span> '; } |
|
178 | - if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] == "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != ""){ print _("Route into:").' <span>'.$_GET['arrival_airport_route'].'</span> '; } |
|
179 | - if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != ""){ print _("Route between:").' <span>'.$_GET['departure_airport_route'].'</span> and <span>'.$_GET['arrival_airport_route'].'</span> '; } |
|
180 | - if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] == ""){ print _("Date starting at:").' <span>'.$_GET['start_date'].'</span> '; } |
|
181 | - if (isset($_GET['start_date']) && $_GET['start_date'] == "" && isset($_GET['end_date']) && $_GET['end_date'] != ""){ print _("Date ending at:").' <span>'.$_GET['end_date'].'</span> '; } |
|
182 | - if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] != ""){ print _("Date between:").' <span>'.$_GET['start_date'].'</span> and <span>'.$_GET['end_date'].'</span> '; } |
|
183 | - if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == ""){ print _("Altitude starting at:").' <span>'.number_format($_GET['lowest_altitude']).' feet</span> '; } |
|
184 | - if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != ""){ print _("Altitude ending at:").' <span>'.number_format($_GET['highest_altitude']).' feet</span> '; } |
|
185 | - if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != ""){ print _("Altitude between:").' <span>'.number_format($_GET['lowest_altitude']).' feet</span> '._("and").' <span>'.number_format($_GET['highest_altitude']).' feet</span> '; } |
|
186 | - if (isset($_GET['number_results']) && $_GET['number_results'] != ""){ print _("limit per page:").' <span>'.$_GET['number_results'].'</span> '; } |
|
163 | + if (isset($_GET['q']) && $_GET['q'] != "") { print _("Keyword:").' <span>'.$_GET['q'].'</span> '; } |
|
164 | + if (isset($_GET['aircraft']) && $_GET['aircraft'] != "") { print _("Aircraft:").' <span>'.$_GET['aircraft'].'</span> '; } |
|
165 | + if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != "") { print _("Manufacturer:").' <span>'.$_GET['manufacturer'].'</span> '; } |
|
166 | + if (isset($_GET['registration']) && $_GET['registration'] != "") { print _("Registration:").' <span>'.$_GET['registration'].'</span> '; } |
|
167 | + if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true") { print _("Highlights:").' <span>'.$_GET['highlights'].'</span> '; } |
|
168 | + if (isset($_GET['airline']) && $_GET['airline'] != "") { print _("Airline:").' <span>'.$_GET['airline'].'</span> '; } |
|
169 | + if (isset($_GET['airline_country']) && $_GET['airline_country'] != "") { print _("Airline country:").' <span>'.$_GET['airline_country'].'</span> '; } |
|
170 | + if (isset($_GET['airline_type']) && $_GET['airline_type'] != "") { print _("Airline type:").' <span>'.$_GET['airline_type'].'</span> '; } |
|
171 | + if (isset($_GET['airport']) && $_GET['airport'] != "") { print _("Airport:").' <span>'.$_GET['airport'].'</span> '; } |
|
172 | + if (isset($_GET['airport_country']) && $_GET['airport_country'] != "") { print _("Airport country:").' <span>'.$_GET['airport_country'].'</span> '; } |
|
173 | + if (isset($_GET['callsign']) && $_GET['callsign'] != "") { print _("Callsign:").' <span>'.$_GET['callsign'].'</span> '; } |
|
174 | + if (isset($_GET['owner']) && $_GET['owner'] != "") { print _("Owner:").' <span>'.$_GET['owner'].'</span> '; } |
|
175 | + if (isset($_GET['pilot_id']) && $_GET['pilot_id'] != "") { print _("Pilot id:").' <span>'.$_GET['pilot_id'].'</span> '; } |
|
176 | + if (isset($_GET['pilot_name']) && $_GET['pilot_name'] != "") { print _("Pilot name:").' <span>'.$_GET['pilot_name'].'</span> '; } |
|
177 | + if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && (!isset($_GET['arrival_airport_route']) || $_GET['arrival_airport_route'] == "")) { print _("Route out of:").' <span>'.$_GET['departure_airport_route'].'</span> '; } |
|
178 | + if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] == "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != "") { print _("Route into:").' <span>'.$_GET['arrival_airport_route'].'</span> '; } |
|
179 | + if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != "") { print _("Route between:").' <span>'.$_GET['departure_airport_route'].'</span> and <span>'.$_GET['arrival_airport_route'].'</span> '; } |
|
180 | + if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] == "") { print _("Date starting at:").' <span>'.$_GET['start_date'].'</span> '; } |
|
181 | + if (isset($_GET['start_date']) && $_GET['start_date'] == "" && isset($_GET['end_date']) && $_GET['end_date'] != "") { print _("Date ending at:").' <span>'.$_GET['end_date'].'</span> '; } |
|
182 | + if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] != "") { print _("Date between:").' <span>'.$_GET['start_date'].'</span> and <span>'.$_GET['end_date'].'</span> '; } |
|
183 | + if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == "") { print _("Altitude starting at:").' <span>'.number_format($_GET['lowest_altitude']).' feet</span> '; } |
|
184 | + if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != "") { print _("Altitude ending at:").' <span>'.number_format($_GET['highest_altitude']).' feet</span> '; } |
|
185 | + if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != "") { print _("Altitude between:").' <span>'.number_format($_GET['lowest_altitude']).' feet</span> '._("and").' <span>'.number_format($_GET['highest_altitude']).' feet</span> '; } |
|
186 | + if (isset($_GET['number_results']) && $_GET['number_results'] != "") { print _("limit per page:").' <span>'.$_GET['number_results'].'</span> '; } |
|
187 | 187 | print '</h1>'; |
188 | 188 | print '</div>'; |
189 | 189 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | </select> |
291 | 291 | </div> |
292 | 292 | </div> |
293 | - <script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) print $_GET['manufacturer']; ?>')</script> |
|
293 | + <script type="text/javascript">getSelect('manufacturer','<?php if (isset($_GET['manufacturer'])) print $_GET['manufacturer']; ?>')</script> |
|
294 | 294 | <div class="form-group"> |
295 | 295 | <label class="control-label col-sm-2"><?php echo _("Type"); ?></label> |
296 | 296 | <div class="col-sm-10"> |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | </select> |
300 | 300 | </div> |
301 | 301 | </div> |
302 | - <script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) print $_GET['aircraft_icao']; ?>');</script> |
|
302 | + <script type="text/javascript">getSelect('aircrafttypes','<?php if (isset($_GET['aircraft_icao'])) print $_GET['aircraft_icao']; ?>');</script> |
|
303 | 303 | <div class="form-group"> |
304 | 304 | <label class="control-label col-sm-2"><?php echo _("Registration"); ?></label> |
305 | 305 | <div class="col-sm-10"> |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | </div> |
323 | 323 | </div> |
324 | 324 | <?php |
325 | -}else { |
|
325 | +} else { |
|
326 | 326 | ?> |
327 | 327 | <div class="form-group"> |
328 | 328 | <label class="control-label col-sm-2"><?php echo _("Owner name"); ?></label> |
@@ -335,8 +335,8 @@ discard block |
||
335 | 335 | ?> |
336 | 336 | <div class="form-group"> |
337 | 337 | <div class="col-sm-offset-2 col-sm-10"> |
338 | - <!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>--> |
|
339 | - <label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label> |
|
338 | + <!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true") { print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>--> |
|
339 | + <label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true") { print 'checked="checked"'; } ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label> |
|
340 | 340 | </div> |
341 | 341 | </div> |
342 | 342 | </fieldset> |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | </select> |
351 | 351 | </div> |
352 | 352 | </div> |
353 | - <script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) print $_GET['airline']; ?>');</script> |
|
353 | + <script type="text/javascript">getSelect('airlinenames','<?php if (isset($_GET['airline'])) print $_GET['airline']; ?>');</script> |
|
354 | 354 | <div class="form-group"> |
355 | 355 | <label class="control-label col-sm-2"><?php echo _("Country"); ?></label> |
356 | 356 | <div class="col-sm-10"> |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | </select> |
360 | 360 | </div> |
361 | 361 | </div> |
362 | - <script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) print $_GET['airline_country']; ?>');</script> |
|
362 | + <script type="text/javascript">getSelect('airlinecountries','<?php if (isset($_GET['airline_country'])) print $_GET['airline_country']; ?>');</script> |
|
363 | 363 | <div class="form-group"> |
364 | 364 | <label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> |
365 | 365 | <div class="col-sm-10"> |
@@ -368,10 +368,10 @@ discard block |
||
368 | 368 | </div> |
369 | 369 | <div class="form-group"> |
370 | 370 | <div class="col-sm-offset-2 col-sm-10"> |
371 | - <label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all"){ print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label> |
|
372 | - <label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label> |
|
373 | - <label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label> |
|
374 | - <label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label> |
|
371 | + <label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all") { print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label> |
|
372 | + <label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger") { print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label> |
|
373 | + <label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "cargo") { print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label> |
|
374 | + <label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "military") { print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label> |
|
375 | 375 | </div> |
376 | 376 | </div> |
377 | 377 | </fieldset> |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | </select> |
386 | 386 | </div> |
387 | 387 | </div> |
388 | - <script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) print $_GET['airport_icao']; ?>');</script> |
|
388 | + <script type="text/javascript">getSelect('airportnames','<?php if (isset($_GET['airport_icao'])) print $_GET['airport_icao']; ?>');</script> |
|
389 | 389 | <div class="form-group"> |
390 | 390 | <label class="control-label col-sm-2"><?php echo _("Country"); ?></label> |
391 | 391 | <div class="col-sm-10"> |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | </select> |
395 | 395 | </div> |
396 | 396 | </div> |
397 | - <script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) print $_GET['airport_country']; ?>');</script> |
|
397 | + <script type="text/javascript">getSelect('airportcountries','<?php if (isset($_GET['airport_country'])) print $_GET['airport_country']; ?>');</script> |
|
398 | 398 | </fieldset> |
399 | 399 | <fieldset> |
400 | 400 | <legend><?php echo _("Route"); ?></legend> |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | </select> |
407 | 407 | </div> |
408 | 408 | </div> |
409 | - <script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) print $_GET['departure_airport_route']; ?>');</script> |
|
409 | + <script type="text/javascript">getSelect('departureairportnames','<?php if (isset($_GET['departure_airport_route'])) print $_GET['departure_airport_route']; ?>');</script> |
|
410 | 410 | <div class="form-group"> |
411 | 411 | <label class="control-label col-sm-2"><?php echo _("Arrival Airport"); ?></label> |
412 | 412 | <div class="col-sm-10"> |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | </select> |
416 | 416 | </div> |
417 | 417 | </div> |
418 | - <script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) print $_GET['arrival_airport_route']; ?>');</script> |
|
418 | + <script type="text/javascript">getSelect('arrivalairportnames','<?php if (isset($_GET['arrival_airport_route'])) print $_GET['arrival_airport_route']; ?>');</script> |
|
419 | 419 | </fieldset> |
420 | 420 | <fieldset> |
421 | 421 | <legend><?php echo _("Date"); ?></legend> |
@@ -469,9 +469,9 @@ discard block |
||
469 | 469 | <option></option> |
470 | 470 | <?php |
471 | 471 | $altitude_array = Array(1000, 5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000); |
472 | -foreach($altitude_array as $altitude) |
|
472 | +foreach ($altitude_array as $altitude) |
|
473 | 473 | { |
474 | - if(isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == $altitude) |
|
474 | + if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == $altitude) |
|
475 | 475 | { |
476 | 476 | print '<option value="'.$altitude.'" selected="selected">'.number_format($altitude).' feet</option>'; |
477 | 477 | } else { |
@@ -489,9 +489,9 @@ discard block |
||
489 | 489 | <option></option> |
490 | 490 | <?php |
491 | 491 | $altitude_array = Array(1000, 5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000); |
492 | -foreach($altitude_array as $altitude) |
|
492 | +foreach ($altitude_array as $altitude) |
|
493 | 493 | { |
494 | - if(isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == $altitude) |
|
494 | + if (isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == $altitude) |
|
495 | 495 | { |
496 | 496 | print '<option value="'.$altitude.'" selected="selected">'.number_format($altitude).' feet</option>'; |
497 | 497 | } else { |
@@ -530,10 +530,10 @@ discard block |
||
530 | 530 | <div class="col-sm-10"> |
531 | 531 | <select class="form-control" name="number_results"> |
532 | 532 | <?php |
533 | -$number_results_array = Array(25, 50, 100, 150, 200, 250, 300, 400, 500, 600, 700, 800, 900, 1000); |
|
534 | -foreach($number_results_array as $number) |
|
533 | +$number_results_array = Array(25, 50, 100, 150, 200, 250, 300, 400, 500, 600, 700, 800, 900, 1000); |
|
534 | +foreach ($number_results_array as $number) |
|
535 | 535 | { |
536 | - if(isset($_GET['number_results']) && $_GET['number_results'] == $number) |
|
536 | + if (isset($_GET['number_results']) && $_GET['number_results'] == $number) |
|
537 | 537 | { |
538 | 538 | print '<option value="'.$number.'" selected="selected">'.$number.'</option>'; |
539 | 539 | } else { |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | <fieldset> |
552 | 552 | <div class="form-group"> |
553 | 553 | <div class="col-sm-offset-2 col-sm-10"> |
554 | - <label class="checkbox-inline"><input type="checkbox" name="archive" value="1" /><?php echo sprintf(_("Search in archive (older than %s months)"),$globalArchiveKeepMonths); ?></label> |
|
554 | + <label class="checkbox-inline"><input type="checkbox" name="archive" value="1" /><?php echo sprintf(_("Search in archive (older than %s months)"), $globalArchiveKeepMonths); ?></label> |
|
555 | 555 | </div> |
556 | 556 | </div> |
557 | 557 | </fieldset> |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | die; |
41 | 41 | } |
42 | 42 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
43 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
43 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | -$options = getopt('s::',array('source::','server','idsource::')); |
|
47 | +$options = getopt('s::', array('source::', 'server', 'idsource::')); |
|
48 | 48 | //if (isset($options['s'])) $hosts = array($options['s']); |
49 | 49 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
50 | 50 | if (isset($options['s'])) { |
@@ -59,17 +59,17 @@ discard block |
||
59 | 59 | else $id_source = 1; |
60 | 60 | if (isset($globalServer) && $globalServer) { |
61 | 61 | if ($globalDebug) echo "Using Server Mode\n"; |
62 | - $SI=new SpotterServer(); |
|
63 | -} else $SI=new SpotterImport($Connection->db); |
|
62 | + $SI = new SpotterServer(); |
|
63 | +} else $SI = new SpotterImport($Connection->db); |
|
64 | 64 | //$APRS=new APRS($Connection->db); |
65 | -$SBS=new SBS(); |
|
66 | -$ACARS=new ACARS($Connection->db); |
|
67 | -$Common=new Common(); |
|
65 | +$SBS = new SBS(); |
|
66 | +$ACARS = new ACARS($Connection->db); |
|
67 | +$Common = new Common(); |
|
68 | 68 | date_default_timezone_set('UTC'); |
69 | 69 | //$servertz = system('date +%Z'); |
70 | 70 | // signal handler - playing nice with sockets and dump1090 |
71 | 71 | if (function_exists('pcntl_fork')) { |
72 | - pcntl_signal(SIGINT, function() { |
|
72 | + pcntl_signal(SIGINT, function() { |
|
73 | 73 | global $sockets; |
74 | 74 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
75 | 75 | die("Bye!\n"); |
@@ -112,34 +112,34 @@ discard block |
||
112 | 112 | |
113 | 113 | function connect_all($hosts) { |
114 | 114 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
115 | - global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
115 | + global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs; |
|
116 | 116 | if ($globalDebug) echo 'Connect to all...'."\n"; |
117 | 117 | foreach ($hosts as $id => $value) { |
118 | 118 | $host = $value['host']; |
119 | 119 | $globalSources[$id]['last_exec'] = 0; |
120 | 120 | // Here we check type of source(s) |
121 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
122 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
121 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
122 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
123 | 123 | //$formats[$id] = 'deltadbtxt'; |
124 | 124 | $globalSources[$id]['format'] = 'deltadbtxt'; |
125 | 125 | //$last_exec['deltadbtxt'] = 0; |
126 | 126 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
127 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
127 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
128 | 128 | //$formats[$id] = 'vatsimtxt'; |
129 | 129 | $globalSources[$id]['format'] = 'vatsimtxt'; |
130 | 130 | //$last_exec['vatsimtxt'] = 0; |
131 | 131 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
132 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
132 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
133 | 133 | //$formats[$id] = 'aircraftlistjson'; |
134 | 134 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
135 | 135 | //$last_exec['aircraftlistjson'] = 0; |
136 | 136 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
137 | - } else if (preg_match('/opensky/i',$host)) { |
|
137 | + } else if (preg_match('/opensky/i', $host)) { |
|
138 | 138 | //$formats[$id] = 'aircraftlistjson'; |
139 | 139 | $globalSources[$id]['format'] = 'opensky'; |
140 | 140 | //$last_exec['aircraftlistjson'] = 0; |
141 | 141 | if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
142 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
142 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
143 | 143 | //$formats[$id] = 'radarvirtueljson'; |
144 | 144 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
145 | 145 | //$last_exec['radarvirtueljson'] = 0; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
149 | 149 | exit(0); |
150 | 150 | } |
151 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
151 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
152 | 152 | //$formats[$id] = 'planeupdatefaa'; |
153 | 153 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
154 | 154 | //$last_exec['planeupdatefaa'] = 0; |
@@ -157,26 +157,26 @@ discard block |
||
157 | 157 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
158 | 158 | exit(0); |
159 | 159 | } |
160 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
160 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
161 | 161 | //$formats[$id] = 'phpvmacars'; |
162 | 162 | $globalSources[$id]['format'] = 'phpvmacars'; |
163 | 163 | //$last_exec['phpvmacars'] = 0; |
164 | 164 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
165 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
165 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
166 | 166 | //$formats[$id] = 'phpvmacars'; |
167 | 167 | $globalSources[$id]['format'] = 'vam'; |
168 | 168 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
169 | - } else if (preg_match('/whazzup/i',$host)) { |
|
169 | + } else if (preg_match('/whazzup/i', $host)) { |
|
170 | 170 | //$formats[$id] = 'whazzup'; |
171 | 171 | $globalSources[$id]['format'] = 'whazzup'; |
172 | 172 | //$last_exec['whazzup'] = 0; |
173 | 173 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
174 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
174 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
175 | 175 | //$formats[$id] = 'pirepsjson'; |
176 | 176 | $globalSources[$id]['format'] = 'pirepsjson'; |
177 | 177 | //$last_exec['pirepsjson'] = 0; |
178 | 178 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
179 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
179 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
180 | 180 | //$formats[$id] = 'fr24json'; |
181 | 181 | $globalSources[$id]['format'] = 'fr24json'; |
182 | 182 | //$last_exec['fr24json'] = 0; |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | exit(0); |
187 | 187 | } |
188 | 188 | //} else if (preg_match('/10001/',$host)) { |
189 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
189 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
190 | 190 | //$formats[$id] = 'tsv'; |
191 | 191 | $globalSources[$id]['format'] = 'tsv'; |
192 | 192 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
193 | 193 | } |
194 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
194 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
195 | 195 | if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
196 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
197 | - $hostport = explode(':',$host); |
|
196 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
197 | + $hostport = explode(':', $host); |
|
198 | 198 | if (isset($hostport[1])) { |
199 | 199 | $port = $hostport[1]; |
200 | 200 | $hostn = $hostport[0]; |
@@ -203,14 +203,14 @@ discard block |
||
203 | 203 | $hostn = $globalSources[$id]['host']; |
204 | 204 | } |
205 | 205 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
206 | - $s = create_socket($hostn,$port, $errno, $errstr); |
|
206 | + $s = create_socket($hostn, $port, $errno, $errstr); |
|
207 | 207 | } else { |
208 | - $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
208 | + $s = create_socket_udp($hostn, $port, $errno, $errstr); |
|
209 | 209 | } |
210 | 210 | if ($s) { |
211 | 211 | $sockets[$id] = $s; |
212 | 212 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
213 | - if (preg_match('/aprs/',$hostn)) { |
|
213 | + if (preg_match('/aprs/', $hostn)) { |
|
214 | 214 | //$formats[$id] = 'aprs'; |
215 | 215 | $globalSources[$id]['format'] = 'aprs'; |
216 | 216 | //$aprs_connect = 0; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
252 | 252 | else $timeout = 20; |
253 | 253 | $errno = ''; |
254 | -$errstr=''; |
|
254 | +$errstr = ''; |
|
255 | 255 | |
256 | 256 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
257 | 257 | /* Initiate connections to all the hosts simultaneously */ |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | |
281 | 281 | if ($use_aprs) { |
282 | 282 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
283 | - $APRS=new APRS(); |
|
283 | + $APRS = new APRS(); |
|
284 | 284 | $aprs_connect = 0; |
285 | 285 | $aprs_keep = 120; |
286 | 286 | $aprs_last_tx = time(); |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | else $aprs_ssid = 'FAM'; |
292 | 292 | //else $aprs_ssid = 'PerlEx'; |
293 | 293 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
294 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
294 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
295 | 295 | if ($aprs_full) $aprs_filter = ''; |
296 | 296 | if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n"; |
297 | 297 | else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n"; |
@@ -302,12 +302,12 @@ discard block |
||
302 | 302 | sleep(1); |
303 | 303 | if ($globalDebug) echo "SCAN MODE \n\n"; |
304 | 304 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
305 | -$endtime = time()+$globalCronEnd; |
|
305 | +$endtime = time() + $globalCronEnd; |
|
306 | 306 | $i = 1; |
307 | 307 | $tt = array(); |
308 | 308 | // Delete all ATC |
309 | 309 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
310 | - $ATC=new ATC($Connection->db); |
|
310 | + $ATC = new ATC($Connection->db); |
|
311 | 311 | } |
312 | 312 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
313 | 313 | $ATC->deleteAll(); |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | |
316 | 316 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
317 | 317 | while ($i > 0) { |
318 | - if (!$globalDaemon) $i = $endtime-time(); |
|
318 | + if (!$globalDaemon) $i = $endtime - time(); |
|
319 | 319 | // Delete old ATC |
320 | 320 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
321 | 321 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | } |
330 | 330 | if ($max != $globalMinFetch) { |
331 | 331 | if ($globalDebug) echo 'Sleeping...'."\n"; |
332 | - sleep($globalMinFetch-$max+2); |
|
332 | + sleep($globalMinFetch - $max + 2); |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
341 | 341 | //$buffer = $Common->getData($hosts[$id]); |
342 | 342 | $buffer = $Common->getData($value['host']); |
343 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
344 | - $buffer = explode('\n',$buffer); |
|
343 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
344 | + $buffer = explode('\n', $buffer); |
|
345 | 345 | foreach ($buffer as $line) { |
346 | 346 | if ($line != '' && count($line) > 7) { |
347 | 347 | $line = explode(',', $line); |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value[' last_exec'] > $globalMinFetch))) { |
371 | 371 | //$buffer = $Common->getData($hosts[$id]); |
372 | 372 | $buffer = $Common->getData($value['host']); |
373 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
374 | - $buffer = explode('\n',$buffer); |
|
373 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
374 | + $buffer = explode('\n', $buffer); |
|
375 | 375 | foreach ($buffer as $line) { |
376 | 376 | if ($line != '') { |
377 | 377 | $line = explode(':', $line); |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | $data['id'] = $line[1].'-'.$line[0]; |
381 | 381 | $data['pilot_id'] = $line[1]; |
382 | 382 | $data['pilot_name'] = $line[2]; |
383 | - $data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT); |
|
383 | + $data['hex'] = str_pad(dechex($line[1]), 6, '000000', STR_PAD_LEFT); |
|
384 | 384 | $data['ident'] = $line[0]; // ident |
385 | 385 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
386 | 386 | $data['speed'] = $line[8]; // speed |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
397 | 397 | if (isset($line[37])) $data['last_update'] = $line[37]; |
398 | 398 | $data['departure_airport_icao'] = $line[11]; |
399 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
399 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
400 | 400 | $data['arrival_airport_icao'] = $line[13]; |
401 | 401 | $data['frequency'] = $line[4]; |
402 | 402 | $data['type'] = $line[18]; |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | $data['id_source'] = $id_source; |
406 | 406 | //$data['arrival_airport_time'] = ; |
407 | 407 | if ($line[9] != '') { |
408 | - $aircraft_data = explode('/',$line[9]); |
|
408 | + $aircraft_data = explode('/', $line[9]); |
|
409 | 409 | if (isset($aircraft_data[1])) { |
410 | 410 | $data['aircraft_icao'] = $aircraft_data[1]; |
411 | 411 | } |
@@ -419,9 +419,9 @@ discard block |
||
419 | 419 | if ($line[3] == 'PILOT') $SI->add($data); |
420 | 420 | elseif ($line[3] == 'ATC') { |
421 | 421 | //print_r($data); |
422 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
423 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
424 | - $typec = substr($data['ident'],-3); |
|
422 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
423 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
424 | + $typec = substr($data['ident'], -3); |
|
425 | 425 | if ($typec == 'APP') $data['type'] = 'Approach'; |
426 | 426 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
427 | 427 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
433 | 433 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
434 | 434 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
435 | - echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
435 | + echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
436 | 436 | } |
437 | 437 | unset($data); |
438 | 438 | } |
@@ -443,9 +443,9 @@ discard block |
||
443 | 443 | $last_exec[$id]['last'] = time(); |
444 | 444 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
445 | 445 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
446 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
446 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
447 | 447 | if ($buffer != '') { |
448 | - $all_data = json_decode($buffer,true); |
|
448 | + $all_data = json_decode($buffer, true); |
|
449 | 449 | if (isset($all_data['acList'])) { |
450 | 450 | foreach ($all_data['acList'] as $line) { |
451 | 451 | $data = array(); |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
500 | 500 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
501 | 501 | $buffer = $Common->getData($value['host']); |
502 | - $all_data = json_decode($buffer,true); |
|
502 | + $all_data = json_decode($buffer, true); |
|
503 | 503 | if (isset($all_data['planes'])) { |
504 | 504 | foreach ($all_data['planes'] as $key => $line) { |
505 | 505 | $data = array(); |
@@ -515,12 +515,12 @@ discard block |
||
515 | 515 | $data['emergency'] = ''; // emergency |
516 | 516 | $data['registration'] = $line[2]; |
517 | 517 | $data['aircraft_icao'] = $line[0]; |
518 | - $deparr = explode('-',$line[1]); |
|
518 | + $deparr = explode('-', $line[1]); |
|
519 | 519 | if (count($deparr) == 2) { |
520 | 520 | $data['departure_airport_icao'] = $deparr[0]; |
521 | 521 | $data['arrival_airport_icao'] = $deparr[1]; |
522 | 522 | } |
523 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
523 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
524 | 524 | $data['format_source'] = 'planeupdatefaa'; |
525 | 525 | $data['id_source'] = $id_source; |
526 | 526 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | $last_exec[$id]['last'] = time(); |
533 | 533 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
534 | 534 | $buffer = $Common->getData($value['host']); |
535 | - $all_data = json_decode($buffer,true); |
|
535 | + $all_data = json_decode($buffer, true); |
|
536 | 536 | if (isset($all_data['states'])) { |
537 | 537 | foreach ($all_data['states'] as $key => $line) { |
538 | 538 | $data = array(); |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | //$data['emergency'] = ''; // emergency |
549 | 549 | //$data['registration'] = $line[2]; |
550 | 550 | //$data['aircraft_icao'] = $line[0]; |
551 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
551 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
552 | 552 | $data['format_source'] = 'opensky'; |
553 | 553 | $data['id_source'] = $id_source; |
554 | 554 | $SI->add($data); |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
562 | 562 | //$buffer = $Common->getData($hosts[$id]); |
563 | 563 | $buffer = $Common->getData($value['host']); |
564 | - $all_data = json_decode($buffer,true); |
|
564 | + $all_data = json_decode($buffer, true); |
|
565 | 565 | foreach ($all_data as $key => $line) { |
566 | 566 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
567 | 567 | $data = array(); |
@@ -592,11 +592,11 @@ discard block |
||
592 | 592 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
593 | 593 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
594 | 594 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
595 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
595 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
596 | 596 | //echo $buffer; |
597 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
598 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
599 | - $all_data = json_decode($buffer,true); |
|
597 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
598 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
599 | + $all_data = json_decode($buffer, true); |
|
600 | 600 | if (json_last_error() != JSON_ERROR_NONE) { |
601 | 601 | die(json_last_error_msg()); |
602 | 602 | } |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | //$data['departure_airport_iata'] = $line[11]; |
619 | 619 | //$data['arrival_airport_iata'] = $line[12]; |
620 | 620 | //$data['emergency'] = ''; // emergency |
621 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
621 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
622 | 622 | $data['format_source'] = 'radarvirtueljson'; |
623 | 623 | $data['id_source'] = $id_source; |
624 | 624 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -633,13 +633,13 @@ discard block |
||
633 | 633 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
634 | 634 | //$buffer = $Common->getData($hosts[$id]); |
635 | 635 | $buffer = $Common->getData($value['host'].'?'.time()); |
636 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
636 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
637 | 637 | |
638 | 638 | if (isset($all_data['pireps'])) { |
639 | 639 | foreach ($all_data['pireps'] as $line) { |
640 | 640 | $data = array(); |
641 | 641 | $data['id'] = $line['id']; |
642 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
642 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
643 | 643 | $data['ident'] = $line['callsign']; // ident |
644 | 644 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
645 | 645 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -668,9 +668,9 @@ discard block |
||
668 | 668 | $SI->add($data); |
669 | 669 | // print_r($data); |
670 | 670 | } elseif ($line['icon'] == 'ct') { |
671 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
672 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
673 | - $typec = substr($data['ident'],-3); |
|
671 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
672 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
673 | + $typec = substr($data['ident'], -3); |
|
674 | 674 | $data['type'] = ''; |
675 | 675 | if ($typec == 'APP') $data['type'] = 'Approach'; |
676 | 676 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
682 | 682 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
683 | 683 | else $data['type'] = 'Observer'; |
684 | - echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
684 | + echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']); |
|
685 | 685 | } |
686 | 686 | unset($data); |
687 | 687 | } |
@@ -693,13 +693,13 @@ discard block |
||
693 | 693 | //$buffer = $Common->getData($hosts[$id]); |
694 | 694 | if ($globalDebug) echo 'Get Data...'."\n"; |
695 | 695 | $buffer = $Common->getData($value['host']); |
696 | - $all_data = json_decode($buffer,true); |
|
696 | + $all_data = json_decode($buffer, true); |
|
697 | 697 | if ($buffer != '' && is_array($all_data)) { |
698 | 698 | foreach ($all_data as $line) { |
699 | 699 | $data = array(); |
700 | 700 | //$data['id'] = $line['id']; // id not usable |
701 | 701 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
702 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
702 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
703 | 703 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
704 | 704 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
705 | 705 | $data['ident'] = $line['flightnum']; // ident |
@@ -722,12 +722,12 @@ discard block |
||
722 | 722 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
723 | 723 | if (isset($line['aircraftname'])) { |
724 | 724 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
725 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
726 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
725 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
726 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
727 | 727 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
728 | 728 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
729 | 729 | else { |
730 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
730 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
731 | 731 | if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
732 | 732 | else $data['aircraft_icao'] = $line['aircraftname']; |
733 | 733 | } |
@@ -749,13 +749,13 @@ discard block |
||
749 | 749 | //$buffer = $Common->getData($hosts[$id]); |
750 | 750 | if ($globalDebug) echo 'Get Data...'."\n"; |
751 | 751 | $buffer = $Common->getData($value['host']); |
752 | - $all_data = json_decode($buffer,true); |
|
752 | + $all_data = json_decode($buffer, true); |
|
753 | 753 | if ($buffer != '' && is_array($all_data)) { |
754 | 754 | foreach ($all_data as $line) { |
755 | 755 | $data = array(); |
756 | 756 | //$data['id'] = $line['id']; // id not usable |
757 | 757 | $data['id'] = trim($line['flight_id']); |
758 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
758 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
759 | 759 | $data['pilot_name'] = $line['pilot_name']; |
760 | 760 | $data['pilot_id'] = $line['pilot_id']; |
761 | 761 | $data['ident'] = trim($line['callsign']); // ident |
@@ -805,9 +805,9 @@ discard block |
||
805 | 805 | //$value = $formats[$nb]; |
806 | 806 | $format = $globalSources[$nb]['format']; |
807 | 807 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
808 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
808 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
809 | 809 | } else { |
810 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
810 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
811 | 811 | } |
812 | 812 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
813 | 813 | //echo $buffer."\n"; |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
816 | 816 | $error = false; |
817 | 817 | //$SI::del(); |
818 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
818 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
819 | 819 | // SBS format is CSV format |
820 | 820 | if ($buffer != '') { |
821 | 821 | $tt[$format] = 0; |
@@ -836,10 +836,10 @@ discard block |
||
836 | 836 | } elseif ($format == 'flightgearsp') { |
837 | 837 | //echo $buffer."\n"; |
838 | 838 | if (strlen($buffer) > 5) { |
839 | - $line = explode(',',$buffer); |
|
839 | + $line = explode(',', $buffer); |
|
840 | 840 | $data = array(); |
841 | 841 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
842 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
842 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
843 | 843 | $data['ident'] = $line[6]; |
844 | 844 | $data['aircraft_name'] = $line[7]; |
845 | 845 | $data['longitude'] = $line[1]; |
@@ -850,21 +850,21 @@ discard block |
||
850 | 850 | $data['datetime'] = date('Y-m-d H:i:s'); |
851 | 851 | $data['format_source'] = 'flightgearsp'; |
852 | 852 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
853 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
853 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
854 | 854 | } |
855 | 855 | } elseif ($format == 'acars') { |
856 | 856 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
857 | 857 | $ACARS->add(trim($buffer)); |
858 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
858 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
859 | 859 | $ACARS->deleteLiveAcarsData(); |
860 | 860 | } elseif ($format == 'flightgearmp') { |
861 | - if (substr($buffer,0,1) != '#') { |
|
861 | + if (substr($buffer, 0, 1) != '#') { |
|
862 | 862 | $data = array(); |
863 | 863 | //echo $buffer."\n"; |
864 | - $line = explode(' ',$buffer); |
|
864 | + $line = explode(' ', $buffer); |
|
865 | 865 | if (count($line) == 11) { |
866 | - $userserver = explode('@',$line[0]); |
|
867 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
866 | + $userserver = explode('@', $line[0]); |
|
867 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
868 | 868 | $data['ident'] = $userserver[0]; |
869 | 869 | $data['registration'] = $userserver[0]; |
870 | 870 | $data['latitude'] = $line[4]; |
@@ -872,24 +872,24 @@ discard block |
||
872 | 872 | $data['altitude'] = $line[6]; |
873 | 873 | $data['datetime'] = date('Y-m-d H:i:s'); |
874 | 874 | $aircraft_type = $line[10]; |
875 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
876 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
875 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
876 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
877 | 877 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
878 | 878 | } |
879 | 879 | } |
880 | 880 | } elseif ($format == 'beast') { |
881 | 881 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
882 | 882 | die; |
883 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
883 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
884 | 884 | $line = explode("\t", $buffer); |
885 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
885 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
886 | 886 | $key = $line[$k]; |
887 | - $lined[$key] = $line[$k+1]; |
|
887 | + $lined[$key] = $line[$k + 1]; |
|
888 | 888 | } |
889 | 889 | if (count($lined) > 3) { |
890 | 890 | $data['hex'] = $lined['hexid']; |
891 | 891 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
892 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
892 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
893 | 893 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
894 | 894 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
895 | 895 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -907,24 +907,24 @@ discard block |
||
907 | 907 | } else $error = true; |
908 | 908 | } elseif ($format == 'aprs' && $use_aprs) { |
909 | 909 | if ($aprs_connect == 0) { |
910 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
910 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
911 | 911 | $aprs_connect = 1; |
912 | 912 | } |
913 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
913 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
914 | 914 | $aprs_last_tx = time(); |
915 | 915 | $data_aprs = "# Keep alive"; |
916 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
916 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
917 | 917 | } |
918 | 918 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
919 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
920 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
921 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
919 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
920 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
921 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
922 | 922 | $line = $APRS->parse($buffer); |
923 | 923 | if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
924 | 924 | $data = array(); |
925 | 925 | //print_r($line); |
926 | 926 | $data['hex'] = $line['address']; |
927 | - $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
927 | + $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
928 | 928 | //$data['datetime'] = date('Y-m-d H:i:s'); |
929 | 929 | $data['ident'] = $line['ident']; |
930 | 930 | $data['latitude'] = $line['latitude']; |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | $currentdate = date('Y-m-d H:i:s'); |
945 | 945 | $aprsdate = strtotime($data['datetime']); |
946 | 946 | // Accept data if time <= system time + 20s |
947 | - if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data); |
|
947 | + if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data); |
|
948 | 948 | else { |
949 | 949 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
950 | 950 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | connect_all($sourceee); |
1030 | 1030 | $sourceee = array(); |
1031 | 1031 | //connect_all($globalSources); |
1032 | - $tt[$format]=0; |
|
1032 | + $tt[$format] = 0; |
|
1033 | 1033 | break; |
1034 | 1034 | } |
1035 | 1035 | } |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | } |
1038 | 1038 | } else { |
1039 | 1039 | $error = socket_strerror(socket_last_error()); |
1040 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1040 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1041 | 1041 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) { |
1042 | 1042 | if (isset($globalDebug)) echo "Restarting...\n"; |
1043 | 1043 | // Restart the script if possible |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | if ($globalDebug) echo "Shutdown all sockets..."; |
1046 | 1046 | |
1047 | 1047 | foreach ($sockets as $sock) { |
1048 | - @socket_shutdown($sock,2); |
|
1048 | + @socket_shutdown($sock, 2); |
|
1049 | 1049 | @socket_close($sock); |
1050 | 1050 | } |
1051 | 1051 |
@@ -3,17 +3,17 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | |
6 | -if (!isset($_GET['departure_airport']) || !isset($_GET['arrival_airport'])){ |
|
6 | +if (!isset($_GET['departure_airport']) || !isset($_GET['arrival_airport'])) { |
|
7 | 7 | header('Location: '.$globalURL.''); |
8 | 8 | } else { |
9 | 9 | $Spotter = new Spotter(); |
10 | 10 | //calculuation for the pagination |
11 | - if(!isset($_GET['limit'])) |
|
11 | + if (!isset($_GET['limit'])) |
|
12 | 12 | { |
13 | 13 | $limit_start = 0; |
14 | 14 | $limit_end = 25; |
15 | 15 | $absolute_difference = 25; |
16 | - } else { |
|
16 | + } else { |
|
17 | 17 | $limit_explode = explode(",", $_GET['limit']); |
18 | 18 | $limit_start = $limit_explode[0]; |
19 | 19 | $limit_end = $limit_explode[1]; |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | $limit_previous_1 = $limit_start - $absolute_difference; |
28 | 28 | $limit_previous_2 = $limit_end - $absolute_difference; |
29 | 29 | |
30 | - $departure_airport = filter_input(INPUT_GET,'departure_airport',FILTER_SANITIZE_STRING); |
|
31 | - $arrival_airport = filter_input(INPUT_GET,'arrival_airport',FILTER_SANITIZE_STRING); |
|
30 | + $departure_airport = filter_input(INPUT_GET, 'departure_airport', FILTER_SANITIZE_STRING); |
|
31 | + $arrival_airport = filter_input(INPUT_GET, 'arrival_airport', FILTER_SANITIZE_STRING); |
|
32 | 32 | $page_url = $globalURL.'/route/'.$departure_airport.'/'.$arrival_airport; |
33 | 33 | if (isset($_GET['sort'])) { |
34 | 34 | $spotter_array = $Spotter->getSpotterDataByRoute($departure_airport, $arrival_airport, $limit_start.",".$absolute_difference, $_GET['sort']); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | if (!empty($spotter_array)) |
40 | 40 | { |
41 | - $title = sprintf(_("Detailed View for flights between %s (%s), %s - %s (%s), %s"),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']); |
|
41 | + $title = sprintf(_("Detailed View for flights between %s (%s), %s - %s (%s), %s"), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']); |
|
42 | 42 | require_once('header.php'); |
43 | 43 | print '<div class="info column">'; |
44 | 44 | print '<h1>'._("Flights between").' '.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].' - '.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</h1>'; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | include('route-sub-menu.php'); |
50 | 50 | print '<div class="table column">'; |
51 | - print '<p>'.sprintf(_("The table below shows the detailed information of all flights that used the route <strong>%s - %s</strong>."),$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['arrival_airport_icao']).'</p>'; |
|
51 | + print '<p>'.sprintf(_("The table below shows the detailed information of all flights that used the route <strong>%s - %s</strong>."), $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['arrival_airport_icao']).'</p>'; |
|
52 | 52 | |
53 | 53 | include('table-output.php'); |
54 | 54 | print '<div class="pagination">'; |
@@ -15,22 +15,22 @@ discard block |
||
15 | 15 | * @param Array $filter the filter |
16 | 16 | * @return Array the SQL part |
17 | 17 | */ |
18 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
18 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
19 | 19 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | - foreach($globalStatsFilters[$globalFilterName] as $source) { |
|
22 | + foreach ($globalStatsFilters[$globalFilterName] as $source) { |
|
23 | 23 | $filter['source'][] = $source; |
24 | 24 | } |
25 | 25 | } else { |
26 | 26 | $filter = $globalStatsFilters[$globalFilterName]; |
27 | 27 | } |
28 | 28 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | 32 | if (isset($filter['source']) && !empty($filter['source'])) { |
33 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
33 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
34 | 34 | } |
35 | 35 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
36 | 36 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -39,31 +39,31 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | public function getAll() { |
42 | - $filter_query = $this->getFilter(array(),true); |
|
42 | + $filter_query = $this->getFilter(array(), true); |
|
43 | 43 | $query = "SELECT * FROM atc".$filter_query; |
44 | 44 | $query_values = array(); |
45 | 45 | try { |
46 | 46 | $sth = $this->db->prepare($query); |
47 | 47 | $sth->execute($query_values); |
48 | - } catch(PDOException $e) { |
|
48 | + } catch (PDOException $e) { |
|
49 | 49 | return "error : ".$e->getMessage(); |
50 | 50 | } |
51 | 51 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
52 | 52 | return $all; |
53 | 53 | } |
54 | 54 | |
55 | - public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
56 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
57 | - $info = str_replace('^','<br />',$info); |
|
58 | - $info = str_replace('&sect;','',$info); |
|
59 | - $info = str_replace('"','',$info); |
|
55 | + public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
56 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
57 | + $info = str_replace('^', '<br />', $info); |
|
58 | + $info = str_replace('&sect;', '', $info); |
|
59 | + $info = str_replace('"', '', $info); |
|
60 | 60 | if ($type == '') $type = NULL; |
61 | 61 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
62 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
62 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
63 | 63 | try { |
64 | 64 | $sth = $this->db->prepare($query); |
65 | 65 | $sth->execute($query_values); |
66 | - } catch(PDOException $e) { |
|
66 | + } catch (PDOException $e) { |
|
67 | 67 | return "error : ".$e->getMessage(); |
68 | 68 | } |
69 | 69 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | try { |
75 | 75 | $sth = $this->db->prepare($query); |
76 | 76 | $sth->execute($query_values); |
77 | - } catch(PDOException $e) { |
|
77 | + } catch (PDOException $e) { |
|
78 | 78 | return "error : ".$e->getMessage(); |
79 | 79 | } |
80 | 80 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | try { |
86 | 86 | $sth = $this->db->prepare($query); |
87 | 87 | $sth->execute($query_values); |
88 | - } catch(PDOException $e) { |
|
88 | + } catch (PDOException $e) { |
|
89 | 89 | return "error : ".$e->getMessage(); |
90 | 90 | } |
91 | 91 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | try { |
101 | 101 | $sth = $this->db->prepare($query); |
102 | 102 | $sth->execute(); |
103 | - } catch(PDOException $e) { |
|
103 | + } catch (PDOException $e) { |
|
104 | 104 | return "error"; |
105 | 105 | } |
106 | 106 | return "success"; |
@@ -13,45 +13,45 @@ discard block |
||
13 | 13 | * @param Array $filter the filter |
14 | 14 | * @return Array the SQL part |
15 | 15 | */ |
16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
16 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
18 | 18 | $filters = array(); |
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
20 | 20 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
21 | 21 | $filters = $globalStatsFilters[$globalFilterName]; |
22 | 22 | } else { |
23 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
23 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
24 | 24 | } |
25 | 25 | } |
26 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
26 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
27 | 27 | $filter_query_join = ''; |
28 | 28 | $filter_query_where = ''; |
29 | - foreach($filters as $flt) { |
|
29 | + foreach ($filters as $flt) { |
|
30 | 30 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
31 | 31 | if ($flt['airlines'][0] != '') { |
32 | 32 | if (isset($flt['source'])) { |
33 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
33 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
34 | 34 | } else { |
35 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
35 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | } |
39 | 39 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
40 | 40 | if (isset($flt['source'])) { |
41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
42 | 42 | } else { |
43 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
43 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
47 | 47 | if (isset($flt['source'])) { |
48 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
48 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | } |
52 | 52 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
53 | 53 | if ($filter['airlines'][0] != '') { |
54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -59,19 +59,19 @@ discard block |
||
59 | 59 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
60 | 60 | } |
61 | 61 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
62 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
62 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
63 | 63 | } |
64 | 64 | if (isset($filter['source']) && !empty($filter['source'])) { |
65 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
65 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
66 | 66 | } |
67 | 67 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
68 | 68 | $filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
69 | 69 | } |
70 | 70 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
71 | 71 | if ($filter_query_where == '') { |
72 | - $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
72 | + $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
73 | 73 | } else { |
74 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
74 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
@@ -81,28 +81,28 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | // Spotter_archive |
84 | - public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
84 | + public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
85 | 85 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
86 | 86 | if ($over_country == '') { |
87 | 87 | $Spotter = new Spotter($this->db); |
88 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
88 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
89 | 89 | if (!empty($data_country)) $country = $data_country['iso2']; |
90 | 90 | else $country = ''; |
91 | 91 | } else $country = $over_country; |
92 | - if ($airline_type === NULL) $airline_type =''; |
|
92 | + if ($airline_type === NULL) $airline_type = ''; |
|
93 | 93 | |
94 | 94 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
95 | 95 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
96 | 96 | |
97 | 97 | // Route is not added in spotter_archive |
98 | - $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
98 | + $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
99 | 99 | VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)"; |
100 | 100 | |
101 | - $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
101 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
102 | 102 | try { |
103 | 103 | $sth = $this->db->prepare($query); |
104 | 104 | $sth->execute($query_values); |
105 | - } catch(PDOException $e) { |
|
105 | + } catch (PDOException $e) { |
|
106 | 106 | return "error : ".$e->getMessage(); |
107 | 107 | } |
108 | 108 | return "success"; |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | |
123 | 123 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
124 | 124 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
125 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
125 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
126 | 126 | |
127 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
127 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
128 | 128 | |
129 | 129 | return $spotter_array; |
130 | 130 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
144 | 144 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
145 | 145 | //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
146 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
146 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
147 | 147 | |
148 | 148 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
149 | 149 | /* |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
158 | 158 | */ |
159 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
159 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
160 | 160 | |
161 | 161 | return $spotter_array; |
162 | 162 | } |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | { |
172 | 172 | date_default_timezone_set('UTC'); |
173 | 173 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
174 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
174 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
175 | 175 | |
176 | 176 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
177 | 177 | |
178 | 178 | try { |
179 | 179 | $sth = $this->db->prepare($query); |
180 | 180 | $sth->execute(array(':id' => $id)); |
181 | - } catch(PDOException $e) { |
|
181 | + } catch (PDOException $e) { |
|
182 | 182 | echo $e->getMessage(); |
183 | 183 | die; |
184 | 184 | } |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | { |
198 | 198 | date_default_timezone_set('UTC'); |
199 | 199 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
200 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
200 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
201 | 201 | |
202 | 202 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
203 | 203 | |
204 | 204 | try { |
205 | 205 | $sth = $this->db->prepare($query); |
206 | 206 | $sth->execute(array(':id' => $id)); |
207 | - } catch(PDOException $e) { |
|
207 | + } catch (PDOException $e) { |
|
208 | 208 | echo $e->getMessage(); |
209 | 209 | die; |
210 | 210 | } |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | date_default_timezone_set('UTC'); |
227 | 227 | |
228 | 228 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
229 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
229 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
230 | 230 | |
231 | 231 | try { |
232 | 232 | $sth = $this->db->prepare($query); |
233 | 233 | $sth->execute(array(':ident' => $ident)); |
234 | - } catch(PDOException $e) { |
|
234 | + } catch (PDOException $e) { |
|
235 | 235 | echo $e->getMessage(); |
236 | 236 | die; |
237 | 237 | } |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | date_default_timezone_set('UTC'); |
253 | 253 | |
254 | 254 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
255 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
255 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
256 | 256 | |
257 | 257 | try { |
258 | 258 | $sth = $this->db->prepare($query); |
259 | 259 | $sth->execute(array(':id' => $id)); |
260 | - } catch(PDOException $e) { |
|
260 | + } catch (PDOException $e) { |
|
261 | 261 | echo $e->getMessage(); |
262 | 262 | die; |
263 | 263 | } |
@@ -278,12 +278,12 @@ discard block |
||
278 | 278 | date_default_timezone_set('UTC'); |
279 | 279 | |
280 | 280 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
281 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
281 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
282 | 282 | |
283 | 283 | try { |
284 | 284 | $sth = $this->db->prepare($query); |
285 | 285 | $sth->execute(array(':id' => $id)); |
286 | - } catch(PDOException $e) { |
|
286 | + } catch (PDOException $e) { |
|
287 | 287 | echo $e->getMessage(); |
288 | 288 | die; |
289 | 289 | } |
@@ -305,13 +305,13 @@ discard block |
||
305 | 305 | date_default_timezone_set('UTC'); |
306 | 306 | |
307 | 307 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
308 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
308 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
309 | 309 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
310 | 310 | |
311 | 311 | try { |
312 | 312 | $sth = $this->db->prepare($query); |
313 | 313 | $sth->execute(array(':ident' => $ident)); |
314 | - } catch(PDOException $e) { |
|
314 | + } catch (PDOException $e) { |
|
315 | 315 | echo $e->getMessage(); |
316 | 316 | die; |
317 | 317 | } |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | * @return Array the spotter information |
329 | 329 | * |
330 | 330 | */ |
331 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
331 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
332 | 332 | { |
333 | 333 | $Spotter = new Spotter($this->db); |
334 | 334 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
335 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
335 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
336 | 336 | |
337 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
337 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
338 | 338 | |
339 | 339 | return $spotter_array; |
340 | 340 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | try { |
348 | 348 | $sth = $this->db->prepare($query); |
349 | 349 | $sth->execute(); |
350 | - } catch(PDOException $e) { |
|
350 | + } catch (PDOException $e) { |
|
351 | 351 | echo $e->getMessage(); |
352 | 352 | die; |
353 | 353 | } |
@@ -359,24 +359,24 @@ discard block |
||
359 | 359 | * @return Array the spotter information |
360 | 360 | * |
361 | 361 | */ |
362 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
362 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
363 | 363 | { |
364 | 364 | global $globalDBdriver, $globalLiveInterval; |
365 | 365 | date_default_timezone_set('UTC'); |
366 | 366 | |
367 | 367 | $filter_query = ''; |
368 | 368 | if (isset($filter['source']) && !empty($filter['source'])) { |
369 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
369 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
370 | 370 | } |
371 | 371 | // Use spotter_output also ? |
372 | 372 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
373 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
373 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
374 | 374 | } |
375 | 375 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
376 | 376 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
377 | 377 | } |
378 | 378 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
379 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
379 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -395,14 +395,14 @@ discard block |
||
395 | 395 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
396 | 396 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
397 | 397 | */ |
398 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
398 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
399 | 399 | FROM spotter_archive |
400 | 400 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
401 | 401 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
402 | 402 | '.$filter_query.' ORDER BY flightaware_id'; |
403 | 403 | } else { |
404 | 404 | //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
405 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
405 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
406 | 406 | FROM spotter_archive |
407 | 407 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
408 | 408 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | try { |
413 | 413 | $sth = $this->db->prepare($query); |
414 | 414 | $sth->execute(); |
415 | - } catch(PDOException $e) { |
|
415 | + } catch (PDOException $e) { |
|
416 | 416 | echo $e->getMessage(); |
417 | 417 | die; |
418 | 418 | } |
@@ -427,24 +427,24 @@ discard block |
||
427 | 427 | * @return Array the spotter information |
428 | 428 | * |
429 | 429 | */ |
430 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
430 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
431 | 431 | { |
432 | 432 | global $globalDBdriver, $globalLiveInterval; |
433 | 433 | date_default_timezone_set('UTC'); |
434 | 434 | |
435 | 435 | $filter_query = ''; |
436 | 436 | if (isset($filter['source']) && !empty($filter['source'])) { |
437 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
437 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
438 | 438 | } |
439 | 439 | // Should use spotter_output also ? |
440 | 440 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
441 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
441 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
442 | 442 | } |
443 | 443 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
444 | 444 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
445 | 445 | } |
446 | 446 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
447 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
447 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | FROM spotter_archive |
455 | 455 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
456 | 456 | */ |
457 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
457 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
458 | 458 | FROM spotter_archive_output |
459 | 459 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
460 | 460 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
470 | 470 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
471 | 471 | */ |
472 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
472 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
473 | 473 | FROM spotter_archive_output |
474 | 474 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
475 | 475 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | try { |
482 | 482 | $sth = $this->db->prepare($query); |
483 | 483 | $sth->execute(); |
484 | - } catch(PDOException $e) { |
|
484 | + } catch (PDOException $e) { |
|
485 | 485 | echo $e->getMessage(); |
486 | 486 | die; |
487 | 487 | } |
@@ -496,23 +496,23 @@ discard block |
||
496 | 496 | * @return Array the spotter information |
497 | 497 | * |
498 | 498 | */ |
499 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
499 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
500 | 500 | { |
501 | 501 | global $globalDBdriver, $globalLiveInterval; |
502 | 502 | date_default_timezone_set('UTC'); |
503 | 503 | |
504 | 504 | $filter_query = ''; |
505 | 505 | if (isset($filter['source']) && !empty($filter['source'])) { |
506 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
506 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
507 | 507 | } |
508 | 508 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
509 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
509 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
510 | 510 | } |
511 | 511 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
512 | 512 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
513 | 513 | } |
514 | 514 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
515 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
515 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $this->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | echo $e->getMessage(); |
532 | 532 | die; |
533 | 533 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | * @return Array the spotter information |
548 | 548 | * |
549 | 549 | */ |
550 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
550 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
551 | 551 | { |
552 | 552 | global $globalTimezone, $globalDBdriver; |
553 | 553 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | |
570 | 570 | $q_array = explode(" ", $q); |
571 | 571 | |
572 | - foreach ($q_array as $q_item){ |
|
572 | + foreach ($q_array as $q_item) { |
|
573 | 573 | $additional_query .= " AND ("; |
574 | 574 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
575 | 575 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | |
602 | 602 | if ($registration != "") |
603 | 603 | { |
604 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
604 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
605 | 605 | if (!is_string($registration)) |
606 | 606 | { |
607 | 607 | return false; |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | if ($aircraft_icao != "") |
614 | 614 | { |
615 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
615 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
616 | 616 | if (!is_string($aircraft_icao)) |
617 | 617 | { |
618 | 618 | return false; |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | |
624 | 624 | if ($aircraft_manufacturer != "") |
625 | 625 | { |
626 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
626 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
627 | 627 | if (!is_string($aircraft_manufacturer)) |
628 | 628 | { |
629 | 629 | return false; |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | |
645 | 645 | if ($airline_icao != "") |
646 | 646 | { |
647 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
647 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
648 | 648 | if (!is_string($airline_icao)) |
649 | 649 | { |
650 | 650 | return false; |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | |
656 | 656 | if ($airline_country != "") |
657 | 657 | { |
658 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
658 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
659 | 659 | if (!is_string($airline_country)) |
660 | 660 | { |
661 | 661 | return false; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | |
667 | 667 | if ($airline_type != "") |
668 | 668 | { |
669 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
669 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
670 | 670 | if (!is_string($airline_type)) |
671 | 671 | { |
672 | 672 | return false; |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | |
689 | 689 | if ($airport != "") |
690 | 690 | { |
691 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
691 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
692 | 692 | if (!is_string($airport)) |
693 | 693 | { |
694 | 694 | return false; |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | |
700 | 700 | if ($airport_country != "") |
701 | 701 | { |
702 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
702 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
703 | 703 | if (!is_string($airport_country)) |
704 | 704 | { |
705 | 705 | return false; |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | |
711 | 711 | if ($callsign != "") |
712 | 712 | { |
713 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
713 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
714 | 714 | if (!is_string($callsign)) |
715 | 715 | { |
716 | 716 | return false; |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | $translate = $Translation->ident2icao($callsign); |
719 | 719 | if ($translate != $callsign) { |
720 | 720 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
721 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
721 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
722 | 722 | } else { |
723 | 723 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
724 | 724 | } |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | |
728 | 728 | if ($owner != "") |
729 | 729 | { |
730 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
730 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
731 | 731 | if (!is_string($owner)) |
732 | 732 | { |
733 | 733 | return false; |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | |
739 | 739 | if ($pilot_name != "") |
740 | 740 | { |
741 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
741 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
742 | 742 | if (!is_string($pilot_name)) |
743 | 743 | { |
744 | 744 | return false; |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | |
750 | 750 | if ($pilot_id != "") |
751 | 751 | { |
752 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
752 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
753 | 753 | if (!is_string($pilot_id)) |
754 | 754 | { |
755 | 755 | return false; |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | |
761 | 761 | if ($departure_airport_route != "") |
762 | 762 | { |
763 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
763 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
764 | 764 | if (!is_string($departure_airport_route)) |
765 | 765 | { |
766 | 766 | return false; |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | |
772 | 772 | if ($arrival_airport_route != "") |
773 | 773 | { |
774 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
774 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
775 | 775 | if (!is_string($arrival_airport_route)) |
776 | 776 | { |
777 | 777 | return false; |
@@ -784,8 +784,8 @@ discard block |
||
784 | 784 | { |
785 | 785 | $altitude_array = explode(",", $altitude); |
786 | 786 | |
787 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
787 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
788 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
789 | 789 | |
790 | 790 | |
791 | 791 | if ($altitude_array[1] != "") |
@@ -803,8 +803,8 @@ discard block |
||
803 | 803 | { |
804 | 804 | $date_array = explode(",", $date_posted); |
805 | 805 | |
806 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
807 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
806 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
807 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
808 | 808 | |
809 | 809 | if ($globalTimezone != '') { |
810 | 810 | date_default_timezone_set($globalTimezone); |
@@ -836,8 +836,8 @@ discard block |
||
836 | 836 | { |
837 | 837 | $limit_array = explode(",", $limit); |
838 | 838 | |
839 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
840 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
839 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
840 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
841 | 841 | |
842 | 842 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
843 | 843 | { |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | |
849 | 849 | |
850 | 850 | if ($origLat != "" && $origLon != "" && $dist != "") { |
851 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
852 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
851 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
852 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
853 | 853 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
854 | 854 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
855 | 855 | } else { |
@@ -866,12 +866,12 @@ discard block |
||
866 | 866 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
867 | 867 | } |
868 | 868 | |
869 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
869 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
870 | 870 | WHERE spotter_archive_output.ident <> '' |
871 | 871 | ".$additional_query." |
872 | 872 | ".$filter_query.$orderby_query; |
873 | 873 | } |
874 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
874 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
875 | 875 | |
876 | 876 | return $spotter_array; |
877 | 877 | } |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | try { |
889 | 889 | $sth = $this->db->prepare($query); |
890 | 890 | $sth->execute(); |
891 | - } catch(PDOException $e) { |
|
891 | + } catch (PDOException $e) { |
|
892 | 892 | return "error"; |
893 | 893 | } |
894 | 894 | } |
@@ -925,8 +925,8 @@ discard block |
||
925 | 925 | { |
926 | 926 | $limit_array = explode(",", $limit); |
927 | 927 | |
928 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
929 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
928 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
929 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
930 | 930 | |
931 | 931 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
932 | 932 | { |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | * @return Array the airline country list |
957 | 957 | * |
958 | 958 | */ |
959 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
959 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
960 | 960 | { |
961 | 961 | global $globalDBdriver; |
962 | 962 | /* |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | $flight_array = array(); |
986 | 986 | $temp_array = array(); |
987 | 987 | |
988 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
988 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
989 | 989 | { |
990 | 990 | $temp_array['flight_count'] = $row['nb']; |
991 | 991 | $temp_array['flight_country'] = $row['name']; |
@@ -1002,14 +1002,14 @@ discard block |
||
1002 | 1002 | * @return Array the spotter information |
1003 | 1003 | * |
1004 | 1004 | */ |
1005 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1005 | + public function getDateArchiveSpotterDataById($id, $date) |
|
1006 | 1006 | { |
1007 | 1007 | $Spotter = new Spotter($this->db); |
1008 | 1008 | date_default_timezone_set('UTC'); |
1009 | 1009 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1010 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1011 | - $date = date('c',$date); |
|
1012 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1010 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1011 | + $date = date('c', $date); |
|
1012 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1013 | 1013 | return $spotter_array; |
1014 | 1014 | } |
1015 | 1015 | |
@@ -1019,14 +1019,14 @@ discard block |
||
1019 | 1019 | * @return Array the spotter information |
1020 | 1020 | * |
1021 | 1021 | */ |
1022 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1022 | + public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
1023 | 1023 | { |
1024 | 1024 | $Spotter = new Spotter($this->db); |
1025 | 1025 | date_default_timezone_set('UTC'); |
1026 | 1026 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1027 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1028 | - $date = date('c',$date); |
|
1029 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1027 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
1028 | + $date = date('c', $date); |
|
1029 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1030 | 1030 | return $spotter_array; |
1031 | 1031 | } |
1032 | 1032 | |
@@ -1036,7 +1036,7 @@ discard block |
||
1036 | 1036 | * @return Array the spotter information |
1037 | 1037 | * |
1038 | 1038 | */ |
1039 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1039 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1040 | 1040 | { |
1041 | 1041 | global $global_query; |
1042 | 1042 | $Spotter = new Spotter(); |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | $query_values = array(); |
1045 | 1045 | $limit_query = ''; |
1046 | 1046 | $additional_query = ''; |
1047 | - $filter_query = $this->getFilter($filters,true,true); |
|
1047 | + $filter_query = $this->getFilter($filters, true, true); |
|
1048 | 1048 | |
1049 | 1049 | if ($airport != "") |
1050 | 1050 | { |
@@ -1061,8 +1061,8 @@ discard block |
||
1061 | 1061 | { |
1062 | 1062 | $limit_array = explode(",", $limit); |
1063 | 1063 | |
1064 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1065 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1064 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1065 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1066 | 1066 | |
1067 | 1067 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1068 | 1068 | { |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | try { |
15 | 15 | $sth = $Connection->db->prepare($query); |
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch (PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | 19 | } |
20 | 20 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
21 | + $Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | try { |
51 | 51 | $sth = $Connection->db->prepare($query); |
52 | 52 | $sth->execute(); |
53 | - } catch(PDOException $e) { |
|
53 | + } catch (PDOException $e) { |
|
54 | 54 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
55 | 55 | } |
56 | 56 | // Copy schedules data to routes table |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | try { |
61 | 61 | $sth = $Connection->db->prepare($query); |
62 | 62 | $sth->execute(); |
63 | - } catch(PDOException $e) { |
|
63 | + } catch (PDOException $e) { |
|
64 | 64 | return "error (delete schedule table) : ".$e->getMessage()."\n"; |
65 | 65 | } |
66 | 66 | // Add source column |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | try { |
69 | 69 | $sth = $Connection->db->prepare($query); |
70 | 70 | $sth->execute(); |
71 | - } catch(PDOException $e) { |
|
71 | + } catch (PDOException $e) { |
|
72 | 72 | return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
73 | 73 | } |
74 | 74 | // Delete unused column |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | try { |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
81 | 81 | } |
82 | 82 | // Add ModeS column |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | try { |
85 | 85 | $sth = $Connection->db->prepare($query); |
86 | 86 | $sth->execute(); |
87 | - } catch(PDOException $e) { |
|
87 | + } catch (PDOException $e) { |
|
88 | 88 | return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
89 | 89 | } |
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | 91 | try { |
92 | 92 | $sth = $Connection->db->prepare($query); |
93 | 93 | $sth->execute(); |
94 | - } catch(PDOException $e) { |
|
94 | + } catch (PDOException $e) { |
|
95 | 95 | return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
96 | 96 | } |
97 | 97 | // Add auto_increment for aircraft_modes |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | try { |
100 | 100 | $sth = $Connection->db->prepare($query); |
101 | 101 | $sth->execute(); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
104 | 104 | } |
105 | 105 | $error = ''; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | try { |
111 | 111 | $sth = $Connection->db->prepare($query); |
112 | 112 | $sth->execute(); |
113 | - } catch(PDOException $e) { |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
115 | 115 | } |
116 | 116 | return $error; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | try { |
124 | 124 | $sth = $Connection->db->prepare($query); |
125 | 125 | $sth->execute(); |
126 | - } catch(PDOException $e) { |
|
126 | + } catch (PDOException $e) { |
|
127 | 127 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
128 | 128 | } |
129 | 129 | $error = ''; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | try { |
135 | 135 | $sth = $Connection->db->prepare($query); |
136 | 136 | $sth->execute(); |
137 | - } catch(PDOException $e) { |
|
137 | + } catch (PDOException $e) { |
|
138 | 138 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
139 | 139 | } |
140 | 140 | return $error; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | try { |
148 | 148 | $sth = $Connection->db->prepare($query); |
149 | 149 | $sth->execute(); |
150 | - } catch(PDOException $e) { |
|
150 | + } catch (PDOException $e) { |
|
151 | 151 | return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
152 | 152 | } |
153 | 153 | // Add image_source_website column to spotter_image |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | try { |
156 | 156 | $sth = $Connection->db->prepare($query); |
157 | 157 | $sth->execute(); |
158 | - } catch(PDOException $e) { |
|
158 | + } catch (PDOException $e) { |
|
159 | 159 | return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
160 | 160 | } |
161 | 161 | $error = ''; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $sth = $Connection->db->prepare($query); |
166 | 166 | $sth->execute(); |
167 | - } catch(PDOException $e) { |
|
167 | + } catch (PDOException $e) { |
|
168 | 168 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
169 | 169 | } |
170 | 170 | return $error; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | try { |
183 | 183 | $sth = $Connection->db->prepare($query); |
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch (PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | 187 | } |
188 | 188 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $Connection->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
201 | 201 | } |
202 | 202 | // Add aircraft_shadow column to aircraft |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | try { |
205 | 205 | $sth = $Connection->db->prepare($query); |
206 | 206 | $sth->execute(); |
207 | - } catch(PDOException $e) { |
|
207 | + } catch (PDOException $e) { |
|
208 | 208 | return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
209 | 209 | } |
210 | 210 | // Add aircraft_shadow column to spotter_live |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | $sth = $Connection->db->prepare($query); |
214 | 214 | $sth->execute(); |
215 | - } catch(PDOException $e) { |
|
215 | + } catch (PDOException $e) { |
|
216 | 216 | return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
217 | 217 | } |
218 | 218 | $error = ''; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | try { |
226 | 226 | $sth = $Connection->db->prepare($query); |
227 | 227 | $sth->execute(); |
228 | - } catch(PDOException $e) { |
|
228 | + } catch (PDOException $e) { |
|
229 | 229 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
230 | 230 | } |
231 | 231 | return $error; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | 235 | $Connection = new Connection(); |
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
236 | + if (!$Connection->indexExists('spotter_output', 'flightaware_id')) { |
|
237 | 237 | $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | 255 | } |
256 | 256 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | try { |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | 267 | $sth->execute(); |
268 | - } catch(PDOException $e) { |
|
268 | + } catch (PDOException $e) { |
|
269 | 269 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
270 | 270 | } |
271 | 271 | return $error; |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | 276 | $Connection = new Connection(); |
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
277 | + $query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | 279 | try { |
280 | 280 | $sth = $Connection->db->prepare($query); |
281 | 281 | $sth->execute(); |
282 | - } catch(PDOException $e) { |
|
282 | + } catch (PDOException $e) { |
|
283 | 283 | return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
284 | 284 | } |
285 | 285 | if ($globalDBdriver == 'mysql') { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | try { |
288 | 288 | $sth = $Connection->db->prepare($query); |
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch (PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | 292 | } |
293 | 293 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | 301 | } else { |
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
302 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | 303 | } |
304 | 304 | } else { |
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
305 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | 306 | } |
307 | 307 | try { |
308 | 308 | $sth = $Connection->db->prepare($query); |
309 | 309 | $sth->execute(); |
310 | - } catch(PDOException $e) { |
|
310 | + } catch (PDOException $e) { |
|
311 | 311 | return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
312 | 312 | } |
313 | 313 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | try { |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | 322 | $sth->execute(); |
323 | - } catch(PDOException $e) { |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
325 | 325 | } |
326 | 326 | return $error; |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | try { |
340 | 340 | $sth = $Connection->db->prepare($query); |
341 | 341 | $sth->execute(); |
342 | - } catch(PDOException $e) { |
|
342 | + } catch (PDOException $e) { |
|
343 | 343 | return "error (insert last_update values) : ".$e->getMessage()."\n"; |
344 | 344 | } |
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | 346 | try { |
347 | 347 | $sth = $Connection->db->prepare($query); |
348 | 348 | $sth->execute(); |
349 | - } catch(PDOException $e) { |
|
349 | + } catch (PDOException $e) { |
|
350 | 350 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
351 | 351 | } |
352 | 352 | return $error; |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | 356 | $Connection = new Connection(); |
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
357 | + $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | 359 | try { |
360 | 360 | $sth = $Connection->db->prepare($query); |
361 | 361 | $sth->execute(); |
362 | - } catch(PDOException $e) { |
|
362 | + } catch (PDOException $e) { |
|
363 | 363 | return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
364 | 364 | } |
365 | 365 | $error = ''; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | try { |
372 | 372 | $sth = $Connection->db->prepare($query); |
373 | 373 | $sth->execute(); |
374 | - } catch(PDOException $e) { |
|
374 | + } catch (PDOException $e) { |
|
375 | 375 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
376 | 376 | } |
377 | 377 | return $error; |
@@ -379,11 +379,11 @@ discard block |
||
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | 381 | $Connection = new Connection(); |
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
382 | + $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | 383 | try { |
384 | 384 | $sth = $Connection->db->prepare($query); |
385 | 385 | $sth->execute(); |
386 | - } catch(PDOException $e) { |
|
386 | + } catch (PDOException $e) { |
|
387 | 387 | return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
388 | 388 | } |
389 | 389 | $error = ''; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | try { |
402 | 402 | $sth = $Connection->db->prepare($query); |
403 | 403 | $sth->execute(); |
404 | - } catch(PDOException $e) { |
|
404 | + } catch (PDOException $e) { |
|
405 | 405 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
406 | 406 | } |
407 | 407 | return $error; |
@@ -410,18 +410,18 @@ discard block |
||
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | 412 | $Connection = new Connection(); |
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
413 | + $query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | 414 | try { |
415 | 415 | $sth = $Connection->db->prepare($query); |
416 | 416 | $sth->execute(); |
417 | - } catch(PDOException $e) { |
|
417 | + } catch (PDOException $e) { |
|
418 | 418 | return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
419 | 419 | } |
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
420 | + $query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | 421 | try { |
422 | 422 | $sth = $Connection->db->prepare($query); |
423 | 423 | $sth->execute(); |
424 | - } catch(PDOException $e) { |
|
424 | + } catch (PDOException $e) { |
|
425 | 425 | return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
426 | 426 | } |
427 | 427 | if ($globalDBdriver == 'mysql') { |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | try { |
430 | 430 | $sth = $Connection->db->prepare($query); |
431 | 431 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
432 | + } catch (PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | 434 | } |
435 | 435 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -441,15 +441,15 @@ discard block |
||
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | 443 | } else { |
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
444 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | 445 | } |
446 | 446 | } else { |
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
447 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | 448 | } |
449 | 449 | try { |
450 | 450 | $sth = $Connection->db->prepare($query); |
451 | 451 | $sth->execute(); |
452 | - } catch(PDOException $e) { |
|
452 | + } catch (PDOException $e) { |
|
453 | 453 | return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
454 | 454 | } |
455 | 455 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | try { |
460 | 460 | $sth = $Connection->db->prepare($query); |
461 | 461 | $sth->execute(); |
462 | - } catch(PDOException $e) { |
|
462 | + } catch (PDOException $e) { |
|
463 | 463 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
464 | 464 | } |
465 | 465 | return $error; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | try { |
488 | 488 | $sth = $Connection->db->prepare($query); |
489 | 489 | $sth->execute(); |
490 | - } catch(PDOException $e) { |
|
490 | + } catch (PDOException $e) { |
|
491 | 491 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
492 | 492 | } |
493 | 493 | return $error; |
@@ -495,12 +495,12 @@ discard block |
||
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | 497 | $Connection = new Connection(); |
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) { |
|
499 | + $query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch (PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | 505 | } |
506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | try { |
510 | 510 | $sth = $Connection->db->prepare($query); |
511 | 511 | $sth->execute(); |
512 | - } catch(PDOException $e) { |
|
512 | + } catch (PDOException $e) { |
|
513 | 513 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
514 | 514 | } |
515 | 515 | return $error; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $Connection->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
532 | 532 | } |
533 | 533 | return $error; |
@@ -538,11 +538,11 @@ discard block |
||
538 | 538 | $Connection = new Connection(); |
539 | 539 | $error = ''; |
540 | 540 | // Add tables |
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
541 | + $query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | 542 | try { |
543 | 543 | $sth = $Connection->db->prepare($query); |
544 | 544 | $sth->execute(); |
545 | - } catch(PDOException $e) { |
|
545 | + } catch (PDOException $e) { |
|
546 | 546 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 547 | } |
548 | 548 | if ($error != '') return $error; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | try { |
551 | 551 | $sth = $Connection->db->prepare($query); |
552 | 552 | $sth->execute(); |
553 | - } catch(PDOException $e) { |
|
553 | + } catch (PDOException $e) { |
|
554 | 554 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
555 | 555 | } |
556 | 556 | return $error; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | try { |
572 | 572 | $sth = $Connection->db->prepare($query); |
573 | 573 | $sth->execute(); |
574 | - } catch(PDOException $e) { |
|
574 | + } catch (PDOException $e) { |
|
575 | 575 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
576 | 576 | } |
577 | 577 | return $error; |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | try { |
590 | 590 | $sth = $Connection->db->prepare($query); |
591 | 591 | $sth->execute(); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
594 | 594 | } |
595 | 595 | return $error; |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | $Connection = new Connection(); |
599 | 599 | $error = ''; |
600 | 600 | // Modify stats_airport table |
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
601 | + if (!$Connection->checkColumnName('stats_airport', 'airport_name')) { |
|
602 | 602 | $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
603 | 603 | try { |
604 | 604 | $sth = $Connection->db->prepare($query); |
605 | 605 | $sth->execute(); |
606 | - } catch(PDOException $e) { |
|
606 | + } catch (PDOException $e) { |
|
607 | 607 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 608 | } |
609 | 609 | } |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | try { |
613 | 613 | $sth = $Connection->db->prepare($query); |
614 | 614 | $sth->execute(); |
615 | - } catch(PDOException $e) { |
|
615 | + } catch (PDOException $e) { |
|
616 | 616 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
617 | 617 | } |
618 | 618 | return $error; |
@@ -629,73 +629,73 @@ discard block |
||
629 | 629 | try { |
630 | 630 | $sth = $Connection->db->prepare($query); |
631 | 631 | $sth->execute(); |
632 | - } catch(PDOException $e) { |
|
632 | + } catch (PDOException $e) { |
|
633 | 633 | return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
634 | 634 | } |
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | 636 | try { |
637 | 637 | $sth = $Connection->db->prepare($query); |
638 | 638 | $sth->execute(); |
639 | - } catch(PDOException $e) { |
|
639 | + } catch (PDOException $e) { |
|
640 | 640 | return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
641 | 641 | } |
642 | - if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
|
642 | + if (!$Connection->checkColumnName('spotter_archive', 'over_country')) { |
|
643 | 643 | // Add column over_country |
644 | 644 | $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
645 | 645 | try { |
646 | 646 | $sth = $Connection->db->prepare($query); |
647 | 647 | $sth->execute(); |
648 | - } catch(PDOException $e) { |
|
648 | + } catch (PDOException $e) { |
|
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
650 | 650 | } |
651 | 651 | } |
652 | - if (!$Connection->checkColumnName('spotter_live','over_country')) { |
|
652 | + if (!$Connection->checkColumnName('spotter_live', 'over_country')) { |
|
653 | 653 | // Add column over_country |
654 | 654 | $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
655 | 655 | try { |
656 | 656 | $sth = $Connection->db->prepare($query); |
657 | 657 | $sth->execute(); |
658 | - } catch(PDOException $e) { |
|
658 | + } catch (PDOException $e) { |
|
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
660 | 660 | } |
661 | 661 | } |
662 | - if (!$Connection->checkColumnName('spotter_output','source_name')) { |
|
662 | + if (!$Connection->checkColumnName('spotter_output', 'source_name')) { |
|
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | 664 | $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | - } catch(PDOException $e) { |
|
668 | + } catch (PDOException $e) { |
|
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | 670 | } |
671 | 671 | } |
672 | - if (!$Connection->checkColumnName('spotter_live','source_name')) { |
|
672 | + if (!$Connection->checkColumnName('spotter_live', 'source_name')) { |
|
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | 674 | $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | - } catch(PDOException $e) { |
|
678 | + } catch (PDOException $e) { |
|
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | 680 | } |
681 | 681 | } |
682 | - if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
|
682 | + if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) { |
|
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | 684 | $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | - } catch(PDOException $e) { |
|
688 | + } catch (PDOException $e) { |
|
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | 690 | } |
691 | 691 | } |
692 | - if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
|
692 | + if (!$Connection->checkColumnName('spotter_archive', 'source_name')) { |
|
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | 694 | $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | - } catch(PDOException $e) { |
|
698 | + } catch (PDOException $e) { |
|
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 700 | } |
701 | 701 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | try { |
705 | 705 | $sth = $Connection->db->prepare($query); |
706 | 706 | $sth->execute(); |
707 | - } catch(PDOException $e) { |
|
707 | + } catch (PDOException $e) { |
|
708 | 708 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
709 | 709 | } |
710 | 710 | return $error; |
@@ -719,13 +719,13 @@ discard block |
||
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | - if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
|
722 | + if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) { |
|
723 | 723 | // Add column over_country |
724 | 724 | $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
725 | 725 | try { |
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | - } catch(PDOException $e) { |
|
728 | + } catch (PDOException $e) { |
|
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 730 | } |
731 | 731 | } |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | try { |
742 | 742 | $sth = $Connection->db->prepare($query); |
743 | 743 | $sth->execute(); |
744 | - } catch(PDOException $e) { |
|
744 | + } catch (PDOException $e) { |
|
745 | 745 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
746 | 746 | } |
747 | 747 | return $error; |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | private static function update_from_21() { |
751 | 751 | $Connection = new Connection(); |
752 | 752 | $error = ''; |
753 | - if (!$Connection->checkColumnName('stats_airport','stats_type')) { |
|
753 | + if (!$Connection->checkColumnName('stats_airport', 'stats_type')) { |
|
754 | 754 | // Rename type to stats_type |
755 | 755 | $query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; |
756 | 756 | try { |
757 | 757 | $sth = $Connection->db->prepare($query); |
758 | 758 | $sth->execute(); |
759 | - } catch(PDOException $e) { |
|
759 | + } catch (PDOException $e) { |
|
760 | 760 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 761 | } |
762 | 762 | if ($error != '') return $error; |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | try { |
766 | 766 | $sth = $Connection->db->prepare($query); |
767 | 767 | $sth->execute(); |
768 | - } catch(PDOException $e) { |
|
768 | + } catch (PDOException $e) { |
|
769 | 769 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
770 | 770 | } |
771 | 771 | return $error; |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | try { |
789 | 789 | $sth = $Connection->db->prepare($query); |
790 | 790 | $sth->execute(); |
791 | - } catch(PDOException $e) { |
|
791 | + } catch (PDOException $e) { |
|
792 | 792 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
793 | 793 | } |
794 | 794 | return $error; |
@@ -815,17 +815,17 @@ discard block |
||
815 | 815 | try { |
816 | 816 | $sth = $Connection->db->prepare($query); |
817 | 817 | $sth->execute(); |
818 | - } catch(PDOException $e) { |
|
818 | + } catch (PDOException $e) { |
|
819 | 819 | return "error (create index on spotter_archive) : ".$e->getMessage()."\n"; |
820 | 820 | } |
821 | 821 | } |
822 | - if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
|
822 | + if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) { |
|
823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
824 | 824 | $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
825 | 825 | try { |
826 | 826 | $sth = $Connection->db->prepare($query); |
827 | 827 | $sth->execute(); |
828 | - } catch(PDOException $e) { |
|
828 | + } catch (PDOException $e) { |
|
829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
830 | 830 | } |
831 | 831 | } |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | try { |
835 | 835 | $sth = $Connection->db->prepare($query); |
836 | 836 | $sth->execute(); |
837 | - } catch(PDOException $e) { |
|
837 | + } catch (PDOException $e) { |
|
838 | 838 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
839 | 839 | } |
840 | 840 | return $error; |
@@ -850,23 +850,23 @@ discard block |
||
850 | 850 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
851 | 851 | } |
852 | 852 | if ($error != '') return 'Import airlines.sql : '.$error; |
853 | - if (!$Connection->checkColumnName('airlines','forsource')) { |
|
853 | + if (!$Connection->checkColumnName('airlines', 'forsource')) { |
|
854 | 854 | // Add forsource to airlines |
855 | 855 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
856 | 856 | try { |
857 | 857 | $sth = $Connection->db->prepare($query); |
858 | 858 | $sth->execute(); |
859 | - } catch(PDOException $e) { |
|
859 | + } catch (PDOException $e) { |
|
860 | 860 | return "error (add forsource column) : ".$e->getMessage()."\n"; |
861 | 861 | } |
862 | 862 | } |
863 | - if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) { |
|
863 | + if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) { |
|
864 | 864 | // Add forsource to airlines |
865 | 865 | $query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
866 | 866 | try { |
867 | 867 | $sth = $Connection->db->prepare($query); |
868 | 868 | $sth->execute(); |
869 | - } catch(PDOException $e) { |
|
869 | + } catch (PDOException $e) { |
|
870 | 870 | return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n"; |
871 | 871 | } |
872 | 872 | // Add unique key |
@@ -878,17 +878,17 @@ discard block |
||
878 | 878 | try { |
879 | 879 | $sth = $Connection->db->prepare($query); |
880 | 880 | $sth->execute(); |
881 | - } catch(PDOException $e) { |
|
881 | + } catch (PDOException $e) { |
|
882 | 882 | return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n"; |
883 | 883 | } |
884 | 884 | } |
885 | - if (!$Connection->checkColumnName('stats_airport','stats_airline')) { |
|
885 | + if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) { |
|
886 | 886 | // Add forsource to airlines |
887 | 887 | $query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
888 | 888 | try { |
889 | 889 | $sth = $Connection->db->prepare($query); |
890 | 890 | $sth->execute(); |
891 | - } catch(PDOException $e) { |
|
891 | + } catch (PDOException $e) { |
|
892 | 892 | return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n"; |
893 | 893 | } |
894 | 894 | // Add unique key |
@@ -900,17 +900,17 @@ discard block |
||
900 | 900 | try { |
901 | 901 | $sth = $Connection->db->prepare($query); |
902 | 902 | $sth->execute(); |
903 | - } catch(PDOException $e) { |
|
903 | + } catch (PDOException $e) { |
|
904 | 904 | return "error (add unique key in stats_airport) : ".$e->getMessage()."\n"; |
905 | 905 | } |
906 | 906 | } |
907 | - if (!$Connection->checkColumnName('stats_country','stats_airline')) { |
|
907 | + if (!$Connection->checkColumnName('stats_country', 'stats_airline')) { |
|
908 | 908 | // Add forsource to airlines |
909 | 909 | $query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
910 | 910 | try { |
911 | 911 | $sth = $Connection->db->prepare($query); |
912 | 912 | $sth->execute(); |
913 | - } catch(PDOException $e) { |
|
913 | + } catch (PDOException $e) { |
|
914 | 914 | return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n"; |
915 | 915 | } |
916 | 916 | // Add unique key |
@@ -922,36 +922,36 @@ discard block |
||
922 | 922 | try { |
923 | 923 | $sth = $Connection->db->prepare($query); |
924 | 924 | $sth->execute(); |
925 | - } catch(PDOException $e) { |
|
925 | + } catch (PDOException $e) { |
|
926 | 926 | return "error (add unique key in stats_airline) : ".$e->getMessage()."\n"; |
927 | 927 | } |
928 | 928 | } |
929 | - if (!$Connection->checkColumnName('stats_flight','stats_airline')) { |
|
929 | + if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) { |
|
930 | 930 | // Add forsource to airlines |
931 | 931 | $query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
932 | 932 | try { |
933 | 933 | $sth = $Connection->db->prepare($query); |
934 | 934 | $sth->execute(); |
935 | - } catch(PDOException $e) { |
|
935 | + } catch (PDOException $e) { |
|
936 | 936 | return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n"; |
937 | 937 | } |
938 | 938 | } |
939 | - if (!$Connection->checkColumnName('stats','stats_airline')) { |
|
939 | + if (!$Connection->checkColumnName('stats', 'stats_airline')) { |
|
940 | 940 | // Add forsource to airlines |
941 | 941 | $query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
942 | 942 | try { |
943 | 943 | $sth = $Connection->db->prepare($query); |
944 | 944 | $sth->execute(); |
945 | - } catch(PDOException $e) { |
|
945 | + } catch (PDOException $e) { |
|
946 | 946 | return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n"; |
947 | 947 | } |
948 | - if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) { |
|
948 | + if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) { |
|
949 | 949 | // Add unique key |
950 | 950 | $query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);"; |
951 | 951 | try { |
952 | 952 | $sth = $Connection->db->prepare($query); |
953 | 953 | $sth->execute(); |
954 | - } catch(PDOException $e) { |
|
954 | + } catch (PDOException $e) { |
|
955 | 955 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
956 | 956 | } |
957 | 957 | } else { |
@@ -964,18 +964,18 @@ discard block |
||
964 | 964 | try { |
965 | 965 | $sth = $Connection->db->prepare($query); |
966 | 966 | $sth->execute(); |
967 | - } catch(PDOException $e) { |
|
967 | + } catch (PDOException $e) { |
|
968 | 968 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
969 | 969 | } |
970 | 970 | } |
971 | 971 | } |
972 | - if (!$Connection->checkColumnName('stats_registration','stats_airline')) { |
|
972 | + if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) { |
|
973 | 973 | // Add forsource to airlines |
974 | 974 | $query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
975 | 975 | try { |
976 | 976 | $sth = $Connection->db->prepare($query); |
977 | 977 | $sth->execute(); |
978 | - } catch(PDOException $e) { |
|
978 | + } catch (PDOException $e) { |
|
979 | 979 | return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n"; |
980 | 980 | } |
981 | 981 | // Add unique key |
@@ -987,17 +987,17 @@ discard block |
||
987 | 987 | try { |
988 | 988 | $sth = $Connection->db->prepare($query); |
989 | 989 | $sth->execute(); |
990 | - } catch(PDOException $e) { |
|
990 | + } catch (PDOException $e) { |
|
991 | 991 | return "error (add unique key in stats_registration) : ".$e->getMessage()."\n"; |
992 | 992 | } |
993 | 993 | } |
994 | - if (!$Connection->checkColumnName('stats_callsign','filter_name')) { |
|
994 | + if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) { |
|
995 | 995 | // Add forsource to airlines |
996 | 996 | $query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
997 | 997 | try { |
998 | 998 | $sth = $Connection->db->prepare($query); |
999 | 999 | $sth->execute(); |
1000 | - } catch(PDOException $e) { |
|
1000 | + } catch (PDOException $e) { |
|
1001 | 1001 | return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n"; |
1002 | 1002 | } |
1003 | 1003 | // Add unique key |
@@ -1009,17 +1009,17 @@ discard block |
||
1009 | 1009 | try { |
1010 | 1010 | $sth = $Connection->db->prepare($query); |
1011 | 1011 | $sth->execute(); |
1012 | - } catch(PDOException $e) { |
|
1012 | + } catch (PDOException $e) { |
|
1013 | 1013 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1014 | 1014 | } |
1015 | 1015 | } |
1016 | - if (!$Connection->checkColumnName('stats_airline','filter_name')) { |
|
1016 | + if (!$Connection->checkColumnName('stats_airline', 'filter_name')) { |
|
1017 | 1017 | // Add forsource to airlines |
1018 | 1018 | $query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1019 | 1019 | try { |
1020 | 1020 | $sth = $Connection->db->prepare($query); |
1021 | 1021 | $sth->execute(); |
1022 | - } catch(PDOException $e) { |
|
1022 | + } catch (PDOException $e) { |
|
1023 | 1023 | return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n"; |
1024 | 1024 | } |
1025 | 1025 | // Add unique key |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | try { |
1032 | 1032 | $sth = $Connection->db->prepare($query); |
1033 | 1033 | $sth->execute(); |
1034 | - } catch(PDOException $e) { |
|
1034 | + } catch (PDOException $e) { |
|
1035 | 1035 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1036 | 1036 | } |
1037 | 1037 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | try { |
1041 | 1041 | $sth = $Connection->db->prepare($query); |
1042 | 1042 | $sth->execute(); |
1043 | - } catch(PDOException $e) { |
|
1043 | + } catch (PDOException $e) { |
|
1044 | 1044 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1045 | 1045 | } |
1046 | 1046 | return $error; |
@@ -1050,13 +1050,13 @@ discard block |
||
1050 | 1050 | global $globalDBdriver; |
1051 | 1051 | $Connection = new Connection(); |
1052 | 1052 | $error = ''; |
1053 | - if (!$Connection->checkColumnName('stats_owner','stats_airline')) { |
|
1053 | + if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) { |
|
1054 | 1054 | // Add forsource to airlines |
1055 | 1055 | $query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1056 | 1056 | try { |
1057 | 1057 | $sth = $Connection->db->prepare($query); |
1058 | 1058 | $sth->execute(); |
1059 | - } catch(PDOException $e) { |
|
1059 | + } catch (PDOException $e) { |
|
1060 | 1060 | return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n"; |
1061 | 1061 | } |
1062 | 1062 | // Add unique key |
@@ -1068,17 +1068,17 @@ discard block |
||
1068 | 1068 | try { |
1069 | 1069 | $sth = $Connection->db->prepare($query); |
1070 | 1070 | $sth->execute(); |
1071 | - } catch(PDOException $e) { |
|
1071 | + } catch (PDOException $e) { |
|
1072 | 1072 | return "error (add unique key in stats_owner) : ".$e->getMessage()."\n"; |
1073 | 1073 | } |
1074 | 1074 | } |
1075 | - if (!$Connection->checkColumnName('stats_pilot','stats_airline')) { |
|
1075 | + if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) { |
|
1076 | 1076 | // Add forsource to airlines |
1077 | 1077 | $query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1078 | 1078 | try { |
1079 | 1079 | $sth = $Connection->db->prepare($query); |
1080 | 1080 | $sth->execute(); |
1081 | - } catch(PDOException $e) { |
|
1081 | + } catch (PDOException $e) { |
|
1082 | 1082 | return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n"; |
1083 | 1083 | } |
1084 | 1084 | // Add unique key |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | try { |
1091 | 1091 | $sth = $Connection->db->prepare($query); |
1092 | 1092 | $sth->execute(); |
1093 | - } catch(PDOException $e) { |
|
1093 | + } catch (PDOException $e) { |
|
1094 | 1094 | return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1095 | 1095 | } |
1096 | 1096 | } |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | try { |
1099 | 1099 | $sth = $Connection->db->prepare($query); |
1100 | 1100 | $sth->execute(); |
1101 | - } catch(PDOException $e) { |
|
1101 | + } catch (PDOException $e) { |
|
1102 | 1102 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1103 | 1103 | } |
1104 | 1104 | return $error; |
@@ -1108,12 +1108,12 @@ discard block |
||
1108 | 1108 | global $globalDBdriver; |
1109 | 1109 | $Connection = new Connection(); |
1110 | 1110 | $error = ''; |
1111 | - if (!$Connection->checkColumnName('atc','format_source')) { |
|
1111 | + if (!$Connection->checkColumnName('atc', 'format_source')) { |
|
1112 | 1112 | $query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL"; |
1113 | 1113 | try { |
1114 | 1114 | $sth = $Connection->db->prepare($query); |
1115 | 1115 | $sth->execute(); |
1116 | - } catch(PDOException $e) { |
|
1116 | + } catch (PDOException $e) { |
|
1117 | 1117 | return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n"; |
1118 | 1118 | } |
1119 | 1119 | } |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | try { |
1122 | 1122 | $sth = $Connection->db->prepare($query); |
1123 | 1123 | $sth->execute(); |
1124 | - } catch(PDOException $e) { |
|
1124 | + } catch (PDOException $e) { |
|
1125 | 1125 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1126 | 1126 | } |
1127 | 1127 | return $error; |
@@ -1131,13 +1131,13 @@ discard block |
||
1131 | 1131 | global $globalDBdriver; |
1132 | 1132 | $Connection = new Connection(); |
1133 | 1133 | $error = ''; |
1134 | - if (!$Connection->checkColumnName('stats_pilot','format_source')) { |
|
1134 | + if (!$Connection->checkColumnName('stats_pilot', 'format_source')) { |
|
1135 | 1135 | // Add forsource to airlines |
1136 | 1136 | $query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''"; |
1137 | 1137 | try { |
1138 | 1138 | $sth = $Connection->db->prepare($query); |
1139 | 1139 | $sth->execute(); |
1140 | - } catch(PDOException $e) { |
|
1140 | + } catch (PDOException $e) { |
|
1141 | 1141 | return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n"; |
1142 | 1142 | } |
1143 | 1143 | // Add unique key |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | try { |
1150 | 1150 | $sth = $Connection->db->prepare($query); |
1151 | 1151 | $sth->execute(); |
1152 | - } catch(PDOException $e) { |
|
1152 | + } catch (PDOException $e) { |
|
1153 | 1153 | return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1154 | 1154 | } |
1155 | 1155 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | try { |
1158 | 1158 | $sth = $Connection->db->prepare($query); |
1159 | 1159 | $sth->execute(); |
1160 | - } catch(PDOException $e) { |
|
1160 | + } catch (PDOException $e) { |
|
1161 | 1161 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1162 | 1162 | } |
1163 | 1163 | return $error; |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | try { |
1180 | 1180 | $sth = $Connection->db->prepare($query); |
1181 | 1181 | $sth->execute(); |
1182 | - } catch(PDOException $e) { |
|
1182 | + } catch (PDOException $e) { |
|
1183 | 1183 | return "error : ".$e->getMessage()."\n"; |
1184 | 1184 | } |
1185 | 1185 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | fclose($fp); |
25 | 25 | } |
26 | 26 | |
27 | - public static function gunzip($in_file,$out_file_name = '') { |
|
27 | + public static function gunzip($in_file, $out_file_name = '') { |
|
28 | 28 | //echo $in_file.' -> '.$out_file_name."\n"; |
29 | 29 | $buffer_size = 4096; // read 4kb at a time |
30 | 30 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
31 | 31 | if ($in_file != '' && file_exists($in_file)) { |
32 | 32 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
33 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
34 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
33 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
34 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
35 | 35 | else { |
36 | 36 | echo 'gzopen not available'; |
37 | 37 | die; |
38 | 38 | } |
39 | 39 | $out_file = fopen($out_file_name, 'wb'); |
40 | - while(!gzeof($file)) { |
|
40 | + while (!gzeof($file)) { |
|
41 | 41 | fwrite($out_file, gzread($file, $buffer_size)); |
42 | 42 | } |
43 | 43 | fclose($out_file); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | try { |
62 | 62 | self::$db_sqlite = new PDO('sqlite:'.$database); |
63 | 63 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
64 | - } catch(PDOException $e) { |
|
64 | + } catch (PDOException $e) { |
|
65 | 65 | return "error : ".$e->getMessage(); |
66 | 66 | } |
67 | 67 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | //$Connection = new Connection(); |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(array(':source' => $database_file)); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error : ".$e->getMessage(); |
81 | 81 | } |
82 | 82 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | try { |
88 | 88 | $sth = update_db::$db_sqlite->prepare($query); |
89 | 89 | $sth->execute(); |
90 | - } catch(PDOException $e) { |
|
90 | + } catch (PDOException $e) { |
|
91 | 91 | return "error : ".$e->getMessage(); |
92 | 92 | } |
93 | 93 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | if ($globalTransaction) $Connection->db->beginTransaction(); |
99 | 99 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
100 | 100 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
101 | - $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
|
101 | + $query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file); |
|
102 | 102 | $sth_dest->execute($query_dest_values); |
103 | 103 | } |
104 | 104 | if ($globalTransaction) $Connection->db->commit(); |
105 | - } catch(PDOException $e) { |
|
105 | + } catch (PDOException $e) { |
|
106 | 106 | if ($globalTransaction) $Connection->db->rollBack(); |
107 | 107 | return "error : ".$e->getMessage(); |
108 | 108 | } |
@@ -118,26 +118,26 @@ discard block |
||
118 | 118 | //$Connection = new Connection(); |
119 | 119 | $sth = $Connection->db->prepare($query); |
120 | 120 | $sth->execute(array(':source' => 'oneworld')); |
121 | - } catch(PDOException $e) { |
|
121 | + } catch (PDOException $e) { |
|
122 | 122 | return "error : ".$e->getMessage(); |
123 | 123 | } |
124 | 124 | |
125 | 125 | if ($globalDebug) echo " - Add routes to DB -"; |
126 | 126 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
127 | 127 | $Spotter = new Spotter(); |
128 | - if ($fh = fopen($database_file,"r")) { |
|
128 | + if ($fh = fopen($database_file, "r")) { |
|
129 | 129 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
130 | 130 | $Connection = new Connection(); |
131 | 131 | $sth_dest = $Connection->db->prepare($query_dest); |
132 | 132 | if ($globalTransaction) $Connection->db->beginTransaction(); |
133 | 133 | while (!feof($fh)) { |
134 | - $line = fgetcsv($fh,9999,','); |
|
134 | + $line = fgetcsv($fh, 9999, ','); |
|
135 | 135 | if ($line[0] != '') { |
136 | 136 | if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { |
137 | 137 | try { |
138 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
|
138 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld'); |
|
139 | 139 | $sth_dest->execute($query_dest_values); |
140 | - } catch(PDOException $e) { |
|
140 | + } catch (PDOException $e) { |
|
141 | 141 | if ($globalTransaction) $Connection->db->rollBack(); |
142 | 142 | return "error : ".$e->getMessage(); |
143 | 143 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | //$Connection = new Connection(); |
160 | 160 | $sth = $Connection->db->prepare($query); |
161 | 161 | $sth->execute(array(':source' => 'skyteam')); |
162 | - } catch(PDOException $e) { |
|
162 | + } catch (PDOException $e) { |
|
163 | 163 | return "error : ".$e->getMessage(); |
164 | 164 | } |
165 | 165 | |
@@ -167,24 +167,24 @@ discard block |
||
167 | 167 | |
168 | 168 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
169 | 169 | $Spotter = new Spotter(); |
170 | - if ($fh = fopen($database_file,"r")) { |
|
170 | + if ($fh = fopen($database_file, "r")) { |
|
171 | 171 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
172 | 172 | $Connection = new Connection(); |
173 | 173 | $sth_dest = $Connection->db->prepare($query_dest); |
174 | 174 | try { |
175 | 175 | if ($globalTransaction) $Connection->db->beginTransaction(); |
176 | 176 | while (!feof($fh)) { |
177 | - $line = fgetcsv($fh,9999,','); |
|
177 | + $line = fgetcsv($fh, 9999, ','); |
|
178 | 178 | if ($line[0] != '') { |
179 | - $datebe = explode(' - ',$line[2]); |
|
179 | + $datebe = explode(' - ', $line[2]); |
|
180 | 180 | if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { |
181 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam'); |
|
181 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam'); |
|
182 | 182 | $sth_dest->execute($query_dest_values); |
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
186 | 186 | if ($globalTransaction) $Connection->db->commit(); |
187 | - } catch(PDOException $e) { |
|
187 | + } catch (PDOException $e) { |
|
188 | 188 | if ($globalTransaction) $Connection->db->rollBack(); |
189 | 189 | return "error : ".$e->getMessage(); |
190 | 190 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $Connection = new Connection(); |
200 | 200 | $sth = $Connection->db->prepare($query); |
201 | 201 | $sth->execute(array(':source' => $database_file)); |
202 | - } catch(PDOException $e) { |
|
202 | + } catch (PDOException $e) { |
|
203 | 203 | return "error : ".$e->getMessage(); |
204 | 204 | } |
205 | 205 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $Connection = new Connection(); |
208 | 208 | $sth = $Connection->db->prepare($query); |
209 | 209 | $sth->execute(array(':source' => $database_file)); |
210 | - } catch(PDOException $e) { |
|
210 | + } catch (PDOException $e) { |
|
211 | 211 | return "error : ".$e->getMessage(); |
212 | 212 | } |
213 | 213 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | try { |
217 | 217 | $sth = update_db::$db_sqlite->prepare($query); |
218 | 218 | $sth->execute(); |
219 | - } catch(PDOException $e) { |
|
219 | + } catch (PDOException $e) { |
|
220 | 220 | return "error : ".$e->getMessage(); |
221 | 221 | } |
222 | 222 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -233,15 +233,15 @@ discard block |
||
233 | 233 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
234 | 234 | if ($values['UserString4'] == 'M') $type = 'military'; |
235 | 235 | else $type = null; |
236 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
236 | + $query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type); |
|
237 | 237 | $sth_dest->execute($query_dest_values); |
238 | 238 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
239 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
239 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
240 | 240 | $sth_dest_owner->execute($query_dest_owner_values); |
241 | 241 | } |
242 | 242 | } |
243 | 243 | if ($globalTransaction) $Connection->db->commit(); |
244 | - } catch(PDOException $e) { |
|
244 | + } catch (PDOException $e) { |
|
245 | 245 | return "error : ".$e->getMessage(); |
246 | 246 | } |
247 | 247 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $Connection = new Connection(); |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | 252 | $sth->execute(array(':source' => $database_file)); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | return "error : ".$e->getMessage(); |
255 | 255 | } |
256 | 256 | return ''; |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | $Connection = new Connection(); |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | 267 | $sth->execute(array(':source' => $database_file)); |
268 | - } catch(PDOException $e) { |
|
268 | + } catch (PDOException $e) { |
|
269 | 269 | return "error : ".$e->getMessage(); |
270 | 270 | } |
271 | 271 | |
272 | - if ($fh = fopen($database_file,"r")) { |
|
272 | + if ($fh = fopen($database_file, "r")) { |
|
273 | 273 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
274 | 274 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
275 | 275 | |
@@ -279,13 +279,13 @@ discard block |
||
279 | 279 | if ($globalTransaction) $Connection->db->beginTransaction(); |
280 | 280 | while (!feof($fh)) { |
281 | 281 | $values = array(); |
282 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
282 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
283 | 283 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
284 | - $values['ModeS'] = substr($line,0,6); |
|
285 | - $values['Registration'] = trim(substr($line,69,6)); |
|
286 | - $aircraft_name = trim(substr($line,48,6)); |
|
284 | + $values['ModeS'] = substr($line, 0, 6); |
|
285 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
286 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
287 | 287 | // Check if we can find ICAO, else set it to GLID |
288 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
288 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
289 | 289 | $search_more = ''; |
290 | 290 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
291 | 291 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -297,20 +297,20 @@ discard block |
||
297 | 297 | if (isset($result['icao']) && $result['icao'] != '') { |
298 | 298 | $values['ICAOTypeCode'] = $result['icao']; |
299 | 299 | } |
300 | - } catch(PDOException $e) { |
|
300 | + } catch (PDOException $e) { |
|
301 | 301 | return "error : ".$e->getMessage(); |
302 | 302 | } |
303 | 303 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
304 | 304 | // Add data to db |
305 | 305 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
306 | 306 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
307 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
307 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
308 | 308 | //print_r($query_dest_values); |
309 | 309 | $sth_dest->execute($query_dest_values); |
310 | 310 | } |
311 | 311 | } |
312 | 312 | if ($globalTransaction) $Connection->db->commit(); |
313 | - } catch(PDOException $e) { |
|
313 | + } catch (PDOException $e) { |
|
314 | 314 | return "error : ".$e->getMessage(); |
315 | 315 | } |
316 | 316 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $Connection = new Connection(); |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | 322 | $sth->execute(array(':source' => $database_file)); |
323 | - } catch(PDOException $e) { |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | return "error : ".$e->getMessage(); |
325 | 325 | } |
326 | 326 | return ''; |
@@ -334,11 +334,11 @@ discard block |
||
334 | 334 | $Connection = new Connection(); |
335 | 335 | $sth = $Connection->db->prepare($query); |
336 | 336 | $sth->execute(array(':source' => $database_file)); |
337 | - } catch(PDOException $e) { |
|
337 | + } catch (PDOException $e) { |
|
338 | 338 | return "error : ".$e->getMessage(); |
339 | 339 | } |
340 | 340 | |
341 | - if ($fh = fopen($database_file,"r")) { |
|
341 | + if ($fh = fopen($database_file, "r")) { |
|
342 | 342 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
343 | 343 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
344 | 344 | |
@@ -346,9 +346,9 @@ discard block |
||
346 | 346 | $sth_dest = $Connection->db->prepare($query_dest); |
347 | 347 | try { |
348 | 348 | if ($globalTransaction) $Connection->db->beginTransaction(); |
349 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
349 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
350 | 350 | while (!feof($fh)) { |
351 | - $line = fgetcsv($fh,9999,',',"'"); |
|
351 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
352 | 352 | |
353 | 353 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
354 | 354 | //print_r($line); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $values['Registration'] = $line[3]; |
357 | 357 | $aircraft_name = $line[2]; |
358 | 358 | // Check if we can find ICAO, else set it to GLID |
359 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
359 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
360 | 360 | $search_more = ''; |
361 | 361 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
362 | 362 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -365,20 +365,20 @@ discard block |
||
365 | 365 | $sth_search->execute(); |
366 | 366 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
367 | 367 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
368 | - } catch(PDOException $e) { |
|
368 | + } catch (PDOException $e) { |
|
369 | 369 | return "error : ".$e->getMessage(); |
370 | 370 | } |
371 | 371 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
372 | 372 | // Add data to db |
373 | 373 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
374 | 374 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
375 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
375 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
376 | 376 | //print_r($query_dest_values); |
377 | 377 | $sth_dest->execute($query_dest_values); |
378 | 378 | } |
379 | 379 | } |
380 | 380 | if ($globalTransaction) $Connection->db->commit(); |
381 | - } catch(PDOException $e) { |
|
381 | + } catch (PDOException $e) { |
|
382 | 382 | return "error : ".$e->getMessage(); |
383 | 383 | } |
384 | 384 | } |
@@ -388,13 +388,13 @@ discard block |
||
388 | 388 | $Connection = new Connection(); |
389 | 389 | $sth = $Connection->db->prepare($query); |
390 | 390 | $sth->execute(array(':source' => $database_file)); |
391 | - } catch(PDOException $e) { |
|
391 | + } catch (PDOException $e) { |
|
392 | 392 | return "error : ".$e->getMessage(); |
393 | 393 | } |
394 | 394 | return ''; |
395 | 395 | } |
396 | 396 | |
397 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
397 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
398 | 398 | global $globalTransaction; |
399 | 399 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
400 | 400 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -402,11 +402,11 @@ discard block |
||
402 | 402 | $Connection = new Connection(); |
403 | 403 | $sth = $Connection->db->prepare($query); |
404 | 404 | $sth->execute(array(':source' => $database_file)); |
405 | - } catch(PDOException $e) { |
|
405 | + } catch (PDOException $e) { |
|
406 | 406 | return "error : ".$e->getMessage(); |
407 | 407 | } |
408 | 408 | |
409 | - if ($fh = fopen($database_file,"r")) { |
|
409 | + if ($fh = fopen($database_file, "r")) { |
|
410 | 410 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
411 | 411 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
412 | 412 | |
@@ -414,9 +414,9 @@ discard block |
||
414 | 414 | $sth_dest = $Connection->db->prepare($query_dest); |
415 | 415 | try { |
416 | 416 | if ($globalTransaction) $Connection->db->beginTransaction(); |
417 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
417 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
418 | 418 | while (!feof($fh)) { |
419 | - $line = fgetcsv($fh,9999,',','"'); |
|
419 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
420 | 420 | $values = array(); |
421 | 421 | //print_r($line); |
422 | 422 | if ($country == 'F') { |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | $values['base'] = $line[4]; |
425 | 425 | $values['owner'] = $line[5]; |
426 | 426 | if ($line[6] == '') $values['date_first_reg'] = null; |
427 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
427 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
428 | 428 | $values['cancel'] = $line[7]; |
429 | 429 | } elseif ($country == 'EI') { |
430 | 430 | // TODO : add modeS & reg to aircraft_modes |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $values['base'] = $line[3]; |
433 | 433 | $values['owner'] = $line[2]; |
434 | 434 | if ($line[1] == '') $values['date_first_reg'] = null; |
435 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
435 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
436 | 436 | $values['cancel'] = ''; |
437 | 437 | } elseif ($country == 'HB') { |
438 | 438 | // TODO : add modeS & reg to aircraft_modes |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | $values['base'] = null; |
448 | 448 | $values['owner'] = $line[5]; |
449 | 449 | if ($line[18] == '') $values['date_first_reg'] = null; |
450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
450 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
451 | 451 | $values['cancel'] = ''; |
452 | 452 | } elseif ($country == 'VH') { |
453 | 453 | // TODO : add modeS & reg to aircraft_modes |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | $values['base'] = null; |
456 | 456 | $values['owner'] = $line[12]; |
457 | 457 | if ($line[28] == '') $values['date_first_reg'] = null; |
458 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
458 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
459 | 459 | |
460 | 460 | $values['cancel'] = $line[39]; |
461 | 461 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -475,28 +475,28 @@ discard block |
||
475 | 475 | $values['base'] = null; |
476 | 476 | $values['owner'] = $line[8]; |
477 | 477 | if ($line[7] == '') $values['date_first_reg'] = null; |
478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
478 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
479 | 479 | $values['cancel'] = ''; |
480 | 480 | } elseif ($country == 'PP') { |
481 | 481 | $values['registration'] = $line[0]; |
482 | 482 | $values['base'] = null; |
483 | 483 | $values['owner'] = $line[4]; |
484 | 484 | if ($line[6] == '') $values['date_first_reg'] = null; |
485 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
485 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
486 | 486 | $values['cancel'] = $line[7]; |
487 | 487 | } elseif ($country == 'E7') { |
488 | 488 | $values['registration'] = $line[0]; |
489 | 489 | $values['base'] = null; |
490 | 490 | $values['owner'] = $line[4]; |
491 | 491 | if ($line[5] == '') $values['date_first_reg'] = null; |
492 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
492 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
493 | 493 | $values['cancel'] = ''; |
494 | 494 | } elseif ($country == '8Q') { |
495 | 495 | $values['registration'] = $line[0]; |
496 | 496 | $values['base'] = null; |
497 | 497 | $values['owner'] = $line[3]; |
498 | 498 | if ($line[7] == '') $values['date_first_reg'] = null; |
499 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
499 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
500 | 500 | $values['cancel'] = ''; |
501 | 501 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
502 | 502 | $values['registration'] = $line[0]; |
@@ -506,12 +506,12 @@ discard block |
||
506 | 506 | $values['cancel'] = ''; |
507 | 507 | } |
508 | 508 | if ($values['cancel'] == '' && $values['registration'] != null) { |
509 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
509 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
510 | 510 | $sth_dest->execute($query_dest_values); |
511 | 511 | } |
512 | 512 | } |
513 | 513 | if ($globalTransaction) $Connection->db->commit(); |
514 | - } catch(PDOException $e) { |
|
514 | + } catch (PDOException $e) { |
|
515 | 515 | return "error : ".$e->getMessage(); |
516 | 516 | } |
517 | 517 | } |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | $Connection = new Connection(); |
627 | 627 | $sth = $Connection->db->prepare($query); |
628 | 628 | $sth->execute(); |
629 | - } catch(PDOException $e) { |
|
629 | + } catch (PDOException $e) { |
|
630 | 630 | return "error : ".$e->getMessage(); |
631 | 631 | } |
632 | 632 | |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | $Connection = new Connection(); |
637 | 637 | $sth = $Connection->db->prepare($query); |
638 | 638 | $sth->execute(); |
639 | - } catch(PDOException $e) { |
|
639 | + } catch (PDOException $e) { |
|
640 | 640 | return "error : ".$e->getMessage(); |
641 | 641 | } |
642 | 642 | |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | if ($globalTransaction) $Connection->db->beginTransaction(); |
648 | 648 | |
649 | 649 | $i = 0; |
650 | - while($row = sparql_fetch_array($result)) |
|
650 | + while ($row = sparql_fetch_array($result)) |
|
651 | 651 | { |
652 | 652 | if ($i >= 1) { |
653 | 653 | //print_r($row); |
@@ -667,31 +667,31 @@ discard block |
||
667 | 667 | $row['image'] = ''; |
668 | 668 | $row['image_thumb'] = ''; |
669 | 669 | } else { |
670 | - $image = str_replace(' ','_',$row['image']); |
|
670 | + $image = str_replace(' ', '_', $row['image']); |
|
671 | 671 | $digest = md5($image); |
672 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
673 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
674 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
675 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
672 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
673 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
674 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
675 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
676 | 676 | } |
677 | 677 | |
678 | - $country = explode('-',$row['country']); |
|
678 | + $country = explode('-', $row['country']); |
|
679 | 679 | $row['country'] = $country[0]; |
680 | 680 | |
681 | 681 | $row['type'] = trim($row['type']); |
682 | - if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { |
|
682 | + if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { |
|
683 | 683 | $row['type'] = 'Military'; |
684 | 684 | } elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { |
685 | 685 | $row['type'] = 'small_airport'; |
686 | 686 | } |
687 | 687 | |
688 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
689 | - $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); |
|
688 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
689 | + $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); |
|
690 | 690 | //print_r($query_dest_values); |
691 | 691 | |
692 | 692 | try { |
693 | 693 | $sth_dest->execute($query_dest_values); |
694 | - } catch(PDOException $e) { |
|
694 | + } catch (PDOException $e) { |
|
695 | 695 | return "error : ".$e->getMessage(); |
696 | 696 | } |
697 | 697 | } |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | $Connection = new Connection(); |
706 | 706 | $sth = $Connection->db->prepare($query); |
707 | 707 | $sth->execute(); |
708 | - } catch(PDOException $e) { |
|
708 | + } catch (PDOException $e) { |
|
709 | 709 | return "error : ".$e->getMessage(); |
710 | 710 | } |
711 | 711 | |
@@ -713,12 +713,12 @@ discard block |
||
713 | 713 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
714 | 714 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
715 | 715 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
716 | - $query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); |
|
716 | + $query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => ''); |
|
717 | 717 | try { |
718 | 718 | $Connection = new Connection(); |
719 | 719 | $sth = $Connection->db->prepare($query); |
720 | 720 | $sth->execute($query_values); |
721 | - } catch(PDOException $e) { |
|
721 | + } catch (PDOException $e) { |
|
722 | 722 | return "error : ".$e->getMessage(); |
723 | 723 | } |
724 | 724 | $i++; |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | echo "Download data from ourairports.com...\n"; |
737 | 737 | $delimiter = ','; |
738 | 738 | $out_file = $tmp_dir.'airports.csv'; |
739 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
739 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
740 | 740 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
741 | 741 | echo "Add data from ourairports.com...\n"; |
742 | 742 | |
@@ -747,32 +747,32 @@ discard block |
||
747 | 747 | //$Connection->db->beginTransaction(); |
748 | 748 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
749 | 749 | { |
750 | - if(!$header) $header = $row; |
|
750 | + if (!$header) $header = $row; |
|
751 | 751 | else { |
752 | 752 | $data = array(); |
753 | 753 | $data = array_combine($header, $row); |
754 | 754 | try { |
755 | 755 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao'); |
756 | 756 | $sth->execute(array(':icao' => $data['gps_code'])); |
757 | - } catch(PDOException $e) { |
|
757 | + } catch (PDOException $e) { |
|
758 | 758 | return "error : ".$e->getMessage(); |
759 | 759 | } |
760 | 760 | if ($sth->fetchColumn() > 0) { |
761 | 761 | $query = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
762 | 762 | try { |
763 | 763 | $sth = $Connection->db->prepare($query); |
764 | - $sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type'])); |
|
765 | - } catch(PDOException $e) { |
|
764 | + $sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type'])); |
|
765 | + } catch (PDOException $e) { |
|
766 | 766 | return "error : ".$e->getMessage(); |
767 | 767 | } |
768 | 768 | } else { |
769 | 769 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`) |
770 | 770 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
771 | - $query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
771 | + $query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
772 | 772 | try { |
773 | 773 | $sth = $Connection->db->prepare($query); |
774 | 774 | $sth->execute($query_values); |
775 | - } catch(PDOException $e) { |
|
775 | + } catch (PDOException $e) { |
|
776 | 776 | return "error : ".$e->getMessage(); |
777 | 777 | } |
778 | 778 | $i++; |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | |
786 | 786 | echo "Download data from another free database...\n"; |
787 | 787 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
788 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
788 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
789 | 789 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
790 | 790 | update_db::unzip($out_file); |
791 | 791 | $header = NULL; |
@@ -797,15 +797,15 @@ discard block |
||
797 | 797 | //$Connection->db->beginTransaction(); |
798 | 798 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
799 | 799 | { |
800 | - if(!$header) $header = $row; |
|
800 | + if (!$header) $header = $row; |
|
801 | 801 | else { |
802 | 802 | $data = $row; |
803 | 803 | |
804 | 804 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
805 | 805 | try { |
806 | 806 | $sth = $Connection->db->prepare($query); |
807 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
808 | - } catch(PDOException $e) { |
|
807 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
808 | + } catch (PDOException $e) { |
|
809 | 809 | return "error : ".$e->getMessage(); |
810 | 810 | } |
811 | 811 | } |
@@ -819,15 +819,15 @@ discard block |
||
819 | 819 | try { |
820 | 820 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'"); |
821 | 821 | $sth->execute(); |
822 | - } catch(PDOException $e) { |
|
822 | + } catch (PDOException $e) { |
|
823 | 823 | return "error : ".$e->getMessage(); |
824 | 824 | } |
825 | 825 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
826 | 826 | $query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
827 | 827 | try { |
828 | 828 | $sth2 = $Connection->db->prepare($query2); |
829 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
830 | - } catch(PDOException $e) { |
|
829 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
830 | + } catch (PDOException $e) { |
|
831 | 831 | return "error : ".$e->getMessage(); |
832 | 832 | } |
833 | 833 | } |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | $Connection = new Connection(); |
852 | 852 | $sth = $Connection->db->prepare($query); |
853 | 853 | $sth->execute(array(':source' => 'translation.csv')); |
854 | - } catch(PDOException $e) { |
|
854 | + } catch (PDOException $e) { |
|
855 | 855 | return "error : ".$e->getMessage(); |
856 | 856 | } |
857 | 857 | |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
869 | 869 | { |
870 | 870 | $i++; |
871 | - if($i > 12) { |
|
871 | + if ($i > 12) { |
|
872 | 872 | $data = $row; |
873 | 873 | $operator = $data[2]; |
874 | 874 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | //echo substr($operator, 0, 2)."\n";; |
877 | 877 | if (count($airline_array) > 0) { |
878 | 878 | //print_r($airline_array); |
879 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
879 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
880 | 880 | } |
881 | 881 | } |
882 | 882 | |
@@ -884,14 +884,14 @@ discard block |
||
884 | 884 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
885 | 885 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
886 | 886 | if (count($airline_array) > 0) { |
887 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
887 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
888 | 888 | } |
889 | 889 | } |
890 | 890 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
891 | 891 | try { |
892 | 892 | $sth = $Connection->db->prepare($query); |
893 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
894 | - } catch(PDOException $e) { |
|
893 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
894 | + } catch (PDOException $e) { |
|
895 | 895 | return "error : ".$e->getMessage(); |
896 | 896 | } |
897 | 897 | } |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | $Connection = new Connection(); |
912 | 912 | $sth = $Connection->db->prepare($query); |
913 | 913 | $sth->execute(array(':source' => 'website_fam')); |
914 | - } catch(PDOException $e) { |
|
914 | + } catch (PDOException $e) { |
|
915 | 915 | return "error : ".$e->getMessage(); |
916 | 916 | } |
917 | 917 | |
@@ -931,8 +931,8 @@ discard block |
||
931 | 931 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
932 | 932 | try { |
933 | 933 | $sth = $Connection->db->prepare($query); |
934 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
935 | - } catch(PDOException $e) { |
|
934 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
935 | + } catch (PDOException $e) { |
|
936 | 936 | return "error : ".$e->getMessage(); |
937 | 937 | } |
938 | 938 | } |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | $Connection = new Connection(); |
952 | 952 | $sth = $Connection->db->prepare($query); |
953 | 953 | $sth->execute(array(':source' => 'website_fam')); |
954 | - } catch(PDOException $e) { |
|
954 | + } catch (PDOException $e) { |
|
955 | 955 | return "error : ".$e->getMessage(); |
956 | 956 | } |
957 | 957 | |
@@ -971,8 +971,8 @@ discard block |
||
971 | 971 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
972 | 972 | try { |
973 | 973 | $sth = $Connection->db->prepare($query); |
974 | - $sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam')); |
|
975 | - } catch(PDOException $e) { |
|
974 | + $sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam')); |
|
975 | + } catch (PDOException $e) { |
|
976 | 976 | return "error : ".$e->getMessage(); |
977 | 977 | } |
978 | 978 | } |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | $Connection = new Connection(); |
992 | 992 | $sth = $Connection->db->prepare($query); |
993 | 993 | $sth->execute(array(':source' => 'website_fam')); |
994 | - } catch(PDOException $e) { |
|
994 | + } catch (PDOException $e) { |
|
995 | 995 | return "error : ".$e->getMessage(); |
996 | 996 | } |
997 | 997 | |
@@ -1011,8 +1011,8 @@ discard block |
||
1011 | 1011 | $query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)'; |
1012 | 1012 | try { |
1013 | 1013 | $sth = $Connection->db->prepare($query); |
1014 | - $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
|
1015 | - } catch(PDOException $e) { |
|
1014 | + $sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam')); |
|
1015 | + } catch (PDOException $e) { |
|
1016 | 1016 | return "error : ".$e->getMessage(); |
1017 | 1017 | } |
1018 | 1018 | } |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | return ''; |
1025 | 1025 | } |
1026 | 1026 | |
1027 | - public static function tle($filename,$tletype) { |
|
1027 | + public static function tle($filename, $tletype) { |
|
1028 | 1028 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
1029 | 1029 | global $tmp_dir, $globalTransaction; |
1030 | 1030 | //$Spotter = new Spotter(); |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | $Connection = new Connection(); |
1035 | 1035 | $sth = $Connection->db->prepare($query); |
1036 | 1036 | $sth->execute(array(':source' => $filename)); |
1037 | - } catch(PDOException $e) { |
|
1037 | + } catch (PDOException $e) { |
|
1038 | 1038 | return "error : ".$e->getMessage(); |
1039 | 1039 | } |
1040 | 1040 | |
@@ -1059,8 +1059,8 @@ discard block |
||
1059 | 1059 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
1060 | 1060 | try { |
1061 | 1061 | $sth = $Connection->db->prepare($query); |
1062 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
1063 | - } catch(PDOException $e) { |
|
1062 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
1063 | + } catch (PDOException $e) { |
|
1064 | 1064 | return "error : ".$e->getMessage(); |
1065 | 1065 | } |
1066 | 1066 | |
@@ -1080,28 +1080,28 @@ discard block |
||
1080 | 1080 | */ |
1081 | 1081 | private static function table2array($data) { |
1082 | 1082 | $html = str_get_html($data); |
1083 | - $tabledata=array(); |
|
1084 | - foreach($html->find('tr') as $element) |
|
1083 | + $tabledata = array(); |
|
1084 | + foreach ($html->find('tr') as $element) |
|
1085 | 1085 | { |
1086 | 1086 | $td = array(); |
1087 | - foreach( $element->find('th') as $row) |
|
1087 | + foreach ($element->find('th') as $row) |
|
1088 | 1088 | { |
1089 | 1089 | $td [] = trim($row->plaintext); |
1090 | 1090 | } |
1091 | - $td=array_filter($td); |
|
1091 | + $td = array_filter($td); |
|
1092 | 1092 | $tabledata[] = $td; |
1093 | 1093 | |
1094 | 1094 | $td = array(); |
1095 | 1095 | $tdi = array(); |
1096 | - foreach( $element->find('td') as $row) |
|
1096 | + foreach ($element->find('td') as $row) |
|
1097 | 1097 | { |
1098 | 1098 | $td [] = trim($row->plaintext); |
1099 | 1099 | $tdi [] = trim($row->innertext); |
1100 | 1100 | } |
1101 | - $td=array_filter($td); |
|
1102 | - $tdi=array_filter($tdi); |
|
1101 | + $td = array_filter($td); |
|
1102 | + $tdi = array_filter($tdi); |
|
1103 | 1103 | // $tabledata[]=array_merge($td,$tdi); |
1104 | - $tabledata[]=$td; |
|
1104 | + $tabledata[] = $td; |
|
1105 | 1105 | } |
1106 | 1106 | return(array_filter($tabledata)); |
1107 | 1107 | } |
@@ -1174,13 +1174,13 @@ discard block |
||
1174 | 1174 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1175 | 1175 | { |
1176 | 1176 | $i++; |
1177 | - if($i > 3 && count($row) > 2) { |
|
1177 | + if ($i > 3 && count($row) > 2) { |
|
1178 | 1178 | $data = array_values(array_filter($row)); |
1179 | 1179 | $cntdata = count($data); |
1180 | 1180 | if ($cntdata > 10) { |
1181 | 1181 | $value = $data[9]; |
1182 | 1182 | |
1183 | - for ($i =10;$i < $cntdata;$i++) { |
|
1183 | + for ($i = 10; $i < $cntdata; $i++) { |
|
1184 | 1184 | $value .= ' '.$data[$i]; |
1185 | 1185 | } |
1186 | 1186 | $data[9] = $value; |
@@ -1190,8 +1190,8 @@ discard block |
||
1190 | 1190 | $query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; |
1191 | 1191 | try { |
1192 | 1192 | $sth = $Connection->db->prepare($query); |
1193 | - $sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
1194 | - } catch(PDOException $e) { |
|
1193 | + $sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
1194 | + } catch (PDOException $e) { |
|
1195 | 1195 | return "error : ".$e->getMessage(); |
1196 | 1196 | } |
1197 | 1197 | } |
@@ -1212,7 +1212,7 @@ discard block |
||
1212 | 1212 | $Connection = new Connection(); |
1213 | 1213 | $sth = $Connection->db->prepare($query); |
1214 | 1214 | $sth->execute(); |
1215 | - } catch(PDOException $e) { |
|
1215 | + } catch (PDOException $e) { |
|
1216 | 1216 | return "error : ".$e->getMessage(); |
1217 | 1217 | } |
1218 | 1218 | |
@@ -1224,12 +1224,12 @@ discard block |
||
1224 | 1224 | if ($globalTransaction) $Connection->db->beginTransaction(); |
1225 | 1225 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1226 | 1226 | { |
1227 | - if(count($row) > 1) { |
|
1227 | + if (count($row) > 1) { |
|
1228 | 1228 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
1229 | 1229 | try { |
1230 | 1230 | $sth = $Connection->db->prepare($query); |
1231 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
1232 | - } catch(PDOException $e) { |
|
1231 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
1232 | + } catch (PDOException $e) { |
|
1233 | 1233 | return "error : ".$e->getMessage(); |
1234 | 1234 | } |
1235 | 1235 | } |
@@ -1249,21 +1249,21 @@ discard block |
||
1249 | 1249 | try { |
1250 | 1250 | $sth = $Connection->db->prepare($query); |
1251 | 1251 | $sth->execute(); |
1252 | - } catch(PDOException $e) { |
|
1252 | + } catch (PDOException $e) { |
|
1253 | 1253 | return "error : ".$e->getMessage(); |
1254 | 1254 | } |
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | |
1258 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1258 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1259 | 1259 | else { |
1260 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1260 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
1261 | 1261 | $query = "CREATE EXTENSION postgis"; |
1262 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
1262 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
1263 | 1263 | try { |
1264 | 1264 | $sth = $Connection->db->prepare($query); |
1265 | 1265 | $sth->execute(); |
1266 | - } catch(PDOException $e) { |
|
1266 | + } catch (PDOException $e) { |
|
1267 | 1267 | return "error : ".$e->getMessage(); |
1268 | 1268 | } |
1269 | 1269 | } |
@@ -1276,7 +1276,7 @@ discard block |
||
1276 | 1276 | include_once('class.create_db.php'); |
1277 | 1277 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1278 | 1278 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
1279 | - update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
1279 | + update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
1280 | 1280 | $error = ''; |
1281 | 1281 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1282 | 1282 | if ($globalDebug) echo "Gunzip..."; |
@@ -1308,14 +1308,14 @@ discard block |
||
1308 | 1308 | try { |
1309 | 1309 | $sth = $Connection->db->prepare($query); |
1310 | 1310 | $sth->execute(); |
1311 | - } catch(PDOException $e) { |
|
1311 | + } catch (PDOException $e) { |
|
1312 | 1312 | echo "error : ".$e->getMessage(); |
1313 | 1313 | } |
1314 | 1314 | } |
1315 | 1315 | if ($globalDBdriver == 'mysql') { |
1316 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1316 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1317 | 1317 | } else { |
1318 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
1318 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
1319 | 1319 | } |
1320 | 1320 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
1321 | 1321 | return $error; |
@@ -1328,7 +1328,7 @@ discard block |
||
1328 | 1328 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
1329 | 1329 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
1330 | 1330 | // update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
1331 | - update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
|
1331 | + update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net'); |
|
1332 | 1332 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
1333 | 1333 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
1334 | 1334 | return $error; |
@@ -1348,7 +1348,7 @@ discard block |
||
1348 | 1348 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1349 | 1349 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
1350 | 1350 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1351 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1351 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1352 | 1352 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
1353 | 1353 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
1354 | 1354 | if ($error != '') { |
@@ -1361,7 +1361,7 @@ discard block |
||
1361 | 1361 | global $tmp_dir, $globalDebug; |
1362 | 1362 | $error = ''; |
1363 | 1363 | if ($globalDebug) echo "Routes : Download..."; |
1364 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
1364 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
1365 | 1365 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1366 | 1366 | if ($globalDebug) echo "Gunzip..."; |
1367 | 1367 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | global $tmp_dir, $globalDebug; |
1378 | 1378 | $error = ''; |
1379 | 1379 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
1380 | - update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
1380 | + update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
1381 | 1381 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1382 | 1382 | if ($globalDebug) echo "Gunzip..."; |
1383 | 1383 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -1393,7 +1393,7 @@ discard block |
||
1393 | 1393 | global $tmp_dir, $globalDebug; |
1394 | 1394 | $error = ''; |
1395 | 1395 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
1396 | - update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
1396 | + update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
1397 | 1397 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1398 | 1398 | if ($globalDebug) echo "Gunzip..."; |
1399 | 1399 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -1421,7 +1421,7 @@ discard block |
||
1421 | 1421 | */ |
1422 | 1422 | if ($globalDebug) echo "Modes : Download..."; |
1423 | 1423 | // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
1424 | - update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
|
1424 | + update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz'); |
|
1425 | 1425 | |
1426 | 1426 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1427 | 1427 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
@@ -1441,7 +1441,7 @@ discard block |
||
1441 | 1441 | public static function update_ModeS_flarm() { |
1442 | 1442 | global $tmp_dir, $globalDebug; |
1443 | 1443 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
1444 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
1444 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
1445 | 1445 | if (file_exists($tmp_dir.'data.fln')) { |
1446 | 1446 | if ($globalDebug) echo "Add to DB..."; |
1447 | 1447 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1455,7 +1455,7 @@ discard block |
||
1455 | 1455 | public static function update_ModeS_ogn() { |
1456 | 1456 | global $tmp_dir, $globalDebug; |
1457 | 1457 | if ($globalDebug) echo "Modes OGN: Download..."; |
1458 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
1458 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
1459 | 1459 | if (file_exists($tmp_dir.'ogn.csv')) { |
1460 | 1460 | if ($globalDebug) echo "Add to DB..."; |
1461 | 1461 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1470,173 +1470,173 @@ discard block |
||
1470 | 1470 | global $tmp_dir, $globalDebug; |
1471 | 1471 | |
1472 | 1472 | if ($globalDebug) echo "Owner France: Download..."; |
1473 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
1473 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
1474 | 1474 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1475 | 1475 | if ($globalDebug) echo "Add to DB..."; |
1476 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
1476 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
1477 | 1477 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
1478 | 1478 | if ($error != '') { |
1479 | 1479 | return $error; |
1480 | 1480 | } elseif ($globalDebug) echo "Done\n"; |
1481 | 1481 | |
1482 | 1482 | if ($globalDebug) echo "Owner Ireland: Download..."; |
1483 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
1483 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
1484 | 1484 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1485 | 1485 | if ($globalDebug) echo "Add to DB..."; |
1486 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
1486 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
1487 | 1487 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
1488 | 1488 | if ($error != '') { |
1489 | 1489 | return $error; |
1490 | 1490 | } elseif ($globalDebug) echo "Done\n"; |
1491 | 1491 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
1492 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
1492 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
1493 | 1493 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1494 | 1494 | if ($globalDebug) echo "Add to DB..."; |
1495 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
1495 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
1496 | 1496 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
1497 | 1497 | if ($error != '') { |
1498 | 1498 | return $error; |
1499 | 1499 | } elseif ($globalDebug) echo "Done\n"; |
1500 | 1500 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
1501 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
1501 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
1502 | 1502 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1503 | 1503 | if ($globalDebug) echo "Add to DB..."; |
1504 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
1504 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
1505 | 1505 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
1506 | 1506 | if ($error != '') { |
1507 | 1507 | return $error; |
1508 | 1508 | } elseif ($globalDebug) echo "Done\n"; |
1509 | 1509 | if ($globalDebug) echo "Owner Australia: Download..."; |
1510 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
1510 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
1511 | 1511 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1512 | 1512 | if ($globalDebug) echo "Add to DB..."; |
1513 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
1513 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
1514 | 1514 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
1515 | 1515 | if ($error != '') { |
1516 | 1516 | return $error; |
1517 | 1517 | } elseif ($globalDebug) echo "Done\n"; |
1518 | 1518 | if ($globalDebug) echo "Owner Austria: Download..."; |
1519 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
1519 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
1520 | 1520 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1521 | 1521 | if ($globalDebug) echo "Add to DB..."; |
1522 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
1522 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
1523 | 1523 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
1524 | 1524 | if ($error != '') { |
1525 | 1525 | return $error; |
1526 | 1526 | } elseif ($globalDebug) echo "Done\n"; |
1527 | 1527 | if ($globalDebug) echo "Owner Chile: Download..."; |
1528 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
1528 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
1529 | 1529 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1530 | 1530 | if ($globalDebug) echo "Add to DB..."; |
1531 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
1531 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
1532 | 1532 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
1533 | 1533 | if ($error != '') { |
1534 | 1534 | return $error; |
1535 | 1535 | } elseif ($globalDebug) echo "Done\n"; |
1536 | 1536 | if ($globalDebug) echo "Owner Colombia: Download..."; |
1537 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
1537 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
1538 | 1538 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1539 | 1539 | if ($globalDebug) echo "Add to DB..."; |
1540 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
1540 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
1541 | 1541 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
1542 | 1542 | if ($error != '') { |
1543 | 1543 | return $error; |
1544 | 1544 | } elseif ($globalDebug) echo "Done\n"; |
1545 | 1545 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
1546 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
1546 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
1547 | 1547 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1548 | 1548 | if ($globalDebug) echo "Add to DB..."; |
1549 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
1549 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
1550 | 1550 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
1551 | 1551 | if ($error != '') { |
1552 | 1552 | return $error; |
1553 | 1553 | } elseif ($globalDebug) echo "Done\n"; |
1554 | 1554 | if ($globalDebug) echo "Owner Brazil: Download..."; |
1555 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
1555 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
1556 | 1556 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1557 | 1557 | if ($globalDebug) echo "Add to DB..."; |
1558 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
1558 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
1559 | 1559 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
1560 | 1560 | if ($error != '') { |
1561 | 1561 | return $error; |
1562 | 1562 | } elseif ($globalDebug) echo "Done\n"; |
1563 | 1563 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
1564 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
1564 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
1565 | 1565 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1566 | 1566 | if ($globalDebug) echo "Add to DB..."; |
1567 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
1567 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
1568 | 1568 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
1569 | 1569 | if ($error != '') { |
1570 | 1570 | return $error; |
1571 | 1571 | } elseif ($globalDebug) echo "Done\n"; |
1572 | 1572 | if ($globalDebug) echo "Owner Croatia: Download..."; |
1573 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
1573 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
1574 | 1574 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1575 | 1575 | if ($globalDebug) echo "Add to DB..."; |
1576 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
1576 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
1577 | 1577 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
1578 | 1578 | if ($error != '') { |
1579 | 1579 | return $error; |
1580 | 1580 | } elseif ($globalDebug) echo "Done\n"; |
1581 | 1581 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
1582 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
1582 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
1583 | 1583 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1584 | 1584 | if ($globalDebug) echo "Add to DB..."; |
1585 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
1585 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
1586 | 1586 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
1587 | 1587 | if ($error != '') { |
1588 | 1588 | return $error; |
1589 | 1589 | } elseif ($globalDebug) echo "Done\n"; |
1590 | 1590 | if ($globalDebug) echo "Owner Maldives: Download..."; |
1591 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
1591 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
1592 | 1592 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1593 | 1593 | if ($globalDebug) echo "Add to DB..."; |
1594 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
1594 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
1595 | 1595 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
1596 | 1596 | if ($error != '') { |
1597 | 1597 | return $error; |
1598 | 1598 | } elseif ($globalDebug) echo "Done\n"; |
1599 | 1599 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
1600 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
1600 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
1601 | 1601 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1602 | 1602 | if ($globalDebug) echo "Add to DB..."; |
1603 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
1603 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
1604 | 1604 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
1605 | 1605 | if ($error != '') { |
1606 | 1606 | return $error; |
1607 | 1607 | } elseif ($globalDebug) echo "Done\n"; |
1608 | 1608 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
1609 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
1609 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
1610 | 1610 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1611 | 1611 | if ($globalDebug) echo "Add to DB..."; |
1612 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
1612 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
1613 | 1613 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
1614 | 1614 | if ($error != '') { |
1615 | 1615 | return $error; |
1616 | 1616 | } elseif ($globalDebug) echo "Done\n"; |
1617 | 1617 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
1618 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
1618 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
1619 | 1619 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1620 | 1620 | if ($globalDebug) echo "Add to DB..."; |
1621 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
1621 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
1622 | 1622 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
1623 | 1623 | if ($error != '') { |
1624 | 1624 | return $error; |
1625 | 1625 | } elseif ($globalDebug) echo "Done\n"; |
1626 | 1626 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
1627 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
1627 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
1628 | 1628 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1629 | 1629 | if ($globalDebug) echo "Add to DB..."; |
1630 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
1630 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
1631 | 1631 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
1632 | 1632 | if ($error != '') { |
1633 | 1633 | return $error; |
1634 | 1634 | } elseif ($globalDebug) echo "Done\n"; |
1635 | 1635 | if ($globalDebug) echo "Owner Iceland: Download..."; |
1636 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
1636 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
1637 | 1637 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1638 | 1638 | if ($globalDebug) echo "Add to DB..."; |
1639 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
1639 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
1640 | 1640 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
1641 | 1641 | if ($error != '') { |
1642 | 1642 | return $error; |
@@ -1648,7 +1648,7 @@ discard block |
||
1648 | 1648 | global $tmp_dir, $globalDebug; |
1649 | 1649 | $error = ''; |
1650 | 1650 | if ($globalDebug) echo "Translation : Download..."; |
1651 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
1651 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
1652 | 1652 | if (file_exists($tmp_dir.'translation.zip')) { |
1653 | 1653 | if ($globalDebug) echo "Unzip..."; |
1654 | 1654 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1664,7 +1664,7 @@ discard block |
||
1664 | 1664 | public static function update_translation_fam() { |
1665 | 1665 | global $tmp_dir, $globalDebug; |
1666 | 1666 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
1667 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
1667 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
1668 | 1668 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1669 | 1669 | if ($globalDebug) echo "Gunzip..."; |
1670 | 1670 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1679,7 +1679,7 @@ discard block |
||
1679 | 1679 | public static function update_ModeS_fam() { |
1680 | 1680 | global $tmp_dir, $globalDebug; |
1681 | 1681 | if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
1682 | - update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
|
1682 | + update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz'); |
|
1683 | 1683 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
1684 | 1684 | if ($globalDebug) echo "Gunzip..."; |
1685 | 1685 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
@@ -1694,7 +1694,7 @@ discard block |
||
1694 | 1694 | public static function update_routes_fam() { |
1695 | 1695 | global $tmp_dir, $globalDebug; |
1696 | 1696 | if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
1697 | - update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
|
1697 | + update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz'); |
|
1698 | 1698 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
1699 | 1699 | if ($globalDebug) echo "Gunzip..."; |
1700 | 1700 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
@@ -1713,18 +1713,18 @@ discard block |
||
1713 | 1713 | $error = ''; |
1714 | 1714 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
1715 | 1715 | if ($globalDBdriver == 'mysql') { |
1716 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
1716 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
1717 | 1717 | } else { |
1718 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
1718 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
1719 | 1719 | } |
1720 | 1720 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
1721 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
1721 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
1722 | 1722 | $airspace_md5 = $airspace_md5_file[0]; |
1723 | 1723 | if (!update_db::check_airspace_version($airspace_md5)) { |
1724 | 1724 | if ($globalDBdriver == 'mysql') { |
1725 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
1725 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
1726 | 1726 | } else { |
1727 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
1727 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
1728 | 1728 | } |
1729 | 1729 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
1730 | 1730 | if ($globalDebug) echo "Gunzip..."; |
@@ -1736,7 +1736,7 @@ discard block |
||
1736 | 1736 | try { |
1737 | 1737 | $sth = $Connection->db->prepare($query); |
1738 | 1738 | $sth->execute(); |
1739 | - } catch(PDOException $e) { |
|
1739 | + } catch (PDOException $e) { |
|
1740 | 1740 | return "error : ".$e->getMessage(); |
1741 | 1741 | } |
1742 | 1742 | } |
@@ -1754,15 +1754,15 @@ discard block |
||
1754 | 1754 | public static function update_tle() { |
1755 | 1755 | global $tmp_dir, $globalDebug; |
1756 | 1756 | if ($globalDebug) echo "Download TLE : Download..."; |
1757 | - $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
|
1758 | - 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
|
1759 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
|
1757 | + $alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt', |
|
1758 | + 'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt', |
|
1759 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); |
|
1760 | 1760 | foreach ($alltle as $filename) { |
1761 | 1761 | if ($globalDebug) echo "downloading ".$filename.'...'; |
1762 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
1762 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
1763 | 1763 | if (file_exists($tmp_dir.$filename)) { |
1764 | 1764 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
1765 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
1765 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
1766 | 1766 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
1767 | 1767 | if ($error != '') { |
1768 | 1768 | echo $error."\n"; |
@@ -1775,32 +1775,32 @@ discard block |
||
1775 | 1775 | global $tmp_dir, $globalDebug; |
1776 | 1776 | $error = ''; |
1777 | 1777 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
1778 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
1778 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
1779 | 1779 | if (file_exists($tmp_dir.'models.md5sum')) { |
1780 | 1780 | if ($globalDebug) echo "Check files...\n"; |
1781 | 1781 | $newmodelsdb = array(); |
1782 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
1783 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
1782 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
1783 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
1784 | 1784 | $model = trim($row[2]); |
1785 | 1785 | $newmodelsdb[$model] = trim($row[0]); |
1786 | 1786 | } |
1787 | 1787 | } |
1788 | 1788 | $modelsdb = array(); |
1789 | 1789 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
1790 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
1791 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
1790 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
1791 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
1792 | 1792 | $model = trim($row[2]); |
1793 | 1793 | $modelsdb[$model] = trim($row[0]); |
1794 | 1794 | } |
1795 | 1795 | } |
1796 | 1796 | } |
1797 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
1797 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
1798 | 1798 | foreach ($diff as $key => $value) { |
1799 | 1799 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
1800 | - update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
1800 | + update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
1801 | 1801 | |
1802 | 1802 | } |
1803 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
1803 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
1804 | 1804 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
1805 | 1805 | if ($error != '') { |
1806 | 1806 | return $error; |
@@ -1812,32 +1812,32 @@ discard block |
||
1812 | 1812 | global $tmp_dir, $globalDebug; |
1813 | 1813 | $error = ''; |
1814 | 1814 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
1815 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
1815 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
1816 | 1816 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
1817 | 1817 | if ($globalDebug) echo "Check files...\n"; |
1818 | 1818 | $newmodelsdb = array(); |
1819 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
1820 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
1819 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
1820 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
1821 | 1821 | $model = trim($row[2]); |
1822 | 1822 | $newmodelsdb[$model] = trim($row[0]); |
1823 | 1823 | } |
1824 | 1824 | } |
1825 | 1825 | $modelsdb = array(); |
1826 | 1826 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
1827 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
1828 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
1827 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
1828 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
1829 | 1829 | $model = trim($row[2]); |
1830 | 1830 | $modelsdb[$model] = trim($row[0]); |
1831 | 1831 | } |
1832 | 1832 | } |
1833 | 1833 | } |
1834 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
1834 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
1835 | 1835 | foreach ($diff as $key => $value) { |
1836 | 1836 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
1837 | - update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
1837 | + update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
1838 | 1838 | |
1839 | 1839 | } |
1840 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
1840 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
1841 | 1841 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
1842 | 1842 | if ($error != '') { |
1843 | 1843 | return $error; |
@@ -1860,8 +1860,8 @@ discard block |
||
1860 | 1860 | */ |
1861 | 1861 | if (file_exists($tmp_dir.'aircrafts.html')) { |
1862 | 1862 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
1863 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
1864 | - $result = fread($fh,100000000); |
|
1863 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
1864 | + $result = fread($fh, 100000000); |
|
1865 | 1865 | //echo $result; |
1866 | 1866 | //var_dump(str_get_html($result)); |
1867 | 1867 | //print_r(self::table2array($result)); |
@@ -1879,23 +1879,23 @@ discard block |
||
1879 | 1879 | $Connection = new Connection(); |
1880 | 1880 | $sth = $Connection->db->prepare($query); |
1881 | 1881 | $sth->execute(); |
1882 | - } catch(PDOException $e) { |
|
1882 | + } catch (PDOException $e) { |
|
1883 | 1883 | return "error : ".$e->getMessage(); |
1884 | 1884 | } |
1885 | 1885 | |
1886 | 1886 | $error = ''; |
1887 | 1887 | if ($globalDebug) echo "Notam : Download..."; |
1888 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
1888 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
1889 | 1889 | if (file_exists($tmp_dir.'notam.rss')) { |
1890 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
1890 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
1891 | 1891 | foreach ($notams['channel']['item'] as $notam) { |
1892 | - $title = explode(':',$notam['title']); |
|
1892 | + $title = explode(':', $notam['title']); |
|
1893 | 1893 | $data['ref'] = trim($title[0]); |
1894 | 1894 | unset($title[0]); |
1895 | - $data['title'] = trim(implode(':',$title)); |
|
1896 | - $description = strip_tags($notam['description'],'<pre>'); |
|
1897 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
1898 | - $q = explode('/',$match[1]); |
|
1895 | + $data['title'] = trim(implode(':', $title)); |
|
1896 | + $description = strip_tags($notam['description'], '<pre>'); |
|
1897 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
1898 | + $q = explode('/', $match[1]); |
|
1899 | 1899 | $data['fir'] = $q[0]; |
1900 | 1900 | $data['code'] = $q[1]; |
1901 | 1901 | $ifrvfr = $q[2]; |
@@ -1911,30 +1911,30 @@ discard block |
||
1911 | 1911 | $data['lower_limit'] = $q[5]; |
1912 | 1912 | $data['upper_limit'] = $q[6]; |
1913 | 1913 | $latlonrad = $q[7]; |
1914 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
1915 | - $latitude = $Common->convertDec($las,'latitude'); |
|
1916 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
1914 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
1915 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
1916 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
1917 | 1917 | if ($lac == 'S') $latitude = '-'.$latitude; |
1918 | 1918 | if ($lnc == 'W') $longitude = '-'.$longitude; |
1919 | 1919 | $data['center_latitude'] = $latitude; |
1920 | 1920 | $data['center_longitude'] = $longitude; |
1921 | 1921 | $data['radius'] = intval($radius); |
1922 | 1922 | |
1923 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
1923 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
1924 | 1924 | $data['text'] = $match[1]; |
1925 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
1925 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
1926 | 1926 | $fromto = $match[1]; |
1927 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
1927 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
1928 | 1928 | $fromall = trim($match[1]); |
1929 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
1929 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
1930 | 1930 | $from = trim($match[1]); |
1931 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
1932 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
1931 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
1932 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
1933 | 1933 | $toall = trim($match[1]); |
1934 | - if (!preg_match(':Permanent:',$toall)) { |
|
1935 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
1934 | + if (!preg_match(':Permanent:', $toall)) { |
|
1935 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
1936 | 1936 | $to = trim($match[1]); |
1937 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
1937 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
1938 | 1938 | $data['permanent'] = 0; |
1939 | 1939 | } else { |
1940 | 1940 | $data['date_end'] = NULL; |
@@ -1942,7 +1942,7 @@ discard block |
||
1942 | 1942 | } |
1943 | 1943 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
1944 | 1944 | $NOTAM = new NOTAM(); |
1945 | - $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
1945 | + $NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
1946 | 1946 | unset($data); |
1947 | 1947 | } |
1948 | 1948 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -1965,16 +1965,16 @@ discard block |
||
1965 | 1965 | $Connection = new Connection(); |
1966 | 1966 | $sth = $Connection->db->prepare($query); |
1967 | 1967 | $sth->execute(); |
1968 | - } catch(PDOException $e) { |
|
1968 | + } catch (PDOException $e) { |
|
1969 | 1969 | return "error : ".$e->getMessage(); |
1970 | 1970 | } |
1971 | 1971 | } |
1972 | 1972 | $Common = new Common(); |
1973 | 1973 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
1974 | - $airspace_json = json_decode($airspace_lst,true); |
|
1974 | + $airspace_json = json_decode($airspace_lst, true); |
|
1975 | 1975 | foreach ($airspace_json['records'] as $airspace) { |
1976 | 1976 | if ($globalDebug) echo $airspace['name']."...\n"; |
1977 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
1977 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
1978 | 1978 | if (file_exists($tmp_dir.$airspace['name'])) { |
1979 | 1979 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
1980 | 1980 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -1998,7 +1998,7 @@ discard block |
||
1998 | 1998 | $Connection = new Connection(); |
1999 | 1999 | $sth = $Connection->db->prepare($query); |
2000 | 2000 | $sth->execute(); |
2001 | - } catch(PDOException $e) { |
|
2001 | + } catch (PDOException $e) { |
|
2002 | 2002 | return "error : ".$e->getMessage(); |
2003 | 2003 | } |
2004 | 2004 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2013,7 +2013,7 @@ discard block |
||
2013 | 2013 | $Connection = new Connection(); |
2014 | 2014 | $sth = $Connection->db->prepare($query); |
2015 | 2015 | $sth->execute(); |
2016 | - } catch(PDOException $e) { |
|
2016 | + } catch (PDOException $e) { |
|
2017 | 2017 | return "error : ".$e->getMessage(); |
2018 | 2018 | } |
2019 | 2019 | } |
@@ -2024,7 +2024,7 @@ discard block |
||
2024 | 2024 | $Connection = new Connection(); |
2025 | 2025 | $sth = $Connection->db->prepare($query); |
2026 | 2026 | $sth->execute(array(':version' => $version)); |
2027 | - } catch(PDOException $e) { |
|
2027 | + } catch (PDOException $e) { |
|
2028 | 2028 | return "error : ".$e->getMessage(); |
2029 | 2029 | } |
2030 | 2030 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2040,7 +2040,7 @@ discard block |
||
2040 | 2040 | $Connection = new Connection(); |
2041 | 2041 | $sth = $Connection->db->prepare($query); |
2042 | 2042 | $sth->execute(array(':version' => $version)); |
2043 | - } catch(PDOException $e) { |
|
2043 | + } catch (PDOException $e) { |
|
2044 | 2044 | return "error : ".$e->getMessage(); |
2045 | 2045 | } |
2046 | 2046 | } |
@@ -2056,7 +2056,7 @@ discard block |
||
2056 | 2056 | $Connection = new Connection(); |
2057 | 2057 | $sth = $Connection->db->prepare($query); |
2058 | 2058 | $sth->execute(); |
2059 | - } catch(PDOException $e) { |
|
2059 | + } catch (PDOException $e) { |
|
2060 | 2060 | return "error : ".$e->getMessage(); |
2061 | 2061 | } |
2062 | 2062 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2071,7 +2071,7 @@ discard block |
||
2071 | 2071 | $Connection = new Connection(); |
2072 | 2072 | $sth = $Connection->db->prepare($query); |
2073 | 2073 | $sth->execute(); |
2074 | - } catch(PDOException $e) { |
|
2074 | + } catch (PDOException $e) { |
|
2075 | 2075 | return "error : ".$e->getMessage(); |
2076 | 2076 | } |
2077 | 2077 | } |
@@ -2086,7 +2086,7 @@ discard block |
||
2086 | 2086 | $Connection = new Connection(); |
2087 | 2087 | $sth = $Connection->db->prepare($query); |
2088 | 2088 | $sth->execute(); |
2089 | - } catch(PDOException $e) { |
|
2089 | + } catch (PDOException $e) { |
|
2090 | 2090 | return "error : ".$e->getMessage(); |
2091 | 2091 | } |
2092 | 2092 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2101,7 +2101,7 @@ discard block |
||
2101 | 2101 | $Connection = new Connection(); |
2102 | 2102 | $sth = $Connection->db->prepare($query); |
2103 | 2103 | $sth->execute(); |
2104 | - } catch(PDOException $e) { |
|
2104 | + } catch (PDOException $e) { |
|
2105 | 2105 | return "error : ".$e->getMessage(); |
2106 | 2106 | } |
2107 | 2107 | } |
@@ -2117,7 +2117,7 @@ discard block |
||
2117 | 2117 | $Connection = new Connection(); |
2118 | 2118 | $sth = $Connection->db->prepare($query); |
2119 | 2119 | $sth->execute(); |
2120 | - } catch(PDOException $e) { |
|
2120 | + } catch (PDOException $e) { |
|
2121 | 2121 | return "error : ".$e->getMessage(); |
2122 | 2122 | } |
2123 | 2123 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2132,7 +2132,7 @@ discard block |
||
2132 | 2132 | $Connection = new Connection(); |
2133 | 2133 | $sth = $Connection->db->prepare($query); |
2134 | 2134 | $sth->execute(); |
2135 | - } catch(PDOException $e) { |
|
2135 | + } catch (PDOException $e) { |
|
2136 | 2136 | return "error : ".$e->getMessage(); |
2137 | 2137 | } |
2138 | 2138 | } |
@@ -2147,7 +2147,7 @@ discard block |
||
2147 | 2147 | $Connection = new Connection(); |
2148 | 2148 | $sth = $Connection->db->prepare($query); |
2149 | 2149 | $sth->execute(); |
2150 | - } catch(PDOException $e) { |
|
2150 | + } catch (PDOException $e) { |
|
2151 | 2151 | return "error : ".$e->getMessage(); |
2152 | 2152 | } |
2153 | 2153 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2162,7 +2162,7 @@ discard block |
||
2162 | 2162 | $Connection = new Connection(); |
2163 | 2163 | $sth = $Connection->db->prepare($query); |
2164 | 2164 | $sth->execute(); |
2165 | - } catch(PDOException $e) { |
|
2165 | + } catch (PDOException $e) { |
|
2166 | 2166 | return "error : ".$e->getMessage(); |
2167 | 2167 | } |
2168 | 2168 | } |
@@ -2177,7 +2177,7 @@ discard block |
||
2177 | 2177 | $Connection = new Connection(); |
2178 | 2178 | $sth = $Connection->db->prepare($query); |
2179 | 2179 | $sth->execute(); |
2180 | - } catch(PDOException $e) { |
|
2180 | + } catch (PDOException $e) { |
|
2181 | 2181 | return "error : ".$e->getMessage(); |
2182 | 2182 | } |
2183 | 2183 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2192,7 +2192,7 @@ discard block |
||
2192 | 2192 | $Connection = new Connection(); |
2193 | 2193 | $sth = $Connection->db->prepare($query); |
2194 | 2194 | $sth->execute(); |
2195 | - } catch(PDOException $e) { |
|
2195 | + } catch (PDOException $e) { |
|
2196 | 2196 | return "error : ".$e->getMessage(); |
2197 | 2197 | } |
2198 | 2198 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | <button type="button" class="close">×</button> |
8 | 8 | <?php |
9 | 9 | |
10 | -$sat = filter_input(INPUT_GET,'sat',FILTER_SANITIZE_STRING); |
|
10 | +$sat = filter_input(INPUT_GET, 'sat', FILTER_SANITIZE_STRING); |
|
11 | 11 | $sat = urldecode($sat); |
12 | 12 | |
13 | 13 | if ($sat == 'ISS (ZARYA)') { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $aircraft_name = 'INTEGRAL'; |
43 | 43 | // $ground_speed = 14970; |
44 | 44 | $launch_date = '17 October 2002'; |
45 | -} elseif (strpos($sat,'IRIDIUM') !== false) { |
|
45 | +} elseif (strpos($sat, 'IRIDIUM') !== false) { |
|
46 | 46 | $image = 'https://upload.wikimedia.org/wikipedia/commons/b/b6/Iridium_Satellite.jpg'; |
47 | 47 | $image_copyright = 'Cliff'; |
48 | 48 | $ident = 'Iridium satellite constellation'; |
@@ -50,22 +50,22 @@ discard block |
||
50 | 50 | $aircraft_name = $sat; |
51 | 51 | // $ground_speed = 14970; |
52 | 52 | // $launch_date = '29 september 2011'; |
53 | -} elseif (strpos($sat,'ORBCOMM') !== false) { |
|
53 | +} elseif (strpos($sat, 'ORBCOMM') !== false) { |
|
54 | 54 | $ident = 'Orbcomm'; |
55 | 55 | $aircraft_wiki = 'https://en.wikipedia.org/wiki/Orbcomm_(satellite)'; |
56 | 56 | $aircraft_name = $sat; |
57 | -} elseif (strpos($sat,'GLOBALSTAR') !== false) { |
|
57 | +} elseif (strpos($sat, 'GLOBALSTAR') !== false) { |
|
58 | 58 | $ident = 'Globalstar'; |
59 | 59 | $aircraft_wiki = 'https://en.wikipedia.org/wiki/Globalstar'; |
60 | 60 | $aircraft_name = $sat; |
61 | -} elseif (strpos($sat,'OSCAR 7') !== false) { |
|
61 | +} elseif (strpos($sat, 'OSCAR 7') !== false) { |
|
62 | 62 | $image = 'https://upload.wikimedia.org/wikipedia/en/a/ad/AMSAT-OSCAR_7.jpg'; |
63 | 63 | $image_copyright = 'Amsat.org'; |
64 | 64 | $ident = 'AMSAT-OSCAR 7'; |
65 | 65 | $aircraft_wiki = 'https://en.wikipedia.org/wiki/AMSAT-OSCAR_7'; |
66 | 66 | $aircraft_name = $sat; |
67 | 67 | $launch_date = '15 November 1974'; |
68 | -} elseif (strpos($sat,'santaclaus') !== false) { |
|
68 | +} elseif (strpos($sat, 'santaclaus') !== false) { |
|
69 | 69 | $image = 'https://upload.wikimedia.org/wikipedia/commons/4/49/Jonathan_G_Meath_portrays_Santa_Claus.jpg'; |
70 | 70 | $image_copyright = 'Jonathan G Meath'; |
71 | 71 | $ident = 'Santa Claus'; |