@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (SpotterLive)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (SpotterLive)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -123,8 +127,11 @@ discard block |
||
123 | 127 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
124 | 128 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
125 | 129 | } |
126 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
127 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
130 | + if ($filter_query_where == '' && $where) { |
|
131 | + $filter_query_where = ' WHERE'; |
|
132 | + } elseif ($filter_query_where != '' && $and) { |
|
133 | + $filter_query_where .= ' AND'; |
|
134 | + } |
|
128 | 135 | if ($filter_query_where != '') { |
129 | 136 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
130 | 137 | } |
@@ -165,9 +172,13 @@ discard block |
||
165 | 172 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
166 | 173 | } |
167 | 174 | } |
168 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
175 | + if ($orderby_query == '') { |
|
176 | + $orderby_query = ' ORDER BY date DESC'; |
|
177 | + } |
|
169 | 178 | |
170 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
179 | + if (!isset($globalLiveInterval)) { |
|
180 | + $globalLiveInterval = '200'; |
|
181 | + } |
|
171 | 182 | if ($globalDBdriver == 'mysql') { |
172 | 183 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
173 | 184 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -190,7 +201,9 @@ discard block |
||
190 | 201 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
191 | 202 | date_default_timezone_set('UTC'); |
192 | 203 | $filter_query = $this->getFilter($filter,true,true); |
193 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
204 | + if (!isset($globalLiveInterval)) { |
|
205 | + $globalLiveInterval = '200'; |
|
206 | + } |
|
194 | 207 | if ($globalDBdriver == 'mysql') { |
195 | 208 | if (isset($globalArchive) && $globalArchive === TRUE) { |
196 | 209 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -240,8 +253,12 @@ discard block |
||
240 | 253 | } |
241 | 254 | $filter_query = $this->getFilter($filter,true,true); |
242 | 255 | |
243 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
244 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
256 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
257 | + $globalLiveInterval = '200'; |
|
258 | + } |
|
259 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
260 | + $globalMap3DAircraftsLimit = '300'; |
|
261 | + } |
|
245 | 262 | if ($globalDBdriver == 'mysql') { |
246 | 263 | if (isset($globalArchive) && $globalArchive === TRUE) { |
247 | 264 | /* |
@@ -252,22 +269,32 @@ discard block |
||
252 | 269 | */ |
253 | 270 | $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
254 | 271 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
255 | - if ($usecoord) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
272 | + if ($usecoord) { |
|
273 | + $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
274 | + } |
|
256 | 275 | $query .= "UNION |
257 | 276 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
258 | 277 | FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
259 | - if ($usecoord) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
278 | + if ($usecoord) { |
|
279 | + $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
280 | + } |
|
260 | 281 | $query .= ") AS spotter |
261 | 282 | WHERE latitude <> '0' AND longitude <> '0' |
262 | 283 | ORDER BY flightaware_id, date"; |
263 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
284 | + if ($limit) { |
|
285 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
286 | + } |
|
264 | 287 | } else { |
265 | 288 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
266 | 289 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
267 | - if ($usecoord) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
290 | + if ($usecoord) { |
|
291 | + $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
292 | + } |
|
268 | 293 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
269 | 294 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
270 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
295 | + if ($limit) { |
|
296 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
297 | + } |
|
271 | 298 | } |
272 | 299 | } else { |
273 | 300 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -279,21 +306,31 @@ discard block |
||
279 | 306 | */ |
280 | 307 | $query = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
281 | 308 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
282 | - if ($usecoord) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
309 | + if ($usecoord) { |
|
310 | + $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
311 | + } |
|
283 | 312 | $query .= "UNION |
284 | 313 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
285 | 314 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
286 | - if ($usecoord) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
315 | + if ($usecoord) { |
|
316 | + $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
317 | + } |
|
287 | 318 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
288 | 319 | $query .= "ORDER BY flightaware_id, date"; |
289 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
320 | + if ($limit) { |
|
321 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
322 | + } |
|
290 | 323 | } else { |
291 | 324 | $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
292 | 325 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date "; |
293 | - if ($usecoord) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
326 | + if ($usecoord) { |
|
327 | + $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
328 | + } |
|
294 | 329 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
295 | 330 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
296 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
331 | + if ($limit) { |
|
332 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
333 | + } |
|
297 | 334 | } |
298 | 335 | } |
299 | 336 | try { |
@@ -318,7 +355,9 @@ discard block |
||
318 | 355 | global $globalDBdriver, $globalLiveInterval; |
319 | 356 | $filter_query = $this->getFilter($filter,true,true); |
320 | 357 | |
321 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
358 | + if (!isset($globalLiveInterval)) { |
|
359 | + $globalLiveInterval = '200'; |
|
360 | + } |
|
322 | 361 | if ($globalDBdriver == 'mysql') { |
323 | 362 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
324 | 363 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -348,7 +387,9 @@ discard block |
||
348 | 387 | { |
349 | 388 | global $globalDBdriver, $globalLiveInterval; |
350 | 389 | $Spotter = new Spotter($this->db); |
351 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
390 | + if (!isset($globalLiveInterval)) { |
|
391 | + $globalLiveInterval = '200'; |
|
392 | + } |
|
352 | 393 | $filter_query = $this->getFilter($filter); |
353 | 394 | |
354 | 395 | if (is_array($coord)) { |
@@ -356,7 +397,9 @@ discard block |
||
356 | 397 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
357 | 398 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
358 | 399 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
359 | - } else return array(); |
|
400 | + } else { |
|
401 | + return array(); |
|
402 | + } |
|
360 | 403 | if ($globalDBdriver == 'mysql') { |
361 | 404 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
362 | 405 | } else { |
@@ -377,7 +420,9 @@ discard block |
||
377 | 420 | { |
378 | 421 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
379 | 422 | $Spotter = new Spotter($this->db); |
380 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
423 | + if (!isset($globalLiveInterval)) { |
|
424 | + $globalLiveInterval = '200'; |
|
425 | + } |
|
381 | 426 | $filter_query = $this->getFilter($filter,true,true); |
382 | 427 | |
383 | 428 | if (is_array($coord)) { |
@@ -385,7 +430,9 @@ discard block |
||
385 | 430 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
386 | 431 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
387 | 432 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
388 | - } else return array(); |
|
433 | + } else { |
|
434 | + return array(); |
|
435 | + } |
|
389 | 436 | if ($globalDBdriver == 'mysql') { |
390 | 437 | if (isset($globalArchive) && $globalArchive === TRUE) { |
391 | 438 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -612,11 +659,15 @@ discard block |
||
612 | 659 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
613 | 660 | if ($globalDBdriver == 'mysql') { |
614 | 661 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
615 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
662 | + if ($liveinterval) { |
|
663 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
664 | + } |
|
616 | 665 | $query .= ' ORDER BY date'; |
617 | 666 | } else { |
618 | 667 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
619 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
668 | + if ($liveinterval) { |
|
669 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
670 | + } |
|
620 | 671 | $query .= ' ORDER BY date'; |
621 | 672 | } |
622 | 673 | |
@@ -711,7 +762,9 @@ discard block |
||
711 | 762 | $i++; |
712 | 763 | $j++; |
713 | 764 | if ($j == 30) { |
714 | - if ($globalDebug) echo "."; |
|
765 | + if ($globalDebug) { |
|
766 | + echo "."; |
|
767 | + } |
|
715 | 768 | try { |
716 | 769 | |
717 | 770 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -1018,7 +1071,9 @@ discard block |
||
1018 | 1071 | { |
1019 | 1072 | return false; |
1020 | 1073 | } |
1021 | - } else return ''; |
|
1074 | + } else { |
|
1075 | + return ''; |
|
1076 | + } |
|
1022 | 1077 | |
1023 | 1078 | if ($longitude != '') |
1024 | 1079 | { |
@@ -1026,7 +1081,9 @@ discard block |
||
1026 | 1081 | { |
1027 | 1082 | return false; |
1028 | 1083 | } |
1029 | - } else return ''; |
|
1084 | + } else { |
|
1085 | + return ''; |
|
1086 | + } |
|
1030 | 1087 | |
1031 | 1088 | if ($waypoints != '') |
1032 | 1089 | { |
@@ -1042,14 +1099,18 @@ discard block |
||
1042 | 1099 | { |
1043 | 1100 | return false; |
1044 | 1101 | } |
1045 | - } else $altitude = 0; |
|
1102 | + } else { |
|
1103 | + $altitude = 0; |
|
1104 | + } |
|
1046 | 1105 | if ($altitude_real != '') |
1047 | 1106 | { |
1048 | 1107 | if (!is_numeric($altitude_real)) |
1049 | 1108 | { |
1050 | 1109 | return false; |
1051 | 1110 | } |
1052 | - } else $altitude_real = 0; |
|
1111 | + } else { |
|
1112 | + $altitude_real = 0; |
|
1113 | + } |
|
1053 | 1114 | |
1054 | 1115 | if ($heading != '') |
1055 | 1116 | { |
@@ -1057,7 +1118,9 @@ discard block |
||
1057 | 1118 | { |
1058 | 1119 | return false; |
1059 | 1120 | } |
1060 | - } else $heading = 0; |
|
1121 | + } else { |
|
1122 | + $heading = 0; |
|
1123 | + } |
|
1061 | 1124 | |
1062 | 1125 | if ($groundspeed != '') |
1063 | 1126 | { |
@@ -1065,9 +1128,13 @@ discard block |
||
1065 | 1128 | { |
1066 | 1129 | return false; |
1067 | 1130 | } |
1068 | - } else $groundspeed = 0; |
|
1131 | + } else { |
|
1132 | + $groundspeed = 0; |
|
1133 | + } |
|
1069 | 1134 | date_default_timezone_set('UTC'); |
1070 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1135 | + if ($date == '') { |
|
1136 | + $date = date("Y-m-d H:i:s", time()); |
|
1137 | + } |
|
1071 | 1138 | |
1072 | 1139 | |
1073 | 1140 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1112,14 +1179,24 @@ discard block |
||
1112 | 1179 | $arrival_airport_country = ''; |
1113 | 1180 | |
1114 | 1181 | |
1115 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1116 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1117 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1118 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1182 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
1183 | + $squawk = NULL; |
|
1184 | + } |
|
1185 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
1186 | + $verticalrate = NULL; |
|
1187 | + } |
|
1188 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1189 | + $groundspeed = 0; |
|
1190 | + } |
|
1191 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1192 | + $heading = 0; |
|
1193 | + } |
|
1119 | 1194 | |
1120 | 1195 | $query = ''; |
1121 | 1196 | if ($globalArchive) { |
1122 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1197 | + if ($globalDebug) { |
|
1198 | + echo '-- Delete previous data -- '; |
|
1199 | + } |
|
1123 | 1200 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
1124 | 1201 | } |
1125 | 1202 | |
@@ -1136,10 +1213,14 @@ discard block |
||
1136 | 1213 | return "error : ".$e->getMessage(); |
1137 | 1214 | } |
1138 | 1215 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1139 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1216 | + if ($globalDebug) { |
|
1217 | + echo '(Add to SBS archive : '; |
|
1218 | + } |
|
1140 | 1219 | $SpotterArchive = new SpotterArchive($this->db); |
1141 | 1220 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
1142 | - if ($globalDebug) echo $result.')'; |
|
1221 | + if ($globalDebug) { |
|
1222 | + echo $result.')'; |
|
1223 | + } |
|
1143 | 1224 | } elseif ($globalDebug && $putinarchive !== true) { |
1144 | 1225 | echo '(Not adding to archive)'; |
1145 | 1226 | } elseif ($globalDebug && $noarchive === true) { |
@@ -34,7 +34,9 @@ discard block |
||
34 | 34 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
35 | 35 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
36 | 36 | $aircraft_types = $Stats->getAllAircraftTypes(); |
37 | - if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
37 | + if (empty($aircraft_types)) { |
|
38 | + $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
39 | + } |
|
38 | 40 | foreach($aircraft_types as $aircraft_item) |
39 | 41 | { |
40 | 42 | $output .= '<url>'; |
@@ -84,7 +86,9 @@ discard block |
||
84 | 86 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
85 | 87 | |
86 | 88 | $airport_names = $Stats->getAllAirportNames(); |
87 | - if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
|
89 | + if (empty($airport_names)) { |
|
90 | + $airport_names = $Spotter->getAllAirportNames(); |
|
91 | + } |
|
88 | 92 | foreach($airport_names as $airport_item) |
89 | 93 | { |
90 | 94 | $output .= '<url>'; |
@@ -99,7 +103,9 @@ discard block |
||
99 | 103 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
100 | 104 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
101 | 105 | $manufacturer_names = $Stats->getAllManufacturers(); |
102 | - if (empty($manufacturer_names)) $manufacturer_names = $Spotter->getAllManufacturers(); |
|
106 | + if (empty($manufacturer_names)) { |
|
107 | + $manufacturer_names = $Spotter->getAllManufacturers(); |
|
108 | + } |
|
103 | 109 | foreach($manufacturer_names as $manufacturer_item) |
104 | 110 | { |
105 | 111 | $output .= '<url>'; |
@@ -4,7 +4,9 @@ discard block |
||
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Stats = new Stats(); |
6 | 6 | |
7 | -if (!isset($filter_name)) $filter_name = ''; |
|
7 | +if (!isset($filter_name)) { |
|
8 | + $filter_name = ''; |
|
9 | +} |
|
8 | 10 | $type = 'aircraft'; |
9 | 11 | if (isset($_GET['marine'])) { |
10 | 12 | $type = 'marine'; |
@@ -21,8 +23,10 @@ discard block |
||
21 | 23 | } |
22 | 24 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
23 | 25 | if ($airline_icao == '' && isset($globalFilter)) { |
24 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
25 | -} |
|
26 | + if (isset($globalFilter['airline'])) { |
|
27 | + $airline_icao = $globalFilter['airline'][0]; |
|
28 | + } |
|
29 | + } |
|
26 | 30 | |
27 | 31 | require_once('header.php'); |
28 | 32 | include('statistics-sub-menu.php'); |
@@ -64,10 +68,14 @@ discard block |
||
64 | 68 | $flightover_data = ''; |
65 | 69 | foreach($flightover_array as $flightover_item) |
66 | 70 | { |
67 | - if ($type == 'aircraft') $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],'; |
|
68 | - elseif ($type == 'marine') $flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],'; |
|
69 | - elseif ($type == 'tracker') $flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],'; |
|
70 | -} |
|
71 | + if ($type == 'aircraft') { |
|
72 | + $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],'; |
|
73 | + } elseif ($type == 'marine') { |
|
74 | + $flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],'; |
|
75 | + } elseif ($type == 'tracker') { |
|
76 | + $flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],'; |
|
77 | + } |
|
78 | + } |
|
71 | 79 | $flightover_data = substr($flightover_data, 0, -1); |
72 | 80 | print $flightover_data; |
73 | 81 | print '];'; |
@@ -10,7 +10,9 @@ discard block |
||
10 | 10 | public function __construct($dbc = null) { |
11 | 11 | $Connection = new Connection($dbc); |
12 | 12 | $this->db = $Connection->db(); |
13 | - if ($this->db === null) die('Error: No DB connection. (Tracker)'); |
|
13 | + if ($this->db === null) { |
|
14 | + die('Error: No DB connection. (Tracker)'); |
|
15 | + } |
|
14 | 16 | } |
15 | 17 | |
16 | 18 | /** |
@@ -32,7 +34,9 @@ discard block |
||
32 | 34 | if (isset($filter[0]['source'])) { |
33 | 35 | $filters = array_merge($filters,$filter); |
34 | 36 | } |
35 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
37 | + if (is_array($globalFilter)) { |
|
38 | + $filter = array_merge($filter,$globalFilter); |
|
39 | + } |
|
36 | 40 | $filter_query_join = ''; |
37 | 41 | $filter_query_where = ''; |
38 | 42 | foreach($filters as $flt) { |
@@ -71,8 +75,11 @@ discard block |
||
71 | 75 | $filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
72 | 76 | } |
73 | 77 | } |
74 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
75 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
78 | + if ($filter_query_where == '' && $where) { |
|
79 | + $filter_query_where = ' WHERE'; |
|
80 | + } elseif ($filter_query_where != '' && $and) { |
|
81 | + $filter_query_where .= ' AND'; |
|
82 | + } |
|
76 | 83 | if ($filter_query_where != '') { |
77 | 84 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
78 | 85 | } |
@@ -126,26 +133,43 @@ discard block |
||
126 | 133 | $temp_array['tracker_id'] = $row['tracker_archive_id']; |
127 | 134 | } elseif (isset($row['tracker_archive_output_id'])) { |
128 | 135 | $temp_array['tracker_id'] = $row['tracker_archive_output_id']; |
129 | - */} |
|
130 | - elseif (isset($row['trackerid'])) { |
|
136 | + */} elseif (isset($row['trackerid'])) { |
|
131 | 137 | $temp_array['trackerid'] = $row['trackerid']; |
132 | 138 | } else { |
133 | 139 | $temp_array['trackerid'] = ''; |
134 | 140 | } |
135 | - if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid']; |
|
136 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
137 | - if (isset($row['comment'])) $temp_array['comment'] = $row['comment']; |
|
141 | + if (isset($row['famtrackid'])) { |
|
142 | + $temp_array['famtrackid'] = $row['famtrackid']; |
|
143 | + } |
|
144 | + if (isset($row['type'])) { |
|
145 | + $temp_array['type'] = $row['type']; |
|
146 | + } |
|
147 | + if (isset($row['comment'])) { |
|
148 | + $temp_array['comment'] = $row['comment']; |
|
149 | + } |
|
138 | 150 | $temp_array['ident'] = $row['ident']; |
139 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
140 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
141 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
142 | - if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude']; |
|
151 | + if (isset($row['latitude'])) { |
|
152 | + $temp_array['latitude'] = $row['latitude']; |
|
153 | + } |
|
154 | + if (isset($row['longitude'])) { |
|
155 | + $temp_array['longitude'] = $row['longitude']; |
|
156 | + } |
|
157 | + if (isset($row['format_source'])) { |
|
158 | + $temp_array['format_source'] = $row['format_source']; |
|
159 | + } |
|
160 | + if (isset($row['altitude'])) { |
|
161 | + $temp_array['altitude'] = $row['altitude']; |
|
162 | + } |
|
143 | 163 | if (isset($row['heading'])) { |
144 | 164 | $temp_array['heading'] = $row['heading']; |
145 | 165 | $heading_direction = $this->parseDirection($row['heading']); |
146 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
166 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
167 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
168 | + } |
|
169 | + } |
|
170 | + if (isset($row['ground_speed'])) { |
|
171 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
147 | 172 | } |
148 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
149 | 173 | |
150 | 174 | if (isset($row['date'])) { |
151 | 175 | $dateArray = $this->parseDateString($row['date']); |
@@ -188,13 +212,21 @@ discard block |
||
188 | 212 | } |
189 | 213 | |
190 | 214 | $fromsource = NULL; |
191 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
192 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
193 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
215 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
216 | + $temp_array['source_name'] = $row['source_name']; |
|
217 | + } |
|
218 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
219 | + $temp_array['over_country'] = $row['over_country']; |
|
220 | + } |
|
221 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
222 | + $temp_array['distance'] = $row['distance']; |
|
223 | + } |
|
194 | 224 | $temp_array['query_number_rows'] = $num_rows; |
195 | 225 | $tracker_array[] = $temp_array; |
196 | 226 | } |
197 | - if ($num_rows == 0) return array(); |
|
227 | + if ($num_rows == 0) { |
|
228 | + return array(); |
|
229 | + } |
|
198 | 230 | $tracker_array[0]['query_number_rows'] = $num_rows; |
199 | 231 | return $tracker_array; |
200 | 232 | } |
@@ -225,8 +257,12 @@ discard block |
||
225 | 257 | { |
226 | 258 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
227 | 259 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
228 | - } else $limit_query = ""; |
|
229 | - } else $limit_query = ""; |
|
260 | + } else { |
|
261 | + $limit_query = ""; |
|
262 | + } |
|
263 | + } else { |
|
264 | + $limit_query = ""; |
|
265 | + } |
|
230 | 266 | |
231 | 267 | if ($sort != "") |
232 | 268 | { |
@@ -254,7 +290,9 @@ discard block |
||
254 | 290 | global $global_query; |
255 | 291 | |
256 | 292 | date_default_timezone_set('UTC'); |
257 | - if ($id == '') return array(); |
|
293 | + if ($id == '') { |
|
294 | + return array(); |
|
295 | + } |
|
258 | 296 | $additional_query = "tracker_output.famtrackid = :id"; |
259 | 297 | $query_values = array(':id' => $id); |
260 | 298 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -397,8 +435,11 @@ discard block |
||
397 | 435 | $query .= " ORDER BY tracker_output.source_name ASC"; |
398 | 436 | |
399 | 437 | $sth = $this->db->prepare($query); |
400 | - if (!empty($query_values)) $sth->execute($query_values); |
|
401 | - else $sth->execute(); |
|
438 | + if (!empty($query_values)) { |
|
439 | + $sth->execute($query_values); |
|
440 | + } else { |
|
441 | + $sth->execute(); |
|
442 | + } |
|
402 | 443 | |
403 | 444 | $source_array = array(); |
404 | 445 | $temp_array = array(); |
@@ -453,7 +494,9 @@ discard block |
||
453 | 494 | date_default_timezone_set($globalTimezone); |
454 | 495 | $datetime = new DateTime(); |
455 | 496 | $offset = $datetime->format('P'); |
456 | - } else $offset = '+00:00'; |
|
497 | + } else { |
|
498 | + $offset = '+00:00'; |
|
499 | + } |
|
457 | 500 | |
458 | 501 | if ($globalDBdriver == 'mysql') { |
459 | 502 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date |
@@ -609,7 +652,9 @@ discard block |
||
609 | 652 | { |
610 | 653 | return false; |
611 | 654 | } |
612 | - } else $altitude = 0; |
|
655 | + } else { |
|
656 | + $altitude = 0; |
|
657 | + } |
|
613 | 658 | |
614 | 659 | if ($heading != "") |
615 | 660 | { |
@@ -648,8 +693,12 @@ discard block |
||
648 | 693 | $latitude = 0; |
649 | 694 | $longitude = 0; |
650 | 695 | } |
651 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
652 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
696 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
697 | + $heading = 0; |
|
698 | + } |
|
699 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
700 | + $groundspeed = 0; |
|
701 | + } |
|
653 | 702 | $query = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) |
654 | 703 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)"; |
655 | 704 | |
@@ -753,7 +802,9 @@ discard block |
||
753 | 802 | global $globalDBdriver, $globalArchive; |
754 | 803 | //$filter_query = $this->getFilter($filters,true,true); |
755 | 804 | $Connection= new Connection($this->db); |
756 | - if (!$Connection->tableExists('countries')) return array(); |
|
805 | + if (!$Connection->tableExists('countries')) { |
|
806 | + return array(); |
|
807 | + } |
|
757 | 808 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
758 | 809 | require_once('class.TrackerLive.php'); |
759 | 810 | $TrackerLive = new TrackerLive($this->db); |
@@ -796,7 +847,9 @@ discard block |
||
796 | 847 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
797 | 848 | } |
798 | 849 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
799 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
850 | + if ($limit) { |
|
851 | + $query .= " LIMIT 10 OFFSET 0"; |
|
852 | + } |
|
800 | 853 | |
801 | 854 | |
802 | 855 | $sth = $this->db->prepare($query); |
@@ -829,12 +882,18 @@ discard block |
||
829 | 882 | $query = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count |
830 | 883 | FROM tracker_output".$filter_query." tracker_output.ident <> ''"; |
831 | 884 | if ($olderthanmonths > 0) { |
832 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
833 | - else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
885 | + if ($globalDBdriver == 'mysql') { |
|
886 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
887 | + } else { |
|
888 | + $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
889 | + } |
|
834 | 890 | } |
835 | 891 | if ($sincedate != '') { |
836 | - if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
837 | - else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
892 | + if ($globalDBdriver == 'mysql') { |
|
893 | + $query .= " AND tracker_output.date > '".$sincedate."'"; |
|
894 | + } else { |
|
895 | + $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
896 | + } |
|
838 | 897 | } |
839 | 898 | $query_values = array(); |
840 | 899 | if ($year != '') { |
@@ -865,7 +924,9 @@ discard block |
||
865 | 924 | } |
866 | 925 | } |
867 | 926 | $query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC"; |
868 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
927 | + if ($limit) { |
|
928 | + $query .= " LIMIT 10 OFFSET 0"; |
|
929 | + } |
|
869 | 930 | |
870 | 931 | $sth = $this->db->prepare($query); |
871 | 932 | $sth->execute($query_values); |
@@ -900,7 +961,9 @@ discard block |
||
900 | 961 | date_default_timezone_set($globalTimezone); |
901 | 962 | $datetime = new DateTime(); |
902 | 963 | $offset = $datetime->format('P'); |
903 | - } else $offset = '+00:00'; |
|
964 | + } else { |
|
965 | + $offset = '+00:00'; |
|
966 | + } |
|
904 | 967 | |
905 | 968 | if ($globalDBdriver == 'mysql') { |
906 | 969 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -950,7 +1013,9 @@ discard block |
||
950 | 1013 | date_default_timezone_set($globalTimezone); |
951 | 1014 | $datetime = new DateTime(); |
952 | 1015 | $offset = $datetime->format('P'); |
953 | - } else $offset = '+00:00'; |
|
1016 | + } else { |
|
1017 | + $offset = '+00:00'; |
|
1018 | + } |
|
954 | 1019 | $filter_query = $this->getFilter($filters,true,true); |
955 | 1020 | if ($globalDBdriver == 'mysql') { |
956 | 1021 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -996,7 +1061,9 @@ discard block |
||
996 | 1061 | date_default_timezone_set($globalTimezone); |
997 | 1062 | $datetime = new DateTime(); |
998 | 1063 | $offset = $datetime->format('P'); |
999 | - } else $offset = '+00:00'; |
|
1064 | + } else { |
|
1065 | + $offset = '+00:00'; |
|
1066 | + } |
|
1000 | 1067 | $filter_query = $this->getFilter($filters,true,true); |
1001 | 1068 | if ($globalDBdriver == 'mysql') { |
1002 | 1069 | $query = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1044,7 +1111,9 @@ discard block |
||
1044 | 1111 | date_default_timezone_set($globalTimezone); |
1045 | 1112 | $datetime = new DateTime(); |
1046 | 1113 | $offset = $datetime->format('P'); |
1047 | - } else $offset = '+00:00'; |
|
1114 | + } else { |
|
1115 | + $offset = '+00:00'; |
|
1116 | + } |
|
1048 | 1117 | |
1049 | 1118 | if ($globalDBdriver == 'mysql') { |
1050 | 1119 | $query = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1093,7 +1162,9 @@ discard block |
||
1093 | 1162 | date_default_timezone_set($globalTimezone); |
1094 | 1163 | $datetime = new DateTime(); |
1095 | 1164 | $offset = $datetime->format('P'); |
1096 | - } else $offset = '+00:00'; |
|
1165 | + } else { |
|
1166 | + $offset = '+00:00'; |
|
1167 | + } |
|
1097 | 1168 | $filter_query = $this->getFilter($filters,true,true); |
1098 | 1169 | if ($globalDBdriver == 'mysql') { |
1099 | 1170 | $query = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1142,7 +1213,9 @@ discard block |
||
1142 | 1213 | date_default_timezone_set($globalTimezone); |
1143 | 1214 | $datetime = new DateTime(); |
1144 | 1215 | $offset = $datetime->format('P'); |
1145 | - } else $offset = '+00:00'; |
|
1216 | + } else { |
|
1217 | + $offset = '+00:00'; |
|
1218 | + } |
|
1146 | 1219 | |
1147 | 1220 | $orderby_sql = ''; |
1148 | 1221 | if ($orderby == "hour") |
@@ -1211,7 +1284,9 @@ discard block |
||
1211 | 1284 | date_default_timezone_set($globalTimezone); |
1212 | 1285 | $datetime = new DateTime($date); |
1213 | 1286 | $offset = $datetime->format('P'); |
1214 | - } else $offset = '+00:00'; |
|
1287 | + } else { |
|
1288 | + $offset = '+00:00'; |
|
1289 | + } |
|
1215 | 1290 | |
1216 | 1291 | if ($globalDBdriver == 'mysql') { |
1217 | 1292 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1259,7 +1334,9 @@ discard block |
||
1259 | 1334 | date_default_timezone_set($globalTimezone); |
1260 | 1335 | $datetime = new DateTime(); |
1261 | 1336 | $offset = $datetime->format('P'); |
1262 | - } else $offset = '+00:00'; |
|
1337 | + } else { |
|
1338 | + $offset = '+00:00'; |
|
1339 | + } |
|
1263 | 1340 | |
1264 | 1341 | if ($globalDBdriver == 'mysql') { |
1265 | 1342 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1324,8 +1401,11 @@ discard block |
||
1324 | 1401 | $query_values = array_merge($query_values,array(':month' => $month)); |
1325 | 1402 | } |
1326 | 1403 | } |
1327 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1328 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1404 | + if (empty($query_values)) { |
|
1405 | + $queryi .= $this->getFilter($filters); |
|
1406 | + } else { |
|
1407 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1408 | + } |
|
1329 | 1409 | |
1330 | 1410 | $sth = $this->db->prepare($queryi); |
1331 | 1411 | $sth->execute($query_values); |
@@ -1362,8 +1442,11 @@ discard block |
||
1362 | 1442 | $query_values = array_merge($query_values,array(':month' => $month)); |
1363 | 1443 | } |
1364 | 1444 | } |
1365 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1366 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1445 | + if (empty($query_values)) { |
|
1446 | + $queryi .= $this->getFilter($filters); |
|
1447 | + } else { |
|
1448 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1449 | + } |
|
1367 | 1450 | |
1368 | 1451 | $sth = $this->db->prepare($queryi); |
1369 | 1452 | $sth->execute($query_values); |
@@ -1385,7 +1468,9 @@ discard block |
||
1385 | 1468 | date_default_timezone_set($globalTimezone); |
1386 | 1469 | $datetime = new DateTime(); |
1387 | 1470 | $offset = $datetime->format('P'); |
1388 | - } else $offset = '+00:00'; |
|
1471 | + } else { |
|
1472 | + $offset = '+00:00'; |
|
1473 | + } |
|
1389 | 1474 | |
1390 | 1475 | if ($globalDBdriver == 'mysql') { |
1391 | 1476 | $query = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1489,7 +1574,9 @@ discard block |
||
1489 | 1574 | */ |
1490 | 1575 | public function parseDirection($direction = 0) |
1491 | 1576 | { |
1492 | - if ($direction == '') $direction = 0; |
|
1577 | + if ($direction == '') { |
|
1578 | + $direction = 0; |
|
1579 | + } |
|
1493 | 1580 | $direction_array = array(); |
1494 | 1581 | $temp_array = array(); |
1495 | 1582 | |
@@ -1578,7 +1665,9 @@ discard block |
||
1578 | 1665 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1579 | 1666 | |
1580 | 1667 | $Connection = new Connection($this->db); |
1581 | - if (!$Connection->tableExists('countries')) return ''; |
|
1668 | + if (!$Connection->tableExists('countries')) { |
|
1669 | + return ''; |
|
1670 | + } |
|
1582 | 1671 | |
1583 | 1672 | try { |
1584 | 1673 | /* |
@@ -1598,9 +1687,13 @@ discard block |
||
1598 | 1687 | $sth->closeCursor(); |
1599 | 1688 | if (count($row) > 0) { |
1600 | 1689 | return $row; |
1601 | - } else return ''; |
|
1690 | + } else { |
|
1691 | + return ''; |
|
1692 | + } |
|
1602 | 1693 | } catch (PDOException $e) { |
1603 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1694 | + if (isset($globalDebug) && $globalDebug) { |
|
1695 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1696 | + } |
|
1604 | 1697 | return ''; |
1605 | 1698 | } |
1606 | 1699 | |
@@ -1618,7 +1711,9 @@ discard block |
||
1618 | 1711 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1619 | 1712 | |
1620 | 1713 | $Connection = new Connection($this->db); |
1621 | - if (!$Connection->tableExists('countries')) return ''; |
|
1714 | + if (!$Connection->tableExists('countries')) { |
|
1715 | + return ''; |
|
1716 | + } |
|
1622 | 1717 | |
1623 | 1718 | try { |
1624 | 1719 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1630,9 +1725,13 @@ discard block |
||
1630 | 1725 | $sth->closeCursor(); |
1631 | 1726 | if (count($row) > 0) { |
1632 | 1727 | return $row; |
1633 | - } else return ''; |
|
1728 | + } else { |
|
1729 | + return ''; |
|
1730 | + } |
|
1634 | 1731 | } catch (PDOException $e) { |
1635 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1732 | + if (isset($globalDebug) && $globalDebug) { |
|
1733 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1734 | + } |
|
1636 | 1735 | return ''; |
1637 | 1736 | } |
1638 | 1737 | |
@@ -1693,7 +1792,9 @@ discard block |
||
1693 | 1792 | } |
1694 | 1793 | } |
1695 | 1794 | $query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC"; |
1696 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1795 | + if ($limit) { |
|
1796 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1797 | + } |
|
1697 | 1798 | $sth = $this->db->prepare($query); |
1698 | 1799 | $sth->execute($query_values); |
1699 | 1800 | $tracker_array = array(); |
@@ -1730,7 +1831,9 @@ discard block |
||
1730 | 1831 | foreach ($q_array as $q_item){ |
1731 | 1832 | $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
1732 | 1833 | $additional_query .= " AND ("; |
1733 | - if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR "; |
|
1834 | + if (is_int($q_item)) { |
|
1835 | + $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR "; |
|
1836 | + } |
|
1734 | 1837 | $additional_query .= "(tracker_output.ident like '%".$q_item."%') OR "; |
1735 | 1838 | $additional_query .= ")"; |
1736 | 1839 | } |
@@ -1756,7 +1859,9 @@ discard block |
||
1756 | 1859 | date_default_timezone_set($globalTimezone); |
1757 | 1860 | $datetime = new DateTime(); |
1758 | 1861 | $offset = $datetime->format('P'); |
1759 | - } else $offset = '+00:00'; |
|
1862 | + } else { |
|
1863 | + $offset = '+00:00'; |
|
1864 | + } |
|
1760 | 1865 | if ($date_array[1] != "") |
1761 | 1866 | { |
1762 | 1867 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -1783,8 +1888,12 @@ discard block |
||
1783 | 1888 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1784 | 1889 | { |
1785 | 1890 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1786 | - } else $limit_query = ""; |
|
1787 | - } else $limit_query = ""; |
|
1891 | + } else { |
|
1892 | + $limit_query = ""; |
|
1893 | + } |
|
1894 | + } else { |
|
1895 | + $limit_query = ""; |
|
1896 | + } |
|
1788 | 1897 | if ($sort != "") |
1789 | 1898 | { |
1790 | 1899 | $search_orderby_array = $this->getOrderBy(); |
@@ -1827,7 +1936,9 @@ discard block |
||
1827 | 1936 | { |
1828 | 1937 | global $globalBitlyAccessToken; |
1829 | 1938 | |
1830 | - if ($globalBitlyAccessToken == '') return $url; |
|
1939 | + if ($globalBitlyAccessToken == '') { |
|
1940 | + return $url; |
|
1941 | + } |
|
1831 | 1942 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1832 | 1943 | $ch = curl_init(); |
1833 | 1944 | curl_setopt($ch, CURLOPT_HEADER, 0); |
@@ -22,7 +22,9 @@ |
||
22 | 22 | print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">'; |
23 | 23 | $Stats = new Stats(); |
24 | 24 | $all_manufacturers = $Stats->getAllManufacturers(); |
25 | - if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers(); |
|
25 | + if (empty($all_manufacturers)) { |
|
26 | + $all_manufacturers = $Spotter->getAllManufacturers(); |
|
27 | + } |
|
26 | 28 | foreach($all_manufacturers as $all_manufacturer) |
27 | 29 | { |
28 | 30 | if($manufacturer == ucwords($all_manufacturer['aircraft_manufacturer'])) |
@@ -22,7 +22,9 @@ |
||
22 | 22 | print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">'; |
23 | 23 | $Stats = new Stats(); |
24 | 24 | $all_manufacturers = $Stats->getAllManufacturers(); |
25 | - if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers(); |
|
25 | + if (empty($all_manufacturers)) { |
|
26 | + $all_manufacturers = $Spotter->getAllManufacturers(); |
|
27 | + } |
|
26 | 28 | foreach($all_manufacturers as $all_manufacturer) |
27 | 29 | { |
28 | 30 | if($manufacturer == ucwords($all_manufacturer['aircraft_manufacturer'])) |
@@ -1,13 +1,20 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $ident = ''; |
4 | -if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
5 | -if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
4 | +if (isset($_POST['ident'])) { |
|
5 | + $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
6 | +} |
|
7 | +if (isset($_GET['ident'])) { |
|
8 | + $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
9 | +} |
|
6 | 10 | if ($ident != '') |
7 | 11 | { |
8 | - if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident); |
|
9 | - else header('Location: '.$globalURL.'/ident/'.$ident); |
|
10 | -} else { |
|
12 | + if (isset($_GET['marine'])) { |
|
13 | + header('Location: '.$globalURL.'/marine/ident/'.$ident); |
|
14 | + } else { |
|
15 | + header('Location: '.$globalURL.'/ident/'.$ident); |
|
16 | + } |
|
17 | + } else { |
|
11 | 18 | if ($globalURL == '') { |
12 | 19 | header('Location: /'); |
13 | 20 | } else { |
@@ -1,8 +1,10 @@ discard block |
||
1 | 1 | </section> |
2 | 2 | <div class="pub onmap"> |
3 | 3 | <?php |
4 | - if (isset($globalPub)) print $globalPub; |
|
5 | -?> |
|
4 | + if (isset($globalPub)) { |
|
5 | + print $globalPub; |
|
6 | + } |
|
7 | + ?> |
|
6 | 8 | </div> |
7 | 9 | <footer class="container"> |
8 | 10 | <?php |
@@ -13,7 +15,10 @@ discard block |
||
13 | 15 | <?php |
14 | 16 | } |
15 | 17 | ?> |
16 | - <span>Developed in Barrie by <a href="http://mtru.nz/" target="_blank">Mario Trunz</a> & at <a href="http://www.zugaina.com" target="_blank">Zugaina</a> by Ycarus</span> - <span><a href="<?php if (isset($globalURL)) print $globalURL; ?>/about#source">Source & Credits</a></span> - <span><a href="https://www.flightairmap.com/" target="_blank">Get source code</a></span> |
|
18 | + <span>Developed in Barrie by <a href="http://mtru.nz/" target="_blank">Mario Trunz</a> & at <a href="http://www.zugaina.com" target="_blank">Zugaina</a> by Ycarus</span> - <span><a href="<?php if (isset($globalURL)) { |
|
19 | + print $globalURL; |
|
20 | +} |
|
21 | +?>/about#source">Source & Credits</a></span> - <span><a href="https://www.flightairmap.com/" target="_blank">Get source code</a></span> |
|
17 | 22 | </footer> |
18 | 23 | |
19 | 24 | <div class="notifications bottom-left"></div> |
@@ -13,7 +13,7 @@ |
||
13 | 13 | $limit_start = 0; |
14 | 14 | $limit_end = 25; |
15 | 15 | $absolute_difference = 25; |
16 | - } else { |
|
16 | + } else { |
|
17 | 17 | $limit_explode = explode(",", $_GET['limit']); |
18 | 18 | if (isset($limit_explode[1])) { |
19 | 19 | $limit_start = $limit_explode[0]; |