@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | curl_setopt($ch, CURLOPT_URL, $url); |
17 | 17 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
18 | 18 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
19 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
19 | + if ($referer != '') { |
|
20 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
21 | + } |
|
20 | 22 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
21 | 23 | curl_setopt($ch, CURLOPT_FILE, $fp); |
22 | 24 | curl_exec($ch); |
@@ -27,12 +29,16 @@ discard block |
||
27 | 29 | public static function gunzip($in_file,$out_file_name = '') { |
28 | 30 | //echo $in_file.' -> '.$out_file_name."\n"; |
29 | 31 | $buffer_size = 4096; // read 4kb at a time |
30 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
32 | + if ($out_file_name == '') { |
|
33 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
34 | + } |
|
31 | 35 | if ($in_file != '' && file_exists($in_file)) { |
32 | 36 | // 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'); |
|
35 | - else { |
|
37 | + if (function_exists('gzopen')) { |
|
38 | + $file = gzopen($in_file,'rb'); |
|
39 | + } elseif (function_exists('gzopen64')) { |
|
40 | + $file = gzopen64($in_file,'rb'); |
|
41 | + } else { |
|
36 | 42 | echo 'gzopen not available'; |
37 | 43 | die; |
38 | 44 | } |
@@ -53,8 +59,12 @@ discard block |
||
53 | 59 | if ($res === TRUE) { |
54 | 60 | $zip->extractTo($path); |
55 | 61 | $zip->close(); |
56 | - } else return false; |
|
57 | - } else return false; |
|
62 | + } else { |
|
63 | + return false; |
|
64 | + } |
|
65 | + } else { |
|
66 | + return false; |
|
67 | + } |
|
58 | 68 | } |
59 | 69 | |
60 | 70 | public static function connect_sqlite($database) { |
@@ -69,7 +79,9 @@ discard block |
||
69 | 79 | public static function retrieve_route_sqlite_to_dest($database_file) { |
70 | 80 | global $globalDebug, $globalTransaction; |
71 | 81 | //$query = 'TRUNCATE TABLE routes'; |
72 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
82 | + if ($globalDebug) { |
|
83 | + echo " - Delete previous routes from DB -"; |
|
84 | + } |
|
73 | 85 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
74 | 86 | $Connection = new Connection(); |
75 | 87 | try { |
@@ -80,7 +92,9 @@ discard block |
||
80 | 92 | return "error : ".$e->getMessage(); |
81 | 93 | } |
82 | 94 | |
83 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
95 | + if ($globalDebug) { |
|
96 | + echo " - Add routes to DB -"; |
|
97 | + } |
|
84 | 98 | update_db::connect_sqlite($database_file); |
85 | 99 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
86 | 100 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -95,15 +109,21 @@ discard block |
||
95 | 109 | $Connection = new Connection(); |
96 | 110 | $sth_dest = $Connection->db->prepare($query_dest); |
97 | 111 | try { |
98 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
112 | + if ($globalTransaction) { |
|
113 | + $Connection->db->beginTransaction(); |
|
114 | + } |
|
99 | 115 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
100 | 116 | //$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 | 117 | $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 | 118 | $sth_dest->execute($query_dest_values); |
103 | 119 | } |
104 | - if ($globalTransaction) $Connection->db->commit(); |
|
120 | + if ($globalTransaction) { |
|
121 | + $Connection->db->commit(); |
|
122 | + } |
|
105 | 123 | } catch(PDOException $e) { |
106 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
124 | + if ($globalTransaction) { |
|
125 | + $Connection->db->rollBack(); |
|
126 | + } |
|
107 | 127 | return "error : ".$e->getMessage(); |
108 | 128 | } |
109 | 129 | return ''; |
@@ -111,7 +131,9 @@ discard block |
||
111 | 131 | public static function retrieve_route_oneworld($database_file) { |
112 | 132 | global $globalDebug, $globalTransaction; |
113 | 133 | //$query = 'TRUNCATE TABLE routes'; |
114 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
134 | + if ($globalDebug) { |
|
135 | + echo " - Delete previous routes from DB -"; |
|
136 | + } |
|
115 | 137 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
116 | 138 | $Connection = new Connection(); |
117 | 139 | try { |
@@ -122,14 +144,18 @@ discard block |
||
122 | 144 | return "error : ".$e->getMessage(); |
123 | 145 | } |
124 | 146 | |
125 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
147 | + if ($globalDebug) { |
|
148 | + echo " - Add routes to DB -"; |
|
149 | + } |
|
126 | 150 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
127 | 151 | $Spotter = new Spotter(); |
128 | 152 | if ($fh = fopen($database_file,"r")) { |
129 | 153 | $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 | 154 | $Connection = new Connection(); |
131 | 155 | $sth_dest = $Connection->db->prepare($query_dest); |
132 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
156 | + if ($globalTransaction) { |
|
157 | + $Connection->db->beginTransaction(); |
|
158 | + } |
|
133 | 159 | while (!feof($fh)) { |
134 | 160 | $line = fgetcsv($fh,9999,','); |
135 | 161 | if ($line[0] != '') { |
@@ -138,13 +164,17 @@ discard block |
||
138 | 164 | $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 | 165 | $sth_dest->execute($query_dest_values); |
140 | 166 | } catch(PDOException $e) { |
141 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
167 | + if ($globalTransaction) { |
|
168 | + $Connection->db->rollBack(); |
|
169 | + } |
|
142 | 170 | return "error : ".$e->getMessage(); |
143 | 171 | } |
144 | 172 | } |
145 | 173 | } |
146 | 174 | } |
147 | - if ($globalTransaction) $Connection->db->commit(); |
|
175 | + if ($globalTransaction) { |
|
176 | + $Connection->db->commit(); |
|
177 | + } |
|
148 | 178 | } |
149 | 179 | return ''; |
150 | 180 | } |
@@ -152,7 +182,9 @@ discard block |
||
152 | 182 | public static function retrieve_route_skyteam($database_file) { |
153 | 183 | global $globalDebug, $globalTransaction; |
154 | 184 | //$query = 'TRUNCATE TABLE routes'; |
155 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
185 | + if ($globalDebug) { |
|
186 | + echo " - Delete previous routes from DB -"; |
|
187 | + } |
|
156 | 188 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
157 | 189 | $Connection = new Connection(); |
158 | 190 | try { |
@@ -163,7 +195,9 @@ discard block |
||
163 | 195 | return "error : ".$e->getMessage(); |
164 | 196 | } |
165 | 197 | |
166 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
198 | + if ($globalDebug) { |
|
199 | + echo " - Add routes to DB -"; |
|
200 | + } |
|
167 | 201 | |
168 | 202 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
169 | 203 | $Spotter = new Spotter(); |
@@ -172,7 +206,9 @@ discard block |
||
172 | 206 | $Connection = new Connection(); |
173 | 207 | $sth_dest = $Connection->db->prepare($query_dest); |
174 | 208 | try { |
175 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
209 | + if ($globalTransaction) { |
|
210 | + $Connection->db->beginTransaction(); |
|
211 | + } |
|
176 | 212 | while (!feof($fh)) { |
177 | 213 | $line = fgetcsv($fh,9999,','); |
178 | 214 | if ($line[0] != '') { |
@@ -183,9 +219,13 @@ discard block |
||
183 | 219 | } |
184 | 220 | } |
185 | 221 | } |
186 | - if ($globalTransaction) $Connection->db->commit(); |
|
222 | + if ($globalTransaction) { |
|
223 | + $Connection->db->commit(); |
|
224 | + } |
|
187 | 225 | } catch(PDOException $e) { |
188 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
226 | + if ($globalTransaction) { |
|
227 | + $Connection->db->rollBack(); |
|
228 | + } |
|
189 | 229 | return "error : ".$e->getMessage(); |
190 | 230 | } |
191 | 231 | } |
@@ -228,11 +268,16 @@ discard block |
||
228 | 268 | $sth_dest = $Connection->db->prepare($query_dest); |
229 | 269 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
230 | 270 | try { |
231 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
271 | + if ($globalTransaction) { |
|
272 | + $Connection->db->beginTransaction(); |
|
273 | + } |
|
232 | 274 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
233 | 275 | //$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 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
235 | - else $type = null; |
|
276 | + if ($values['UserString4'] == 'M') { |
|
277 | + $type = 'military'; |
|
278 | + } else { |
|
279 | + $type = null; |
|
280 | + } |
|
236 | 281 | $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 | 282 | $sth_dest->execute($query_dest_values); |
238 | 283 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -240,7 +285,9 @@ discard block |
||
240 | 285 | $sth_dest_owner->execute($query_dest_owner_values); |
241 | 286 | } |
242 | 287 | } |
243 | - if ($globalTransaction) $Connection->db->commit(); |
|
288 | + if ($globalTransaction) { |
|
289 | + $Connection->db->commit(); |
|
290 | + } |
|
244 | 291 | } catch(PDOException $e) { |
245 | 292 | return "error : ".$e->getMessage(); |
246 | 293 | } |
@@ -276,7 +323,9 @@ discard block |
||
276 | 323 | $Connection = new Connection(); |
277 | 324 | $sth_dest = $Connection->db->prepare($query_dest); |
278 | 325 | try { |
279 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
326 | + if ($globalTransaction) { |
|
327 | + $Connection->db->beginTransaction(); |
|
328 | + } |
|
280 | 329 | while (!feof($fh)) { |
281 | 330 | $values = array(); |
282 | 331 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -287,7 +336,9 @@ discard block |
||
287 | 336 | // Check if we can find ICAO, else set it to GLID |
288 | 337 | $aircraft_name_split = explode(' ',$aircraft_name); |
289 | 338 | $search_more = ''; |
290 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
339 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
340 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
341 | + } |
|
291 | 342 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
292 | 343 | $sth_search = $Connection->db->prepare($query_search); |
293 | 344 | try { |
@@ -300,7 +351,9 @@ discard block |
||
300 | 351 | } catch(PDOException $e) { |
301 | 352 | return "error : ".$e->getMessage(); |
302 | 353 | } |
303 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
354 | + if (!isset($values['ICAOTypeCode'])) { |
|
355 | + $values['ICAOTypeCode'] = 'GLID'; |
|
356 | + } |
|
304 | 357 | // Add data to db |
305 | 358 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
306 | 359 | //$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']); |
@@ -309,7 +362,9 @@ discard block |
||
309 | 362 | $sth_dest->execute($query_dest_values); |
310 | 363 | } |
311 | 364 | } |
312 | - if ($globalTransaction) $Connection->db->commit(); |
|
365 | + if ($globalTransaction) { |
|
366 | + $Connection->db->commit(); |
|
367 | + } |
|
313 | 368 | } catch(PDOException $e) { |
314 | 369 | return "error : ".$e->getMessage(); |
315 | 370 | } |
@@ -345,7 +400,9 @@ discard block |
||
345 | 400 | $Connection = new Connection(); |
346 | 401 | $sth_dest = $Connection->db->prepare($query_dest); |
347 | 402 | try { |
348 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
403 | + if ($globalTransaction) { |
|
404 | + $Connection->db->beginTransaction(); |
|
405 | + } |
|
349 | 406 | $tmp = fgetcsv($fh,9999,',',"'"); |
350 | 407 | while (!feof($fh)) { |
351 | 408 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -358,13 +415,17 @@ discard block |
||
358 | 415 | // Check if we can find ICAO, else set it to GLID |
359 | 416 | $aircraft_name_split = explode(' ',$aircraft_name); |
360 | 417 | $search_more = ''; |
361 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
418 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
419 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
420 | + } |
|
362 | 421 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
363 | 422 | $sth_search = $Connection->db->prepare($query_search); |
364 | 423 | try { |
365 | 424 | $sth_search->execute(); |
366 | 425 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
367 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
426 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
427 | + $values['ICAOTypeCode'] = $result['icao']; |
|
428 | + } |
|
368 | 429 | } catch(PDOException $e) { |
369 | 430 | return "error : ".$e->getMessage(); |
370 | 431 | } |
@@ -377,7 +438,9 @@ discard block |
||
377 | 438 | $sth_dest->execute($query_dest_values); |
378 | 439 | } |
379 | 440 | } |
380 | - if ($globalTransaction) $Connection->db->commit(); |
|
441 | + if ($globalTransaction) { |
|
442 | + $Connection->db->commit(); |
|
443 | + } |
|
381 | 444 | } catch(PDOException $e) { |
382 | 445 | return "error : ".$e->getMessage(); |
383 | 446 | } |
@@ -413,7 +476,9 @@ discard block |
||
413 | 476 | $Connection = new Connection(); |
414 | 477 | $sth_dest = $Connection->db->prepare($query_dest); |
415 | 478 | try { |
416 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
479 | + if ($globalTransaction) { |
|
480 | + $Connection->db->beginTransaction(); |
|
481 | + } |
|
417 | 482 | $tmp = fgetcsv($fh,9999,',','"'); |
418 | 483 | while (!feof($fh)) { |
419 | 484 | $line = fgetcsv($fh,9999,',','"'); |
@@ -423,16 +488,22 @@ discard block |
||
423 | 488 | $values['registration'] = $line[0]; |
424 | 489 | $values['base'] = $line[4]; |
425 | 490 | $values['owner'] = $line[5]; |
426 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
427 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
491 | + if ($line[6] == '') { |
|
492 | + $values['date_first_reg'] = null; |
|
493 | + } else { |
|
494 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
495 | + } |
|
428 | 496 | $values['cancel'] = $line[7]; |
429 | 497 | } elseif ($country == 'EI') { |
430 | 498 | // TODO : add modeS & reg to aircraft_modes |
431 | 499 | $values['registration'] = $line[0]; |
432 | 500 | $values['base'] = $line[3]; |
433 | 501 | $values['owner'] = $line[2]; |
434 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
435 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
502 | + if ($line[1] == '') { |
|
503 | + $values['date_first_reg'] = null; |
|
504 | + } else { |
|
505 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
506 | + } |
|
436 | 507 | $values['cancel'] = ''; |
437 | 508 | } elseif ($country == 'HB') { |
438 | 509 | // TODO : add modeS & reg to aircraft_modes |
@@ -446,16 +517,22 @@ discard block |
||
446 | 517 | $values['registration'] = $line[3]; |
447 | 518 | $values['base'] = null; |
448 | 519 | $values['owner'] = $line[5]; |
449 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
520 | + if ($line[18] == '') { |
|
521 | + $values['date_first_reg'] = null; |
|
522 | + } else { |
|
523 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
524 | + } |
|
451 | 525 | $values['cancel'] = ''; |
452 | 526 | } elseif ($country == 'VH') { |
453 | 527 | // TODO : add modeS & reg to aircraft_modes |
454 | 528 | $values['registration'] = $line[0]; |
455 | 529 | $values['base'] = null; |
456 | 530 | $values['owner'] = $line[12]; |
457 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
458 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
531 | + if ($line[28] == '') { |
|
532 | + $values['date_first_reg'] = null; |
|
533 | + } else { |
|
534 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
535 | + } |
|
459 | 536 | |
460 | 537 | $values['cancel'] = $line[39]; |
461 | 538 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -474,29 +551,41 @@ discard block |
||
474 | 551 | $values['registration'] = $line[0]; |
475 | 552 | $values['base'] = null; |
476 | 553 | $values['owner'] = $line[8]; |
477 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
554 | + if ($line[7] == '') { |
|
555 | + $values['date_first_reg'] = null; |
|
556 | + } else { |
|
557 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
558 | + } |
|
479 | 559 | $values['cancel'] = ''; |
480 | 560 | } elseif ($country == 'PP') { |
481 | 561 | $values['registration'] = $line[0]; |
482 | 562 | $values['base'] = null; |
483 | 563 | $values['owner'] = $line[4]; |
484 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
485 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
564 | + if ($line[6] == '') { |
|
565 | + $values['date_first_reg'] = null; |
|
566 | + } else { |
|
567 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
568 | + } |
|
486 | 569 | $values['cancel'] = $line[7]; |
487 | 570 | } elseif ($country == 'E7') { |
488 | 571 | $values['registration'] = $line[0]; |
489 | 572 | $values['base'] = null; |
490 | 573 | $values['owner'] = $line[4]; |
491 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
492 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
574 | + if ($line[5] == '') { |
|
575 | + $values['date_first_reg'] = null; |
|
576 | + } else { |
|
577 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
578 | + } |
|
493 | 579 | $values['cancel'] = ''; |
494 | 580 | } elseif ($country == '8Q') { |
495 | 581 | $values['registration'] = $line[0]; |
496 | 582 | $values['base'] = null; |
497 | 583 | $values['owner'] = $line[3]; |
498 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
499 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
584 | + if ($line[7] == '') { |
|
585 | + $values['date_first_reg'] = null; |
|
586 | + } else { |
|
587 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
588 | + } |
|
500 | 589 | $values['cancel'] = ''; |
501 | 590 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
502 | 591 | $values['registration'] = $line[0]; |
@@ -510,7 +599,9 @@ discard block |
||
510 | 599 | $sth_dest->execute($query_dest_values); |
511 | 600 | } |
512 | 601 | } |
513 | - if ($globalTransaction) $Connection->db->commit(); |
|
602 | + if ($globalTransaction) { |
|
603 | + $Connection->db->commit(); |
|
604 | + } |
|
514 | 605 | } catch(PDOException $e) { |
515 | 606 | return "error : ".$e->getMessage(); |
516 | 607 | } |
@@ -644,25 +735,45 @@ discard block |
||
644 | 735 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
645 | 736 | $Connection = new Connection(); |
646 | 737 | $sth_dest = $Connection->db->prepare($query_dest); |
647 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
738 | + if ($globalTransaction) { |
|
739 | + $Connection->db->beginTransaction(); |
|
740 | + } |
|
648 | 741 | |
649 | 742 | $i = 0; |
650 | 743 | while($row = sparql_fetch_array($result)) |
651 | 744 | { |
652 | 745 | if ($i >= 1) { |
653 | 746 | //print_r($row); |
654 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
655 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
656 | - if (!isset($row['type'])) $row['type'] = ''; |
|
657 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
747 | + if (!isset($row['iata'])) { |
|
748 | + $row['iata'] = ''; |
|
749 | + } |
|
750 | + if (!isset($row['icao'])) { |
|
751 | + $row['icao'] = ''; |
|
752 | + } |
|
753 | + if (!isset($row['type'])) { |
|
754 | + $row['type'] = ''; |
|
755 | + } |
|
756 | + if (!isset($row['altitude'])) { |
|
757 | + $row['altitude'] = ''; |
|
758 | + } |
|
658 | 759 | if (isset($row['city_bis'])) { |
659 | 760 | $row['city'] = $row['city_bis']; |
660 | 761 | } |
661 | - if (!isset($row['city'])) $row['city'] = ''; |
|
662 | - if (!isset($row['country'])) $row['country'] = ''; |
|
663 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
664 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
665 | - if (!isset($row['name'])) continue; |
|
762 | + if (!isset($row['city'])) { |
|
763 | + $row['city'] = ''; |
|
764 | + } |
|
765 | + if (!isset($row['country'])) { |
|
766 | + $row['country'] = ''; |
|
767 | + } |
|
768 | + if (!isset($row['homepage'])) { |
|
769 | + $row['homepage'] = ''; |
|
770 | + } |
|
771 | + if (!isset($row['wikipedia_page'])) { |
|
772 | + $row['wikipedia_page'] = ''; |
|
773 | + } |
|
774 | + if (!isset($row['name'])) { |
|
775 | + continue; |
|
776 | + } |
|
666 | 777 | if (!isset($row['image'])) { |
667 | 778 | $row['image'] = ''; |
668 | 779 | $row['image_thumb'] = ''; |
@@ -698,7 +809,9 @@ discard block |
||
698 | 809 | |
699 | 810 | $i++; |
700 | 811 | } |
701 | - if ($globalTransaction) $Connection->db->commit(); |
|
812 | + if ($globalTransaction) { |
|
813 | + $Connection->db->commit(); |
|
814 | + } |
|
702 | 815 | echo "Delete duplicate rows...\n"; |
703 | 816 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
704 | 817 | try { |
@@ -710,7 +823,9 @@ discard block |
||
710 | 823 | } |
711 | 824 | |
712 | 825 | |
713 | - if ($globalDebug) echo "Insert Not available Airport...\n"; |
|
826 | + if ($globalDebug) { |
|
827 | + echo "Insert Not available Airport...\n"; |
|
828 | + } |
|
714 | 829 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
715 | 830 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
716 | 831 | $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' => ''); |
@@ -737,7 +852,9 @@ discard block |
||
737 | 852 | $delimiter = ','; |
738 | 853 | $out_file = $tmp_dir.'airports.csv'; |
739 | 854 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
740 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
855 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
856 | + return FALSE; |
|
857 | + } |
|
741 | 858 | echo "Add data from ourairports.com...\n"; |
742 | 859 | |
743 | 860 | $header = NULL; |
@@ -747,8 +864,9 @@ discard block |
||
747 | 864 | //$Connection->db->beginTransaction(); |
748 | 865 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
749 | 866 | { |
750 | - if(!$header) $header = $row; |
|
751 | - else { |
|
867 | + if(!$header) { |
|
868 | + $header = $row; |
|
869 | + } else { |
|
752 | 870 | $data = array(); |
753 | 871 | $data = array_combine($header, $row); |
754 | 872 | try { |
@@ -786,7 +904,9 @@ discard block |
||
786 | 904 | echo "Download data from another free database...\n"; |
787 | 905 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
788 | 906 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
789 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
907 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
908 | + return FALSE; |
|
909 | + } |
|
790 | 910 | update_db::unzip($out_file); |
791 | 911 | $header = NULL; |
792 | 912 | echo "Add data from another free database...\n"; |
@@ -797,8 +917,9 @@ discard block |
||
797 | 917 | //$Connection->db->beginTransaction(); |
798 | 918 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
799 | 919 | { |
800 | - if(!$header) $header = $row; |
|
801 | - else { |
|
920 | + if(!$header) { |
|
921 | + $header = $row; |
|
922 | + } else { |
|
802 | 923 | $data = $row; |
803 | 924 | |
804 | 925 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
@@ -964,7 +1085,9 @@ discard block |
||
964 | 1085 | $i = 0; |
965 | 1086 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
966 | 1087 | //$Connection->db->beginTransaction(); |
967 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1088 | + if ($globalTransaction) { |
|
1089 | + $Connection->db->beginTransaction(); |
|
1090 | + } |
|
968 | 1091 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
969 | 1092 | { |
970 | 1093 | if ($i > 0) { |
@@ -979,7 +1102,9 @@ discard block |
||
979 | 1102 | $i++; |
980 | 1103 | } |
981 | 1104 | fclose($handle); |
982 | - if ($globalTransaction) $Connection->db->commit(); |
|
1105 | + if ($globalTransaction) { |
|
1106 | + $Connection->db->commit(); |
|
1107 | + } |
|
983 | 1108 | } |
984 | 1109 | return ''; |
985 | 1110 | } |
@@ -1004,7 +1129,9 @@ discard block |
||
1004 | 1129 | $i = 0; |
1005 | 1130 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1006 | 1131 | //$Connection->db->beginTransaction(); |
1007 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1132 | + if ($globalTransaction) { |
|
1133 | + $Connection->db->beginTransaction(); |
|
1134 | + } |
|
1008 | 1135 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1009 | 1136 | { |
1010 | 1137 | if ($i > 0) { |
@@ -1019,7 +1146,9 @@ discard block |
||
1019 | 1146 | $i++; |
1020 | 1147 | } |
1021 | 1148 | fclose($handle); |
1022 | - if ($globalTransaction) $Connection->db->commit(); |
|
1149 | + if ($globalTransaction) { |
|
1150 | + $Connection->db->commit(); |
|
1151 | + } |
|
1023 | 1152 | } |
1024 | 1153 | return ''; |
1025 | 1154 | } |
@@ -1170,7 +1299,9 @@ discard block |
||
1170 | 1299 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1171 | 1300 | { |
1172 | 1301 | $i = 0; |
1173 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1302 | + if ($globalTransaction) { |
|
1303 | + $Connection->db->beginTransaction(); |
|
1304 | + } |
|
1174 | 1305 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1175 | 1306 | { |
1176 | 1307 | $i++; |
@@ -1198,7 +1329,9 @@ discard block |
||
1198 | 1329 | } |
1199 | 1330 | } |
1200 | 1331 | fclose($handle); |
1201 | - if ($globalTransaction) $Connection->db->commit(); |
|
1332 | + if ($globalTransaction) { |
|
1333 | + $Connection->db->commit(); |
|
1334 | + } |
|
1202 | 1335 | } |
1203 | 1336 | return ''; |
1204 | 1337 | } |
@@ -1221,7 +1354,9 @@ discard block |
||
1221 | 1354 | $Connection = new Connection(); |
1222 | 1355 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1223 | 1356 | { |
1224 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1357 | + if ($globalTransaction) { |
|
1358 | + $Connection->db->beginTransaction(); |
|
1359 | + } |
|
1225 | 1360 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1226 | 1361 | { |
1227 | 1362 | if(count($row) > 1) { |
@@ -1235,7 +1370,9 @@ discard block |
||
1235 | 1370 | } |
1236 | 1371 | } |
1237 | 1372 | fclose($handle); |
1238 | - if ($globalTransaction) $Connection->db->commit(); |
|
1373 | + if ($globalTransaction) { |
|
1374 | + $Connection->db->commit(); |
|
1375 | + } |
|
1239 | 1376 | } |
1240 | 1377 | return ''; |
1241 | 1378 | } |
@@ -1255,8 +1392,9 @@ discard block |
||
1255 | 1392 | } |
1256 | 1393 | |
1257 | 1394 | |
1258 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1259 | - else { |
|
1395 | + if ($globalDBdriver == 'mysql') { |
|
1396 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1397 | + } else { |
|
1260 | 1398 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
1261 | 1399 | $query = "CREATE EXTENSION postgis"; |
1262 | 1400 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1275,20 +1413,30 @@ discard block |
||
1275 | 1413 | global $tmp_dir, $globalDebug; |
1276 | 1414 | include_once('class.create_db.php'); |
1277 | 1415 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1278 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
1416 | + if ($globalDebug) { |
|
1417 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
1418 | + } |
|
1279 | 1419 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
1280 | 1420 | $error = ''; |
1281 | 1421 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1282 | - if ($globalDebug) echo "Gunzip..."; |
|
1422 | + if ($globalDebug) { |
|
1423 | + echo "Gunzip..."; |
|
1424 | + } |
|
1283 | 1425 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
1284 | - if ($globalDebug) echo "Add to DB..."; |
|
1426 | + if ($globalDebug) { |
|
1427 | + echo "Add to DB..."; |
|
1428 | + } |
|
1285 | 1429 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
1286 | 1430 | $NOTAM = new NOTAM(); |
1287 | 1431 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
1288 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1432 | + } else { |
|
1433 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1434 | + } |
|
1289 | 1435 | if ($error != '') { |
1290 | 1436 | return $error; |
1291 | - } elseif ($globalDebug) echo "Done\n"; |
|
1437 | + } elseif ($globalDebug) { |
|
1438 | + echo "Done\n"; |
|
1439 | + } |
|
1292 | 1440 | return ''; |
1293 | 1441 | } |
1294 | 1442 | |
@@ -1342,67 +1490,111 @@ discard block |
||
1342 | 1490 | //if ($globalDebug) echo "IVAO : Download..."; |
1343 | 1491 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
1344 | 1492 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
1345 | - if ($globalDebug) echo "Unzip..."; |
|
1493 | + if ($globalDebug) { |
|
1494 | + echo "Unzip..."; |
|
1495 | + } |
|
1346 | 1496 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
1347 | - if ($globalDebug) echo "Add to DB..."; |
|
1497 | + if ($globalDebug) { |
|
1498 | + echo "Add to DB..."; |
|
1499 | + } |
|
1348 | 1500 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
1349 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
1501 | + if ($globalDebug) { |
|
1502 | + echo "Copy airlines logos to airlines images directory..."; |
|
1503 | + } |
|
1350 | 1504 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
1351 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
1352 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1353 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1505 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
1506 | + $error = "Failed to copy airlines logo."; |
|
1507 | + } |
|
1508 | + } else { |
|
1509 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
1510 | + } |
|
1511 | + } else { |
|
1512 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
1513 | + } |
|
1354 | 1514 | if ($error != '') { |
1355 | 1515 | return $error; |
1356 | - } elseif ($globalDebug) echo "Done\n"; |
|
1516 | + } elseif ($globalDebug) { |
|
1517 | + echo "Done\n"; |
|
1518 | + } |
|
1357 | 1519 | return ''; |
1358 | 1520 | } |
1359 | 1521 | |
1360 | 1522 | public static function update_routes() { |
1361 | 1523 | global $tmp_dir, $globalDebug; |
1362 | 1524 | $error = ''; |
1363 | - if ($globalDebug) echo "Routes : Download..."; |
|
1525 | + if ($globalDebug) { |
|
1526 | + echo "Routes : Download..."; |
|
1527 | + } |
|
1364 | 1528 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
1365 | 1529 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
1366 | - if ($globalDebug) echo "Gunzip..."; |
|
1530 | + if ($globalDebug) { |
|
1531 | + echo "Gunzip..."; |
|
1532 | + } |
|
1367 | 1533 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
1368 | - if ($globalDebug) echo "Add to DB..."; |
|
1534 | + if ($globalDebug) { |
|
1535 | + echo "Add to DB..."; |
|
1536 | + } |
|
1369 | 1537 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
1370 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1538 | + } else { |
|
1539 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
1540 | + } |
|
1371 | 1541 | if ($error != '') { |
1372 | 1542 | return $error; |
1373 | - } elseif ($globalDebug) echo "Done\n"; |
|
1543 | + } elseif ($globalDebug) { |
|
1544 | + echo "Done\n"; |
|
1545 | + } |
|
1374 | 1546 | return ''; |
1375 | 1547 | } |
1376 | 1548 | public static function update_oneworld() { |
1377 | 1549 | global $tmp_dir, $globalDebug; |
1378 | 1550 | $error = ''; |
1379 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
1551 | + if ($globalDebug) { |
|
1552 | + echo "Schedules Oneworld : Download..."; |
|
1553 | + } |
|
1380 | 1554 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
1381 | 1555 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
1382 | - if ($globalDebug) echo "Gunzip..."; |
|
1556 | + if ($globalDebug) { |
|
1557 | + echo "Gunzip..."; |
|
1558 | + } |
|
1383 | 1559 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
1384 | - if ($globalDebug) echo "Add to DB..."; |
|
1560 | + if ($globalDebug) { |
|
1561 | + echo "Add to DB..."; |
|
1562 | + } |
|
1385 | 1563 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
1386 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1564 | + } else { |
|
1565 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
1566 | + } |
|
1387 | 1567 | if ($error != '') { |
1388 | 1568 | return $error; |
1389 | - } elseif ($globalDebug) echo "Done\n"; |
|
1569 | + } elseif ($globalDebug) { |
|
1570 | + echo "Done\n"; |
|
1571 | + } |
|
1390 | 1572 | return ''; |
1391 | 1573 | } |
1392 | 1574 | public static function update_skyteam() { |
1393 | 1575 | global $tmp_dir, $globalDebug; |
1394 | 1576 | $error = ''; |
1395 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
1577 | + if ($globalDebug) { |
|
1578 | + echo "Schedules Skyteam : Download..."; |
|
1579 | + } |
|
1396 | 1580 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
1397 | 1581 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
1398 | - if ($globalDebug) echo "Gunzip..."; |
|
1582 | + if ($globalDebug) { |
|
1583 | + echo "Gunzip..."; |
|
1584 | + } |
|
1399 | 1585 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
1400 | - if ($globalDebug) echo "Add to DB..."; |
|
1586 | + if ($globalDebug) { |
|
1587 | + echo "Add to DB..."; |
|
1588 | + } |
|
1401 | 1589 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
1402 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1590 | + } else { |
|
1591 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
1592 | + } |
|
1403 | 1593 | if ($error != '') { |
1404 | 1594 | return $error; |
1405 | - } elseif ($globalDebug) echo "Done\n"; |
|
1595 | + } elseif ($globalDebug) { |
|
1596 | + echo "Done\n"; |
|
1597 | + } |
|
1406 | 1598 | return ''; |
1407 | 1599 | } |
1408 | 1600 | public static function update_ModeS() { |
@@ -1419,291 +1611,509 @@ discard block |
||
1419 | 1611 | exit; |
1420 | 1612 | } elseif ($globalDebug) echo "Done\n"; |
1421 | 1613 | */ |
1422 | - if ($globalDebug) echo "Modes : Download..."; |
|
1423 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1614 | + if ($globalDebug) { |
|
1615 | + echo "Modes : Download..."; |
|
1616 | + } |
|
1617 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
1424 | 1618 | update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
1425 | 1619 | |
1426 | 1620 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
1427 | 1621 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
1428 | - if ($globalDebug) echo "Unzip..."; |
|
1429 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1622 | + if ($globalDebug) { |
|
1623 | + echo "Unzip..."; |
|
1624 | + } |
|
1625 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
1430 | 1626 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
1431 | - if ($globalDebug) echo "Add to DB..."; |
|
1627 | + if ($globalDebug) { |
|
1628 | + echo "Add to DB..."; |
|
1629 | + } |
|
1432 | 1630 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
1433 | 1631 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
1434 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1632 | + } else { |
|
1633 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
1634 | + } |
|
1435 | 1635 | if ($error != '') { |
1436 | 1636 | return $error; |
1437 | - } elseif ($globalDebug) echo "Done\n"; |
|
1637 | + } elseif ($globalDebug) { |
|
1638 | + echo "Done\n"; |
|
1639 | + } |
|
1438 | 1640 | return ''; |
1439 | 1641 | } |
1440 | 1642 | |
1441 | 1643 | public static function update_ModeS_flarm() { |
1442 | 1644 | global $tmp_dir, $globalDebug; |
1443 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
1645 | + if ($globalDebug) { |
|
1646 | + echo "Modes Flarmnet: Download..."; |
|
1647 | + } |
|
1444 | 1648 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
1445 | 1649 | if (file_exists($tmp_dir.'data.fln')) { |
1446 | - if ($globalDebug) echo "Add to DB..."; |
|
1650 | + if ($globalDebug) { |
|
1651 | + echo "Add to DB..."; |
|
1652 | + } |
|
1447 | 1653 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
1448 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1654 | + } else { |
|
1655 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
1656 | + } |
|
1449 | 1657 | if ($error != '') { |
1450 | 1658 | return $error; |
1451 | - } elseif ($globalDebug) echo "Done\n"; |
|
1659 | + } elseif ($globalDebug) { |
|
1660 | + echo "Done\n"; |
|
1661 | + } |
|
1452 | 1662 | return ''; |
1453 | 1663 | } |
1454 | 1664 | |
1455 | 1665 | public static function update_ModeS_ogn() { |
1456 | 1666 | global $tmp_dir, $globalDebug; |
1457 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
1667 | + if ($globalDebug) { |
|
1668 | + echo "Modes OGN: Download..."; |
|
1669 | + } |
|
1458 | 1670 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
1459 | 1671 | if (file_exists($tmp_dir.'ogn.csv')) { |
1460 | - if ($globalDebug) echo "Add to DB..."; |
|
1672 | + if ($globalDebug) { |
|
1673 | + echo "Add to DB..."; |
|
1674 | + } |
|
1461 | 1675 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
1462 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1676 | + } else { |
|
1677 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
1678 | + } |
|
1463 | 1679 | if ($error != '') { |
1464 | 1680 | return $error; |
1465 | - } elseif ($globalDebug) echo "Done\n"; |
|
1681 | + } elseif ($globalDebug) { |
|
1682 | + echo "Done\n"; |
|
1683 | + } |
|
1466 | 1684 | return ''; |
1467 | 1685 | } |
1468 | 1686 | |
1469 | 1687 | public static function update_owner() { |
1470 | 1688 | global $tmp_dir, $globalDebug; |
1471 | 1689 | |
1472 | - if ($globalDebug) echo "Owner France: Download..."; |
|
1690 | + if ($globalDebug) { |
|
1691 | + echo "Owner France: Download..."; |
|
1692 | + } |
|
1473 | 1693 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
1474 | 1694 | if (file_exists($tmp_dir.'owner_f.csv')) { |
1475 | - if ($globalDebug) echo "Add to DB..."; |
|
1695 | + if ($globalDebug) { |
|
1696 | + echo "Add to DB..."; |
|
1697 | + } |
|
1476 | 1698 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
1477 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1699 | + } else { |
|
1700 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
1701 | + } |
|
1478 | 1702 | if ($error != '') { |
1479 | 1703 | return $error; |
1480 | - } elseif ($globalDebug) echo "Done\n"; |
|
1704 | + } elseif ($globalDebug) { |
|
1705 | + echo "Done\n"; |
|
1706 | + } |
|
1481 | 1707 | |
1482 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
1708 | + if ($globalDebug) { |
|
1709 | + echo "Owner Ireland: Download..."; |
|
1710 | + } |
|
1483 | 1711 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
1484 | 1712 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
1485 | - if ($globalDebug) echo "Add to DB..."; |
|
1713 | + if ($globalDebug) { |
|
1714 | + echo "Add to DB..."; |
|
1715 | + } |
|
1486 | 1716 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
1487 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1717 | + } else { |
|
1718 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
1719 | + } |
|
1488 | 1720 | if ($error != '') { |
1489 | 1721 | return $error; |
1490 | - } elseif ($globalDebug) echo "Done\n"; |
|
1491 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
1722 | + } elseif ($globalDebug) { |
|
1723 | + echo "Done\n"; |
|
1724 | + } |
|
1725 | + if ($globalDebug) { |
|
1726 | + echo "Owner Switzerland: Download..."; |
|
1727 | + } |
|
1492 | 1728 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
1493 | 1729 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
1494 | - if ($globalDebug) echo "Add to DB..."; |
|
1730 | + if ($globalDebug) { |
|
1731 | + echo "Add to DB..."; |
|
1732 | + } |
|
1495 | 1733 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
1496 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1734 | + } else { |
|
1735 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
1736 | + } |
|
1497 | 1737 | if ($error != '') { |
1498 | 1738 | return $error; |
1499 | - } elseif ($globalDebug) echo "Done\n"; |
|
1500 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
1739 | + } elseif ($globalDebug) { |
|
1740 | + echo "Done\n"; |
|
1741 | + } |
|
1742 | + if ($globalDebug) { |
|
1743 | + echo "Owner Czech Republic: Download..."; |
|
1744 | + } |
|
1501 | 1745 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
1502 | 1746 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
1503 | - if ($globalDebug) echo "Add to DB..."; |
|
1747 | + if ($globalDebug) { |
|
1748 | + echo "Add to DB..."; |
|
1749 | + } |
|
1504 | 1750 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
1505 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
1751 | + } else { |
|
1752 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
1753 | + } |
|
1506 | 1754 | if ($error != '') { |
1507 | 1755 | return $error; |
1508 | - } elseif ($globalDebug) echo "Done\n"; |
|
1509 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
1756 | + } elseif ($globalDebug) { |
|
1757 | + echo "Done\n"; |
|
1758 | + } |
|
1759 | + if ($globalDebug) { |
|
1760 | + echo "Owner Australia: Download..."; |
|
1761 | + } |
|
1510 | 1762 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
1511 | 1763 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
1512 | - if ($globalDebug) echo "Add to DB..."; |
|
1764 | + if ($globalDebug) { |
|
1765 | + echo "Add to DB..."; |
|
1766 | + } |
|
1513 | 1767 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
1514 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
1768 | + } else { |
|
1769 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
1770 | + } |
|
1515 | 1771 | if ($error != '') { |
1516 | 1772 | return $error; |
1517 | - } elseif ($globalDebug) echo "Done\n"; |
|
1518 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
1773 | + } elseif ($globalDebug) { |
|
1774 | + echo "Done\n"; |
|
1775 | + } |
|
1776 | + if ($globalDebug) { |
|
1777 | + echo "Owner Austria: Download..."; |
|
1778 | + } |
|
1519 | 1779 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
1520 | 1780 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
1521 | - if ($globalDebug) echo "Add to DB..."; |
|
1781 | + if ($globalDebug) { |
|
1782 | + echo "Add to DB..."; |
|
1783 | + } |
|
1522 | 1784 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
1523 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
1785 | + } else { |
|
1786 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
1787 | + } |
|
1524 | 1788 | if ($error != '') { |
1525 | 1789 | return $error; |
1526 | - } elseif ($globalDebug) echo "Done\n"; |
|
1527 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
1790 | + } elseif ($globalDebug) { |
|
1791 | + echo "Done\n"; |
|
1792 | + } |
|
1793 | + if ($globalDebug) { |
|
1794 | + echo "Owner Chile: Download..."; |
|
1795 | + } |
|
1528 | 1796 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
1529 | 1797 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
1530 | - if ($globalDebug) echo "Add to DB..."; |
|
1798 | + if ($globalDebug) { |
|
1799 | + echo "Add to DB..."; |
|
1800 | + } |
|
1531 | 1801 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
1532 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
1802 | + } else { |
|
1803 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
1804 | + } |
|
1533 | 1805 | if ($error != '') { |
1534 | 1806 | return $error; |
1535 | - } elseif ($globalDebug) echo "Done\n"; |
|
1536 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
1807 | + } elseif ($globalDebug) { |
|
1808 | + echo "Done\n"; |
|
1809 | + } |
|
1810 | + if ($globalDebug) { |
|
1811 | + echo "Owner Colombia: Download..."; |
|
1812 | + } |
|
1537 | 1813 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
1538 | 1814 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
1539 | - if ($globalDebug) echo "Add to DB..."; |
|
1815 | + if ($globalDebug) { |
|
1816 | + echo "Add to DB..."; |
|
1817 | + } |
|
1540 | 1818 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
1541 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
1819 | + } else { |
|
1820 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
1821 | + } |
|
1542 | 1822 | if ($error != '') { |
1543 | 1823 | return $error; |
1544 | - } elseif ($globalDebug) echo "Done\n"; |
|
1545 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
1824 | + } elseif ($globalDebug) { |
|
1825 | + echo "Done\n"; |
|
1826 | + } |
|
1827 | + if ($globalDebug) { |
|
1828 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
1829 | + } |
|
1546 | 1830 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
1547 | 1831 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
1548 | - if ($globalDebug) echo "Add to DB..."; |
|
1832 | + if ($globalDebug) { |
|
1833 | + echo "Add to DB..."; |
|
1834 | + } |
|
1549 | 1835 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
1550 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
1836 | + } else { |
|
1837 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
1838 | + } |
|
1551 | 1839 | if ($error != '') { |
1552 | 1840 | return $error; |
1553 | - } elseif ($globalDebug) echo "Done\n"; |
|
1554 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
1841 | + } elseif ($globalDebug) { |
|
1842 | + echo "Done\n"; |
|
1843 | + } |
|
1844 | + if ($globalDebug) { |
|
1845 | + echo "Owner Brazil: Download..."; |
|
1846 | + } |
|
1555 | 1847 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
1556 | 1848 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
1557 | - if ($globalDebug) echo "Add to DB..."; |
|
1849 | + if ($globalDebug) { |
|
1850 | + echo "Add to DB..."; |
|
1851 | + } |
|
1558 | 1852 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
1559 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
1853 | + } else { |
|
1854 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
1855 | + } |
|
1560 | 1856 | if ($error != '') { |
1561 | 1857 | return $error; |
1562 | - } elseif ($globalDebug) echo "Done\n"; |
|
1563 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
1858 | + } elseif ($globalDebug) { |
|
1859 | + echo "Done\n"; |
|
1860 | + } |
|
1861 | + if ($globalDebug) { |
|
1862 | + echo "Owner Cayman Islands: Download..."; |
|
1863 | + } |
|
1564 | 1864 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
1565 | 1865 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
1566 | - if ($globalDebug) echo "Add to DB..."; |
|
1866 | + if ($globalDebug) { |
|
1867 | + echo "Add to DB..."; |
|
1868 | + } |
|
1567 | 1869 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
1568 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
1870 | + } else { |
|
1871 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
1872 | + } |
|
1569 | 1873 | if ($error != '') { |
1570 | 1874 | return $error; |
1571 | - } elseif ($globalDebug) echo "Done\n"; |
|
1572 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
1875 | + } elseif ($globalDebug) { |
|
1876 | + echo "Done\n"; |
|
1877 | + } |
|
1878 | + if ($globalDebug) { |
|
1879 | + echo "Owner Croatia: Download..."; |
|
1880 | + } |
|
1573 | 1881 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
1574 | 1882 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
1575 | - if ($globalDebug) echo "Add to DB..."; |
|
1883 | + if ($globalDebug) { |
|
1884 | + echo "Add to DB..."; |
|
1885 | + } |
|
1576 | 1886 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
1577 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
1887 | + } else { |
|
1888 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
1889 | + } |
|
1578 | 1890 | if ($error != '') { |
1579 | 1891 | return $error; |
1580 | - } elseif ($globalDebug) echo "Done\n"; |
|
1581 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
1892 | + } elseif ($globalDebug) { |
|
1893 | + echo "Done\n"; |
|
1894 | + } |
|
1895 | + if ($globalDebug) { |
|
1896 | + echo "Owner Luxembourg: Download..."; |
|
1897 | + } |
|
1582 | 1898 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
1583 | 1899 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
1584 | - if ($globalDebug) echo "Add to DB..."; |
|
1900 | + if ($globalDebug) { |
|
1901 | + echo "Add to DB..."; |
|
1902 | + } |
|
1585 | 1903 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
1586 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
1904 | + } else { |
|
1905 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
1906 | + } |
|
1587 | 1907 | if ($error != '') { |
1588 | 1908 | return $error; |
1589 | - } elseif ($globalDebug) echo "Done\n"; |
|
1590 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
1909 | + } elseif ($globalDebug) { |
|
1910 | + echo "Done\n"; |
|
1911 | + } |
|
1912 | + if ($globalDebug) { |
|
1913 | + echo "Owner Maldives: Download..."; |
|
1914 | + } |
|
1591 | 1915 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
1592 | 1916 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
1593 | - if ($globalDebug) echo "Add to DB..."; |
|
1917 | + if ($globalDebug) { |
|
1918 | + echo "Add to DB..."; |
|
1919 | + } |
|
1594 | 1920 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
1595 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
1921 | + } else { |
|
1922 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
1923 | + } |
|
1596 | 1924 | if ($error != '') { |
1597 | 1925 | return $error; |
1598 | - } elseif ($globalDebug) echo "Done\n"; |
|
1599 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
1926 | + } elseif ($globalDebug) { |
|
1927 | + echo "Done\n"; |
|
1928 | + } |
|
1929 | + if ($globalDebug) { |
|
1930 | + echo "Owner New Zealand: Download..."; |
|
1931 | + } |
|
1600 | 1932 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
1601 | 1933 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
1602 | - if ($globalDebug) echo "Add to DB..."; |
|
1934 | + if ($globalDebug) { |
|
1935 | + echo "Add to DB..."; |
|
1936 | + } |
|
1603 | 1937 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
1604 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
1938 | + } else { |
|
1939 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
1940 | + } |
|
1605 | 1941 | if ($error != '') { |
1606 | 1942 | return $error; |
1607 | - } elseif ($globalDebug) echo "Done\n"; |
|
1608 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
1943 | + } elseif ($globalDebug) { |
|
1944 | + echo "Done\n"; |
|
1945 | + } |
|
1946 | + if ($globalDebug) { |
|
1947 | + echo "Owner Papua New Guinea: Download..."; |
|
1948 | + } |
|
1609 | 1949 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
1610 | 1950 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
1611 | - if ($globalDebug) echo "Add to DB..."; |
|
1951 | + if ($globalDebug) { |
|
1952 | + echo "Add to DB..."; |
|
1953 | + } |
|
1612 | 1954 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
1613 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
1955 | + } else { |
|
1956 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
1957 | + } |
|
1614 | 1958 | if ($error != '') { |
1615 | 1959 | return $error; |
1616 | - } elseif ($globalDebug) echo "Done\n"; |
|
1617 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
1960 | + } elseif ($globalDebug) { |
|
1961 | + echo "Done\n"; |
|
1962 | + } |
|
1963 | + if ($globalDebug) { |
|
1964 | + echo "Owner Slovakia: Download..."; |
|
1965 | + } |
|
1618 | 1966 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
1619 | 1967 | if (file_exists($tmp_dir.'owner_om.csv')) { |
1620 | - if ($globalDebug) echo "Add to DB..."; |
|
1968 | + if ($globalDebug) { |
|
1969 | + echo "Add to DB..."; |
|
1970 | + } |
|
1621 | 1971 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
1622 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
1972 | + } else { |
|
1973 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
1974 | + } |
|
1623 | 1975 | if ($error != '') { |
1624 | 1976 | return $error; |
1625 | - } elseif ($globalDebug) echo "Done\n"; |
|
1626 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
1977 | + } elseif ($globalDebug) { |
|
1978 | + echo "Done\n"; |
|
1979 | + } |
|
1980 | + if ($globalDebug) { |
|
1981 | + echo "Owner Ecuador: Download..."; |
|
1982 | + } |
|
1627 | 1983 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
1628 | 1984 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
1629 | - if ($globalDebug) echo "Add to DB..."; |
|
1985 | + if ($globalDebug) { |
|
1986 | + echo "Add to DB..."; |
|
1987 | + } |
|
1630 | 1988 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
1631 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
1989 | + } else { |
|
1990 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
1991 | + } |
|
1632 | 1992 | if ($error != '') { |
1633 | 1993 | return $error; |
1634 | - } elseif ($globalDebug) echo "Done\n"; |
|
1635 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
1994 | + } elseif ($globalDebug) { |
|
1995 | + echo "Done\n"; |
|
1996 | + } |
|
1997 | + if ($globalDebug) { |
|
1998 | + echo "Owner Iceland: Download..."; |
|
1999 | + } |
|
1636 | 2000 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
1637 | 2001 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
1638 | - if ($globalDebug) echo "Add to DB..."; |
|
2002 | + if ($globalDebug) { |
|
2003 | + echo "Add to DB..."; |
|
2004 | + } |
|
1639 | 2005 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
1640 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2006 | + } else { |
|
2007 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2008 | + } |
|
1641 | 2009 | if ($error != '') { |
1642 | 2010 | return $error; |
1643 | - } elseif ($globalDebug) echo "Done\n"; |
|
2011 | + } elseif ($globalDebug) { |
|
2012 | + echo "Done\n"; |
|
2013 | + } |
|
1644 | 2014 | return ''; |
1645 | 2015 | } |
1646 | 2016 | |
1647 | 2017 | public static function update_translation() { |
1648 | 2018 | global $tmp_dir, $globalDebug; |
1649 | 2019 | $error = ''; |
1650 | - if ($globalDebug) echo "Translation : Download..."; |
|
2020 | + if ($globalDebug) { |
|
2021 | + echo "Translation : Download..."; |
|
2022 | + } |
|
1651 | 2023 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
1652 | 2024 | if (file_exists($tmp_dir.'translation.zip')) { |
1653 | - if ($globalDebug) echo "Unzip..."; |
|
2025 | + if ($globalDebug) { |
|
2026 | + echo "Unzip..."; |
|
2027 | + } |
|
1654 | 2028 | update_db::unzip($tmp_dir.'translation.zip'); |
1655 | - if ($globalDebug) echo "Add to DB..."; |
|
2029 | + if ($globalDebug) { |
|
2030 | + echo "Add to DB..."; |
|
2031 | + } |
|
1656 | 2032 | $error = update_db::translation(); |
1657 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2033 | + } else { |
|
2034 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2035 | + } |
|
1658 | 2036 | if ($error != '') { |
1659 | 2037 | return $error; |
1660 | - } elseif ($globalDebug) echo "Done\n"; |
|
2038 | + } elseif ($globalDebug) { |
|
2039 | + echo "Done\n"; |
|
2040 | + } |
|
1661 | 2041 | return ''; |
1662 | 2042 | } |
1663 | 2043 | |
1664 | 2044 | public static function update_translation_fam() { |
1665 | 2045 | global $tmp_dir, $globalDebug; |
1666 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
2046 | + if ($globalDebug) { |
|
2047 | + echo "Translation from FlightAirMap website : Download..."; |
|
2048 | + } |
|
1667 | 2049 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
1668 | 2050 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
1669 | - if ($globalDebug) echo "Gunzip..."; |
|
2051 | + if ($globalDebug) { |
|
2052 | + echo "Gunzip..."; |
|
2053 | + } |
|
1670 | 2054 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
1671 | - if ($globalDebug) echo "Add to DB..."; |
|
2055 | + if ($globalDebug) { |
|
2056 | + echo "Add to DB..."; |
|
2057 | + } |
|
1672 | 2058 | $error = update_db::translation_fam(); |
1673 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2059 | + } else { |
|
2060 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2061 | + } |
|
1674 | 2062 | if ($error != '') { |
1675 | 2063 | return $error; |
1676 | - } elseif ($globalDebug) echo "Done\n"; |
|
2064 | + } elseif ($globalDebug) { |
|
2065 | + echo "Done\n"; |
|
2066 | + } |
|
1677 | 2067 | return ''; |
1678 | 2068 | } |
1679 | 2069 | public static function update_ModeS_fam() { |
1680 | 2070 | global $tmp_dir, $globalDebug; |
1681 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
2071 | + if ($globalDebug) { |
|
2072 | + echo "ModeS from FlightAirMap website : Download..."; |
|
2073 | + } |
|
1682 | 2074 | update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
1683 | 2075 | if (file_exists($tmp_dir.'modes.tsv.gz')) { |
1684 | - if ($globalDebug) echo "Gunzip..."; |
|
2076 | + if ($globalDebug) { |
|
2077 | + echo "Gunzip..."; |
|
2078 | + } |
|
1685 | 2079 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
1686 | - if ($globalDebug) echo "Add to DB..."; |
|
2080 | + if ($globalDebug) { |
|
2081 | + echo "Add to DB..."; |
|
2082 | + } |
|
1687 | 2083 | $error = update_db::modes_fam(); |
1688 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2084 | + } else { |
|
2085 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2086 | + } |
|
1689 | 2087 | if ($error != '') { |
1690 | 2088 | return $error; |
1691 | - } elseif ($globalDebug) echo "Done\n"; |
|
2089 | + } elseif ($globalDebug) { |
|
2090 | + echo "Done\n"; |
|
2091 | + } |
|
1692 | 2092 | return ''; |
1693 | 2093 | } |
1694 | 2094 | public static function update_routes_fam() { |
1695 | 2095 | global $tmp_dir, $globalDebug; |
1696 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
2096 | + if ($globalDebug) { |
|
2097 | + echo "Routes from FlightAirMap website : Download..."; |
|
2098 | + } |
|
1697 | 2099 | update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
1698 | 2100 | if (file_exists($tmp_dir.'routes.tsv.gz')) { |
1699 | - if ($globalDebug) echo "Gunzip..."; |
|
2101 | + if ($globalDebug) { |
|
2102 | + echo "Gunzip..."; |
|
2103 | + } |
|
1700 | 2104 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
1701 | - if ($globalDebug) echo "Add to DB..."; |
|
2105 | + if ($globalDebug) { |
|
2106 | + echo "Add to DB..."; |
|
2107 | + } |
|
1702 | 2108 | $error = update_db::routes_fam(); |
1703 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
2109 | + } else { |
|
2110 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
2111 | + } |
|
1704 | 2112 | if ($error != '') { |
1705 | 2113 | return $error; |
1706 | - } elseif ($globalDebug) echo "Done\n"; |
|
2114 | + } elseif ($globalDebug) { |
|
2115 | + echo "Done\n"; |
|
2116 | + } |
|
1707 | 2117 | return ''; |
1708 | 2118 | } |
1709 | 2119 | |
@@ -1711,7 +2121,9 @@ discard block |
||
1711 | 2121 | global $tmp_dir, $globalDebug, $globalDBdriver; |
1712 | 2122 | include_once('class.create_db.php'); |
1713 | 2123 | $error = ''; |
1714 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
2124 | + if ($globalDebug) { |
|
2125 | + echo "Airspace from FlightAirMap website : Download..."; |
|
2126 | + } |
|
1715 | 2127 | if ($globalDBdriver == 'mysql') { |
1716 | 2128 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
1717 | 2129 | } else { |
@@ -1727,9 +2139,13 @@ discard block |
||
1727 | 2139 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
1728 | 2140 | } |
1729 | 2141 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
1730 | - if ($globalDebug) echo "Gunzip..."; |
|
2142 | + if ($globalDebug) { |
|
2143 | + echo "Gunzip..."; |
|
2144 | + } |
|
1731 | 2145 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
1732 | - if ($globalDebug) echo "Add to DB..."; |
|
2146 | + if ($globalDebug) { |
|
2147 | + echo "Add to DB..."; |
|
2148 | + } |
|
1733 | 2149 | $Connection = new Connection(); |
1734 | 2150 | if ($Connection->tableExists('airspace')) { |
1735 | 2151 | $query = 'DROP TABLE airspace'; |
@@ -1742,31 +2158,47 @@ discard block |
||
1742 | 2158 | } |
1743 | 2159 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
1744 | 2160 | update_db::insert_airspace_version($airspace_md5); |
1745 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2161 | + } else { |
|
2162 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
2163 | + } |
|
1746 | 2164 | } |
1747 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2165 | + } else { |
|
2166 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
2167 | + } |
|
1748 | 2168 | if ($error != '') { |
1749 | 2169 | return $error; |
1750 | - } elseif ($globalDebug) echo "Done\n"; |
|
2170 | + } elseif ($globalDebug) { |
|
2171 | + echo "Done\n"; |
|
2172 | + } |
|
1751 | 2173 | return ''; |
1752 | 2174 | } |
1753 | 2175 | |
1754 | 2176 | public static function update_tle() { |
1755 | 2177 | global $tmp_dir, $globalDebug; |
1756 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
2178 | + if ($globalDebug) { |
|
2179 | + echo "Download TLE : Download..."; |
|
2180 | + } |
|
1757 | 2181 | $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 | 2182 | '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 | 2183 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
1760 | 2184 | foreach ($alltle as $filename) { |
1761 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
2185 | + if ($globalDebug) { |
|
2186 | + echo "downloading ".$filename.'...'; |
|
2187 | + } |
|
1762 | 2188 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
1763 | 2189 | if (file_exists($tmp_dir.$filename)) { |
1764 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
2190 | + if ($globalDebug) { |
|
2191 | + echo "Add to DB ".$filename."..."; |
|
2192 | + } |
|
1765 | 2193 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
1766 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2194 | + } else { |
|
2195 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
2196 | + } |
|
1767 | 2197 | if ($error != '') { |
1768 | 2198 | echo $error."\n"; |
1769 | - } elseif ($globalDebug) echo "Done\n"; |
|
2199 | + } elseif ($globalDebug) { |
|
2200 | + echo "Done\n"; |
|
2201 | + } |
|
1770 | 2202 | } |
1771 | 2203 | return ''; |
1772 | 2204 | } |
@@ -1774,10 +2206,14 @@ discard block |
||
1774 | 2206 | public static function update_models() { |
1775 | 2207 | global $tmp_dir, $globalDebug; |
1776 | 2208 | $error = ''; |
1777 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
2209 | + if ($globalDebug) { |
|
2210 | + echo "Models from FlightAirMap website : Download..."; |
|
2211 | + } |
|
1778 | 2212 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
1779 | 2213 | if (file_exists($tmp_dir.'models.md5sum')) { |
1780 | - if ($globalDebug) echo "Check files...\n"; |
|
2214 | + if ($globalDebug) { |
|
2215 | + echo "Check files...\n"; |
|
2216 | + } |
|
1781 | 2217 | $newmodelsdb = array(); |
1782 | 2218 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
1783 | 2219 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -1796,25 +2232,35 @@ discard block |
||
1796 | 2232 | } |
1797 | 2233 | $diff = array_diff($newmodelsdb,$modelsdb); |
1798 | 2234 | foreach ($diff as $key => $value) { |
1799 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
2235 | + if ($globalDebug) { |
|
2236 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
2237 | + } |
|
1800 | 2238 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
1801 | 2239 | |
1802 | 2240 | } |
1803 | 2241 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
1804 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2242 | + } else { |
|
2243 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2244 | + } |
|
1805 | 2245 | if ($error != '') { |
1806 | 2246 | return $error; |
1807 | - } elseif ($globalDebug) echo "Done\n"; |
|
2247 | + } elseif ($globalDebug) { |
|
2248 | + echo "Done\n"; |
|
2249 | + } |
|
1808 | 2250 | return ''; |
1809 | 2251 | } |
1810 | 2252 | |
1811 | 2253 | public static function update_space_models() { |
1812 | 2254 | global $tmp_dir, $globalDebug; |
1813 | 2255 | $error = ''; |
1814 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
2256 | + if ($globalDebug) { |
|
2257 | + echo "Space models from FlightAirMap website : Download..."; |
|
2258 | + } |
|
1815 | 2259 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
1816 | 2260 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
1817 | - if ($globalDebug) echo "Check files...\n"; |
|
2261 | + if ($globalDebug) { |
|
2262 | + echo "Check files...\n"; |
|
2263 | + } |
|
1818 | 2264 | $newmodelsdb = array(); |
1819 | 2265 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
1820 | 2266 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -1833,15 +2279,21 @@ discard block |
||
1833 | 2279 | } |
1834 | 2280 | $diff = array_diff($newmodelsdb,$modelsdb); |
1835 | 2281 | foreach ($diff as $key => $value) { |
1836 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
2282 | + if ($globalDebug) { |
|
2283 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
2284 | + } |
|
1837 | 2285 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
1838 | 2286 | |
1839 | 2287 | } |
1840 | 2288 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
1841 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2289 | + } else { |
|
2290 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
2291 | + } |
|
1842 | 2292 | if ($error != '') { |
1843 | 2293 | return $error; |
1844 | - } elseif ($globalDebug) echo "Done\n"; |
|
2294 | + } elseif ($globalDebug) { |
|
2295 | + echo "Done\n"; |
|
2296 | + } |
|
1845 | 2297 | return ''; |
1846 | 2298 | } |
1847 | 2299 | |
@@ -1884,7 +2336,9 @@ discard block |
||
1884 | 2336 | } |
1885 | 2337 | |
1886 | 2338 | $error = ''; |
1887 | - if ($globalDebug) echo "Notam : Download..."; |
|
2339 | + if ($globalDebug) { |
|
2340 | + echo "Notam : Download..."; |
|
2341 | + } |
|
1888 | 2342 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
1889 | 2343 | if (file_exists($tmp_dir.'notam.rss')) { |
1890 | 2344 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -1899,14 +2353,30 @@ discard block |
||
1899 | 2353 | $data['fir'] = $q[0]; |
1900 | 2354 | $data['code'] = $q[1]; |
1901 | 2355 | $ifrvfr = $q[2]; |
1902 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
1903 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
1904 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
1905 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
1906 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
1907 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
1908 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
1909 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
2356 | + if ($ifrvfr == 'IV') { |
|
2357 | + $data['rules'] = 'IFR/VFR'; |
|
2358 | + } |
|
2359 | + if ($ifrvfr == 'I') { |
|
2360 | + $data['rules'] = 'IFR'; |
|
2361 | + } |
|
2362 | + if ($ifrvfr == 'V') { |
|
2363 | + $data['rules'] = 'VFR'; |
|
2364 | + } |
|
2365 | + if ($q[4] == 'A') { |
|
2366 | + $data['scope'] = 'Airport warning'; |
|
2367 | + } |
|
2368 | + if ($q[4] == 'E') { |
|
2369 | + $data['scope'] = 'Enroute warning'; |
|
2370 | + } |
|
2371 | + if ($q[4] == 'W') { |
|
2372 | + $data['scope'] = 'Navigation warning'; |
|
2373 | + } |
|
2374 | + if ($q[4] == 'AE') { |
|
2375 | + $data['scope'] = 'Airport/Enroute warning'; |
|
2376 | + } |
|
2377 | + if ($q[4] == 'AW') { |
|
2378 | + $data['scope'] = 'Airport/Navigation warning'; |
|
2379 | + } |
|
1910 | 2380 | //$data['scope'] = $q[4]; |
1911 | 2381 | $data['lower_limit'] = $q[5]; |
1912 | 2382 | $data['upper_limit'] = $q[6]; |
@@ -1914,8 +2384,12 @@ discard block |
||
1914 | 2384 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
1915 | 2385 | $latitude = $Common->convertDec($las,'latitude'); |
1916 | 2386 | $longitude = $Common->convertDec($lns,'longitude'); |
1917 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
1918 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
2387 | + if ($lac == 'S') { |
|
2388 | + $latitude = '-'.$latitude; |
|
2389 | + } |
|
2390 | + if ($lnc == 'W') { |
|
2391 | + $longitude = '-'.$longitude; |
|
2392 | + } |
|
1919 | 2393 | $data['center_latitude'] = $latitude; |
1920 | 2394 | $data['center_longitude'] = $longitude; |
1921 | 2395 | $data['radius'] = intval($radius); |
@@ -1945,10 +2419,14 @@ discard block |
||
1945 | 2419 | $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 | 2420 | unset($data); |
1947 | 2421 | } |
1948 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2422 | + } else { |
|
2423 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
2424 | + } |
|
1949 | 2425 | if ($error != '') { |
1950 | 2426 | return $error; |
1951 | - } elseif ($globalDebug) echo "Done\n"; |
|
2427 | + } elseif ($globalDebug) { |
|
2428 | + echo "Done\n"; |
|
2429 | + } |
|
1952 | 2430 | return ''; |
1953 | 2431 | } |
1954 | 2432 | |
@@ -1973,7 +2451,9 @@ discard block |
||
1973 | 2451 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
1974 | 2452 | $airspace_json = json_decode($airspace_lst,true); |
1975 | 2453 | foreach ($airspace_json['records'] as $airspace) { |
1976 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
2454 | + if ($globalDebug) { |
|
2455 | + echo $airspace['name']."...\n"; |
|
2456 | + } |
|
1977 | 2457 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
1978 | 2458 | if (file_exists($tmp_dir.$airspace['name'])) { |
1979 | 2459 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -2002,8 +2482,11 @@ discard block |
||
2002 | 2482 | return "error : ".$e->getMessage(); |
2003 | 2483 | } |
2004 | 2484 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2005 | - if ($row['nb'] > 0) return false; |
|
2006 | - else return true; |
|
2485 | + if ($row['nb'] > 0) { |
|
2486 | + return false; |
|
2487 | + } else { |
|
2488 | + return true; |
|
2489 | + } |
|
2007 | 2490 | } |
2008 | 2491 | |
2009 | 2492 | public static function insert_last_update() { |
@@ -2028,8 +2511,11 @@ discard block |
||
2028 | 2511 | return "error : ".$e->getMessage(); |
2029 | 2512 | } |
2030 | 2513 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2031 | - if ($row['nb'] > 0) return true; |
|
2032 | - else return false; |
|
2514 | + if ($row['nb'] > 0) { |
|
2515 | + return true; |
|
2516 | + } else { |
|
2517 | + return false; |
|
2518 | + } |
|
2033 | 2519 | } |
2034 | 2520 | |
2035 | 2521 | |
@@ -2060,8 +2546,11 @@ discard block |
||
2060 | 2546 | return "error : ".$e->getMessage(); |
2061 | 2547 | } |
2062 | 2548 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2063 | - if ($row['nb'] > 0) return false; |
|
2064 | - else return true; |
|
2549 | + if ($row['nb'] > 0) { |
|
2550 | + return false; |
|
2551 | + } else { |
|
2552 | + return true; |
|
2553 | + } |
|
2065 | 2554 | } |
2066 | 2555 | |
2067 | 2556 | public static function insert_last_notam_update() { |
@@ -2090,8 +2579,11 @@ discard block |
||
2090 | 2579 | return "error : ".$e->getMessage(); |
2091 | 2580 | } |
2092 | 2581 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2093 | - if ($row['nb'] > 0) return false; |
|
2094 | - else return true; |
|
2582 | + if ($row['nb'] > 0) { |
|
2583 | + return false; |
|
2584 | + } else { |
|
2585 | + return true; |
|
2586 | + } |
|
2095 | 2587 | } |
2096 | 2588 | |
2097 | 2589 | public static function insert_last_airspace_update() { |
@@ -2121,8 +2613,11 @@ discard block |
||
2121 | 2613 | return "error : ".$e->getMessage(); |
2122 | 2614 | } |
2123 | 2615 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2124 | - if ($row['nb'] > 0) return false; |
|
2125 | - else return true; |
|
2616 | + if ($row['nb'] > 0) { |
|
2617 | + return false; |
|
2618 | + } else { |
|
2619 | + return true; |
|
2620 | + } |
|
2126 | 2621 | } |
2127 | 2622 | |
2128 | 2623 | public static function insert_last_owner_update() { |
@@ -2151,8 +2646,11 @@ discard block |
||
2151 | 2646 | return "error : ".$e->getMessage(); |
2152 | 2647 | } |
2153 | 2648 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2154 | - if ($row['nb'] > 0) return false; |
|
2155 | - else return true; |
|
2649 | + if ($row['nb'] > 0) { |
|
2650 | + return false; |
|
2651 | + } else { |
|
2652 | + return true; |
|
2653 | + } |
|
2156 | 2654 | } |
2157 | 2655 | |
2158 | 2656 | public static function insert_last_schedules_update() { |
@@ -2181,8 +2679,11 @@ discard block |
||
2181 | 2679 | return "error : ".$e->getMessage(); |
2182 | 2680 | } |
2183 | 2681 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2184 | - if ($row['nb'] > 0) return false; |
|
2185 | - else return true; |
|
2682 | + if ($row['nb'] > 0) { |
|
2683 | + return false; |
|
2684 | + } else { |
|
2685 | + return true; |
|
2686 | + } |
|
2186 | 2687 | } |
2187 | 2688 | |
2188 | 2689 | public static function insert_last_tle_update() { |
@@ -28,7 +28,9 @@ discard block |
||
28 | 28 | |
29 | 29 | // $output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
30 | 30 | $output .= ',"clock": {"currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"'; |
31 | -if (!isset($_GET['now'])) $output .= ',"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z"'; |
|
31 | +if (!isset($_GET['now'])) { |
|
32 | + $output .= ',"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z"'; |
|
33 | +} |
|
32 | 34 | $output .= '}'; |
33 | 35 | //$output .= ',"clock": {"currentTime" : "'.date("c",time()).'","multiplier" : 300,"range" : "UNBOUNDED","step": "TICK_DEPENDENT"}'; |
34 | 36 | //$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}'; |
@@ -37,7 +39,9 @@ discard block |
||
37 | 39 | $output .= '},'; |
38 | 40 | $output .= '{'; |
39 | 41 | $output .= '"id": "santaclaus",'; |
40 | -if (!isset($_GET['now'])) $output .= '"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z",'; |
|
42 | +if (!isset($_GET['now'])) { |
|
43 | + $output .= '"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z",'; |
|
44 | +} |
|
41 | 45 | $output .= '"properties": {'; |
42 | 46 | // Not yet supported in CZML with Cesium |
43 | 47 | $output .= '},'; |
@@ -9,7 +9,9 @@ discard block |
||
9 | 9 | if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { |
10 | 10 | exec("ps ux", $output, $result); |
11 | 11 | $j = 0; |
12 | - foreach ($output as $line) if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++; |
|
12 | + foreach ($output as $line) { |
|
13 | + if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++; |
|
14 | + } |
|
13 | 15 | if ($j > 1) { |
14 | 16 | echo "Script is already runnning..."; |
15 | 17 | die(); |
@@ -29,14 +31,18 @@ discard block |
||
29 | 31 | $update_db->update_notam(); |
30 | 32 | } |
31 | 33 | $update_db->insert_last_notam_update(); |
32 | - } elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n"; |
|
34 | + } elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) { |
|
35 | + echo "NOTAM are only updated once a day.\n"; |
|
36 | + } |
|
33 | 37 | if ($update_db->check_last_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
34 | 38 | $update_db->update_all(); |
35 | 39 | // require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
36 | 40 | // $Spotter = new Spotter(); |
37 | 41 | // $Spotter->updateFieldsFromOtherTables(); |
38 | 42 | $update_db->insert_last_update(); |
39 | - } elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n"; |
|
43 | + } elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) { |
|
44 | + echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n"; |
|
45 | + } |
|
40 | 46 | if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) { |
41 | 47 | echo "Check if new airspace version exist..."; |
42 | 48 | echo $update_db->update_airspace_fam(); |
@@ -52,22 +58,28 @@ discard block |
||
52 | 58 | if ($METAR->check_last_update()) { |
53 | 59 | $METAR->addMETARCycle(); |
54 | 60 | $METAR->insert_last_update(); |
55 | - } else echo "METAR are only updated every 30 minutes.\n"; |
|
56 | -} |
|
61 | + } else { |
|
62 | + echo "METAR are only updated every 30 minutes.\n"; |
|
63 | + } |
|
64 | + } |
|
57 | 65 | |
58 | 66 | |
59 | 67 | if (isset($globalOwner) && $globalOwner && $update_db->check_last_owner_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
60 | 68 | echo "Updating private aircraft's owners...\n"; |
61 | 69 | $update_db->update_owner(); |
62 | 70 | $update_db->insert_last_owner_update(); |
63 | -} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n"; |
|
71 | +} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
72 | + echo "Owner are only updated every 15 days.\n"; |
|
73 | +} |
|
64 | 74 | |
65 | 75 | if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
66 | 76 | echo "Updating schedules..."; |
67 | 77 | //$update_db->update_oneworld(); |
68 | 78 | $update_db->update_skyteam(); |
69 | 79 | $update_db->insert_last_schedules_update(); |
70 | -} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n"; |
|
80 | +} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) { |
|
81 | + echo "Schedules are only updated every 15 days.\n"; |
|
82 | +} |
|
71 | 83 | |
72 | 84 | if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) { |
73 | 85 | echo "Updating statistics and archive old data..."; |
@@ -6,8 +6,11 @@ discard block |
||
6 | 6 | //$_COOKIE['MapFormat'] = '2d'; |
7 | 7 | |
8 | 8 | // Compressed GeoJson is used if true |
9 | -if (!isset($globalJsonCompress)) $compress = true; |
|
10 | -else $compress = $globalJsonCompress; |
|
9 | +if (!isset($globalJsonCompress)) { |
|
10 | + $compress = true; |
|
11 | +} else { |
|
12 | + $compress = $globalJsonCompress; |
|
13 | +} |
|
11 | 14 | ?> |
12 | 15 | <?php |
13 | 16 | if (isset($_GET['archive'])) { |
@@ -19,8 +22,11 @@ discard block |
||
19 | 22 | //$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10)); |
20 | 23 | //$lastupd = 20; |
21 | 24 | $lastupd = $_GET['archivespeed']*$archiveupdatetime; |
22 | - if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate']; |
|
23 | - else $enddate = time(); |
|
25 | + if (isset($_GET['enddate']) && $_GET['enddate'] != '') { |
|
26 | + $enddate = $_GET['enddate']; |
|
27 | + } else { |
|
28 | + $enddate = time(); |
|
29 | + } |
|
24 | 30 | setcookie("archive_begin",$begindate); |
25 | 31 | setcookie("archive_end",$enddate); |
26 | 32 | setcookie("archive_update",$lastupd); |
@@ -127,7 +133,17 @@ discard block |
||
127 | 133 | } |
128 | 134 | |
129 | 135 | //create the map |
130 | - map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom); |
|
136 | + map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) { |
|
137 | + print $latitude; |
|
138 | +} else { |
|
139 | + print $globalCenterLatitude; |
|
140 | +} |
|
141 | +?>,<?php if (isset($longitude)) { |
|
142 | + print $longitude; |
|
143 | +} else { |
|
144 | + print $globalCenterLongitude; |
|
145 | +} |
|
146 | +?>], zoom); |
|
131 | 147 | <?php |
132 | 148 | } else { |
133 | 149 | ?> |
@@ -140,9 +156,19 @@ discard block |
||
140 | 156 | || navigator.userAgent.match(/BlackBerry/i) |
141 | 157 | || navigator.userAgent.match(/Windows Phone/i)) |
142 | 158 | { |
143 | - var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>; |
|
159 | + var zoom = <?php if (isset($globalLiveZoom)) { |
|
160 | + print $globalLiveZoom-1; |
|
161 | +} else { |
|
162 | + print '8'; |
|
163 | +} |
|
164 | +?>; |
|
144 | 165 | } else { |
145 | - var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>; |
|
166 | + var zoom = <?php if (isset($globalLiveZoom)) { |
|
167 | + print $globalLiveZoom; |
|
168 | +} else { |
|
169 | + print '9'; |
|
170 | +} |
|
171 | +?>; |
|
146 | 172 | } |
147 | 173 | |
148 | 174 | //create the map |
@@ -167,16 +193,27 @@ discard block |
||
167 | 193 | bounds = L.latLngBounds(southWest,northEast); |
168 | 194 | //a few title layers |
169 | 195 | <?php |
170 | - if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType']; |
|
171 | - else $MapType = $globalMapProvider; |
|
196 | + if (isset($_COOKIE['MapType'])) { |
|
197 | + $MapType = $_COOKIE['MapType']; |
|
198 | + } else { |
|
199 | + $MapType = $globalMapProvider; |
|
200 | + } |
|
172 | 201 | |
173 | 202 | if ($MapType == 'Mapbox') { |
174 | - if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId; |
|
175 | - else $MapBoxId = $_COOKIE['MapTypeId']; |
|
176 | -?> |
|
203 | + if ($_COOKIE['MapTypeId'] == 'default') { |
|
204 | + $MapBoxId = $globalMapboxId; |
|
205 | + } else { |
|
206 | + $MapBoxId = $_COOKIE['MapTypeId']; |
|
207 | + } |
|
208 | + ?> |
|
177 | 209 | L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', { |
178 | 210 | maxZoom: 18, |
179 | - noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>, |
|
211 | + noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) { |
|
212 | + print 'false'; |
|
213 | +} else { |
|
214 | + print 'true'; |
|
215 | +} |
|
216 | +?>, |
|
180 | 217 | attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' + |
181 | 218 | '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + |
182 | 219 | 'Imagery © <a href="http://mapbox.com">Mapbox</a>', |
@@ -188,7 +225,12 @@ discard block |
||
188 | 225 | ?> |
189 | 226 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
190 | 227 | maxZoom: 18, |
191 | - noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>, |
|
228 | + noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) { |
|
229 | + print 'false'; |
|
230 | +} else { |
|
231 | + print 'true'; |
|
232 | +} |
|
233 | +?>, |
|
192 | 234 | attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' + |
193 | 235 | '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>' |
194 | 236 | }).addTo(map); |
@@ -234,20 +276,26 @@ discard block |
||
234 | 276 | map.addLayer(yandexLayer); |
235 | 277 | <?php |
236 | 278 | } elseif ($MapType == 'Bing-Aerial') { |
237 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
238 | -?> |
|
279 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') { |
|
280 | + setcookie('MapType','OpenStreetMap'); |
|
281 | + } |
|
282 | + ?> |
|
239 | 283 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'}); |
240 | 284 | map.addLayer(bingLayer); |
241 | 285 | <?php |
242 | 286 | } elseif ($MapType == 'Bing-Hybrid') { |
243 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
244 | -?> |
|
287 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') { |
|
288 | + setcookie('MapType','OpenStreetMap'); |
|
289 | + } |
|
290 | + ?> |
|
245 | 291 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'}); |
246 | 292 | map.addLayer(bingLayer); |
247 | 293 | <?php |
248 | 294 | } elseif ($MapType == 'Bing-Road') { |
249 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
250 | -?> |
|
295 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') { |
|
296 | + setcookie('MapType','OpenStreetMap'); |
|
297 | + } |
|
298 | + ?> |
|
251 | 299 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'}); |
252 | 300 | map.addLayer(bingLayer); |
253 | 301 | <?php |
@@ -295,7 +343,12 @@ discard block |
||
295 | 343 | } |
296 | 344 | } elseif ($globalBounding == 'circle') { |
297 | 345 | ?> |
298 | - var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{ |
|
346 | + var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) { |
|
347 | + print $globalBoundingCircleSize; |
|
348 | +} else { |
|
349 | + print '70000'; |
|
350 | +} |
|
351 | +?>,{ |
|
299 | 352 | color: '#92C7D1', |
300 | 353 | fillColor: '#92C7D1', |
301 | 354 | fillOpacity: 0.3, |
@@ -354,8 +407,11 @@ discard block |
||
354 | 407 | |
355 | 408 | function update_airportsLayer() { |
356 | 409 | <?php |
357 | - if (isset($_COOKIE['AirportZoom'])) $getZoom = $_COOKIE['AirportZoom']; |
|
358 | - else $getZoom = '7'; |
|
410 | + if (isset($_COOKIE['AirportZoom'])) { |
|
411 | + $getZoom = $_COOKIE['AirportZoom']; |
|
412 | + } else { |
|
413 | + $getZoom = '7'; |
|
414 | + } |
|
359 | 415 | ?> |
360 | 416 | //if (map.getZoom() <= <?php print $getZoom; ?>) { |
361 | 417 | if (typeof airportsLayer != 'undefined') { |
@@ -689,9 +745,13 @@ discard block |
||
689 | 745 | if (callsign != ""){ markerLabel += callsign; } |
690 | 746 | if (departure_airport_code != "" && arrival_airport_code != "" && departure_airport_code != "NA" && arrival_airport_code != "NA"){ markerLabel += ' ( '+departure_airport_code+' - '+arrival_airport_code+' )'; } |
691 | 747 | <?php |
692 | - if (isset($_COOKIE['IconColor'])) $IconColor = $_COOKIE['IconColor']; |
|
693 | - elseif (isset($globalAircraftIconColor)) $IconColor = $globalAircraftIconColor; |
|
694 | - else $IconColor = '1a3151'; |
|
748 | + if (isset($_COOKIE['IconColor'])) { |
|
749 | + $IconColor = $_COOKIE['IconColor']; |
|
750 | + } elseif (isset($globalAircraftIconColor)) { |
|
751 | + $IconColor = $globalAircraftIconColor; |
|
752 | + } else { |
|
753 | + $IconColor = '1a3151'; |
|
754 | + } |
|
695 | 755 | if (!isset($ident) && !isset($flightaware_id)) { |
696 | 756 | ?> |
697 | 757 | info_update(feature.properties.fc); |
@@ -739,7 +799,12 @@ discard block |
||
739 | 799 | <?php |
740 | 800 | } else { |
741 | 801 | ?> |
742 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
802 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
803 | + print $archiveupdatetime*1000; |
|
804 | +} else { |
|
805 | + print $globalMapRefresh*1000+20000; |
|
806 | +} |
|
807 | +?>+feature.properties.sqt*1000); |
|
743 | 808 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
744 | 809 | <?php |
745 | 810 | } |
@@ -786,7 +851,12 @@ discard block |
||
786 | 851 | <?php |
787 | 852 | } else { |
788 | 853 | ?> |
789 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
854 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
855 | + print $archiveupdatetime*1000; |
|
856 | +} else { |
|
857 | + print $globalMapRefresh*1000+20000; |
|
858 | +} |
|
859 | +?>+feature.properties.sqt*1000); |
|
790 | 860 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
791 | 861 | <?php |
792 | 862 | } |
@@ -832,7 +902,12 @@ discard block |
||
832 | 902 | <?php |
833 | 903 | } else { |
834 | 904 | ?> |
835 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
905 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
906 | + print $archiveupdatetime*1000; |
|
907 | +} else { |
|
908 | + print $globalMapRefresh*1000+20000; |
|
909 | +} |
|
910 | +?>+feature.properties.sqt*1000); |
|
836 | 911 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
837 | 912 | <?php |
838 | 913 | } |
@@ -1173,14 +1248,24 @@ discard block |
||
1173 | 1248 | if (isset($_GET['archive'])) { |
1174 | 1249 | ?> |
1175 | 1250 | //then load it again every 30 seconds |
1176 | -// var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>); |
|
1251 | +// var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) { |
|
1252 | + print ($globalMapRefresh*1000)/2; |
|
1253 | +} else { |
|
1254 | + print '15000'; |
|
1255 | +} |
|
1256 | +?>); |
|
1177 | 1257 | reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php print $archiveupdatetime*1000; ?>); |
1178 | 1258 | <?php |
1179 | 1259 | } else { |
1180 | 1260 | ?> |
1181 | 1261 | //then load it again every 30 seconds |
1182 | 1262 | reloadPage = setInterval( |
1183 | - function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
1263 | + function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) { |
|
1264 | + print $globalMapRefresh*1000; |
|
1265 | +} else { |
|
1266 | + print '30000'; |
|
1267 | +} |
|
1268 | +?>); |
|
1184 | 1269 | var currentdate = new Date(Date.UTC()); |
1185 | 1270 | var currentyear = new Date().getFullYear(); |
1186 | 1271 | var begindate = new Date(Date.UTC(currentyear,12,24,2,0,0,0)); |
@@ -1192,7 +1277,12 @@ discard block |
||
1192 | 1277 | if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) { |
1193 | 1278 | ?> |
1194 | 1279 | update_polarLayer(); |
1195 | -setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
1280 | +setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) { |
|
1281 | + print $globalMapRefresh*1000*2; |
|
1282 | +} else { |
|
1283 | + print '60000'; |
|
1284 | +} |
|
1285 | +?>); |
|
1196 | 1286 | <?php |
1197 | 1287 | } |
1198 | 1288 | ?> |
@@ -1208,7 +1298,12 @@ discard block |
||
1208 | 1298 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
1209 | 1299 | ?> |
1210 | 1300 | update_atcLayer(); |
1211 | -setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
1301 | +setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) { |
|
1302 | + print $globalMapRefresh*1000*2; |
|
1303 | +} else { |
|
1304 | + print '60000'; |
|
1305 | +} |
|
1306 | +?>); |
|
1212 | 1307 | <?php |
1213 | 1308 | } |
1214 | 1309 | ?> |
@@ -22,8 +22,11 @@ |
||
22 | 22 | $j = 0; |
23 | 23 | $prev_satname = ''; |
24 | 24 | $timearray = array(); |
25 | -if (isset($_GET['now'])) $begin = time(); |
|
26 | -else $begin = strtotime(date("Y").'-12-24T02:00:00Z'); |
|
25 | +if (isset($_GET['now'])) { |
|
26 | + $begin = time(); |
|
27 | +} else { |
|
28 | + $begin = strtotime(date("Y").'-12-24T02:00:00Z'); |
|
29 | +} |
|
27 | 30 | for ($i =0; $i <= 288; $i++) { |
28 | 31 | $timearray[] = ($begin + $i*300)*1000; |
29 | 32 | } |
@@ -53,7 +53,9 @@ discard block |
||
53 | 53 | $dbc = $this->db; |
54 | 54 | $this->all_flights[$id]['schedule_check'] = true; |
55 | 55 | if ($globalSchedulesFetch) { |
56 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
56 | + if ($globalDebug) { |
|
57 | + echo 'Getting schedule info...'."\n"; |
|
58 | + } |
|
57 | 59 | $Spotter = new Spotter($dbc); |
58 | 60 | $Schedule = new Schedule($dbc); |
59 | 61 | $Translation = new Translation($dbc); |
@@ -63,7 +65,9 @@ discard block |
||
63 | 65 | if ($Schedule->checkSchedule($operator) == 0) { |
64 | 66 | $schedule = $Schedule->fetchSchedule($operator); |
65 | 67 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
66 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
68 | + if ($globalDebug) { |
|
69 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
70 | + } |
|
67 | 71 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
68 | 72 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
69 | 73 | // Should also check if route schedule = route from DB |
@@ -72,7 +76,9 @@ discard block |
||
72 | 76 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
73 | 77 | if ($airport_icao != '') { |
74 | 78 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
75 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
79 | + if ($globalDebug) { |
|
80 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
81 | + } |
|
76 | 82 | } |
77 | 83 | } |
78 | 84 | } |
@@ -81,7 +87,9 @@ discard block |
||
81 | 87 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
82 | 88 | if ($airport_icao != '') { |
83 | 89 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
84 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
90 | + if ($globalDebug) { |
|
91 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
92 | + } |
|
85 | 93 | } |
86 | 94 | } |
87 | 95 | } |
@@ -109,7 +117,9 @@ discard block |
||
109 | 117 | |
110 | 118 | public function checkAll() { |
111 | 119 | global $globalDebug; |
112 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
120 | + if ($globalDebug) { |
|
121 | + echo "Update last seen flights data...\n"; |
|
122 | + } |
|
113 | 123 | foreach ($this->all_flights as $key => $flight) { |
114 | 124 | if (isset($this->all_flights[$key]['id'])) { |
115 | 125 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
@@ -122,24 +132,32 @@ discard block |
||
122 | 132 | |
123 | 133 | public function arrival($key) { |
124 | 134 | global $globalClosestMinDist, $globalDebug; |
125 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
135 | + if ($globalDebug) { |
|
136 | + echo 'Update arrival...'."\n"; |
|
137 | + } |
|
126 | 138 | $Spotter = new Spotter($this->db); |
127 | 139 | $airport_icao = ''; |
128 | 140 | $airport_time = ''; |
129 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
141 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
142 | + $globalClosestMinDist = 50; |
|
143 | + } |
|
130 | 144 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
131 | 145 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
132 | 146 | if (isset($closestAirports[0])) { |
133 | 147 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
134 | 148 | $airport_icao = $closestAirports[0]['icao']; |
135 | 149 | $airport_time = $this->all_flights[$key]['datetime']; |
136 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
150 | + if ($globalDebug) { |
|
151 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
152 | + } |
|
137 | 153 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
138 | 154 | foreach ($closestAirports as $airport) { |
139 | 155 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
140 | 156 | $airport_icao = $airport['icao']; |
141 | 157 | $airport_time = $this->all_flights[$key]['datetime']; |
142 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
158 | + if ($globalDebug) { |
|
159 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
160 | + } |
|
143 | 161 | break; |
144 | 162 | } |
145 | 163 | } |
@@ -147,14 +165,20 @@ discard block |
||
147 | 165 | $airport_icao = $closestAirports[0]['icao']; |
148 | 166 | $airport_time = $this->all_flights[$key]['datetime']; |
149 | 167 | } else { |
150 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
168 | + if ($globalDebug) { |
|
169 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
170 | + } |
|
151 | 171 | } |
152 | 172 | } else { |
153 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
173 | + if ($globalDebug) { |
|
174 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
175 | + } |
|
154 | 176 | } |
155 | 177 | |
156 | 178 | } else { |
157 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
179 | + if ($globalDebug) { |
|
180 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
181 | + } |
|
158 | 182 | } |
159 | 183 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
160 | 184 | } |
@@ -164,12 +188,16 @@ discard block |
||
164 | 188 | public function del() { |
165 | 189 | global $globalDebug; |
166 | 190 | // Delete old infos |
167 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
191 | + if ($globalDebug) { |
|
192 | + echo 'Delete old values and update latest data...'."\n"; |
|
193 | + } |
|
168 | 194 | foreach ($this->all_flights as $key => $flight) { |
169 | 195 | if (isset($flight['lastupdate'])) { |
170 | 196 | if ($flight['lastupdate'] < (time()-3000)) { |
171 | 197 | if (isset($this->all_flights[$key]['id'])) { |
172 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
198 | + if ($globalDebug) { |
|
199 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
200 | + } |
|
173 | 201 | /* |
174 | 202 | $SpotterLive = new SpotterLive(); |
175 | 203 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
@@ -179,7 +207,9 @@ discard block |
||
179 | 207 | $Spotter = new Spotter($this->db); |
180 | 208 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
181 | 209 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
182 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
210 | + if ($globalDebug && $result != 'success') { |
|
211 | + echo '!!! ERROR : '.$result."\n"; |
|
212 | + } |
|
183 | 213 | } |
184 | 214 | // Put in archive |
185 | 215 | // $Spotter->db = null; |
@@ -193,8 +223,10 @@ discard block |
||
193 | 223 | public function add($line) { |
194 | 224 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights; |
195 | 225 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
196 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
197 | -/* |
|
226 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
227 | + $globalCoordMinChange = '0.02'; |
|
228 | + } |
|
229 | + /* |
|
198 | 230 | $Spotter = new Spotter(); |
199 | 231 | $dbc = $Spotter->db; |
200 | 232 | $SpotterLive = new SpotterLive($dbc); |
@@ -222,11 +254,15 @@ discard block |
||
222 | 254 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
223 | 255 | $current_date = date('Y-m-d'); |
224 | 256 | $source = $line['source_name']; |
225 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
257 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
258 | + $source = $line['format_source']; |
|
259 | + } |
|
226 | 260 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
227 | 261 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
228 | 262 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
229 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
263 | + } else { |
|
264 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
265 | + } |
|
230 | 266 | } |
231 | 267 | |
232 | 268 | /* |
@@ -242,8 +278,11 @@ discard block |
||
242 | 278 | //$this->db = $dbc; |
243 | 279 | |
244 | 280 | $hex = trim($line['hex']); |
245 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
246 | - else $id = trim($line['id']); |
|
281 | + if (!isset($line['id'])) { |
|
282 | + $id = trim($line['hex']); |
|
283 | + } else { |
|
284 | + $id = trim($line['id']); |
|
285 | + } |
|
247 | 286 | |
248 | 287 | //print_r($this->all_flights); |
249 | 288 | if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) { |
@@ -258,13 +297,20 @@ discard block |
||
258 | 297 | $Spotter = new Spotter($this->db); |
259 | 298 | $aircraft_icao = $Spotter->getAllAircraftType($hex); |
260 | 299 | $Spotter->db = null; |
261 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
300 | + if ($globalDebugTimeElapsed) { |
|
301 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
302 | + } |
|
262 | 303 | |
263 | 304 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
264 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
265 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
266 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
267 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
305 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
306 | + $aircraft_icao = 'GLID'; |
|
307 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
308 | + $aircraft_icao = 'UHEL'; |
|
309 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
310 | + $aircraft_icao = 'TOWPLANE'; |
|
311 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
312 | + $aircraft_icao = 'POWAIRC'; |
|
313 | + } |
|
268 | 314 | } |
269 | 315 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
270 | 316 | } else if (isset($line['aircraft_name'])) { |
@@ -272,29 +318,47 @@ discard block |
||
272 | 318 | $Spotter = new Spotter($this->db); |
273 | 319 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
274 | 320 | $Spotter->db = null; |
275 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
276 | - else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
277 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
321 | + if ($aircraft_icao != '') { |
|
322 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
323 | + } else { |
|
324 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
325 | + } |
|
326 | + } else { |
|
327 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
328 | + } |
|
278 | 329 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
279 | 330 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
280 | 331 | if (!isset($line['id'])) { |
281 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
282 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
332 | + if (!isset($globalDaemon)) { |
|
333 | + $globalDaemon = TRUE; |
|
334 | + } |
|
335 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
283 | 336 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
284 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
337 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
|
338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
339 | + } |
|
285 | 340 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
286 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
341 | + } else { |
|
342 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
343 | + } |
|
287 | 344 | |
288 | - if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
289 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
345 | + if ($globalDebug) { |
|
346 | + echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
347 | + } |
|
348 | + if ($globalAllFlights !== FALSE) { |
|
349 | + $dataFound = true; |
|
350 | + } |
|
290 | 351 | } |
291 | 352 | |
292 | 353 | if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
293 | 354 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
294 | 355 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
295 | 356 | } else { |
296 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
297 | - elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
357 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
358 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
359 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
360 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
361 | + } |
|
298 | 362 | /* |
299 | 363 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
300 | 364 | print_r($this->all_flights[$id]); |
@@ -302,7 +366,9 @@ discard block |
||
302 | 366 | */ |
303 | 367 | return ''; |
304 | 368 | } |
305 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
369 | + } else { |
|
370 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
371 | + } |
|
306 | 372 | |
307 | 373 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
308 | 374 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
@@ -323,15 +389,25 @@ discard block |
||
323 | 389 | $timeelapsed = microtime(true); |
324 | 390 | $Spotter = new Spotter($this->db); |
325 | 391 | $fromsource = NULL; |
326 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
327 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
328 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
329 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
330 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
392 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
393 | + $fromsource = $globalAirlinesSource; |
|
394 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
395 | + $fromsource = 'vatsim'; |
|
396 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
397 | + $fromsource = 'ivao'; |
|
398 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
399 | + $fromsource = 'vatsim'; |
|
400 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
401 | + $fromsource = 'ivao'; |
|
402 | + } |
|
331 | 403 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
332 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
404 | + if ($globalDebug && $result != 'success') { |
|
405 | + echo '!!! ERROR : '.$result."\n"; |
|
406 | + } |
|
333 | 407 | $Spotter->db = null; |
334 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
408 | + if ($globalDebugTimeElapsed) { |
|
409 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
410 | + } |
|
335 | 411 | } |
336 | 412 | |
337 | 413 | /* |
@@ -342,7 +418,9 @@ discard block |
||
342 | 418 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
343 | 419 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
344 | 420 | */ |
345 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
421 | + if (!isset($this->all_flights[$id]['id'])) { |
|
422 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
423 | + } |
|
346 | 424 | |
347 | 425 | //$putinarchive = true; |
348 | 426 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -359,7 +437,9 @@ discard block |
||
359 | 437 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
360 | 438 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
361 | 439 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
362 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
440 | + if ($globalDebugTimeElapsed) { |
|
441 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
442 | + } |
|
363 | 443 | |
364 | 444 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
365 | 445 | $timeelapsed = microtime(true); |
@@ -372,7 +452,9 @@ discard block |
||
372 | 452 | $Translation->db = null; |
373 | 453 | } |
374 | 454 | $Spotter->db = null; |
375 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
455 | + if ($globalDebugTimeElapsed) { |
|
456 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
457 | + } |
|
376 | 458 | |
377 | 459 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
378 | 460 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -381,9 +463,13 @@ discard block |
||
381 | 463 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
382 | 464 | } |
383 | 465 | } |
384 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
466 | + if (!isset($globalFork)) { |
|
467 | + $globalFork = TRUE; |
|
468 | + } |
|
385 | 469 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
386 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
470 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
471 | + $this->get_Schedule($id,trim($line['ident'])); |
|
472 | + } |
|
387 | 473 | } |
388 | 474 | } |
389 | 475 | } |
@@ -399,16 +485,23 @@ discard block |
||
399 | 485 | // use datetime |
400 | 486 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
401 | 487 | $speed = $speed*3.6; |
402 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
403 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
488 | + if ($speed < 1000) { |
|
489 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
490 | + } |
|
491 | + if ($globalDebug) { |
|
492 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
493 | + } |
|
404 | 494 | } |
405 | 495 | } |
406 | 496 | |
407 | 497 | |
408 | 498 | |
409 | 499 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
410 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
411 | - else unset($timediff); |
|
500 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
501 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
502 | + } else { |
|
503 | + unset($timediff); |
|
504 | + } |
|
412 | 505 | if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
413 | 506 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
414 | 507 | if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -416,21 +509,31 @@ discard block |
||
416 | 509 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
417 | 510 | $this->all_flights[$id]['putinarchive'] = true; |
418 | 511 | |
419 | - if ($globalDebug) echo "\n".' ------- Check Country.... '; |
|
512 | + if ($globalDebug) { |
|
513 | + echo "\n".' ------- Check Country.... '; |
|
514 | + } |
|
420 | 515 | $timeelapsed = microtime(true); |
421 | 516 | $Spotter = new Spotter($this->db); |
422 | 517 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
423 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
518 | + if (!empty($all_country)) { |
|
519 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
520 | + } |
|
424 | 521 | $Spotter->db = null; |
425 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
522 | + if ($globalDebugTimeElapsed) { |
|
523 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
524 | + } |
|
426 | 525 | $this->tmd = 0; |
427 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
526 | + if ($globalDebug) { |
|
527 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
528 | + } |
|
428 | 529 | } |
429 | 530 | } |
430 | 531 | |
431 | 532 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
432 | 533 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
433 | - if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
534 | + if (!isset($this->all_flights[$id]['archive_latitude'])) { |
|
535 | + $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
536 | + } |
|
434 | 537 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
435 | 538 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
436 | 539 | $dataFound = true; |
@@ -452,9 +555,13 @@ discard block |
||
452 | 555 | */ |
453 | 556 | } |
454 | 557 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
455 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
558 | + if ($line['longitude'] > 180) { |
|
559 | + $line['longitude'] = $line['longitude'] - 360; |
|
560 | + } |
|
456 | 561 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
457 | - if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
562 | + if (!isset($this->all_flights[$id]['archive_longitude'])) { |
|
563 | + $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
564 | + } |
|
458 | 565 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
459 | 566 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
460 | 567 | $dataFound = true; |
@@ -485,7 +592,9 @@ discard block |
||
485 | 592 | } |
486 | 593 | } |
487 | 594 | if (isset($line['last_update']) && $line['last_update'] != '') { |
488 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
595 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
596 | + $dataFound = true; |
|
597 | + } |
|
489 | 598 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
490 | 599 | } |
491 | 600 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -507,11 +616,17 @@ discard block |
||
507 | 616 | // Here we force archive of flight because after ground it's a new one (or should be) |
508 | 617 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
509 | 618 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
510 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
511 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
512 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
619 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) { |
|
620 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
621 | + } elseif (isset($line['id'])) { |
|
622 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
623 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
624 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
625 | + } |
|
626 | + } |
|
627 | + if ($line['ground'] != 1) { |
|
628 | + $line['ground'] = 0; |
|
513 | 629 | } |
514 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
515 | 630 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
516 | 631 | //$dataFound = true; |
517 | 632 | } |
@@ -519,28 +634,40 @@ discard block |
||
519 | 634 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
520 | 635 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
521 | 636 | $highlight = ''; |
522 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
523 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
524 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
637 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
638 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
639 | + } |
|
640 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
641 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
642 | + } |
|
643 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
644 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
645 | + } |
|
525 | 646 | if ($highlight != '') { |
526 | 647 | $timeelapsed = microtime(true); |
527 | 648 | $Spotter = new Spotter($this->db); |
528 | 649 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
529 | 650 | $Spotter->db = null; |
530 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
651 | + if ($globalDebugTimeElapsed) { |
|
652 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
653 | + } |
|
531 | 654 | |
532 | 655 | $this->all_flights[$id]['putinarchive'] = true; |
533 | 656 | //$putinarchive = true; |
534 | 657 | //$highlight = ''; |
535 | 658 | } |
536 | 659 | |
537 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
660 | + } else { |
|
661 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
662 | + } |
|
538 | 663 | //$dataFound = true; |
539 | 664 | } |
540 | 665 | |
541 | 666 | if (isset($line['altitude']) && $line['altitude'] != '') { |
542 | 667 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
543 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
668 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) { |
|
669 | + $this->all_flights[$id]['putinarchive'] = true; |
|
670 | + } |
|
544 | 671 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
545 | 672 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
546 | 673 | //$dataFound = true; |
@@ -552,21 +679,30 @@ discard block |
||
552 | 679 | } |
553 | 680 | |
554 | 681 | if (isset($line['heading']) && $line['heading'] != '') { |
555 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
682 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) { |
|
683 | + $this->all_flights[$id]['putinarchive'] = true; |
|
684 | + } |
|
556 | 685 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
557 | 686 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
558 | 687 | //$dataFound = true; |
559 | 688 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
560 | 689 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
561 | 690 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
562 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
563 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
691 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) { |
|
692 | + $this->all_flights[$id]['putinarchive'] = true; |
|
693 | + } |
|
694 | + if ($globalDebug) { |
|
695 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
696 | + } |
|
564 | 697 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
565 | 698 | // If not enough messages and ACARS set heading to 0 |
566 | 699 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
567 | 700 | } |
568 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
569 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
701 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
702 | + $dataFound = false; |
|
703 | + } elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
704 | + $dataFound = false; |
|
705 | + } |
|
570 | 706 | |
571 | 707 | // print_r($this->all_flights[$id]); |
572 | 708 | //gets the callsign from the last hour |
@@ -581,23 +717,36 @@ discard block |
||
581 | 717 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
582 | 718 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
583 | 719 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
584 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
720 | + if ($globalDebug) { |
|
721 | + echo "Check if aircraft is already in DB..."; |
|
722 | + } |
|
585 | 723 | $timeelapsed = microtime(true); |
586 | 724 | $SpotterLive = new SpotterLive($this->db); |
587 | 725 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
588 | 726 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
589 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
727 | + if ($globalDebugTimeElapsed) { |
|
728 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
729 | + } |
|
590 | 730 | } elseif (isset($line['id'])) { |
591 | 731 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
592 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
732 | + if ($globalDebugTimeElapsed) { |
|
733 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
734 | + } |
|
593 | 735 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
594 | 736 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
595 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
596 | - } else $recent_ident = ''; |
|
737 | + if ($globalDebugTimeElapsed) { |
|
738 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
739 | + } |
|
740 | + } else { |
|
741 | + $recent_ident = ''; |
|
742 | + } |
|
597 | 743 | $SpotterLive->db=null; |
598 | 744 | |
599 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
600 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
745 | + if ($globalDebug && $recent_ident == '') { |
|
746 | + echo " Not in DB.\n"; |
|
747 | + } elseif ($globalDebug && $recent_ident != '') { |
|
748 | + echo " Already in DB.\n"; |
|
749 | + } |
|
601 | 750 | } else { |
602 | 751 | $recent_ident = ''; |
603 | 752 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -605,7 +754,9 @@ discard block |
||
605 | 754 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
606 | 755 | if($recent_ident == "") |
607 | 756 | { |
608 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
757 | + if ($globalDebug) { |
|
758 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
759 | + } |
|
609 | 760 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
610 | 761 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
611 | 762 | //adds the spotter data for the archive |
@@ -649,26 +800,44 @@ discard block |
||
649 | 800 | |
650 | 801 | if (!$ignoreImport) { |
651 | 802 | $highlight = ''; |
652 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
653 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
654 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
655 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
803 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
804 | + $highlight = 'Squawk 7500 : Hijack'; |
|
805 | + } |
|
806 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
807 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
808 | + } |
|
809 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
810 | + $highlight = 'Squawk 7700 : Emergency'; |
|
811 | + } |
|
812 | + if (!isset($this->all_flights[$id]['id'])) { |
|
813 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
814 | + } |
|
656 | 815 | $timeelapsed = microtime(true); |
657 | 816 | $Spotter = new Spotter($this->db); |
658 | 817 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
659 | 818 | $Spotter->db = null; |
660 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
661 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
819 | + if ($globalDebug && isset($result)) { |
|
820 | + echo $result."\n"; |
|
821 | + } |
|
822 | + if ($globalDebugTimeElapsed) { |
|
823 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
824 | + } |
|
662 | 825 | |
663 | 826 | // Add source stat in DB |
664 | 827 | $Stats = new Stats($this->db); |
665 | 828 | if (!empty($this->stats)) { |
666 | - if ($globalDebug) echo 'Add source stats : '; |
|
829 | + if ($globalDebug) { |
|
830 | + echo 'Add source stats : '; |
|
831 | + } |
|
667 | 832 | foreach($this->stats as $date => $data) { |
668 | 833 | foreach($data as $source => $sourced) { |
669 | 834 | //print_r($sourced); |
670 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
671 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
835 | + if (isset($sourced['polar'])) { |
|
836 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
837 | + } |
|
838 | + if (isset($sourced['hist'])) { |
|
839 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
840 | + } |
|
672 | 841 | if (isset($sourced['msg'])) { |
673 | 842 | if (time() - $sourced['msg']['date'] > 10) { |
674 | 843 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -681,13 +850,17 @@ discard block |
||
681 | 850 | unset($this->stats[$date]); |
682 | 851 | } |
683 | 852 | } |
684 | - if ($globalDebug) echo 'Done'."\n"; |
|
853 | + if ($globalDebug) { |
|
854 | + echo 'Done'."\n"; |
|
855 | + } |
|
685 | 856 | |
686 | 857 | } |
687 | 858 | $Stats->db = null; |
688 | 859 | |
689 | 860 | $this->del(); |
690 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
861 | + } elseif ($globalDebug) { |
|
862 | + echo 'Ignore data'."\n"; |
|
863 | + } |
|
691 | 864 | //$ignoreImport = false; |
692 | 865 | $this->all_flights[$id]['addedSpotter'] = 1; |
693 | 866 | //print_r($this->all_flights[$id]); |
@@ -704,12 +877,16 @@ discard block |
||
704 | 877 | */ |
705 | 878 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
706 | 879 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
707 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
880 | + if ($globalDebug) { |
|
881 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
882 | + } |
|
708 | 883 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
709 | 884 | $SpotterLive = new SpotterLive($this->db); |
710 | 885 | $SpotterLive->deleteLiveSpotterData(); |
711 | 886 | $SpotterLive->db=null; |
712 | - if ($globalDebug) echo " Done\n"; |
|
887 | + if ($globalDebug) { |
|
888 | + echo " Done\n"; |
|
889 | + } |
|
713 | 890 | $this->last_delete = time(); |
714 | 891 | } |
715 | 892 | } else { |
@@ -732,11 +909,17 @@ discard block |
||
732 | 909 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
733 | 910 | if ($globalDebug) { |
734 | 911 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
735 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
736 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
912 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
913 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
914 | + } else { |
|
915 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
916 | + } |
|
737 | 917 | } else { |
738 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
739 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
918 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
919 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
920 | + } else { |
|
921 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
922 | + } |
|
740 | 923 | } |
741 | 924 | } |
742 | 925 | $ignoreImport = false; |
@@ -782,19 +965,25 @@ discard block |
||
782 | 965 | |
783 | 966 | if (!$ignoreImport) { |
784 | 967 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
785 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
968 | + if ($globalDebug) { |
|
969 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
970 | + } |
|
786 | 971 | $timeelapsed = microtime(true); |
787 | 972 | $SpotterLive = new SpotterLive($this->db); |
788 | 973 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
789 | 974 | $SpotterLive->db = null; |
790 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
975 | + if ($globalDebugTimeElapsed) { |
|
976 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
977 | + } |
|
791 | 978 | |
792 | 979 | // Put statistics in $this->stats variable |
793 | 980 | //if ($line['format_source'] != 'aprs') { |
794 | 981 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
795 | 982 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
796 | 983 | $source = $this->all_flights[$id]['source_name']; |
797 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
984 | + if ($source == '') { |
|
985 | + $source = $this->all_flights[$id]['format_source']; |
|
986 | + } |
|
798 | 987 | if (!isset($this->source_location[$source])) { |
799 | 988 | $Location = new Source(); |
800 | 989 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -815,7 +1004,9 @@ discard block |
||
815 | 1004 | $stats_heading = round($stats_heading/22.5); |
816 | 1005 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
817 | 1006 | $current_date = date('Y-m-d'); |
818 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1007 | + if ($stats_heading == 16) { |
|
1008 | + $stats_heading = 0; |
|
1009 | + } |
|
819 | 1010 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
820 | 1011 | for ($i=0;$i<=15;$i++) { |
821 | 1012 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -833,7 +1024,9 @@ discard block |
||
833 | 1024 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
834 | 1025 | end($this->stats[$current_date][$source]['hist']); |
835 | 1026 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
836 | - } else $mini = 0; |
|
1027 | + } else { |
|
1028 | + $mini = 0; |
|
1029 | + } |
|
837 | 1030 | for ($i=$mini;$i<=$distance;$i+=10) { |
838 | 1031 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
839 | 1032 | } |
@@ -844,20 +1037,30 @@ discard block |
||
844 | 1037 | } |
845 | 1038 | |
846 | 1039 | $this->all_flights[$id]['lastupdate'] = time(); |
847 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1040 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1041 | + $send = true; |
|
1042 | + } |
|
848 | 1043 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
849 | - if ($globalDebug) echo $result."\n"; |
|
850 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1044 | + if ($globalDebug) { |
|
1045 | + echo $result."\n"; |
|
1046 | + } |
|
1047 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1048 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1049 | + } |
|
851 | 1050 | //$this->del(); |
852 | 1051 | |
853 | 1052 | |
854 | 1053 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
855 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1054 | + if ($globalDebug) { |
|
1055 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1056 | + } |
|
856 | 1057 | $SpotterLive = new SpotterLive($this->db); |
857 | 1058 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
858 | 1059 | $SpotterLive->db = null; |
859 | 1060 | //SpotterLive->deleteLiveSpotterData(); |
860 | - if ($globalDebug) echo " Done\n"; |
|
1061 | + if ($globalDebug) { |
|
1062 | + echo " Done\n"; |
|
1063 | + } |
|
861 | 1064 | $this->last_delete_hourly = time(); |
862 | 1065 | } |
863 | 1066 | |
@@ -865,7 +1068,9 @@ discard block |
||
865 | 1068 | //$ignoreImport = false; |
866 | 1069 | } |
867 | 1070 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
868 | - if ($send) return $this->all_flights[$id]; |
|
1071 | + if ($send) { |
|
1072 | + return $this->all_flights[$id]; |
|
1073 | + } |
|
869 | 1074 | } |
870 | 1075 | } |
871 | 1076 | } |
@@ -27,7 +27,9 @@ discard block |
||
27 | 27 | $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
28 | 28 | } |
29 | 29 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
30 | + if (is_array($globalFilter)) { |
|
31 | + $filter = array_merge($filter,$globalFilter); |
|
32 | + } |
|
31 | 33 | $filter_query_join = ''; |
32 | 34 | $filter_query_where = ''; |
33 | 35 | foreach($filters as $flt) { |
@@ -77,8 +79,11 @@ discard block |
||
77 | 79 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
78 | 80 | } |
79 | 81 | } |
80 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
81 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
82 | + if ($filter_query_where == '' && $where) { |
|
83 | + $filter_query_where = ' WHERE'; |
|
84 | + } elseif ($filter_query_where != '' && $and) { |
|
85 | + $filter_query_where .= ' AND'; |
|
86 | + } |
|
82 | 87 | $filter_query = $filter_query_join.$filter_query_where; |
83 | 88 | return $filter_query; |
84 | 89 | } |
@@ -98,10 +103,18 @@ discard block |
||
98 | 103 | $Image = new Image($this->db); |
99 | 104 | $Schedule = new Schedule($this->db); |
100 | 105 | $ACARS = new ACARS($this->db); |
101 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
102 | - if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
|
103 | - if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
|
104 | - if (!isset($globalVAM)) $globalVAM = FALSE; |
|
106 | + if (!isset($globalIVAO)) { |
|
107 | + $globalIVAO = FALSE; |
|
108 | + } |
|
109 | + if (!isset($globalVATSIM)) { |
|
110 | + $globalVATSIM = FALSE; |
|
111 | + } |
|
112 | + if (!isset($globalphpVMS)) { |
|
113 | + $globalphpVMS = FALSE; |
|
114 | + } |
|
115 | + if (!isset($globalVAM)) { |
|
116 | + $globalVAM = FALSE; |
|
117 | + } |
|
105 | 118 | date_default_timezone_set('UTC'); |
106 | 119 | |
107 | 120 | if (!is_string($query)) |
@@ -148,21 +161,35 @@ discard block |
||
148 | 161 | } else { |
149 | 162 | $temp_array['spotter_id'] = ''; |
150 | 163 | } |
151 | - if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id']; |
|
152 | - if (isset($row['modes'])) $temp_array['modes'] = $row['modes']; |
|
164 | + if (isset($row['flightaware_id'])) { |
|
165 | + $temp_array['flightaware_id'] = $row['flightaware_id']; |
|
166 | + } |
|
167 | + if (isset($row['modes'])) { |
|
168 | + $temp_array['modes'] = $row['modes']; |
|
169 | + } |
|
153 | 170 | $temp_array['ident'] = $row['ident']; |
154 | 171 | if (isset($row['registration']) && $row['registration'] != '') { |
155 | 172 | $temp_array['registration'] = $row['registration']; |
156 | 173 | } elseif (isset($temp_array['modes'])) { |
157 | 174 | $temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']); |
158 | - } else $temp_array['registration'] = ''; |
|
159 | - if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao']; |
|
175 | + } else { |
|
176 | + $temp_array['registration'] = ''; |
|
177 | + } |
|
178 | + if (isset($row['aircraft_icao'])) { |
|
179 | + $temp_array['aircraft_type'] = $row['aircraft_icao']; |
|
180 | + } |
|
160 | 181 | |
161 | 182 | $temp_array['departure_airport'] = $row['departure_airport_icao']; |
162 | 183 | $temp_array['arrival_airport'] = $row['arrival_airport_icao']; |
163 | - if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; |
|
164 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
165 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
184 | + if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) { |
|
185 | + $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao']; |
|
186 | + } |
|
187 | + if (isset($row['latitude'])) { |
|
188 | + $temp_array['latitude'] = $row['latitude']; |
|
189 | + } |
|
190 | + if (isset($row['longitude'])) { |
|
191 | + $temp_array['longitude'] = $row['longitude']; |
|
192 | + } |
|
166 | 193 | /* |
167 | 194 | if (Connection->tableExists('countries')) { |
168 | 195 | $country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']); |
@@ -172,8 +199,12 @@ discard block |
||
172 | 199 | } |
173 | 200 | } |
174 | 201 | */ |
175 | - if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints']; |
|
176 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
202 | + if (isset($row['waypoints'])) { |
|
203 | + $temp_array['waypoints'] = $row['waypoints']; |
|
204 | + } |
|
205 | + if (isset($row['format_source'])) { |
|
206 | + $temp_array['format_source'] = $row['format_source']; |
|
207 | + } |
|
177 | 208 | if (isset($row['route_stop'])) { |
178 | 209 | $temp_array['route_stop'] = $row['route_stop']; |
179 | 210 | if ($row['route_stop'] != '') { |
@@ -192,13 +223,19 @@ discard block |
||
192 | 223 | } |
193 | 224 | } |
194 | 225 | } |
195 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
226 | + if (isset($row['altitude'])) { |
|
227 | + $temp_array['altitude'] = $row['altitude']; |
|
228 | + } |
|
196 | 229 | if (isset($row['heading'])) { |
197 | 230 | $temp_array['heading'] = $row['heading']; |
198 | 231 | $heading_direction = $this->parseDirection($row['heading']); |
199 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
232 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
233 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
234 | + } |
|
235 | + } |
|
236 | + if (isset($row['ground_speed'])) { |
|
237 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
200 | 238 | } |
201 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
202 | 239 | $temp_array['image'] = ""; |
203 | 240 | $temp_array['image_thumbnail'] = ""; |
204 | 241 | $temp_array['image_source'] = ""; |
@@ -206,7 +243,9 @@ discard block |
||
206 | 243 | |
207 | 244 | if (isset($row['highlight'])) { |
208 | 245 | $temp_array['highlight'] = $row['highlight']; |
209 | - } else $temp_array['highlight'] = ''; |
|
246 | + } else { |
|
247 | + $temp_array['highlight'] = ''; |
|
248 | + } |
|
210 | 249 | |
211 | 250 | if (isset($row['date'])) { |
212 | 251 | $dateArray = $this->parseDateString($row['date']); |
@@ -254,7 +293,9 @@ discard block |
||
254 | 293 | |
255 | 294 | if ($aircraft_array[0]['aircraft_shadow'] != NULL) { |
256 | 295 | $temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow']; |
257 | - } else $temp_array['aircraft_shadow'] = 'default.png'; |
|
296 | + } else { |
|
297 | + $temp_array['aircraft_shadow'] = 'default.png'; |
|
298 | + } |
|
258 | 299 | } else { |
259 | 300 | $temp_array['aircraft_shadow'] = 'default.png'; |
260 | 301 | $temp_array['aircraft_name'] = 'N/A'; |
@@ -262,11 +303,17 @@ discard block |
||
262 | 303 | } |
263 | 304 | } |
264 | 305 | $fromsource = NULL; |
265 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
266 | - elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
267 | - elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
268 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
269 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
306 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
307 | + $fromsource = $globalAirlinesSource; |
|
308 | + } elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') { |
|
309 | + $fromsource = 'vatsim'; |
|
310 | + } elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') { |
|
311 | + $fromsource = 'ivao'; |
|
312 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
313 | + $fromsource = 'vatsim'; |
|
314 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
315 | + $fromsource = 'ivao'; |
|
316 | + } |
|
270 | 317 | if (!isset($row['airline_name']) || $row['airline_name'] == '') { |
271 | 318 | if (!is_numeric(substr($row['ident'], 0, 3))) { |
272 | 319 | if (is_numeric(substr($row['ident'], 2, 1))) { |
@@ -289,12 +336,18 @@ discard block |
||
289 | 336 | } |
290 | 337 | } else { |
291 | 338 | $temp_array['airline_icao'] = $row['airline_icao']; |
292 | - if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata']; |
|
293 | - else $temp_array['airline_iata'] = 'N/A'; |
|
339 | + if (isset($row['airline_iata'])) { |
|
340 | + $temp_array['airline_iata'] = $row['airline_iata']; |
|
341 | + } else { |
|
342 | + $temp_array['airline_iata'] = 'N/A'; |
|
343 | + } |
|
294 | 344 | $temp_array['airline_name'] = $row['airline_name']; |
295 | 345 | $temp_array['airline_country'] = $row['airline_country']; |
296 | - if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign']; |
|
297 | - else $temp_array['airline_callsign'] = 'N/A'; |
|
346 | + if (isset($row['airline_callsign'])) { |
|
347 | + $temp_array['airline_callsign'] = $row['airline_callsign']; |
|
348 | + } else { |
|
349 | + $temp_array['airline_callsign'] = 'N/A'; |
|
350 | + } |
|
298 | 351 | $temp_array['airline_type'] = $row['airline_type']; |
299 | 352 | if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') { |
300 | 353 | $airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']); |
@@ -321,7 +374,9 @@ discard block |
||
321 | 374 | } |
322 | 375 | if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) { |
323 | 376 | $owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']); |
324 | - if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); |
|
377 | + if ($owner_info['owner'] != '') { |
|
378 | + $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner'])); |
|
379 | + } |
|
325 | 380 | $temp_array['aircraft_base'] = $owner_info['base']; |
326 | 381 | $temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg']; |
327 | 382 | } |
@@ -329,9 +384,14 @@ discard block |
||
329 | 384 | if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != '')) |
330 | 385 | { |
331 | 386 | if ($globalIVAO) { |
332 | - if (isset($temp_array['airline_icao'])) $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
|
333 | - else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
|
334 | - } else $image_array = $Image->getSpotterImage($temp_array['registration']); |
|
387 | + if (isset($temp_array['airline_icao'])) { |
|
388 | + $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
|
389 | + } else { |
|
390 | + $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
|
391 | + } |
|
392 | + } else { |
|
393 | + $image_array = $Image->getSpotterImage($temp_array['registration']); |
|
394 | + } |
|
335 | 395 | if (count($image_array) > 0) { |
336 | 396 | $temp_array['image'] = $image_array[0]['image']; |
337 | 397 | $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -382,7 +442,9 @@ discard block |
||
382 | 442 | //if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') { |
383 | 443 | if ($row['departure_airport_icao'] != '') { |
384 | 444 | $departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']); |
385 | - if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
445 | + if (!isset($departure_airport_array[0]['name'])) { |
|
446 | + $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
447 | + } |
|
386 | 448 | /* |
387 | 449 | } elseif ($row['departure_airport_name'] != '') { |
388 | 450 | $temp_array['departure_airport_name'] = $row['departure_airport_name']; |
@@ -390,7 +452,9 @@ discard block |
||
390 | 452 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
391 | 453 | $temp_array['departure_airport_icao'] = $row['departure_airport_icao']; |
392 | 454 | */ |
393 | - } else $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
455 | + } else { |
|
456 | + $departure_airport_array = $this->getAllAirportInfo('NA'); |
|
457 | + } |
|
394 | 458 | if (isset($departure_airport_array[0]['name'])) { |
395 | 459 | $temp_array['departure_airport_name'] = $departure_airport_array[0]['name']; |
396 | 460 | $temp_array['departure_airport_city'] = $departure_airport_array[0]['city']; |
@@ -410,8 +474,12 @@ discard block |
||
410 | 474 | |
411 | 475 | if ($row['arrival_airport_icao'] != '') { |
412 | 476 | $arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']); |
413 | - if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
414 | - } else $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
477 | + if (count($arrival_airport_array) == 0) { |
|
478 | + $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
479 | + } |
|
480 | + } else { |
|
481 | + $arrival_airport_array = $this->getAllAirportInfo('NA'); |
|
482 | + } |
|
415 | 483 | if (isset($arrival_airport_array[0]['name'])) { |
416 | 484 | $temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name']; |
417 | 485 | $temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city']; |
@@ -427,27 +495,45 @@ discard block |
||
427 | 495 | $temp_array['arrival_airport_time'] = $row['arrival_airport_time']; |
428 | 496 | } |
429 | 497 | */ |
430 | - if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id']; |
|
431 | - if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name']; |
|
432 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
433 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
434 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
498 | + if (isset($row['pilot_id']) && $row['pilot_id'] != '') { |
|
499 | + $temp_array['pilot_id'] = $row['pilot_id']; |
|
500 | + } |
|
501 | + if (isset($row['pilot_name']) && $row['pilot_name'] != '') { |
|
502 | + $temp_array['pilot_name'] = $row['pilot_name']; |
|
503 | + } |
|
504 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
505 | + $temp_array['source_name'] = $row['source_name']; |
|
506 | + } |
|
507 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
508 | + $temp_array['over_country'] = $row['over_country']; |
|
509 | + } |
|
510 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
511 | + $temp_array['distance'] = $row['distance']; |
|
512 | + } |
|
435 | 513 | if (isset($row['squawk'])) { |
436 | 514 | $temp_array['squawk'] = $row['squawk']; |
437 | 515 | if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) { |
438 | 516 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']); |
439 | - if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
517 | + if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) { |
|
518 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
519 | + } |
|
440 | 520 | } elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) { |
441 | 521 | $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']); |
442 | - if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
443 | - } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
522 | + if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) { |
|
523 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
524 | + } |
|
525 | + } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) { |
|
526 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
527 | + } |
|
444 | 528 | } |
445 | 529 | |
446 | 530 | $temp_array['query_number_rows'] = $num_rows; |
447 | 531 | |
448 | 532 | $spotter_array[] = $temp_array; |
449 | 533 | } |
450 | - if ($num_rows == 0) return array(); |
|
534 | + if ($num_rows == 0) { |
|
535 | + return array(); |
|
536 | + } |
|
451 | 537 | $spotter_array[0]['query_number_rows'] = $num_rows; |
452 | 538 | return $spotter_array; |
453 | 539 | } |
@@ -480,7 +566,9 @@ discard block |
||
480 | 566 | foreach ($q_array as $q_item){ |
481 | 567 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
482 | 568 | $additional_query .= " AND ("; |
483 | - if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
|
569 | + if (is_int($q_item)) { |
|
570 | + $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
|
571 | + } |
|
484 | 572 | $additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
485 | 573 | $additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; |
486 | 574 | $additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
@@ -501,7 +589,9 @@ discard block |
||
501 | 589 | $additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR "; |
502 | 590 | $additional_query .= "(spotter_output.ident like '%".$q_item."%') OR "; |
503 | 591 | $translate = $Translation->ident2icao($q_item); |
504 | - if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; |
|
592 | + if ($translate != $q_item) { |
|
593 | + $additional_query .= "(spotter_output.ident like '%".$translate."%') OR "; |
|
594 | + } |
|
505 | 595 | $additional_query .= "(spotter_output.highlight like '%".$q_item."%')"; |
506 | 596 | $additional_query .= ")"; |
507 | 597 | } |
@@ -728,7 +818,9 @@ discard block |
||
728 | 818 | date_default_timezone_set($globalTimezone); |
729 | 819 | $datetime = new DateTime(); |
730 | 820 | $offset = $datetime->format('P'); |
731 | - } else $offset = '+00:00'; |
|
821 | + } else { |
|
822 | + $offset = '+00:00'; |
|
823 | + } |
|
732 | 824 | |
733 | 825 | if ($date_array[1] != "") |
734 | 826 | { |
@@ -760,8 +852,12 @@ discard block |
||
760 | 852 | { |
761 | 853 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
762 | 854 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
763 | - } else $limit_query = ""; |
|
764 | - } else $limit_query = ""; |
|
855 | + } else { |
|
856 | + $limit_query = ""; |
|
857 | + } |
|
858 | + } else { |
|
859 | + $limit_query = ""; |
|
860 | + } |
|
765 | 861 | |
766 | 862 | |
767 | 863 | if ($sort != "") |
@@ -829,8 +925,12 @@ discard block |
||
829 | 925 | { |
830 | 926 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
831 | 927 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
832 | - } else $limit_query = ""; |
|
833 | - } else $limit_query = ""; |
|
928 | + } else { |
|
929 | + $limit_query = ""; |
|
930 | + } |
|
931 | + } else { |
|
932 | + $limit_query = ""; |
|
933 | + } |
|
834 | 934 | |
835 | 935 | if ($sort != "") |
836 | 936 | { |
@@ -1154,7 +1254,9 @@ discard block |
||
1154 | 1254 | global $global_query; |
1155 | 1255 | |
1156 | 1256 | date_default_timezone_set('UTC'); |
1157 | - if ($id == '') return array(); |
|
1257 | + if ($id == '') { |
|
1258 | + return array(); |
|
1259 | + } |
|
1158 | 1260 | $additional_query = "spotter_output.spotter_id = :id"; |
1159 | 1261 | $query_values = array(':id' => $id); |
1160 | 1262 | |
@@ -1781,7 +1883,9 @@ discard block |
||
1781 | 1883 | { |
1782 | 1884 | $highlight = $row['highlight']; |
1783 | 1885 | } |
1784 | - if (isset($highlight)) return $highlight; |
|
1886 | + if (isset($highlight)) { |
|
1887 | + return $highlight; |
|
1888 | + } |
|
1785 | 1889 | } |
1786 | 1890 | |
1787 | 1891 | |
@@ -1809,7 +1913,9 @@ discard block |
||
1809 | 1913 | $sth->closeCursor(); |
1810 | 1914 | if (count($row) > 0) { |
1811 | 1915 | return $row['usage']; |
1812 | - } else return ''; |
|
1916 | + } else { |
|
1917 | + return ''; |
|
1918 | + } |
|
1813 | 1919 | } |
1814 | 1920 | |
1815 | 1921 | /** |
@@ -1834,7 +1940,9 @@ discard block |
||
1834 | 1940 | $sth->closeCursor(); |
1835 | 1941 | if (count($row) > 0) { |
1836 | 1942 | return $row['icao']; |
1837 | - } else return ''; |
|
1943 | + } else { |
|
1944 | + return ''; |
|
1945 | + } |
|
1838 | 1946 | } |
1839 | 1947 | |
1840 | 1948 | /** |
@@ -1862,7 +1970,9 @@ discard block |
||
1862 | 1970 | $airport_longitude = $row['longitude']; |
1863 | 1971 | $Common = new Common(); |
1864 | 1972 | return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude); |
1865 | - } else return ''; |
|
1973 | + } else { |
|
1974 | + return ''; |
|
1975 | + } |
|
1866 | 1976 | } |
1867 | 1977 | |
1868 | 1978 | /** |
@@ -1974,7 +2084,9 @@ discard block |
||
1974 | 2084 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1975 | 2085 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1976 | 2086 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1977 | - } else return array(); |
|
2087 | + } else { |
|
2088 | + return array(); |
|
2089 | + } |
|
1978 | 2090 | if ($globalDBdriver == 'mysql') { |
1979 | 2091 | $query = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'"; |
1980 | 2092 | } else { |
@@ -2009,7 +2121,9 @@ discard block |
||
2009 | 2121 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2010 | 2122 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2011 | 2123 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
2012 | - } else return array(); |
|
2124 | + } else { |
|
2125 | + return array(); |
|
2126 | + } |
|
2013 | 2127 | //$query = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; |
2014 | 2128 | $query = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")"; |
2015 | 2129 | //$query = "SELECT waypoints.* FROM waypoints"; |
@@ -2044,7 +2158,9 @@ discard block |
||
2044 | 2158 | public function getAllAirlineInfo($airline_icao, $fromsource = NULL) |
2045 | 2159 | { |
2046 | 2160 | global $globalUseRealAirlines; |
2047 | - if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; |
|
2161 | + if (isset($globalUseRealAirlines) && $globalUseRealAirlines) { |
|
2162 | + $fromsource = NULL; |
|
2163 | + } |
|
2048 | 2164 | $airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING)); |
2049 | 2165 | if ($airline_icao == 'NA') { |
2050 | 2166 | $airline_array = array(); |
@@ -2094,7 +2210,9 @@ discard block |
||
2094 | 2210 | $sth->execute(array(':fromsource' => $fromsource)); |
2095 | 2211 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
2096 | 2212 | $sth->closeCursor(); |
2097 | - if ($row['nb'] == 0) $result = $this->getAllAirlineInfo($airline_icao); |
|
2213 | + if ($row['nb'] == 0) { |
|
2214 | + $result = $this->getAllAirlineInfo($airline_icao); |
|
2215 | + } |
|
2098 | 2216 | } |
2099 | 2217 | return $result; |
2100 | 2218 | } |
@@ -2158,15 +2276,20 @@ discard block |
||
2158 | 2276 | 'A320-211' => 'A320', |
2159 | 2277 | '747-8i' => 'B748', |
2160 | 2278 | 'A380' => 'A388'); |
2161 | - if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type]; |
|
2279 | + if (isset($all_aircraft[$aircraft_type])) { |
|
2280 | + return $all_aircraft[$aircraft_type]; |
|
2281 | + } |
|
2162 | 2282 | |
2163 | 2283 | $query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1"; |
2164 | 2284 | $aircraft_type = strtoupper($aircraft_type); |
2165 | 2285 | $sth = $this->db->prepare($query); |
2166 | 2286 | $sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,)); |
2167 | 2287 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
2168 | - if (isset($result[0]['icao'])) return $result[0]['icao']; |
|
2169 | - else return ''; |
|
2288 | + if (isset($result[0]['icao'])) { |
|
2289 | + return $result[0]['icao']; |
|
2290 | + } else { |
|
2291 | + return ''; |
|
2292 | + } |
|
2170 | 2293 | } |
2171 | 2294 | |
2172 | 2295 | /** |
@@ -2189,7 +2312,9 @@ discard block |
||
2189 | 2312 | $sth->closeCursor(); |
2190 | 2313 | if (isset($row['icaotypecode'])) { |
2191 | 2314 | return $row['icaotypecode']; |
2192 | - } else return ''; |
|
2315 | + } else { |
|
2316 | + return ''; |
|
2317 | + } |
|
2193 | 2318 | } |
2194 | 2319 | |
2195 | 2320 | /** |
@@ -2211,7 +2336,9 @@ discard block |
||
2211 | 2336 | $sth->closeCursor(); |
2212 | 2337 | if (isset($row['operator_correct'])) { |
2213 | 2338 | return $row['operator_correct']; |
2214 | - } else return $operator; |
|
2339 | + } else { |
|
2340 | + return $operator; |
|
2341 | + } |
|
2215 | 2342 | } |
2216 | 2343 | |
2217 | 2344 | /** |
@@ -2224,7 +2351,9 @@ discard block |
||
2224 | 2351 | public function getRouteInfo($callsign) |
2225 | 2352 | { |
2226 | 2353 | $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
2227 | - if ($callsign == '') return array(); |
|
2354 | + if ($callsign == '') { |
|
2355 | + return array(); |
|
2356 | + } |
|
2228 | 2357 | $query = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1"; |
2229 | 2358 | |
2230 | 2359 | $sth = $this->db->prepare($query); |
@@ -2234,7 +2363,9 @@ discard block |
||
2234 | 2363 | $sth->closeCursor(); |
2235 | 2364 | if (count($row) > 0) { |
2236 | 2365 | return $row; |
2237 | - } else return array(); |
|
2366 | + } else { |
|
2367 | + return array(); |
|
2368 | + } |
|
2238 | 2369 | } |
2239 | 2370 | |
2240 | 2371 | /** |
@@ -2287,7 +2418,9 @@ discard block |
||
2287 | 2418 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
2288 | 2419 | $sth->closeCursor(); |
2289 | 2420 | return $result; |
2290 | - } else return array(); |
|
2421 | + } else { |
|
2422 | + return array(); |
|
2423 | + } |
|
2291 | 2424 | } |
2292 | 2425 | |
2293 | 2426 | |
@@ -2444,8 +2577,11 @@ discard block |
||
2444 | 2577 | $query .= " ORDER BY spotter_output.source_name ASC"; |
2445 | 2578 | |
2446 | 2579 | $sth = $this->db->prepare($query); |
2447 | - if (!empty($query_values)) $sth->execute($query_values); |
|
2448 | - else $sth->execute(); |
|
2580 | + if (!empty($query_values)) { |
|
2581 | + $sth->execute($query_values); |
|
2582 | + } else { |
|
2583 | + $sth->execute(); |
|
2584 | + } |
|
2449 | 2585 | |
2450 | 2586 | $source_array = array(); |
2451 | 2587 | $temp_array = array(); |
@@ -2478,9 +2614,13 @@ discard block |
||
2478 | 2614 | WHERE spotter_output.airline_icao <> '' |
2479 | 2615 | ORDER BY spotter_output.airline_name ASC"; |
2480 | 2616 | */ |
2481 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource; |
|
2482 | - elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim'; |
|
2483 | - elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao'; |
|
2617 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
2618 | + $forsource = $globalAirlinesSource; |
|
2619 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
2620 | + $forsource = 'vatsim'; |
|
2621 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
2622 | + $forsource = 'ivao'; |
|
2623 | + } |
|
2484 | 2624 | if ($forsource === NULL) { |
2485 | 2625 | $query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource IS NULL ORDER BY name ASC"; |
2486 | 2626 | $query_data = array(); |
@@ -2772,7 +2912,9 @@ discard block |
||
2772 | 2912 | date_default_timezone_set($globalTimezone); |
2773 | 2913 | $datetime = new DateTime(); |
2774 | 2914 | $offset = $datetime->format('P'); |
2775 | - } else $offset = '+00:00'; |
|
2915 | + } else { |
|
2916 | + $offset = '+00:00'; |
|
2917 | + } |
|
2776 | 2918 | if ($airport_icao == '') { |
2777 | 2919 | if ($globalDBdriver == 'mysql') { |
2778 | 2920 | $query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
@@ -2804,7 +2946,9 @@ discard block |
||
2804 | 2946 | date_default_timezone_set($globalTimezone); |
2805 | 2947 | $datetime = new DateTime(); |
2806 | 2948 | $offset = $datetime->format('P'); |
2807 | - } else $offset = '+00:00'; |
|
2949 | + } else { |
|
2950 | + $offset = '+00:00'; |
|
2951 | + } |
|
2808 | 2952 | if ($airport_icao == '') { |
2809 | 2953 | if ($globalDBdriver == 'mysql') { |
2810 | 2954 | $query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC"; |
@@ -2837,7 +2981,9 @@ discard block |
||
2837 | 2981 | date_default_timezone_set($globalTimezone); |
2838 | 2982 | $datetime = new DateTime(); |
2839 | 2983 | $offset = $datetime->format('P'); |
2840 | - } else $offset = '+00:00'; |
|
2984 | + } else { |
|
2985 | + $offset = '+00:00'; |
|
2986 | + } |
|
2841 | 2987 | if ($airport_icao == '') { |
2842 | 2988 | if ($globalDBdriver == 'mysql') { |
2843 | 2989 | $query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
@@ -2876,7 +3022,9 @@ discard block |
||
2876 | 3022 | date_default_timezone_set($globalTimezone); |
2877 | 3023 | $datetime = new DateTime(); |
2878 | 3024 | $offset = $datetime->format('P'); |
2879 | - } else $offset = '+00:00'; |
|
3025 | + } else { |
|
3026 | + $offset = '+00:00'; |
|
3027 | + } |
|
2880 | 3028 | if ($airport_icao == '') { |
2881 | 3029 | if ($globalDBdriver == 'mysql') { |
2882 | 3030 | $query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
@@ -2921,7 +3069,9 @@ discard block |
||
2921 | 3069 | date_default_timezone_set($globalTimezone); |
2922 | 3070 | $datetime = new DateTime(); |
2923 | 3071 | $offset = $datetime->format('P'); |
2924 | - } else $offset = '+00:00'; |
|
3072 | + } else { |
|
3073 | + $offset = '+00:00'; |
|
3074 | + } |
|
2925 | 3075 | if ($airport_icao == '') { |
2926 | 3076 | if ($globalDBdriver == 'mysql') { |
2927 | 3077 | $query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
@@ -2956,7 +3106,9 @@ discard block |
||
2956 | 3106 | date_default_timezone_set($globalTimezone); |
2957 | 3107 | $datetime = new DateTime(); |
2958 | 3108 | $offset = $datetime->format('P'); |
2959 | - } else $offset = '+00:00'; |
|
3109 | + } else { |
|
3110 | + $offset = '+00:00'; |
|
3111 | + } |
|
2960 | 3112 | if ($airport_icao == '') { |
2961 | 3113 | if ($globalDBdriver == 'mysql') { |
2962 | 3114 | $query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
@@ -2998,7 +3150,9 @@ discard block |
||
2998 | 3150 | date_default_timezone_set($globalTimezone); |
2999 | 3151 | $datetime = new DateTime(); |
3000 | 3152 | $offset = $datetime->format('P'); |
3001 | - } else $offset = '+00:00'; |
|
3153 | + } else { |
|
3154 | + $offset = '+00:00'; |
|
3155 | + } |
|
3002 | 3156 | if ($airport_icao == '') { |
3003 | 3157 | if ($globalDBdriver == 'mysql') { |
3004 | 3158 | $query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC"; |
@@ -3032,7 +3186,9 @@ discard block |
||
3032 | 3186 | date_default_timezone_set($globalTimezone); |
3033 | 3187 | $datetime = new DateTime(); |
3034 | 3188 | $offset = $datetime->format('P'); |
3035 | - } else $offset = '+00:00'; |
|
3189 | + } else { |
|
3190 | + $offset = '+00:00'; |
|
3191 | + } |
|
3036 | 3192 | if ($airport_icao == '') { |
3037 | 3193 | if ($globalDBdriver == 'mysql') { |
3038 | 3194 | $query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date |
@@ -3080,7 +3236,9 @@ discard block |
||
3080 | 3236 | date_default_timezone_set($globalTimezone); |
3081 | 3237 | $datetime = new DateTime(); |
3082 | 3238 | $offset = $datetime->format('P'); |
3083 | - } else $offset = '+00:00'; |
|
3239 | + } else { |
|
3240 | + $offset = '+00:00'; |
|
3241 | + } |
|
3084 | 3242 | |
3085 | 3243 | if ($globalDBdriver == 'mysql') { |
3086 | 3244 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date |
@@ -3200,7 +3358,9 @@ discard block |
||
3200 | 3358 | */ |
3201 | 3359 | public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '') |
3202 | 3360 | { |
3203 | - if ($groundspeed == '') $groundspeed = NULL; |
|
3361 | + if ($groundspeed == '') { |
|
3362 | + $groundspeed = NULL; |
|
3363 | + } |
|
3204 | 3364 | $query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id'; |
3205 | 3365 | $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident); |
3206 | 3366 | |
@@ -3250,10 +3410,18 @@ discard block |
||
3250 | 3410 | $Image = new Image($this->db); |
3251 | 3411 | $Common = new Common(); |
3252 | 3412 | |
3253 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
3254 | - if (!isset($globalVATSIM)) $globalVATSIM = FALSE; |
|
3255 | - if (!isset($globalphpVMS)) $globalphpVMS = FALSE; |
|
3256 | - if (!isset($globalVAM)) $globalVAM = FALSE; |
|
3413 | + if (!isset($globalIVAO)) { |
|
3414 | + $globalIVAO = FALSE; |
|
3415 | + } |
|
3416 | + if (!isset($globalVATSIM)) { |
|
3417 | + $globalVATSIM = FALSE; |
|
3418 | + } |
|
3419 | + if (!isset($globalphpVMS)) { |
|
3420 | + $globalphpVMS = FALSE; |
|
3421 | + } |
|
3422 | + if (!isset($globalVAM)) { |
|
3423 | + $globalVAM = FALSE; |
|
3424 | + } |
|
3257 | 3425 | date_default_timezone_set('UTC'); |
3258 | 3426 | |
3259 | 3427 | //getting the registration |
@@ -3266,23 +3434,33 @@ discard block |
||
3266 | 3434 | if ($ModeS != '') { |
3267 | 3435 | $timeelapsed = microtime(true); |
3268 | 3436 | $registration = $this->getAircraftRegistrationBymodeS($ModeS); |
3269 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3437 | + if ($globalDebugTimeElapsed) { |
|
3438 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3439 | + } |
|
3270 | 3440 | } else { |
3271 | 3441 | $myhex = explode('-',$flightaware_id); |
3272 | 3442 | if (count($myhex) > 0) { |
3273 | 3443 | $timeelapsed = microtime(true); |
3274 | 3444 | $registration = $this->getAircraftRegistrationBymodeS($myhex[0]); |
3275 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3445 | + if ($globalDebugTimeElapsed) { |
|
3446 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3447 | + } |
|
3276 | 3448 | } |
3277 | 3449 | } |
3278 | 3450 | } |
3279 | 3451 | } |
3280 | 3452 | $fromsource = NULL; |
3281 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
3282 | - elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim'; |
|
3283 | - elseif ($format_source == 'whazzup') $fromsource = 'ivao'; |
|
3284 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
3285 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
3453 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
3454 | + $fromsource = $globalAirlinesSource; |
|
3455 | + } elseif ($format_source == 'vatsimtxt') { |
|
3456 | + $fromsource = 'vatsim'; |
|
3457 | + } elseif ($format_source == 'whazzup') { |
|
3458 | + $fromsource = 'ivao'; |
|
3459 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
3460 | + $fromsource = 'vatsim'; |
|
3461 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
3462 | + $fromsource = 'ivao'; |
|
3463 | + } |
|
3286 | 3464 | //getting the airline information |
3287 | 3465 | if ($ident != "") |
3288 | 3466 | { |
@@ -3306,15 +3484,21 @@ discard block |
||
3306 | 3484 | if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
3307 | 3485 | $airline_array = $this->getAllAirlineInfo("NA"); |
3308 | 3486 | } |
3309 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3487 | + if ($globalDebugTimeElapsed) { |
|
3488 | + echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3489 | + } |
|
3310 | 3490 | |
3311 | 3491 | } else { |
3312 | 3492 | $timeelapsed = microtime(true); |
3313 | 3493 | $airline_array = $this->getAllAirlineInfo("NA"); |
3314 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3494 | + if ($globalDebugTimeElapsed) { |
|
3495 | + echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3496 | + } |
|
3315 | 3497 | } |
3316 | 3498 | } |
3317 | - } else $airline_array = array(); |
|
3499 | + } else { |
|
3500 | + $airline_array = array(); |
|
3501 | + } |
|
3318 | 3502 | |
3319 | 3503 | //getting the aircraft information |
3320 | 3504 | $aircraft_array = array(); |
@@ -3328,27 +3512,37 @@ discard block |
||
3328 | 3512 | { |
3329 | 3513 | $timeelapsed = microtime(true); |
3330 | 3514 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
3331 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3515 | + if ($globalDebugTimeElapsed) { |
|
3516 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3517 | + } |
|
3332 | 3518 | } else { |
3333 | 3519 | $timeelapsed = microtime(true); |
3334 | 3520 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
3335 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3521 | + if ($globalDebugTimeElapsed) { |
|
3522 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3523 | + } |
|
3336 | 3524 | } |
3337 | 3525 | } |
3338 | 3526 | } else { |
3339 | 3527 | if ($ModeS != '') { |
3340 | 3528 | $timeelapsed = microtime(true); |
3341 | 3529 | $aircraft_icao = $this->getAllAircraftType($ModeS); |
3342 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3530 | + if ($globalDebugTimeElapsed) { |
|
3531 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3532 | + } |
|
3343 | 3533 | if ($aircraft_icao == "" || $aircraft_icao == "XXXX") |
3344 | 3534 | { |
3345 | 3535 | $timeelapsed = microtime(true); |
3346 | 3536 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
3347 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3537 | + if ($globalDebugTimeElapsed) { |
|
3538 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3539 | + } |
|
3348 | 3540 | } else { |
3349 | 3541 | $timeelapsed = microtime(true); |
3350 | 3542 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
3351 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3543 | + if ($globalDebugTimeElapsed) { |
|
3544 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3545 | + } |
|
3352 | 3546 | } |
3353 | 3547 | } |
3354 | 3548 | } |
@@ -3363,7 +3557,9 @@ discard block |
||
3363 | 3557 | } else { |
3364 | 3558 | $timeelapsed = microtime(true); |
3365 | 3559 | $departure_airport_array = $this->getAllAirportInfo($departure_airport_icao); |
3366 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3560 | + if ($globalDebugTimeElapsed) { |
|
3561 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3562 | + } |
|
3367 | 3563 | } |
3368 | 3564 | } |
3369 | 3565 | |
@@ -3377,7 +3573,9 @@ discard block |
||
3377 | 3573 | } else { |
3378 | 3574 | $timeelapsed = microtime(true); |
3379 | 3575 | $arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao); |
3380 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3576 | + if ($globalDebugTimeElapsed) { |
|
3577 | + echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3578 | + } |
|
3381 | 3579 | } |
3382 | 3580 | } |
3383 | 3581 | |
@@ -3412,7 +3610,9 @@ discard block |
||
3412 | 3610 | { |
3413 | 3611 | return false; |
3414 | 3612 | } |
3415 | - } else $altitude = 0; |
|
3613 | + } else { |
|
3614 | + $altitude = 0; |
|
3615 | + } |
|
3416 | 3616 | |
3417 | 3617 | if ($heading != "") |
3418 | 3618 | { |
@@ -3441,7 +3641,9 @@ discard block |
||
3441 | 3641 | { |
3442 | 3642 | $timeelapsed = microtime(true); |
3443 | 3643 | $image_array = $Image->getSpotterImage($registration); |
3444 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3644 | + if ($globalDebugTimeElapsed) { |
|
3645 | + echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3646 | + } |
|
3445 | 3647 | if (!isset($image_array[0]['registration'])) |
3446 | 3648 | { |
3447 | 3649 | //echo "Add image !!!! \n"; |
@@ -3449,14 +3651,21 @@ discard block |
||
3449 | 3651 | } |
3450 | 3652 | $timeelapsed = microtime(true); |
3451 | 3653 | $owner_info = $this->getAircraftOwnerByRegistration($registration); |
3452 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3453 | - if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
|
3654 | + if ($globalDebugTimeElapsed) { |
|
3655 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3656 | + } |
|
3657 | + if ($owner_info['owner'] != '') { |
|
3658 | + $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
|
3659 | + } |
|
3454 | 3660 | } |
3455 | 3661 | |
3456 | 3662 | if ($globalIVAO && $aircraft_icao != '') |
3457 | 3663 | { |
3458 | - if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao']; |
|
3459 | - else $airline_icao = ''; |
|
3664 | + if (isset($airline_array[0]['icao'])) { |
|
3665 | + $airline_icao = $airline_array[0]['icao']; |
|
3666 | + } else { |
|
3667 | + $airline_icao = ''; |
|
3668 | + } |
|
3460 | 3669 | $image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao); |
3461 | 3670 | if (!isset($image_array[0]['registration'])) |
3462 | 3671 | { |
@@ -3501,16 +3710,28 @@ discard block |
||
3501 | 3710 | { |
3502 | 3711 | $arrival_airport_array = $this->getAllAirportInfo('NA'); |
3503 | 3712 | } |
3504 | - if ($registration == '') $registration = 'NA'; |
|
3713 | + if ($registration == '') { |
|
3714 | + $registration = 'NA'; |
|
3715 | + } |
|
3505 | 3716 | if ($latitude == '' && $longitude == '') { |
3506 | 3717 | $latitude = 0; |
3507 | 3718 | $longitude = 0; |
3508 | 3719 | } |
3509 | - if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
3510 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
3511 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
3512 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
3513 | - if (!isset($aircraft_owner)) $aircraft_owner = NULL; |
|
3720 | + if ($squawk == '' || $Common->isInteger($squawk) === false) { |
|
3721 | + $squawk = NULL; |
|
3722 | + } |
|
3723 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) { |
|
3724 | + $verticalrate = NULL; |
|
3725 | + } |
|
3726 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
3727 | + $heading = 0; |
|
3728 | + } |
|
3729 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
3730 | + $groundspeed = 0; |
|
3731 | + } |
|
3732 | + if (!isset($aircraft_owner)) { |
|
3733 | + $aircraft_owner = NULL; |
|
3734 | + } |
|
3514 | 3735 | $query = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) |
3515 | 3736 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)"; |
3516 | 3737 | |
@@ -3521,9 +3742,13 @@ discard block |
||
3521 | 3742 | if ($airline_type == '') { |
3522 | 3743 | $timeelapsed = microtime(true); |
3523 | 3744 | $airline_type = $this->getAircraftTypeBymodeS($ModeS); |
3524 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3745 | + if ($globalDebugTimeElapsed) { |
|
3746 | + echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
3747 | + } |
|
3748 | + } |
|
3749 | + if ($airline_type == null) { |
|
3750 | + $airline_type = ''; |
|
3525 | 3751 | } |
3526 | - if ($airline_type == null) $airline_type = ''; |
|
3527 | 3752 | $aircraft_type = $aircraft_array[0]['type']; |
3528 | 3753 | $aircraft_manufacturer = $aircraft_array[0]['manufacturer']; |
3529 | 3754 | $departure_airport_name = $departure_airport_array[0]['name']; |
@@ -3658,7 +3883,9 @@ discard block |
||
3658 | 3883 | } |
3659 | 3884 | } |
3660 | 3885 | $query .= "GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC"; |
3661 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
3886 | + if ($limit) { |
|
3887 | + $query .= " LIMIT 10 OFFSET 0"; |
|
3888 | + } |
|
3662 | 3889 | |
3663 | 3890 | $sth = $this->db->prepare($query); |
3664 | 3891 | $sth->execute(); |
@@ -3703,7 +3930,9 @@ discard block |
||
3703 | 3930 | } |
3704 | 3931 | } |
3705 | 3932 | $query .= "GROUP BY spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC"; |
3706 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
3933 | + if ($limit) { |
|
3934 | + $query .= " LIMIT 10 OFFSET 0"; |
|
3935 | + } |
|
3707 | 3936 | |
3708 | 3937 | |
3709 | 3938 | $sth = $this->db->prepare($query); |
@@ -3749,7 +3978,9 @@ discard block |
||
3749 | 3978 | } |
3750 | 3979 | } |
3751 | 3980 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC"; |
3752 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
3981 | + if ($limit) { |
|
3982 | + $query .= " LIMIT 10 OFFSET 0"; |
|
3983 | + } |
|
3753 | 3984 | |
3754 | 3985 | |
3755 | 3986 | $sth = $this->db->prepare($query); |
@@ -3797,7 +4028,9 @@ discard block |
||
3797 | 4028 | } |
3798 | 4029 | } |
3799 | 4030 | $query .= "GROUP BY spotter_output.owner_name ORDER BY owner_count DESC"; |
3800 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4031 | + if ($limit) { |
|
4032 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4033 | + } |
|
3801 | 4034 | |
3802 | 4035 | |
3803 | 4036 | $sth = $this->db->prepare($query); |
@@ -3842,7 +4075,9 @@ discard block |
||
3842 | 4075 | } |
3843 | 4076 | } |
3844 | 4077 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC"; |
3845 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4078 | + if ($limit) { |
|
4079 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4080 | + } |
|
3846 | 4081 | |
3847 | 4082 | |
3848 | 4083 | $sth = $this->db->prepare($query); |
@@ -4085,7 +4320,9 @@ discard block |
||
4085 | 4320 | date_default_timezone_set($globalTimezone); |
4086 | 4321 | $datetime = new DateTime($date); |
4087 | 4322 | $offset = $datetime->format('P'); |
4088 | - } else $offset = '+00:00'; |
|
4323 | + } else { |
|
4324 | + $offset = '+00:00'; |
|
4325 | + } |
|
4089 | 4326 | |
4090 | 4327 | if ($globalDBdriver == 'mysql') { |
4091 | 4328 | $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
@@ -4133,7 +4370,9 @@ discard block |
||
4133 | 4370 | date_default_timezone_set($globalTimezone); |
4134 | 4371 | $datetime = new DateTime($date); |
4135 | 4372 | $offset = $datetime->format('P'); |
4136 | - } else $offset = '+00:00'; |
|
4373 | + } else { |
|
4374 | + $offset = '+00:00'; |
|
4375 | + } |
|
4137 | 4376 | |
4138 | 4377 | if ($globalDBdriver == 'mysql') { |
4139 | 4378 | $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
@@ -4351,7 +4590,9 @@ discard block |
||
4351 | 4590 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' |
4352 | 4591 | GROUP BY spotter_output.airline_country |
4353 | 4592 | ORDER BY airline_country_count DESC"; |
4354 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4593 | + if ($limit) { |
|
4594 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4595 | + } |
|
4355 | 4596 | |
4356 | 4597 | $sth = $this->db->prepare($query); |
4357 | 4598 | $sth->execute(); |
@@ -4379,7 +4620,9 @@ discard block |
||
4379 | 4620 | global $globalDBdriver; |
4380 | 4621 | //$filter_query = $this->getFilter($filters,true,true); |
4381 | 4622 | $Connection= new Connection($this->db); |
4382 | - if (!$Connection->tableExists('countries')) return array(); |
|
4623 | + if (!$Connection->tableExists('countries')) { |
|
4624 | + return array(); |
|
4625 | + } |
|
4383 | 4626 | /* |
4384 | 4627 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
4385 | 4628 | FROM countries c, spotter_output s |
@@ -4404,7 +4647,9 @@ discard block |
||
4404 | 4647 | } |
4405 | 4648 | |
4406 | 4649 | $query .= "GROUP BY c.name ORDER BY nb DESC"; |
4407 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4650 | + if ($limit) { |
|
4651 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4652 | + } |
|
4408 | 4653 | |
4409 | 4654 | |
4410 | 4655 | $sth = $this->db->prepare($query); |
@@ -4454,7 +4699,9 @@ discard block |
||
4454 | 4699 | } |
4455 | 4700 | |
4456 | 4701 | $query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
4457 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4702 | + if ($limit) { |
|
4703 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4704 | + } |
|
4458 | 4705 | |
4459 | 4706 | $sth = $this->db->prepare($query); |
4460 | 4707 | $sth->execute(); |
@@ -4500,7 +4747,9 @@ discard block |
||
4500 | 4747 | } |
4501 | 4748 | |
4502 | 4749 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
4503 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4750 | + if ($limit) { |
|
4751 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4752 | + } |
|
4504 | 4753 | |
4505 | 4754 | $sth = $this->db->prepare($query); |
4506 | 4755 | $sth->execute(); |
@@ -4547,7 +4796,9 @@ discard block |
||
4547 | 4796 | } |
4548 | 4797 | |
4549 | 4798 | $query .= "GROUP BY EXTRACT(month from spotter_output.date), EXTRACT(year from spotter_output.date), spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC"; |
4550 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
4799 | + if ($limit) { |
|
4800 | + $query .= " LIMIT 10 OFFSET 0"; |
|
4801 | + } |
|
4551 | 4802 | |
4552 | 4803 | $sth = $this->db->prepare($query); |
4553 | 4804 | $sth->execute(); |
@@ -4600,7 +4851,9 @@ discard block |
||
4600 | 4851 | if($row['registration'] != "") |
4601 | 4852 | { |
4602 | 4853 | $image_array = $Image->getSpotterImage($row['registration']); |
4603 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
4854 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
4855 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
4856 | + } |
|
4604 | 4857 | } |
4605 | 4858 | $temp_array['registration_count'] = $row['registration_count']; |
4606 | 4859 | |
@@ -4675,7 +4928,9 @@ discard block |
||
4675 | 4928 | if($row['registration'] != "") |
4676 | 4929 | { |
4677 | 4930 | $image_array = $Image->getSpotterImage($row['registration']); |
4678 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
4931 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
4932 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
4933 | + } |
|
4679 | 4934 | } |
4680 | 4935 | $temp_array['registration_count'] = $row['registration_count']; |
4681 | 4936 | |
@@ -4782,7 +5037,9 @@ discard block |
||
4782 | 5037 | if($row['registration'] != "") |
4783 | 5038 | { |
4784 | 5039 | $image_array = $Image->getSpotterImage($row['registration']); |
4785 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5040 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5041 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5042 | + } |
|
4786 | 5043 | } |
4787 | 5044 | $temp_array['registration_count'] = $row['registration_count']; |
4788 | 5045 | $aircraft_array[] = $temp_array; |
@@ -4907,7 +5164,9 @@ discard block |
||
4907 | 5164 | date_default_timezone_set($globalTimezone); |
4908 | 5165 | $datetime = new DateTime($date); |
4909 | 5166 | $offset = $datetime->format('P'); |
4910 | - } else $offset = '+00:00'; |
|
5167 | + } else { |
|
5168 | + $offset = '+00:00'; |
|
5169 | + } |
|
4911 | 5170 | |
4912 | 5171 | if ($globalDBdriver == 'mysql') { |
4913 | 5172 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
@@ -4954,7 +5213,9 @@ discard block |
||
4954 | 5213 | date_default_timezone_set($globalTimezone); |
4955 | 5214 | $datetime = new DateTime($date); |
4956 | 5215 | $offset = $datetime->format('P'); |
4957 | - } else $offset = '+00:00'; |
|
5216 | + } else { |
|
5217 | + $offset = '+00:00'; |
|
5218 | + } |
|
4958 | 5219 | |
4959 | 5220 | if ($globalDBdriver == 'mysql') { |
4960 | 5221 | $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
@@ -4983,7 +5244,9 @@ discard block |
||
4983 | 5244 | if($row['registration'] != "") |
4984 | 5245 | { |
4985 | 5246 | $image_array = $Image->getSpotterImage($row['registration']); |
4986 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5247 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5248 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5249 | + } |
|
4987 | 5250 | } |
4988 | 5251 | $temp_array['registration_count'] = $row['registration_count']; |
4989 | 5252 | |
@@ -5008,7 +5271,9 @@ discard block |
||
5008 | 5271 | date_default_timezone_set($globalTimezone); |
5009 | 5272 | $datetime = new DateTime($date); |
5010 | 5273 | $offset = $datetime->format('P'); |
5011 | - } else $offset = '+00:00'; |
|
5274 | + } else { |
|
5275 | + $offset = '+00:00'; |
|
5276 | + } |
|
5012 | 5277 | |
5013 | 5278 | if ($globalDBdriver == 'mysql') { |
5014 | 5279 | $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
@@ -5106,8 +5371,11 @@ discard block |
||
5106 | 5371 | if($row['registration'] != "") |
5107 | 5372 | { |
5108 | 5373 | $image_array = $Image->getSpotterImage($row['registration']); |
5109 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5110 | - else $temp_array['image_thumbnail'] = ''; |
|
5374 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5375 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5376 | + } else { |
|
5377 | + $temp_array['image_thumbnail'] = ''; |
|
5378 | + } |
|
5111 | 5379 | } |
5112 | 5380 | $temp_array['registration_count'] = $row['registration_count']; |
5113 | 5381 | $aircraft_array[] = $temp_array; |
@@ -5214,7 +5482,9 @@ discard block |
||
5214 | 5482 | if($row['registration'] != "") |
5215 | 5483 | { |
5216 | 5484 | $image_array = $Image->getSpotterImage($row['registration']); |
5217 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5485 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5486 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5487 | + } |
|
5218 | 5488 | } |
5219 | 5489 | $temp_array['registration_count'] = $row['registration_count']; |
5220 | 5490 | |
@@ -5331,7 +5601,9 @@ discard block |
||
5331 | 5601 | if($row['registration'] != "") |
5332 | 5602 | { |
5333 | 5603 | $image_array = $Image->getSpotterImage($row['registration']); |
5334 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5604 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5605 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5606 | + } |
|
5335 | 5607 | } |
5336 | 5608 | $temp_array['registration_count'] = $row['registration_count']; |
5337 | 5609 | |
@@ -5443,7 +5715,9 @@ discard block |
||
5443 | 5715 | // if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
5444 | 5716 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
5445 | 5717 | $query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; |
5446 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5718 | + if ($limit) { |
|
5719 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5720 | + } |
|
5447 | 5721 | |
5448 | 5722 | $sth = $this->db->prepare($query); |
5449 | 5723 | $sth->execute(); |
@@ -5462,7 +5736,9 @@ discard block |
||
5462 | 5736 | if($row['registration'] != "") |
5463 | 5737 | { |
5464 | 5738 | $image_array = $Image->getSpotterImage($row['registration']); |
5465 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5739 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5740 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5741 | + } |
|
5466 | 5742 | } |
5467 | 5743 | |
5468 | 5744 | $aircraft_array[] = $temp_array; |
@@ -5503,7 +5779,9 @@ discard block |
||
5503 | 5779 | // if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
5504 | 5780 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
5505 | 5781 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; |
5506 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5782 | + if ($limit) { |
|
5783 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5784 | + } |
|
5507 | 5785 | |
5508 | 5786 | $sth = $this->db->prepare($query); |
5509 | 5787 | $sth->execute(); |
@@ -5523,7 +5801,9 @@ discard block |
||
5523 | 5801 | if($row['registration'] != "") |
5524 | 5802 | { |
5525 | 5803 | $image_array = $Image->getSpotterImage($row['registration']); |
5526 | - if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5804 | + if (isset($image_array[0]['image_thumbnail'])) { |
|
5805 | + $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
|
5806 | + } |
|
5527 | 5807 | } |
5528 | 5808 | |
5529 | 5809 | $aircraft_array[] = $temp_array; |
@@ -5564,7 +5844,9 @@ discard block |
||
5564 | 5844 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
5565 | 5845 | $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
5566 | 5846 | ORDER BY airport_departure_icao_count DESC"; |
5567 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5847 | + if ($limit) { |
|
5848 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5849 | + } |
|
5568 | 5850 | |
5569 | 5851 | $sth = $this->db->prepare($query); |
5570 | 5852 | $sth->execute(); |
@@ -5616,7 +5898,9 @@ discard block |
||
5616 | 5898 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
5617 | 5899 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
5618 | 5900 | ORDER BY airport_departure_icao_count DESC"; |
5619 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5901 | + if ($limit) { |
|
5902 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5903 | + } |
|
5620 | 5904 | |
5621 | 5905 | $sth = $this->db->prepare($query); |
5622 | 5906 | $sth->execute(); |
@@ -5668,7 +5952,9 @@ discard block |
||
5668 | 5952 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
5669 | 5953 | $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country |
5670 | 5954 | ORDER BY airport_departure_icao_count DESC"; |
5671 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
5955 | + if ($limit) { |
|
5956 | + $query .= " LIMIT 10 OFFSET 0"; |
|
5957 | + } |
|
5672 | 5958 | //echo $query; |
5673 | 5959 | $sth = $this->db->prepare($query); |
5674 | 5960 | $sth->execute(); |
@@ -5720,7 +6006,9 @@ discard block |
||
5720 | 6006 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
5721 | 6007 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country |
5722 | 6008 | ORDER BY airport_departure_icao_count DESC"; |
5723 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
6009 | + if ($limit) { |
|
6010 | + $query .= " LIMIT 10 OFFSET 0"; |
|
6011 | + } |
|
5724 | 6012 | |
5725 | 6013 | $sth = $this->db->prepare($query); |
5726 | 6014 | $sth->execute(); |
@@ -6115,7 +6403,9 @@ discard block |
||
6115 | 6403 | date_default_timezone_set($globalTimezone); |
6116 | 6404 | $datetime = new DateTime($date); |
6117 | 6405 | $offset = $datetime->format('P'); |
6118 | - } else $offset = '+00:00'; |
|
6406 | + } else { |
|
6407 | + $offset = '+00:00'; |
|
6408 | + } |
|
6119 | 6409 | |
6120 | 6410 | if ($globalDBdriver == 'mysql') { |
6121 | 6411 | $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
@@ -6165,7 +6455,9 @@ discard block |
||
6165 | 6455 | date_default_timezone_set($globalTimezone); |
6166 | 6456 | $datetime = new DateTime($date); |
6167 | 6457 | $offset = $datetime->format('P'); |
6168 | - } else $offset = '+00:00'; |
|
6458 | + } else { |
|
6459 | + $offset = '+00:00'; |
|
6460 | + } |
|
6169 | 6461 | |
6170 | 6462 | if ($globalDBdriver == 'mysql') { |
6171 | 6463 | $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
@@ -6378,7 +6670,9 @@ discard block |
||
6378 | 6670 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
6379 | 6671 | $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
6380 | 6672 | ORDER BY airport_arrival_icao_count DESC"; |
6381 | - if ($limit) $query .= " LIMIT 10"; |
|
6673 | + if ($limit) { |
|
6674 | + $query .= " LIMIT 10"; |
|
6675 | + } |
|
6382 | 6676 | |
6383 | 6677 | |
6384 | 6678 | $sth = $this->db->prepare($query); |
@@ -6398,7 +6692,9 @@ discard block |
||
6398 | 6692 | if ($icaoaskey) { |
6399 | 6693 | $icao = $row['arrival_airport_icao']; |
6400 | 6694 | $airport_array[$icao] = $temp_array; |
6401 | - } else $airport_array[] = $temp_array; |
|
6695 | + } else { |
|
6696 | + $airport_array[] = $temp_array; |
|
6697 | + } |
|
6402 | 6698 | } |
6403 | 6699 | |
6404 | 6700 | return $airport_array; |
@@ -6440,7 +6736,9 @@ discard block |
||
6440 | 6736 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
6441 | 6737 | $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
6442 | 6738 | ORDER BY airport_arrival_icao_count DESC"; |
6443 | - if ($limit) $query .= " LIMIT 10"; |
|
6739 | + if ($limit) { |
|
6740 | + $query .= " LIMIT 10"; |
|
6741 | + } |
|
6444 | 6742 | |
6445 | 6743 | |
6446 | 6744 | $sth = $this->db->prepare($query); |
@@ -6461,7 +6759,9 @@ discard block |
||
6461 | 6759 | if ($icaoaskey) { |
6462 | 6760 | $icao = $row['arrival_airport_icao']; |
6463 | 6761 | $airport_array[$icao] = $temp_array; |
6464 | - } else $airport_array[] = $temp_array; |
|
6762 | + } else { |
|
6763 | + $airport_array[] = $temp_array; |
|
6764 | + } |
|
6465 | 6765 | } |
6466 | 6766 | |
6467 | 6767 | return $airport_array; |
@@ -6503,7 +6803,9 @@ discard block |
||
6503 | 6803 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
6504 | 6804 | $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country |
6505 | 6805 | ORDER BY airport_arrival_icao_count DESC"; |
6506 | - if ($limit) $query .= " LIMIT 10"; |
|
6806 | + if ($limit) { |
|
6807 | + $query .= " LIMIT 10"; |
|
6808 | + } |
|
6507 | 6809 | |
6508 | 6810 | |
6509 | 6811 | $sth = $this->db->prepare($query); |
@@ -6523,7 +6825,9 @@ discard block |
||
6523 | 6825 | if ($icaoaskey) { |
6524 | 6826 | $icao = $row['arrival_airport_icao']; |
6525 | 6827 | $airport_array[$icao] = $temp_array; |
6526 | - } else $airport_array[] = $temp_array; |
|
6828 | + } else { |
|
6829 | + $airport_array[] = $temp_array; |
|
6830 | + } |
|
6527 | 6831 | } |
6528 | 6832 | |
6529 | 6833 | return $airport_array; |
@@ -6565,7 +6869,9 @@ discard block |
||
6565 | 6869 | //if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
6566 | 6870 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country |
6567 | 6871 | ORDER BY airport_arrival_icao_count DESC"; |
6568 | - if ($limit) $query .= " LIMIT 10"; |
|
6872 | + if ($limit) { |
|
6873 | + $query .= " LIMIT 10"; |
|
6874 | + } |
|
6569 | 6875 | |
6570 | 6876 | |
6571 | 6877 | $sth = $this->db->prepare($query); |
@@ -6586,7 +6892,9 @@ discard block |
||
6586 | 6892 | if ($icaoaskey) { |
6587 | 6893 | $icao = $row['arrival_airport_icao']; |
6588 | 6894 | $airport_array[$icao] = $temp_array; |
6589 | - } else $airport_array[] = $temp_array; |
|
6895 | + } else { |
|
6896 | + $airport_array[] = $temp_array; |
|
6897 | + } |
|
6590 | 6898 | } |
6591 | 6899 | |
6592 | 6900 | return $airport_array; |
@@ -6967,7 +7275,9 @@ discard block |
||
6967 | 7275 | date_default_timezone_set($globalTimezone); |
6968 | 7276 | $datetime = new DateTime($date); |
6969 | 7277 | $offset = $datetime->format('P'); |
6970 | - } else $offset = '+00:00'; |
|
7278 | + } else { |
|
7279 | + $offset = '+00:00'; |
|
7280 | + } |
|
6971 | 7281 | |
6972 | 7282 | if ($globalDBdriver == 'mysql') { |
6973 | 7283 | $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
@@ -7017,7 +7327,9 @@ discard block |
||
7017 | 7327 | date_default_timezone_set($globalTimezone); |
7018 | 7328 | $datetime = new DateTime($date); |
7019 | 7329 | $offset = $datetime->format('P'); |
7020 | - } else $offset = '+00:00'; |
|
7330 | + } else { |
|
7331 | + $offset = '+00:00'; |
|
7332 | + } |
|
7021 | 7333 | |
7022 | 7334 | if ($globalDBdriver == 'mysql') { |
7023 | 7335 | $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
@@ -7240,7 +7552,9 @@ discard block |
||
7240 | 7552 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA'"; |
7241 | 7553 | $query .= " GROUP BY spotter_output.arrival_airport_country |
7242 | 7554 | ORDER BY airport_arrival_country_count DESC"; |
7243 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
7555 | + if ($limit) { |
|
7556 | + $query .= " LIMIT 10 OFFSET 0"; |
|
7557 | + } |
|
7244 | 7558 | |
7245 | 7559 | |
7246 | 7560 | $sth = $this->db->prepare($query); |
@@ -7527,7 +7841,9 @@ discard block |
||
7527 | 7841 | date_default_timezone_set($globalTimezone); |
7528 | 7842 | $datetime = new DateTime($date); |
7529 | 7843 | $offset = $datetime->format('P'); |
7530 | - } else $offset = '+00:00'; |
|
7844 | + } else { |
|
7845 | + $offset = '+00:00'; |
|
7846 | + } |
|
7531 | 7847 | |
7532 | 7848 | if ($globalDBdriver == 'mysql') { |
7533 | 7849 | $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
@@ -7703,15 +8019,23 @@ discard block |
||
7703 | 8019 | $query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao |
7704 | 8020 | FROM spotter_output".$filter_query." spotter_output.ident <> '' "; |
7705 | 8021 | if ($olderthanmonths > 0) { |
7706 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
7707 | - else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
8022 | + if ($globalDBdriver == 'mysql') { |
|
8023 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
8024 | + } else { |
|
8025 | + $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
8026 | + } |
|
7708 | 8027 | } |
7709 | 8028 | if ($sincedate != '') { |
7710 | - if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'"; |
|
7711 | - else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
8029 | + if ($globalDBdriver == 'mysql') { |
|
8030 | + $query .= " AND spotter_output.date > '".$sincedate."'"; |
|
8031 | + } else { |
|
8032 | + $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
8033 | + } |
|
7712 | 8034 | } |
7713 | 8035 | $query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC"; |
7714 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
8036 | + if ($limit) { |
|
8037 | + $query .= " LIMIT 10 OFFSET 0"; |
|
8038 | + } |
|
7715 | 8039 | |
7716 | 8040 | $sth = $this->db->prepare($query); |
7717 | 8041 | $sth->execute(); |
@@ -7745,15 +8069,23 @@ discard block |
||
7745 | 8069 | $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name |
7746 | 8070 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao <> '' "; |
7747 | 8071 | if ($olderthanmonths > 0) { |
7748 | - if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
7749 | - else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
8072 | + if ($globalDBdriver == 'mysql') { |
|
8073 | + $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
|
8074 | + } else { |
|
8075 | + $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' "; |
|
8076 | + } |
|
7750 | 8077 | } |
7751 | 8078 | if ($sincedate != '') { |
7752 | - if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' "; |
|
7753 | - else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) "; |
|
8079 | + if ($globalDBdriver == 'mysql') { |
|
8080 | + $query .= "AND spotter_output.date > '".$sincedate."' "; |
|
8081 | + } else { |
|
8082 | + $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) "; |
|
8083 | + } |
|
7754 | 8084 | } |
7755 | 8085 | $query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC"; |
7756 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
8086 | + if ($limit) { |
|
8087 | + $query .= " LIMIT 10 OFFSET 0"; |
|
8088 | + } |
|
7757 | 8089 | |
7758 | 8090 | $sth = $this->db->prepare($query); |
7759 | 8091 | $sth->execute(); |
@@ -7790,7 +8122,9 @@ discard block |
||
7790 | 8122 | date_default_timezone_set($globalTimezone); |
7791 | 8123 | $datetime = new DateTime(); |
7792 | 8124 | $offset = $datetime->format('P'); |
7793 | - } else $offset = '+00:00'; |
|
8125 | + } else { |
|
8126 | + $offset = '+00:00'; |
|
8127 | + } |
|
7794 | 8128 | |
7795 | 8129 | if ($globalDBdriver == 'mysql') { |
7796 | 8130 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -7839,7 +8173,9 @@ discard block |
||
7839 | 8173 | date_default_timezone_set($globalTimezone); |
7840 | 8174 | $datetime = new DateTime(); |
7841 | 8175 | $offset = $datetime->format('P'); |
7842 | - } else $offset = '+00:00'; |
|
8176 | + } else { |
|
8177 | + $offset = '+00:00'; |
|
8178 | + } |
|
7843 | 8179 | $filter_query = $this->getFilter($filters,true,true); |
7844 | 8180 | if ($globalDBdriver == 'mysql') { |
7845 | 8181 | $query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -7888,7 +8224,9 @@ discard block |
||
7888 | 8224 | date_default_timezone_set($globalTimezone); |
7889 | 8225 | $datetime = new DateTime(); |
7890 | 8226 | $offset = $datetime->format('P'); |
7891 | - } else $offset = '+00:00'; |
|
8227 | + } else { |
|
8228 | + $offset = '+00:00'; |
|
8229 | + } |
|
7892 | 8230 | $filter_query = $this->getFilter($filters,true,true); |
7893 | 8231 | if ($globalDBdriver == 'mysql') { |
7894 | 8232 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -7934,7 +8272,9 @@ discard block |
||
7934 | 8272 | date_default_timezone_set($globalTimezone); |
7935 | 8273 | $datetime = new DateTime(); |
7936 | 8274 | $offset = $datetime->format('P'); |
7937 | - } else $offset = '+00:00'; |
|
8275 | + } else { |
|
8276 | + $offset = '+00:00'; |
|
8277 | + } |
|
7938 | 8278 | $filter_query = $this->getFilter($filters,true,true); |
7939 | 8279 | if ($globalDBdriver == 'mysql') { |
7940 | 8280 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -7982,7 +8322,9 @@ discard block |
||
7982 | 8322 | date_default_timezone_set($globalTimezone); |
7983 | 8323 | $datetime = new DateTime(); |
7984 | 8324 | $offset = $datetime->format('P'); |
7985 | - } else $offset = '+00:00'; |
|
8325 | + } else { |
|
8326 | + $offset = '+00:00'; |
|
8327 | + } |
|
7986 | 8328 | |
7987 | 8329 | if ($globalDBdriver == 'mysql') { |
7988 | 8330 | $query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -8030,7 +8372,9 @@ discard block |
||
8030 | 8372 | date_default_timezone_set($globalTimezone); |
8031 | 8373 | $datetime = new DateTime(); |
8032 | 8374 | $offset = $datetime->format('P'); |
8033 | - } else $offset = '+00:00'; |
|
8375 | + } else { |
|
8376 | + $offset = '+00:00'; |
|
8377 | + } |
|
8034 | 8378 | |
8035 | 8379 | if ($globalDBdriver == 'mysql') { |
8036 | 8380 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -8077,7 +8421,9 @@ discard block |
||
8077 | 8421 | date_default_timezone_set($globalTimezone); |
8078 | 8422 | $datetime = new DateTime(); |
8079 | 8423 | $offset = $datetime->format('P'); |
8080 | - } else $offset = '+00:00'; |
|
8424 | + } else { |
|
8425 | + $offset = '+00:00'; |
|
8426 | + } |
|
8081 | 8427 | |
8082 | 8428 | if ($globalDBdriver == 'mysql') { |
8083 | 8429 | $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -8125,7 +8471,9 @@ discard block |
||
8125 | 8471 | date_default_timezone_set($globalTimezone); |
8126 | 8472 | $datetime = new DateTime(); |
8127 | 8473 | $offset = $datetime->format('P'); |
8128 | - } else $offset = '+00:00'; |
|
8474 | + } else { |
|
8475 | + $offset = '+00:00'; |
|
8476 | + } |
|
8129 | 8477 | $filter_query = $this->getFilter($filters,true,true); |
8130 | 8478 | if ($globalDBdriver == 'mysql') { |
8131 | 8479 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -8170,7 +8518,9 @@ discard block |
||
8170 | 8518 | date_default_timezone_set($globalTimezone); |
8171 | 8519 | $datetime = new DateTime(); |
8172 | 8520 | $offset = $datetime->format('P'); |
8173 | - } else $offset = '+00:00'; |
|
8521 | + } else { |
|
8522 | + $offset = '+00:00'; |
|
8523 | + } |
|
8174 | 8524 | $filter_query = $this->getFilter($filters,true,true); |
8175 | 8525 | |
8176 | 8526 | if ($globalDBdriver == 'mysql') { |
@@ -8217,7 +8567,9 @@ discard block |
||
8217 | 8567 | date_default_timezone_set($globalTimezone); |
8218 | 8568 | $datetime = new DateTime(); |
8219 | 8569 | $offset = $datetime->format('P'); |
8220 | - } else $offset = '+00:00'; |
|
8570 | + } else { |
|
8571 | + $offset = '+00:00'; |
|
8572 | + } |
|
8221 | 8573 | |
8222 | 8574 | if ($globalDBdriver == 'mysql') { |
8223 | 8575 | $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count |
@@ -8263,7 +8615,9 @@ discard block |
||
8263 | 8615 | date_default_timezone_set($globalTimezone); |
8264 | 8616 | $datetime = new DateTime(); |
8265 | 8617 | $offset = $datetime->format('P'); |
8266 | - } else $offset = '+00:00'; |
|
8618 | + } else { |
|
8619 | + $offset = '+00:00'; |
|
8620 | + } |
|
8267 | 8621 | $filter_query = $this->getFilter($filters,true,true); |
8268 | 8622 | |
8269 | 8623 | if ($globalDBdriver == 'mysql') { |
@@ -8310,7 +8664,9 @@ discard block |
||
8310 | 8664 | date_default_timezone_set($globalTimezone); |
8311 | 8665 | $datetime = new DateTime(); |
8312 | 8666 | $offset = $datetime->format('P'); |
8313 | - } else $offset = '+00:00'; |
|
8667 | + } else { |
|
8668 | + $offset = '+00:00'; |
|
8669 | + } |
|
8314 | 8670 | |
8315 | 8671 | if ($globalDBdriver == 'mysql') { |
8316 | 8672 | $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count |
@@ -8357,7 +8713,9 @@ discard block |
||
8357 | 8713 | date_default_timezone_set($globalTimezone); |
8358 | 8714 | $datetime = new DateTime(); |
8359 | 8715 | $offset = $datetime->format('P'); |
8360 | - } else $offset = '+00:00'; |
|
8716 | + } else { |
|
8717 | + $offset = '+00:00'; |
|
8718 | + } |
|
8361 | 8719 | |
8362 | 8720 | if ($globalDBdriver == 'mysql') { |
8363 | 8721 | $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count |
@@ -8402,7 +8760,9 @@ discard block |
||
8402 | 8760 | date_default_timezone_set($globalTimezone); |
8403 | 8761 | $datetime = new DateTime(); |
8404 | 8762 | $offset = $datetime->format('P'); |
8405 | - } else $offset = '+00:00'; |
|
8763 | + } else { |
|
8764 | + $offset = '+00:00'; |
|
8765 | + } |
|
8406 | 8766 | $filter_query = $this->getFilter($filters,true,true); |
8407 | 8767 | |
8408 | 8768 | if ($globalDBdriver == 'mysql') { |
@@ -8450,7 +8810,9 @@ discard block |
||
8450 | 8810 | date_default_timezone_set($globalTimezone); |
8451 | 8811 | $datetime = new DateTime(); |
8452 | 8812 | $offset = $datetime->format('P'); |
8453 | - } else $offset = '+00:00'; |
|
8813 | + } else { |
|
8814 | + $offset = '+00:00'; |
|
8815 | + } |
|
8454 | 8816 | |
8455 | 8817 | if ($globalDBdriver == 'mysql') { |
8456 | 8818 | $query = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count |
@@ -8496,7 +8858,9 @@ discard block |
||
8496 | 8858 | date_default_timezone_set($globalTimezone); |
8497 | 8859 | $datetime = new DateTime(); |
8498 | 8860 | $offset = $datetime->format('P'); |
8499 | - } else $offset = '+00:00'; |
|
8861 | + } else { |
|
8862 | + $offset = '+00:00'; |
|
8863 | + } |
|
8500 | 8864 | $filter_query = $this->getFilter($filters,true,true); |
8501 | 8865 | |
8502 | 8866 | if ($globalDBdriver == 'mysql') { |
@@ -8544,7 +8908,9 @@ discard block |
||
8544 | 8908 | date_default_timezone_set($globalTimezone); |
8545 | 8909 | $datetime = new DateTime(); |
8546 | 8910 | $offset = $datetime->format('P'); |
8547 | - } else $offset = '+00:00'; |
|
8911 | + } else { |
|
8912 | + $offset = '+00:00'; |
|
8913 | + } |
|
8548 | 8914 | |
8549 | 8915 | if ($globalDBdriver == 'mysql') { |
8550 | 8916 | $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count |
@@ -8591,7 +8957,9 @@ discard block |
||
8591 | 8957 | date_default_timezone_set($globalTimezone); |
8592 | 8958 | $datetime = new DateTime(); |
8593 | 8959 | $offset = $datetime->format('P'); |
8594 | - } else $offset = '+00:00'; |
|
8960 | + } else { |
|
8961 | + $offset = '+00:00'; |
|
8962 | + } |
|
8595 | 8963 | $filter_query = $this->getFilter($filters,true,true); |
8596 | 8964 | if ($globalDBdriver == 'mysql') { |
8597 | 8965 | $query = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -8640,7 +9008,9 @@ discard block |
||
8640 | 9008 | date_default_timezone_set($globalTimezone); |
8641 | 9009 | $datetime = new DateTime(); |
8642 | 9010 | $offset = $datetime->format('P'); |
8643 | - } else $offset = '+00:00'; |
|
9011 | + } else { |
|
9012 | + $offset = '+00:00'; |
|
9013 | + } |
|
8644 | 9014 | |
8645 | 9015 | $orderby_sql = ''; |
8646 | 9016 | if ($orderby == "hour") |
@@ -8706,7 +9076,9 @@ discard block |
||
8706 | 9076 | date_default_timezone_set($globalTimezone); |
8707 | 9077 | $datetime = new DateTime(); |
8708 | 9078 | $offset = $datetime->format('P'); |
8709 | - } else $offset = '+00:00'; |
|
9079 | + } else { |
|
9080 | + $offset = '+00:00'; |
|
9081 | + } |
|
8710 | 9082 | |
8711 | 9083 | $orderby_sql = ''; |
8712 | 9084 | if ($orderby == "hour") |
@@ -8773,7 +9145,9 @@ discard block |
||
8773 | 9145 | date_default_timezone_set($globalTimezone); |
8774 | 9146 | $datetime = new DateTime(); |
8775 | 9147 | $offset = $datetime->format('P'); |
8776 | - } else $offset = '+00:00'; |
|
9148 | + } else { |
|
9149 | + $offset = '+00:00'; |
|
9150 | + } |
|
8777 | 9151 | |
8778 | 9152 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
8779 | 9153 | |
@@ -8824,7 +9198,9 @@ discard block |
||
8824 | 9198 | date_default_timezone_set($globalTimezone); |
8825 | 9199 | $datetime = new DateTime(); |
8826 | 9200 | $offset = $datetime->format('P'); |
8827 | - } else $offset = '+00:00'; |
|
9201 | + } else { |
|
9202 | + $offset = '+00:00'; |
|
9203 | + } |
|
8828 | 9204 | |
8829 | 9205 | if ($globalDBdriver == 'mysql') { |
8830 | 9206 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -8871,7 +9247,9 @@ discard block |
||
8871 | 9247 | date_default_timezone_set($globalTimezone); |
8872 | 9248 | $datetime = new DateTime(); |
8873 | 9249 | $offset = $datetime->format('P'); |
8874 | - } else $offset = '+00:00'; |
|
9250 | + } else { |
|
9251 | + $offset = '+00:00'; |
|
9252 | + } |
|
8875 | 9253 | |
8876 | 9254 | if ($globalDBdriver == 'mysql') { |
8877 | 9255 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -8918,7 +9296,9 @@ discard block |
||
8918 | 9296 | date_default_timezone_set($globalTimezone); |
8919 | 9297 | $datetime = new DateTime(); |
8920 | 9298 | $offset = $datetime->format('P'); |
8921 | - } else $offset = '+00:00'; |
|
9299 | + } else { |
|
9300 | + $offset = '+00:00'; |
|
9301 | + } |
|
8922 | 9302 | |
8923 | 9303 | if ($globalDBdriver == 'mysql') { |
8924 | 9304 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -8966,7 +9346,9 @@ discard block |
||
8966 | 9346 | date_default_timezone_set($globalTimezone); |
8967 | 9347 | $datetime = new DateTime(); |
8968 | 9348 | $offset = $datetime->format('P'); |
8969 | - } else $offset = '+00:00'; |
|
9349 | + } else { |
|
9350 | + $offset = '+00:00'; |
|
9351 | + } |
|
8970 | 9352 | |
8971 | 9353 | if ($globalDBdriver == 'mysql') { |
8972 | 9354 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -9014,7 +9396,9 @@ discard block |
||
9014 | 9396 | date_default_timezone_set($globalTimezone); |
9015 | 9397 | $datetime = new DateTime($date); |
9016 | 9398 | $offset = $datetime->format('P'); |
9017 | - } else $offset = '+00:00'; |
|
9399 | + } else { |
|
9400 | + $offset = '+00:00'; |
|
9401 | + } |
|
9018 | 9402 | |
9019 | 9403 | if ($globalDBdriver == 'mysql') { |
9020 | 9404 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -9062,7 +9446,9 @@ discard block |
||
9062 | 9446 | date_default_timezone_set($globalTimezone); |
9063 | 9447 | $datetime = new DateTime(); |
9064 | 9448 | $offset = $datetime->format('P'); |
9065 | - } else $offset = '+00:00'; |
|
9449 | + } else { |
|
9450 | + $offset = '+00:00'; |
|
9451 | + } |
|
9066 | 9452 | |
9067 | 9453 | if ($globalDBdriver == 'mysql') { |
9068 | 9454 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -9112,7 +9498,9 @@ discard block |
||
9112 | 9498 | date_default_timezone_set($globalTimezone); |
9113 | 9499 | $datetime = new DateTime(); |
9114 | 9500 | $offset = $datetime->format('P'); |
9115 | - } else $offset = '+00:00'; |
|
9501 | + } else { |
|
9502 | + $offset = '+00:00'; |
|
9503 | + } |
|
9116 | 9504 | |
9117 | 9505 | if ($globalDBdriver == 'mysql') { |
9118 | 9506 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -9159,7 +9547,9 @@ discard block |
||
9159 | 9547 | date_default_timezone_set($globalTimezone); |
9160 | 9548 | $datetime = new DateTime(); |
9161 | 9549 | $offset = $datetime->format('P'); |
9162 | - } else $offset = '+00:00'; |
|
9550 | + } else { |
|
9551 | + $offset = '+00:00'; |
|
9552 | + } |
|
9163 | 9553 | |
9164 | 9554 | if ($globalDBdriver == 'mysql') { |
9165 | 9555 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -9327,7 +9717,9 @@ discard block |
||
9327 | 9717 | date_default_timezone_set($globalTimezone); |
9328 | 9718 | $datetime = new DateTime(); |
9329 | 9719 | $offset = $datetime->format('P'); |
9330 | - } else $offset = '+00:00'; |
|
9720 | + } else { |
|
9721 | + $offset = '+00:00'; |
|
9722 | + } |
|
9331 | 9723 | |
9332 | 9724 | if ($globalDBdriver == 'mysql') { |
9333 | 9725 | $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -9513,7 +9905,9 @@ discard block |
||
9513 | 9905 | */ |
9514 | 9906 | public function parseDirection($direction = 0) |
9515 | 9907 | { |
9516 | - if ($direction == '') $direction = 0; |
|
9908 | + if ($direction == '') { |
|
9909 | + $direction = 0; |
|
9910 | + } |
|
9517 | 9911 | $direction_array = array(); |
9518 | 9912 | $temp_array = array(); |
9519 | 9913 | |
@@ -9614,7 +10008,9 @@ discard block |
||
9614 | 10008 | if (isset($result->AirlineFlightInfoResult)) |
9615 | 10009 | { |
9616 | 10010 | $registration = $result->AirlineFlightInfoResult->tailnumber; |
9617 | - } else return ''; |
|
10011 | + } else { |
|
10012 | + return ''; |
|
10013 | + } |
|
9618 | 10014 | |
9619 | 10015 | $registration = $this->convertAircraftRegistration($registration); |
9620 | 10016 | |
@@ -9643,7 +10039,9 @@ discard block |
||
9643 | 10039 | if (count($row) > 0) { |
9644 | 10040 | //return $row['Registration']; |
9645 | 10041 | return $row['registration']; |
9646 | - } else return ''; |
|
10042 | + } else { |
|
10043 | + return ''; |
|
10044 | + } |
|
9647 | 10045 | |
9648 | 10046 | } |
9649 | 10047 | |
@@ -9666,9 +10064,14 @@ discard block |
||
9666 | 10064 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
9667 | 10065 | $sth->closeCursor(); |
9668 | 10066 | if (count($row) > 0) { |
9669 | - if ($row['type_flight'] == null) return ''; |
|
9670 | - else return $row['type_flight']; |
|
9671 | - } else return ''; |
|
10067 | + if ($row['type_flight'] == null) { |
|
10068 | + return ''; |
|
10069 | + } else { |
|
10070 | + return $row['type_flight']; |
|
10071 | + } |
|
10072 | + } else { |
|
10073 | + return ''; |
|
10074 | + } |
|
9672 | 10075 | |
9673 | 10076 | } |
9674 | 10077 | |
@@ -9686,7 +10089,9 @@ discard block |
||
9686 | 10089 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
9687 | 10090 | |
9688 | 10091 | $Connection = new Connection($this->db); |
9689 | - if (!$Connection->tableExists('countries')) return ''; |
|
10092 | + if (!$Connection->tableExists('countries')) { |
|
10093 | + return ''; |
|
10094 | + } |
|
9690 | 10095 | |
9691 | 10096 | try { |
9692 | 10097 | /* |
@@ -9706,9 +10111,13 @@ discard block |
||
9706 | 10111 | $sth->closeCursor(); |
9707 | 10112 | if (count($row) > 0) { |
9708 | 10113 | return $row; |
9709 | - } else return ''; |
|
10114 | + } else { |
|
10115 | + return ''; |
|
10116 | + } |
|
9710 | 10117 | } catch (PDOException $e) { |
9711 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
10118 | + if (isset($globalDebug) && $globalDebug) { |
|
10119 | + echo 'Error : '.$e->getMessage()."\n"; |
|
10120 | + } |
|
9712 | 10121 | return ''; |
9713 | 10122 | } |
9714 | 10123 | |
@@ -9856,7 +10265,9 @@ discard block |
||
9856 | 10265 | { |
9857 | 10266 | global $globalBitlyAccessToken; |
9858 | 10267 | |
9859 | - if ($globalBitlyAccessToken == '') return $url; |
|
10268 | + if ($globalBitlyAccessToken == '') { |
|
10269 | + return $url; |
|
10270 | + } |
|
9860 | 10271 | |
9861 | 10272 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
9862 | 10273 | |
@@ -10005,7 +10416,9 @@ discard block |
||
10005 | 10416 | |
10006 | 10417 | |
10007 | 10418 | // routes |
10008 | - if ($globalDebug) print "Routes...\n"; |
|
10419 | + if ($globalDebug) { |
|
10420 | + print "Routes...\n"; |
|
10421 | + } |
|
10009 | 10422 | if ($globalDBdriver == 'mysql') { |
10010 | 10423 | $query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)"; |
10011 | 10424 | } else { |
@@ -10024,7 +10437,9 @@ discard block |
||
10024 | 10437 | } |
10025 | 10438 | } |
10026 | 10439 | |
10027 | - if ($globalDebug) print "Airlines...\n"; |
|
10440 | + if ($globalDebug) { |
|
10441 | + print "Airlines...\n"; |
|
10442 | + } |
|
10028 | 10443 | //airlines |
10029 | 10444 | if ($globalDBdriver == 'mysql') { |
10030 | 10445 | $query = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)"; |
@@ -10038,10 +10453,15 @@ discard block |
||
10038 | 10453 | if (is_numeric(substr($row['ident'], -1, 1))) |
10039 | 10454 | { |
10040 | 10455 | $fromsource = NULL; |
10041 | - if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
10042 | - elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
10043 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
10044 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
10456 | + if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') { |
|
10457 | + $fromsource = 'vatsim'; |
|
10458 | + } elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') { |
|
10459 | + $fromsource = 'ivao'; |
|
10460 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
10461 | + $fromsource = 'vatsim'; |
|
10462 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
10463 | + $fromsource = 'ivao'; |
|
10464 | + } |
|
10045 | 10465 | $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource); |
10046 | 10466 | if (isset($airline_array[0]['name'])) { |
10047 | 10467 | $update_query = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id"; |
@@ -10051,13 +10471,17 @@ discard block |
||
10051 | 10471 | } |
10052 | 10472 | } |
10053 | 10473 | |
10054 | - if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n"; |
|
10474 | + if ($globalDebug) { |
|
10475 | + print "Remove Duplicate in aircraft_modes...\n"; |
|
10476 | + } |
|
10055 | 10477 | //duplicate modes |
10056 | 10478 | $query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL"; |
10057 | 10479 | $sth = $this->db->prepare($query); |
10058 | 10480 | $sth->execute(); |
10059 | 10481 | |
10060 | - if ($globalDebug) print "Aircraft...\n"; |
|
10482 | + if ($globalDebug) { |
|
10483 | + print "Aircraft...\n"; |
|
10484 | + } |
|
10061 | 10485 | //aircraft |
10062 | 10486 | if ($globalDBdriver == 'mysql') { |
10063 | 10487 | $query = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -10100,26 +10524,38 @@ discard block |
||
10100 | 10524 | if (isset($closestAirports[0])) { |
10101 | 10525 | if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) { |
10102 | 10526 | $airport_icao = $closestAirports[0]['icao']; |
10103 | - if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
10527 | + if ($globalDebug) { |
|
10528 | + echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
10529 | + } |
|
10104 | 10530 | } elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') { |
10105 | 10531 | foreach ($closestAirports as $airport) { |
10106 | 10532 | if ($row['arrival_airport_icao'] == $airport['icao']) { |
10107 | 10533 | $airport_icao = $airport['icao']; |
10108 | - if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
10534 | + if ($globalDebug) { |
|
10535 | + echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
10536 | + } |
|
10109 | 10537 | break; |
10110 | 10538 | } |
10111 | 10539 | } |
10112 | 10540 | } elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) { |
10113 | 10541 | $airport_icao = $closestAirports[0]['icao']; |
10114 | - if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." ! Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
10542 | + if ($globalDebug) { |
|
10543 | + echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." ! Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
10544 | + } |
|
10115 | 10545 | } else { |
10116 | - if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
10546 | + if ($globalDebug) { |
|
10547 | + echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
|
10548 | + } |
|
10117 | 10549 | } |
10118 | 10550 | } else { |
10119 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
10551 | + if ($globalDebug) { |
|
10552 | + echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
10553 | + } |
|
10120 | 10554 | } |
10121 | 10555 | if ($row['real_arrival_airport_icao'] != $airport_icao) { |
10122 | - if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n"; |
|
10556 | + if ($globalDebug) { |
|
10557 | + echo "Updating airport to ".$airport_icao."...\n"; |
|
10558 | + } |
|
10123 | 10559 | $update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id"; |
10124 | 10560 | $sthu = $this->db->prepare($update_query); |
10125 | 10561 | $sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id'])); |
@@ -6,7 +6,9 @@ discard block |
||
6 | 6 | $Stats = new Stats(); |
7 | 7 | $title = _("Statistics"); |
8 | 8 | |
9 | -if (!isset($filter_name)) $filter_name = ''; |
|
9 | +if (!isset($filter_name)) { |
|
10 | + $filter_name = ''; |
|
11 | +} |
|
10 | 12 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
11 | 13 | if ($airline_icao == 'all') { |
12 | 14 | unset($_COOKIE['stats_airline_icao']); |
@@ -15,8 +17,10 @@ discard block |
||
15 | 17 | } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) { |
16 | 18 | $airline_icao = $_COOKIE['stats_airline_icao']; |
17 | 19 | } elseif ($airline_icao == '' && isset($globalFilter)) { |
18 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
19 | -} |
|
20 | + if (isset($globalFilter['airline'])) { |
|
21 | + $airline_icao = $globalFilter['airline'][0]; |
|
22 | + } |
|
23 | + } |
|
20 | 24 | setcookie('stats_airline_icao',$airline_icao); |
21 | 25 | require_once('header.php'); |
22 | 26 | |
@@ -36,7 +40,9 @@ discard block |
||
36 | 40 | if (isset($last_update[0]['value'])) { |
37 | 41 | date_default_timezone_set('UTC'); |
38 | 42 | $lastupdate = strtotime($last_update[0]['value']); |
39 | - if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone); |
|
43 | + if (isset($globalTimezone) && $globalTimezone != '') { |
|
44 | + date_default_timezone_set($globalTimezone); |
|
45 | + } |
|
40 | 46 | print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>'; |
41 | 47 | } |
42 | 48 | ?> |
@@ -89,8 +95,9 @@ discard block |
||
89 | 95 | <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2> |
90 | 96 | <?php |
91 | 97 | $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name); |
92 | - if (count($aircraft_array) == 0) print _("No data available"); |
|
93 | - else { |
|
98 | + if (count($aircraft_array) == 0) { |
|
99 | + print _("No data available"); |
|
100 | + } else { |
|
94 | 101 | |
95 | 102 | print '<div id="chart1" class="chart" width="100%"></div> |
96 | 103 | <script> |
@@ -191,8 +198,9 @@ discard block |
||
191 | 198 | <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2> |
192 | 199 | <?php |
193 | 200 | $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name); |
194 | - if (count($pilot_array) == 0) print _("No data available"); |
|
195 | - else { |
|
201 | + if (count($pilot_array) == 0) { |
|
202 | + print _("No data available"); |
|
203 | + } else { |
|
196 | 204 | |
197 | 205 | print '<div id="chart7" class="chart" width="100%"></div> |
198 | 206 | <script> |
@@ -238,8 +246,9 @@ discard block |
||
238 | 246 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
239 | 247 | <?php |
240 | 248 | $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name); |
241 | - if (count($owner_array) == 0) print _("No data available"); |
|
242 | - else { |
|
249 | + if (count($owner_array) == 0) { |
|
250 | + print _("No data available"); |
|
251 | + } else { |
|
243 | 252 | |
244 | 253 | print '<div id="chart7" class="chart" width="100%"></div> |
245 | 254 | <script> |
@@ -287,8 +296,9 @@ discard block |
||
287 | 296 | <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2> |
288 | 297 | <?php |
289 | 298 | //$flightover_array = $Stats->countAllFlightOverCountries(); |
290 | - if (count($flightover_array) == 0) print _("No data available"); |
|
291 | - else { |
|
299 | + if (count($flightover_array) == 0) { |
|
300 | + print _("No data available"); |
|
301 | + } else { |
|
292 | 302 | |
293 | 303 | print '<div id="chart10" class="chart" width="100%"></div> |
294 | 304 | <script> |
@@ -340,8 +350,9 @@ discard block |
||
340 | 350 | <h2><?php echo _("Top 10 Most Common Departure Airports"); ?></h2> |
341 | 351 | <?php |
342 | 352 | $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name); |
343 | - if (count($airport_airport_array) == 0) print _("No data available"); |
|
344 | - else { |
|
353 | + if (count($airport_airport_array) == 0) { |
|
354 | + print _("No data available"); |
|
355 | + } else { |
|
345 | 356 | |
346 | 357 | print '<div id="chart3" class="chart" width="100%"></div> |
347 | 358 | <script> |
@@ -390,8 +401,9 @@ discard block |
||
390 | 401 | <h2><?php echo _("Top 10 Most Common Arrival Airports"); ?></h2> |
391 | 402 | <?php |
392 | 403 | $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name); |
393 | - if (count($airport_airport_array2) == 0) print _("No data available"); |
|
394 | - else { |
|
404 | + if (count($airport_airport_array2) == 0) { |
|
405 | + print _("No data available"); |
|
406 | + } else { |
|
395 | 407 | |
396 | 408 | print '<div id="chart4" class="chart" width="100%"></div> |
397 | 409 | <script> |
@@ -442,8 +454,9 @@ discard block |
||
442 | 454 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
443 | 455 | <?php |
444 | 456 | $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
445 | - if (count($year_array) == 0) print _("No data available"); |
|
446 | - else { |
|
457 | + if (count($year_array) == 0) { |
|
458 | + print _("No data available"); |
|
459 | + } else { |
|
447 | 460 | print '<div id="chart8" class="chart" width="100%"></div> |
448 | 461 | <script> |
449 | 462 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -488,8 +501,9 @@ discard block |
||
488 | 501 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
489 | 502 | <?php |
490 | 503 | $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
491 | - if (count($month_array) == 0) print _("No data available"); |
|
492 | - else { |
|
504 | + if (count($month_array) == 0) { |
|
505 | + print _("No data available"); |
|
506 | + } else { |
|
493 | 507 | print '<div id="chart9" class="chart" width="100%"></div> |
494 | 508 | <script> |
495 | 509 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -534,8 +548,9 @@ discard block |
||
534 | 548 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
535 | 549 | <?php |
536 | 550 | $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
537 | - if (empty($date_array)) print _("No data available"); |
|
538 | - else { |
|
551 | + if (empty($date_array)) { |
|
552 | + print _("No data available"); |
|
553 | + } else { |
|
539 | 554 | print '<div id="chart5" class="chart" width="100%"></div> |
540 | 555 | <script> |
541 | 556 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -581,8 +596,9 @@ discard block |
||
581 | 596 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
582 | 597 | <?php |
583 | 598 | $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
584 | - if (empty($hour_array)) print _("No data available"); |
|
585 | - else { |
|
599 | + if (empty($hour_array)) { |
|
600 | + print _("No data available"); |
|
601 | + } else { |
|
586 | 602 | |
587 | 603 | print '<div id="chart6" class="chart" width="100%"></div> |
588 | 604 | <script> |
@@ -650,8 +666,11 @@ discard block |
||
650 | 666 | $distance = $distance; |
651 | 667 | $unit = 'km'; |
652 | 668 | } |
653 | - if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
654 | - else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
669 | + if (!isset($polar_data)) { |
|
670 | + $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
671 | + } else { |
|
672 | + $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
673 | + } |
|
655 | 674 | } |
656 | 675 | ?> |
657 | 676 | <div class="col-md-6"> |
@@ -698,8 +717,11 @@ discard block |
||
698 | 717 | foreach ($msg as $eachmsg) { |
699 | 718 | //$eachmsg = $msg[0]; |
700 | 719 | $data = $eachmsg['source_data']; |
701 | - if ($data > 500) $max = (round(($data+100)/100))*100; |
|
702 | - else $max = 500; |
|
720 | + if ($data > 500) { |
|
721 | + $max = (round(($data+100)/100))*100; |
|
722 | + } else { |
|
723 | + $max = 500; |
|
724 | + } |
|
703 | 725 | ?> |
704 | 726 | <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
705 | 727 | <script> |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | public function __construct($dbc = null) { |
14 | 14 | global $globalFilterName; |
15 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
15 | + if (isset($globalFilterName)) { |
|
16 | + $this->filter_name = $globalFilterName; |
|
17 | + } |
|
16 | 18 | $Connection = new Connection($dbc); |
17 | 19 | $this->db = $Connection->db(); |
18 | 20 | } |
@@ -59,7 +61,9 @@ discard block |
||
59 | 61 | } |
60 | 62 | } |
61 | 63 | public function getAllAirlineNames($filter_name = '') { |
62 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
64 | + if ($filter_name == '') { |
|
65 | + $filter_name = $this->filter_name; |
|
66 | + } |
|
63 | 67 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
64 | 68 | try { |
65 | 69 | $sth = $this->db->prepare($query); |
@@ -71,7 +75,9 @@ discard block |
||
71 | 75 | return $all; |
72 | 76 | } |
73 | 77 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
74 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
78 | + if ($filter_name == '') { |
|
79 | + $filter_name = $this->filter_name; |
|
80 | + } |
|
75 | 81 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
76 | 82 | try { |
77 | 83 | $sth = $this->db->prepare($query); |
@@ -83,7 +89,9 @@ discard block |
||
83 | 89 | return $all; |
84 | 90 | } |
85 | 91 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
86 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
92 | + if ($filter_name == '') { |
|
93 | + $filter_name = $this->filter_name; |
|
94 | + } |
|
87 | 95 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
88 | 96 | try { |
89 | 97 | $sth = $this->db->prepare($query); |
@@ -95,7 +103,9 @@ discard block |
||
95 | 103 | return $all; |
96 | 104 | } |
97 | 105 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
98 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
106 | + if ($filter_name == '') { |
|
107 | + $filter_name = $this->filter_name; |
|
108 | + } |
|
99 | 109 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
100 | 110 | try { |
101 | 111 | $sth = $this->db->prepare($query); |
@@ -110,9 +120,14 @@ discard block |
||
110 | 120 | |
111 | 121 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
112 | 122 | global $globalStatsFilters; |
113 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
114 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
115 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
123 | + if ($filter_name == '') { |
|
124 | + $filter_name = $this->filter_name; |
|
125 | + } |
|
126 | + if ($limit) { |
|
127 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
128 | + } else { |
|
129 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
130 | + } |
|
116 | 131 | try { |
117 | 132 | $sth = $this->db->prepare($query); |
118 | 133 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -132,9 +147,14 @@ discard block |
||
132 | 147 | } |
133 | 148 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
134 | 149 | global $globalStatsFilters; |
135 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
136 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
137 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
150 | + if ($filter_name == '') { |
|
151 | + $filter_name = $this->filter_name; |
|
152 | + } |
|
153 | + if ($limit) { |
|
154 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
155 | + } else { |
|
156 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
157 | + } |
|
138 | 158 | try { |
139 | 159 | $sth = $this->db->prepare($query); |
140 | 160 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -154,9 +174,14 @@ discard block |
||
154 | 174 | } |
155 | 175 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
156 | 176 | global $globalStatsFilters; |
157 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
158 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
159 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
177 | + if ($filter_name == '') { |
|
178 | + $filter_name = $this->filter_name; |
|
179 | + } |
|
180 | + if ($limit) { |
|
181 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
182 | + } else { |
|
183 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
184 | + } |
|
160 | 185 | try { |
161 | 186 | $sth = $this->db->prepare($query); |
162 | 187 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -177,9 +202,14 @@ discard block |
||
177 | 202 | |
178 | 203 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
179 | 204 | global $globalStatsFilters; |
180 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
181 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
182 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
205 | + if ($filter_name == '') { |
|
206 | + $filter_name = $this->filter_name; |
|
207 | + } |
|
208 | + if ($limit) { |
|
209 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
210 | + } else { |
|
211 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
212 | + } |
|
183 | 213 | try { |
184 | 214 | $sth = $this->db->prepare($query); |
185 | 215 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -199,9 +229,14 @@ discard block |
||
199 | 229 | } |
200 | 230 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
201 | 231 | global $globalStatsFilters; |
202 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
203 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
204 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
232 | + if ($filter_name == '') { |
|
233 | + $filter_name = $this->filter_name; |
|
234 | + } |
|
235 | + if ($limit) { |
|
236 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
237 | + } else { |
|
238 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
239 | + } |
|
205 | 240 | try { |
206 | 241 | $sth = $this->db->prepare($query); |
207 | 242 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -222,9 +257,14 @@ discard block |
||
222 | 257 | |
223 | 258 | public function countAllAirlines($limit = true,$filter_name = '') { |
224 | 259 | global $globalStatsFilters; |
225 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
226 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
227 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC"; |
|
260 | + if ($filter_name == '') { |
|
261 | + $filter_name = $this->filter_name; |
|
262 | + } |
|
263 | + if ($limit) { |
|
264 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
265 | + } else { |
|
266 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC"; |
|
267 | + } |
|
228 | 268 | try { |
229 | 269 | $sth = $this->db->prepare($query); |
230 | 270 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -245,9 +285,14 @@ discard block |
||
245 | 285 | } |
246 | 286 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
247 | 287 | global $globalStatsFilters; |
248 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
249 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
250 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
288 | + if ($filter_name == '') { |
|
289 | + $filter_name = $this->filter_name; |
|
290 | + } |
|
291 | + if ($limit) { |
|
292 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
293 | + } else { |
|
294 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
295 | + } |
|
251 | 296 | try { |
252 | 297 | $sth = $this->db->prepare($query); |
253 | 298 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -267,9 +312,14 @@ discard block |
||
267 | 312 | } |
268 | 313 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
269 | 314 | global $globalStatsFilters; |
270 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
271 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
272 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
315 | + if ($filter_name == '') { |
|
316 | + $filter_name = $this->filter_name; |
|
317 | + } |
|
318 | + if ($limit) { |
|
319 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
320 | + } else { |
|
321 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
322 | + } |
|
273 | 323 | try { |
274 | 324 | $sth = $this->db->prepare($query); |
275 | 325 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -289,10 +339,15 @@ discard block |
||
289 | 339 | } |
290 | 340 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') { |
291 | 341 | $Connection = new Connection(); |
292 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
342 | + if ($filter_name == '') { |
|
343 | + $filter_name = $this->filter_name; |
|
344 | + } |
|
293 | 345 | if ($Connection->tableExists('countries')) { |
294 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
295 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
346 | + if ($limit) { |
|
347 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
348 | + } else { |
|
349 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
350 | + } |
|
296 | 351 | try { |
297 | 352 | $sth = $this->db->prepare($query); |
298 | 353 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -313,9 +368,14 @@ discard block |
||
313 | 368 | } |
314 | 369 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') { |
315 | 370 | global $globalStatsFilters; |
316 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
317 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
318 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
371 | + if ($filter_name == '') { |
|
372 | + $filter_name = $this->filter_name; |
|
373 | + } |
|
374 | + if ($limit) { |
|
375 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
376 | + } else { |
|
377 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
378 | + } |
|
319 | 379 | try { |
320 | 380 | $sth = $this->db->prepare($query); |
321 | 381 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -335,9 +395,14 @@ discard block |
||
335 | 395 | } |
336 | 396 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
337 | 397 | global $globalStatsFilters; |
338 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
339 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
340 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
398 | + if ($filter_name == '') { |
|
399 | + $filter_name = $this->filter_name; |
|
400 | + } |
|
401 | + if ($limit) { |
|
402 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
403 | + } else { |
|
404 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
405 | + } |
|
341 | 406 | try { |
342 | 407 | $sth = $this->db->prepare($query); |
343 | 408 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -357,9 +422,14 @@ discard block |
||
357 | 422 | } |
358 | 423 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
359 | 424 | global $globalStatsFilters; |
360 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
361 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
362 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
425 | + if ($filter_name == '') { |
|
426 | + $filter_name = $this->filter_name; |
|
427 | + } |
|
428 | + if ($limit) { |
|
429 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
430 | + } else { |
|
431 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
432 | + } |
|
363 | 433 | try { |
364 | 434 | $sth = $this->db->prepare($query); |
365 | 435 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -385,7 +455,9 @@ discard block |
||
385 | 455 | $icao = $value['airport_departure_icao']; |
386 | 456 | if (isset($all[$icao])) { |
387 | 457 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
388 | - } else $all[$icao] = $value; |
|
458 | + } else { |
|
459 | + $all[$icao] = $value; |
|
460 | + } |
|
389 | 461 | } |
390 | 462 | $count = array(); |
391 | 463 | foreach ($all as $key => $row) { |
@@ -397,9 +469,14 @@ discard block |
||
397 | 469 | } |
398 | 470 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
399 | 471 | global $globalStatsFilters; |
400 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
401 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
402 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
472 | + if ($filter_name == '') { |
|
473 | + $filter_name = $this->filter_name; |
|
474 | + } |
|
475 | + if ($limit) { |
|
476 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
477 | + } else { |
|
478 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
479 | + } |
|
403 | 480 | try { |
404 | 481 | $sth = $this->db->prepare($query); |
405 | 482 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -425,7 +502,9 @@ discard block |
||
425 | 502 | $icao = $value['airport_arrival_icao']; |
426 | 503 | if (isset($all[$icao])) { |
427 | 504 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
428 | - } else $all[$icao] = $value; |
|
505 | + } else { |
|
506 | + $all[$icao] = $value; |
|
507 | + } |
|
429 | 508 | } |
430 | 509 | $count = array(); |
431 | 510 | foreach ($all as $key => $row) { |
@@ -438,13 +517,21 @@ discard block |
||
438 | 517 | } |
439 | 518 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
440 | 519 | global $globalDBdriver, $globalStatsFilters; |
441 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
520 | + if ($filter_name == '') { |
|
521 | + $filter_name = $this->filter_name; |
|
522 | + } |
|
442 | 523 | if ($globalDBdriver == 'mysql') { |
443 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
444 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
524 | + if ($limit) { |
|
525 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
526 | + } else { |
|
527 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
528 | + } |
|
445 | 529 | } else { |
446 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
447 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
530 | + if ($limit) { |
|
531 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
532 | + } else { |
|
533 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
534 | + } |
|
448 | 535 | } |
449 | 536 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
450 | 537 | try { |
@@ -468,7 +555,9 @@ discard block |
||
468 | 555 | |
469 | 556 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
470 | 557 | global $globalStatsFilters; |
471 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
558 | + if ($filter_name == '') { |
|
559 | + $filter_name = $this->filter_name; |
|
560 | + } |
|
472 | 561 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
473 | 562 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
474 | 563 | try { |
@@ -490,7 +579,9 @@ discard block |
||
490 | 579 | } |
491 | 580 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
492 | 581 | global $globalDBdriver, $globalStatsFilters; |
493 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
582 | + if ($filter_name == '') { |
|
583 | + $filter_name = $this->filter_name; |
|
584 | + } |
|
494 | 585 | if ($globalDBdriver == 'mysql') { |
495 | 586 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
496 | 587 | } else { |
@@ -516,7 +607,9 @@ discard block |
||
516 | 607 | } |
517 | 608 | public function countAllDates($stats_airline = '',$filter_name = '') { |
518 | 609 | global $globalStatsFilters; |
519 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
610 | + if ($filter_name == '') { |
|
611 | + $filter_name = $this->filter_name; |
|
612 | + } |
|
520 | 613 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
521 | 614 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
522 | 615 | try { |
@@ -538,7 +631,9 @@ discard block |
||
538 | 631 | } |
539 | 632 | public function countAllDatesByAirlines($filter_name = '') { |
540 | 633 | global $globalStatsFilters; |
541 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
634 | + if ($filter_name == '') { |
|
635 | + $filter_name = $this->filter_name; |
|
636 | + } |
|
542 | 637 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
543 | 638 | $query_data = array('filter_name' => $filter_name); |
544 | 639 | try { |
@@ -560,7 +655,9 @@ discard block |
||
560 | 655 | } |
561 | 656 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
562 | 657 | global $globalStatsFilters; |
563 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
658 | + if ($filter_name == '') { |
|
659 | + $filter_name = $this->filter_name; |
|
660 | + } |
|
564 | 661 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
565 | 662 | try { |
566 | 663 | $sth = $this->db->prepare($query); |
@@ -581,7 +678,9 @@ discard block |
||
581 | 678 | } |
582 | 679 | public function countAllMilitaryMonths($filter_name = '') { |
583 | 680 | global $globalStatsFilters; |
584 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
681 | + if ($filter_name == '') { |
|
682 | + $filter_name = $this->filter_name; |
|
683 | + } |
|
585 | 684 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
586 | 685 | try { |
587 | 686 | $sth = $this->db->prepare($query); |
@@ -602,9 +701,14 @@ discard block |
||
602 | 701 | } |
603 | 702 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
604 | 703 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
605 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
606 | - if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
607 | - else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
704 | + if ($filter_name == '') { |
|
705 | + $filter_name = $this->filter_name; |
|
706 | + } |
|
707 | + if ($limit) { |
|
708 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
709 | + } else { |
|
710 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
711 | + } |
|
608 | 712 | if ($orderby == 'hour') { |
609 | 713 | /* |
610 | 714 | if ($globalDBdriver == 'mysql') { |
@@ -613,7 +717,9 @@ discard block |
||
613 | 717 | */ |
614 | 718 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
615 | 719 | } |
616 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
720 | + if ($orderby == 'count') { |
|
721 | + $query .= " ORDER BY hour_count DESC"; |
|
722 | + } |
|
617 | 723 | try { |
618 | 724 | $sth = $this->db->prepare($query); |
619 | 725 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -634,7 +740,9 @@ discard block |
||
634 | 740 | |
635 | 741 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
636 | 742 | global $globalStatsFilters; |
637 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
743 | + if ($filter_name == '') { |
|
744 | + $filter_name = $this->filter_name; |
|
745 | + } |
|
638 | 746 | $all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name); |
639 | 747 | if (empty($all)) { |
640 | 748 | $filters = array('airlines' => array($stats_airline)); |
@@ -648,7 +756,9 @@ discard block |
||
648 | 756 | } |
649 | 757 | public function countOverallMilitaryFlights($filter_name = '') { |
650 | 758 | global $globalStatsFilters; |
651 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
759 | + if ($filter_name == '') { |
|
760 | + $filter_name = $this->filter_name; |
|
761 | + } |
|
652 | 762 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
653 | 763 | if (empty($all)) { |
654 | 764 | $filters = array(); |
@@ -662,7 +772,9 @@ discard block |
||
662 | 772 | } |
663 | 773 | public function countOverallArrival($stats_airline = '',$filter_name = '') { |
664 | 774 | global $globalStatsFilters; |
665 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
775 | + if ($filter_name == '') { |
|
776 | + $filter_name = $this->filter_name; |
|
777 | + } |
|
666 | 778 | $all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name); |
667 | 779 | if (empty($all)) { |
668 | 780 | $filters = array('airlines' => array($stats_airline)); |
@@ -676,7 +788,9 @@ discard block |
||
676 | 788 | } |
677 | 789 | public function countOverallAircrafts($stats_airline = '',$filter_name = '') { |
678 | 790 | global $globalStatsFilters; |
679 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
791 | + if ($filter_name == '') { |
|
792 | + $filter_name = $this->filter_name; |
|
793 | + } |
|
680 | 794 | $all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name); |
681 | 795 | if (empty($all)) { |
682 | 796 | $filters = array('airlines' => array($stats_airline)); |
@@ -690,7 +804,9 @@ discard block |
||
690 | 804 | } |
691 | 805 | public function countOverallAirlines($filter_name = '') { |
692 | 806 | global $globalStatsFilters; |
693 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
807 | + if ($filter_name == '') { |
|
808 | + $filter_name = $this->filter_name; |
|
809 | + } |
|
694 | 810 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
695 | 811 | try { |
696 | 812 | $sth = $this->db->prepare($query); |
@@ -713,7 +829,9 @@ discard block |
||
713 | 829 | } |
714 | 830 | public function countOverallOwners($stats_airline = '',$filter_name = '') { |
715 | 831 | global $globalStatsFilters; |
716 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
832 | + if ($filter_name == '') { |
|
833 | + $filter_name = $this->filter_name; |
|
834 | + } |
|
717 | 835 | /* |
718 | 836 | $query = "SELECT COUNT(*) AS nb_owner FROM stats_owner"; |
719 | 837 | try { |
@@ -738,7 +856,9 @@ discard block |
||
738 | 856 | } |
739 | 857 | public function countOverallPilots($stats_airline = '',$filter_name = '') { |
740 | 858 | global $globalStatsFilters; |
741 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
859 | + if ($filter_name == '') { |
|
860 | + $filter_name = $this->filter_name; |
|
861 | + } |
|
742 | 862 | $all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name); |
743 | 863 | if (empty($all)) { |
744 | 864 | $filters = array('airlines' => array($stats_airline)); |
@@ -752,7 +872,9 @@ discard block |
||
752 | 872 | } |
753 | 873 | |
754 | 874 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
755 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
875 | + if ($filter_name == '') { |
|
876 | + $filter_name = $this->filter_name; |
|
877 | + } |
|
756 | 878 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
757 | 879 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
758 | 880 | try { |
@@ -765,7 +887,9 @@ discard block |
||
765 | 887 | return $all; |
766 | 888 | } |
767 | 889 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
768 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
890 | + if ($filter_name == '') { |
|
891 | + $filter_name = $this->filter_name; |
|
892 | + } |
|
769 | 893 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
770 | 894 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
771 | 895 | try { |
@@ -778,7 +902,9 @@ discard block |
||
778 | 902 | return $all; |
779 | 903 | } |
780 | 904 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
781 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
905 | + if ($filter_name == '') { |
|
906 | + $filter_name = $this->filter_name; |
|
907 | + } |
|
782 | 908 | global $globalArchiveMonths, $globalDBdriver; |
783 | 909 | if ($globalDBdriver == 'mysql') { |
784 | 910 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -797,7 +923,9 @@ discard block |
||
797 | 923 | } |
798 | 924 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
799 | 925 | global $globalArchiveMonths, $globalDBdriver; |
800 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
926 | + if ($filter_name == '') { |
|
927 | + $filter_name = $this->filter_name; |
|
928 | + } |
|
801 | 929 | if ($globalDBdriver == 'mysql') { |
802 | 930 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
803 | 931 | } else { |
@@ -815,7 +943,9 @@ discard block |
||
815 | 943 | } |
816 | 944 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
817 | 945 | global $globalArchiveMonths, $globalDBdriver; |
818 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
946 | + if ($filter_name == '') { |
|
947 | + $filter_name = $this->filter_name; |
|
948 | + } |
|
819 | 949 | if ($globalDBdriver == 'mysql') { |
820 | 950 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
821 | 951 | } else { |
@@ -832,7 +962,9 @@ discard block |
||
832 | 962 | } |
833 | 963 | public function getStatsAirlineTotal($filter_name = '') { |
834 | 964 | global $globalArchiveMonths, $globalDBdriver; |
835 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
965 | + if ($filter_name == '') { |
|
966 | + $filter_name = $this->filter_name; |
|
967 | + } |
|
836 | 968 | if ($globalDBdriver == 'mysql') { |
837 | 969 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
838 | 970 | } else { |
@@ -849,7 +981,9 @@ discard block |
||
849 | 981 | } |
850 | 982 | public function getStatsOwnerTotal($filter_name = '') { |
851 | 983 | global $globalArchiveMonths, $globalDBdriver; |
852 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
984 | + if ($filter_name == '') { |
|
985 | + $filter_name = $this->filter_name; |
|
986 | + } |
|
853 | 987 | if ($globalDBdriver == 'mysql') { |
854 | 988 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
855 | 989 | } else { |
@@ -866,7 +1000,9 @@ discard block |
||
866 | 1000 | } |
867 | 1001 | public function getStatsPilotTotal($filter_name = '') { |
868 | 1002 | global $globalArchiveMonths, $globalDBdriver; |
869 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1003 | + if ($filter_name == '') { |
|
1004 | + $filter_name = $this->filter_name; |
|
1005 | + } |
|
870 | 1006 | if ($globalDBdriver == 'mysql') { |
871 | 1007 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
872 | 1008 | } else { |
@@ -884,7 +1020,9 @@ discard block |
||
884 | 1020 | |
885 | 1021 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
886 | 1022 | global $globalDBdriver; |
887 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1023 | + if ($filter_name == '') { |
|
1024 | + $filter_name = $this->filter_name; |
|
1025 | + } |
|
888 | 1026 | if ($globalDBdriver == 'mysql') { |
889 | 1027 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
890 | 1028 | } else { |
@@ -900,7 +1038,9 @@ discard block |
||
900 | 1038 | } |
901 | 1039 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
902 | 1040 | global $globalDBdriver; |
903 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
1041 | + if ($filter_name == '') { |
|
1042 | + $filter_name = $this->filter_name; |
|
1043 | + } |
|
904 | 1044 | if ($globalDBdriver == 'mysql') { |
905 | 1045 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
906 | 1046 | } else { |
@@ -1383,47 +1523,69 @@ discard block |
||
1383 | 1523 | $this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s')); |
1384 | 1524 | } else { |
1385 | 1525 | */ |
1386 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
1387 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
1526 | + if ($globalDebug) { |
|
1527 | + echo 'Update stats !'."\n"; |
|
1528 | + } |
|
1529 | + if ($globalDebug) { |
|
1530 | + echo 'Count all aircraft types...'."\n"; |
|
1531 | + } |
|
1388 | 1532 | if (isset($last_update[0]['value'])) { |
1389 | 1533 | $last_update_day = $last_update[0]['value']; |
1390 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
1534 | + } else { |
|
1535 | + $last_update_day = '2012-12-12 12:12:12'; |
|
1536 | + } |
|
1391 | 1537 | $Spotter = new Spotter($this->db); |
1392 | 1538 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
1393 | 1539 | foreach ($alldata as $number) { |
1394 | 1540 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']); |
1395 | 1541 | } |
1396 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
1542 | + if ($globalDebug) { |
|
1543 | + echo 'Count all airlines...'."\n"; |
|
1544 | + } |
|
1397 | 1545 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
1398 | 1546 | foreach ($alldata as $number) { |
1399 | 1547 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']); |
1400 | 1548 | } |
1401 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
1549 | + if ($globalDebug) { |
|
1550 | + echo 'Count all registrations...'."\n"; |
|
1551 | + } |
|
1402 | 1552 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
1403 | 1553 | foreach ($alldata as $number) { |
1404 | 1554 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']); |
1405 | 1555 | } |
1406 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
1556 | + if ($globalDebug) { |
|
1557 | + echo 'Count all callsigns...'."\n"; |
|
1558 | + } |
|
1407 | 1559 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
1408 | 1560 | foreach ($alldata as $number) { |
1409 | 1561 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
1410 | 1562 | } |
1411 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
1563 | + if ($globalDebug) { |
|
1564 | + echo 'Count all owners...'."\n"; |
|
1565 | + } |
|
1412 | 1566 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
1413 | 1567 | foreach ($alldata as $number) { |
1414 | 1568 | $this->addStatOwner($number['owner_name'],$number['owner_count']); |
1415 | 1569 | } |
1416 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
1570 | + if ($globalDebug) { |
|
1571 | + echo 'Count all pilots...'."\n"; |
|
1572 | + } |
|
1417 | 1573 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
1418 | 1574 | foreach ($alldata as $number) { |
1419 | 1575 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source']); |
1420 | 1576 | } |
1421 | 1577 | |
1422 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
1578 | + if ($globalDebug) { |
|
1579 | + echo 'Count all departure airports...'."\n"; |
|
1580 | + } |
|
1423 | 1581 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1424 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
1582 | + if ($globalDebug) { |
|
1583 | + echo 'Count all detected departure airports...'."\n"; |
|
1584 | + } |
|
1425 | 1585 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
1426 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
1586 | + if ($globalDebug) { |
|
1587 | + echo 'Order departure airports...'."\n"; |
|
1588 | + } |
|
1427 | 1589 | $alldata = array(); |
1428 | 1590 | |
1429 | 1591 | foreach ($pall as $value) { |
@@ -1434,7 +1596,9 @@ discard block |
||
1434 | 1596 | $icao = $value['airport_departure_icao']; |
1435 | 1597 | if (isset($alldata[$icao])) { |
1436 | 1598 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1437 | - } else $alldata[$icao] = $value; |
|
1599 | + } else { |
|
1600 | + $alldata[$icao] = $value; |
|
1601 | + } |
|
1438 | 1602 | } |
1439 | 1603 | $count = array(); |
1440 | 1604 | foreach ($alldata as $key => $row) { |
@@ -1444,11 +1608,17 @@ discard block |
||
1444 | 1608 | foreach ($alldata as $number) { |
1445 | 1609 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
1446 | 1610 | } |
1447 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
1611 | + if ($globalDebug) { |
|
1612 | + echo 'Count all arrival airports...'."\n"; |
|
1613 | + } |
|
1448 | 1614 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1449 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
1615 | + if ($globalDebug) { |
|
1616 | + echo 'Count all detected arrival airports...'."\n"; |
|
1617 | + } |
|
1450 | 1618 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
1451 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
1619 | + if ($globalDebug) { |
|
1620 | + echo 'Order arrival airports...'."\n"; |
|
1621 | + } |
|
1452 | 1622 | $alldata = array(); |
1453 | 1623 | foreach ($pall as $value) { |
1454 | 1624 | $icao = $value['airport_arrival_icao']; |
@@ -1458,7 +1628,9 @@ discard block |
||
1458 | 1628 | $icao = $value['airport_arrival_icao']; |
1459 | 1629 | if (isset($alldata[$icao])) { |
1460 | 1630 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1461 | - } else $alldata[$icao] = $value; |
|
1631 | + } else { |
|
1632 | + $alldata[$icao] = $value; |
|
1633 | + } |
|
1462 | 1634 | } |
1463 | 1635 | $count = array(); |
1464 | 1636 | foreach ($alldata as $key => $row) { |
@@ -1469,7 +1641,9 @@ discard block |
||
1469 | 1641 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
1470 | 1642 | } |
1471 | 1643 | if ($Connection->tableExists('countries')) { |
1472 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
1644 | + if ($globalDebug) { |
|
1645 | + echo 'Count all flights by countries...'."\n"; |
|
1646 | + } |
|
1473 | 1647 | $SpotterArchive = new SpotterArchive(); |
1474 | 1648 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
1475 | 1649 | foreach ($alldata as $number) { |
@@ -1481,46 +1655,66 @@ discard block |
||
1481 | 1655 | // Add by month using getstat if month finish... |
1482 | 1656 | |
1483 | 1657 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
1484 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
1658 | + if ($globalDebug) { |
|
1659 | + echo 'Count all flights by months...'."\n"; |
|
1660 | + } |
|
1485 | 1661 | $Spotter = new Spotter($this->db); |
1486 | 1662 | $alldata = $Spotter->countAllMonths(); |
1487 | 1663 | $lastyear = false; |
1488 | 1664 | foreach ($alldata as $number) { |
1489 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1665 | + if ($number['year_name'] != date('Y')) { |
|
1666 | + $lastyear = true; |
|
1667 | + } |
|
1490 | 1668 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1491 | 1669 | } |
1492 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
1670 | + if ($globalDebug) { |
|
1671 | + echo 'Count all military flights by months...'."\n"; |
|
1672 | + } |
|
1493 | 1673 | $alldata = $Spotter->countAllMilitaryMonths(); |
1494 | 1674 | foreach ($alldata as $number) { |
1495 | 1675 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1496 | 1676 | } |
1497 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
1677 | + if ($globalDebug) { |
|
1678 | + echo 'Count all owners by months...'."\n"; |
|
1679 | + } |
|
1498 | 1680 | $alldata = $Spotter->countAllMonthsOwners(); |
1499 | 1681 | foreach ($alldata as $number) { |
1500 | 1682 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1501 | 1683 | } |
1502 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
1684 | + if ($globalDebug) { |
|
1685 | + echo 'Count all pilots by months...'."\n"; |
|
1686 | + } |
|
1503 | 1687 | $alldata = $Spotter->countAllMonthsPilots(); |
1504 | 1688 | foreach ($alldata as $number) { |
1505 | 1689 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1506 | 1690 | } |
1507 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
1691 | + if ($globalDebug) { |
|
1692 | + echo 'Count all airlines by months...'."\n"; |
|
1693 | + } |
|
1508 | 1694 | $alldata = $Spotter->countAllMonthsAirlines(); |
1509 | 1695 | foreach ($alldata as $number) { |
1510 | 1696 | $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1511 | 1697 | } |
1512 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
1698 | + if ($globalDebug) { |
|
1699 | + echo 'Count all aircrafts by months...'."\n"; |
|
1700 | + } |
|
1513 | 1701 | $alldata = $Spotter->countAllMonthsAircrafts(); |
1514 | 1702 | foreach ($alldata as $number) { |
1515 | 1703 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1516 | 1704 | } |
1517 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
1705 | + if ($globalDebug) { |
|
1706 | + echo 'Count all real arrivals by months...'."\n"; |
|
1707 | + } |
|
1518 | 1708 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
1519 | 1709 | foreach ($alldata as $number) { |
1520 | 1710 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1521 | 1711 | } |
1522 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
1523 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1712 | + if ($globalDebug) { |
|
1713 | + echo 'Airports data...'."\n"; |
|
1714 | + } |
|
1715 | + if ($globalDebug) { |
|
1716 | + echo '...Departure'."\n"; |
|
1717 | + } |
|
1524 | 1718 | $this->deleteStatAirport('daily'); |
1525 | 1719 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1526 | 1720 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1640,37 +1834,53 @@ discard block |
||
1640 | 1834 | |
1641 | 1835 | // Count by airlines |
1642 | 1836 | echo '--- Stats by airlines ---'."\n"; |
1643 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
1837 | + if ($globalDebug) { |
|
1838 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
1839 | + } |
|
1644 | 1840 | $Spotter = new Spotter($this->db); |
1645 | 1841 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
1646 | 1842 | foreach ($alldata as $number) { |
1647 | 1843 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']); |
1648 | 1844 | } |
1649 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1845 | + if ($globalDebug) { |
|
1846 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
1847 | + } |
|
1650 | 1848 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
1651 | 1849 | foreach ($alldata as $number) { |
1652 | 1850 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']); |
1653 | 1851 | } |
1654 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
1852 | + if ($globalDebug) { |
|
1853 | + echo 'Count all callsigns by airlines...'."\n"; |
|
1854 | + } |
|
1655 | 1855 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
1656 | 1856 | foreach ($alldata as $number) { |
1657 | 1857 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']); |
1658 | 1858 | } |
1659 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
1859 | + if ($globalDebug) { |
|
1860 | + echo 'Count all owners by airlines...'."\n"; |
|
1861 | + } |
|
1660 | 1862 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
1661 | 1863 | foreach ($alldata as $number) { |
1662 | 1864 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']); |
1663 | 1865 | } |
1664 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
1866 | + if ($globalDebug) { |
|
1867 | + echo 'Count all pilots by airlines...'."\n"; |
|
1868 | + } |
|
1665 | 1869 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
1666 | 1870 | foreach ($alldata as $number) { |
1667 | 1871 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source']); |
1668 | 1872 | } |
1669 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
1873 | + if ($globalDebug) { |
|
1874 | + echo 'Count all departure airports by airlines...'."\n"; |
|
1875 | + } |
|
1670 | 1876 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1671 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
1877 | + if ($globalDebug) { |
|
1878 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
1879 | + } |
|
1672 | 1880 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
1673 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
1881 | + if ($globalDebug) { |
|
1882 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
1883 | + } |
|
1674 | 1884 | //$alldata = array(); |
1675 | 1885 | foreach ($dall as $value) { |
1676 | 1886 | $icao = $value['airport_departure_icao']; |
@@ -1691,11 +1901,17 @@ discard block |
||
1691 | 1901 | foreach ($alldata as $number) { |
1692 | 1902 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao']); |
1693 | 1903 | } |
1694 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
1904 | + if ($globalDebug) { |
|
1905 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
1906 | + } |
|
1695 | 1907 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1696 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
1908 | + if ($globalDebug) { |
|
1909 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
1910 | + } |
|
1697 | 1911 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
1698 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
1912 | + if ($globalDebug) { |
|
1913 | + echo 'Order arrival airports by airlines...'."\n"; |
|
1914 | + } |
|
1699 | 1915 | //$alldata = array(); |
1700 | 1916 | foreach ($dall as $value) { |
1701 | 1917 | $icao = $value['airport_arrival_icao']; |
@@ -1716,35 +1932,49 @@ discard block |
||
1716 | 1932 | foreach ($alldata as $number) { |
1717 | 1933 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao']); |
1718 | 1934 | } |
1719 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
1935 | + if ($globalDebug) { |
|
1936 | + echo 'Count all flights by months by airlines...'."\n"; |
|
1937 | + } |
|
1720 | 1938 | $Spotter = new Spotter($this->db); |
1721 | 1939 | $alldata = $Spotter->countAllMonthsByAirlines(); |
1722 | 1940 | $lastyear = false; |
1723 | 1941 | foreach ($alldata as $number) { |
1724 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1942 | + if ($number['year_name'] != date('Y')) { |
|
1943 | + $lastyear = true; |
|
1944 | + } |
|
1725 | 1945 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1726 | 1946 | } |
1727 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
1947 | + if ($globalDebug) { |
|
1948 | + echo 'Count all owners by months by airlines...'."\n"; |
|
1949 | + } |
|
1728 | 1950 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
1729 | 1951 | foreach ($alldata as $number) { |
1730 | 1952 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1731 | 1953 | } |
1732 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
1954 | + if ($globalDebug) { |
|
1955 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
1956 | + } |
|
1733 | 1957 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
1734 | 1958 | foreach ($alldata as $number) { |
1735 | 1959 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1736 | 1960 | } |
1737 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
1961 | + if ($globalDebug) { |
|
1962 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
1963 | + } |
|
1738 | 1964 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
1739 | 1965 | foreach ($alldata as $number) { |
1740 | 1966 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1741 | 1967 | } |
1742 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
1968 | + if ($globalDebug) { |
|
1969 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
1970 | + } |
|
1743 | 1971 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
1744 | 1972 | foreach ($alldata as $number) { |
1745 | 1973 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
1746 | 1974 | } |
1747 | - if ($globalDebug) echo '...Departure'."\n"; |
|
1975 | + if ($globalDebug) { |
|
1976 | + echo '...Departure'."\n"; |
|
1977 | + } |
|
1748 | 1978 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1749 | 1979 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
1750 | 1980 | foreach ($dall as $value) { |
@@ -1767,7 +1997,9 @@ discard block |
||
1767 | 1997 | foreach ($alldata as $number) { |
1768 | 1998 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
1769 | 1999 | } |
1770 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
2000 | + if ($globalDebug) { |
|
2001 | + echo '...Arrival'."\n"; |
|
2002 | + } |
|
1771 | 2003 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1772 | 2004 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
1773 | 2005 | foreach ($dall as $value) { |
@@ -1791,13 +2023,19 @@ discard block |
||
1791 | 2023 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
1792 | 2024 | } |
1793 | 2025 | |
1794 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
1795 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
2026 | + if ($globalDebug) { |
|
2027 | + echo 'Flights data...'."\n"; |
|
2028 | + } |
|
2029 | + if ($globalDebug) { |
|
2030 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
2031 | + } |
|
1796 | 2032 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
1797 | 2033 | foreach ($alldata as $number) { |
1798 | 2034 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
1799 | 2035 | } |
1800 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
2036 | + if ($globalDebug) { |
|
2037 | + echo '-> countAllDates...'."\n"; |
|
2038 | + } |
|
1801 | 2039 | //$previousdata = $this->countAllDatesByAirlines(); |
1802 | 2040 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
1803 | 2041 | $values = array(); |
@@ -1810,14 +2048,18 @@ discard block |
||
1810 | 2048 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
1811 | 2049 | } |
1812 | 2050 | |
1813 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
2051 | + if ($globalDebug) { |
|
2052 | + echo '-> countAllHours...'."\n"; |
|
2053 | + } |
|
1814 | 2054 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
1815 | 2055 | foreach ($alldata as $number) { |
1816 | 2056 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
1817 | 2057 | } |
1818 | 2058 | |
1819 | 2059 | |
1820 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
2060 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
2061 | + $globalStatsFilters = array(); |
|
2062 | + } |
|
1821 | 2063 | foreach ($globalStatsFilters as $name => $filter) { |
1822 | 2064 | //$filter_name = $filter['name']; |
1823 | 2065 | $filter_name = $name; |
@@ -1825,10 +2067,14 @@ discard block |
||
1825 | 2067 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
1826 | 2068 | if (isset($last_update[0]['value'])) { |
1827 | 2069 | $last_update_day = $last_update[0]['value']; |
1828 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
2070 | + } else { |
|
2071 | + $last_update_day = '2012-12-12 12:12:12'; |
|
2072 | + } |
|
1829 | 2073 | |
1830 | 2074 | // Count by filter |
1831 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2075 | + if ($globalDebug) { |
|
2076 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
2077 | + } |
|
1832 | 2078 | $Spotter = new Spotter($this->db); |
1833 | 2079 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
1834 | 2080 | foreach ($alldata as $number) { |
@@ -1866,7 +2112,9 @@ discard block |
||
1866 | 2112 | $icao = $value['airport_departure_icao']; |
1867 | 2113 | if (isset($alldata[$icao])) { |
1868 | 2114 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1869 | - } else $alldata[$icao] = $value; |
|
2115 | + } else { |
|
2116 | + $alldata[$icao] = $value; |
|
2117 | + } |
|
1870 | 2118 | } |
1871 | 2119 | $count = array(); |
1872 | 2120 | foreach ($alldata as $key => $row) { |
@@ -1887,7 +2135,9 @@ discard block |
||
1887 | 2135 | $icao = $value['airport_arrival_icao']; |
1888 | 2136 | if (isset($alldata[$icao])) { |
1889 | 2137 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1890 | - } else $alldata[$icao] = $value; |
|
2138 | + } else { |
|
2139 | + $alldata[$icao] = $value; |
|
2140 | + } |
|
1891 | 2141 | } |
1892 | 2142 | $count = array(); |
1893 | 2143 | foreach ($alldata as $key => $row) { |
@@ -1901,7 +2151,9 @@ discard block |
||
1901 | 2151 | $alldata = $Spotter->countAllMonths($filter); |
1902 | 2152 | $lastyear = false; |
1903 | 2153 | foreach ($alldata as $number) { |
1904 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
2154 | + if ($number['year_name'] != date('Y')) { |
|
2155 | + $lastyear = true; |
|
2156 | + } |
|
1905 | 2157 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
1906 | 2158 | } |
1907 | 2159 | $alldata = $Spotter->countAllMonthsOwners($filter); |