@@ -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. (Accident)'); |
|
13 | + if ($this->db === null) { |
|
14 | + die('Error: No DB connection. (Accident)'); |
|
15 | + } |
|
14 | 16 | } |
15 | 17 | |
16 | 18 | public function get() { |
@@ -109,8 +111,11 @@ discard block |
||
109 | 111 | $data = array(); |
110 | 112 | if ($row['registration'] != '') { |
111 | 113 | $image_array = $Image->getSpotterImage($row['registration']); |
112 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
113 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
114 | + if (count($image_array) > 0) { |
|
115 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
116 | + } else { |
|
117 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
118 | + } |
|
114 | 119 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
115 | 120 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
116 | 121 | if (!empty($aircraft_info)) { |
@@ -126,17 +131,30 @@ discard block |
||
126 | 131 | $data['aircraft_base'] = $owner_data['base']; |
127 | 132 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
128 | 133 | } |
129 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
130 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
131 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
134 | + } else { |
|
135 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
136 | + } |
|
137 | + if ($row['registration'] == '') { |
|
138 | + $row['registration'] = 'NA'; |
|
139 | + } |
|
140 | + if ($row['ident'] == '') { |
|
141 | + $row['ident'] = 'NA'; |
|
142 | + } |
|
132 | 143 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
133 | 144 | if (isset($identicao[0])) { |
134 | 145 | if (substr($row['ident'],0,2) == 'AF') { |
135 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
136 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
137 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
146 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
147 | + $icao = $row['ident']; |
|
148 | + } else { |
|
149 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
150 | + } |
|
151 | + } else { |
|
152 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
153 | + } |
|
138 | 154 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
139 | - } else $icao = $row['ident']; |
|
155 | + } else { |
|
156 | + $icao = $row['ident']; |
|
157 | + } |
|
140 | 158 | $icao = $Translation->checkTranslation($icao,false); |
141 | 159 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
142 | 160 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
@@ -151,10 +169,14 @@ discard block |
||
151 | 169 | //else echo 'No data...'."\n"; |
152 | 170 | } |
153 | 171 | $data = array_merge($row,$data); |
154 | - if ($data['ident'] == null) $data['ident'] = $icao; |
|
172 | + if ($data['ident'] == null) { |
|
173 | + $data['ident'] = $icao; |
|
174 | + } |
|
155 | 175 | if ($data['title'] == null) { |
156 | 176 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
157 | - } else $data['message'] = strtolower($data['title']); |
|
177 | + } else { |
|
178 | + $data['message'] = strtolower($data['title']); |
|
179 | + } |
|
158 | 180 | $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
159 | 181 | $date = $data['date']; |
160 | 182 | if (isset($ids[$date])) { |
@@ -173,8 +195,9 @@ discard block |
||
173 | 195 | if (isset($result)) { |
174 | 196 | $result[0]['query_number_rows'] = $i; |
175 | 197 | return $result; |
198 | + } else { |
|
199 | + return array(); |
|
176 | 200 | } |
177 | - else return array(); |
|
178 | 201 | } |
179 | 202 | |
180 | 203 | /* |
@@ -219,7 +242,9 @@ discard block |
||
219 | 242 | */ |
220 | 243 | public function import($file) { |
221 | 244 | global $globalTransaction, $globalDebug; |
222 | - if ($globalDebug) echo 'Import '.$file."\n"; |
|
245 | + if ($globalDebug) { |
|
246 | + echo 'Import '.$file."\n"; |
|
247 | + } |
|
223 | 248 | $result = array(); |
224 | 249 | if (file_exists($file)) { |
225 | 250 | if (($handle = fopen($file,'r')) !== FALSE) { |
@@ -230,8 +255,11 @@ discard block |
||
230 | 255 | } |
231 | 256 | fclose($handle); |
232 | 257 | } |
233 | - if (!empty($result)) $this->add($result,true); |
|
234 | - elseif ($globalDebug) echo 'Nothing to import'; |
|
258 | + if (!empty($result)) { |
|
259 | + $this->add($result,true); |
|
260 | + } elseif ($globalDebug) { |
|
261 | + echo 'Nothing to import'; |
|
262 | + } |
|
235 | 263 | } |
236 | 264 | } |
237 | 265 | |
@@ -267,14 +295,23 @@ discard block |
||
267 | 295 | } |
268 | 296 | } |
269 | 297 | fclose($handle); |
270 | - } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
271 | - } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
298 | + } elseif ($globalDebug) { |
|
299 | + echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
300 | + } |
|
301 | + } elseif ($globalDebug) { |
|
302 | + echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
303 | + } |
|
272 | 304 | $result = $Common->arr_diff($all_md5_new,$all_md5); |
273 | - if (empty($result) && $globalDebug) echo 'Nothing to update'; |
|
305 | + if (empty($result) && $globalDebug) { |
|
306 | + echo 'Nothing to update'; |
|
307 | + } |
|
274 | 308 | foreach ($result as $file => $md5) { |
275 | 309 | $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
276 | - if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
277 | - elseif ($globalDebug) echo 'Download '.$file.' failed'; |
|
310 | + if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) { |
|
311 | + $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
312 | + } elseif ($globalDebug) { |
|
313 | + echo 'Download '.$file.' failed'; |
|
314 | + } |
|
278 | 315 | } |
279 | 316 | } |
280 | 317 | |
@@ -291,13 +328,17 @@ discard block |
||
291 | 328 | $Image = new Image($this->db); |
292 | 329 | $Spotter = new Spotter($this->db); |
293 | 330 | |
294 | - if (empty($crash)) return false; |
|
331 | + if (empty($crash)) { |
|
332 | + return false; |
|
333 | + } |
|
295 | 334 | if (!$new) { |
296 | 335 | $query_delete = 'DELETE FROM accidents WHERE source = :source'; |
297 | 336 | $sthd = $Connection->db->prepare($query_delete); |
298 | 337 | $sthd->execute(array(':source' => $crash[0]['source'])); |
299 | 338 | } |
300 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
339 | + if ($globalTransaction) { |
|
340 | + $Connection->db->beginTransaction(); |
|
341 | + } |
|
301 | 342 | $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
302 | 343 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
303 | 344 | $sth_check = $Connection->db->prepare($query_check); |
@@ -312,7 +353,9 @@ discard block |
||
312 | 353 | return $value === "" ? NULL : $value; |
313 | 354 | }, $cr); |
314 | 355 | if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
315 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
356 | + if (strpos($cr['registration'],'-') === FALSE) { |
|
357 | + $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
358 | + } |
|
316 | 359 | $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
317 | 360 | $sth_check->execute($query_check_values); |
318 | 361 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
@@ -321,13 +364,19 @@ discard block |
||
321 | 364 | $sth->execute($query_values); |
322 | 365 | if ($cr['date'] > time()-(30*86400)) { |
323 | 366 | if (empty($Image->getSpotterImage($cr['registration']))) { |
324 | - if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
|
367 | + if ($globalDebug) { |
|
368 | + echo "\t".'Get image for '.$cr['registration'].'...'; |
|
369 | + } |
|
325 | 370 | $Image->addSpotterImage($cr['registration']); |
326 | - if ($globalDebug) echo "\t".'Done'."\n"; |
|
371 | + if ($globalDebug) { |
|
372 | + echo "\t".'Done'."\n"; |
|
373 | + } |
|
327 | 374 | } |
328 | 375 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
329 | 376 | } |
330 | - if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
377 | + if ($cr['title'] == '') { |
|
378 | + $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
379 | + } |
|
331 | 380 | $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
332 | 381 | } |
333 | 382 | } |
@@ -336,9 +385,13 @@ discard block |
||
336 | 385 | $Connection->db->beginTransaction(); |
337 | 386 | } |
338 | 387 | } |
339 | - if ($globalTransaction) $Connection->db->commit(); |
|
388 | + if ($globalTransaction) { |
|
389 | + $Connection->db->commit(); |
|
390 | + } |
|
340 | 391 | } catch(PDOException $e) { |
341 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
392 | + if ($globalTransaction) { |
|
393 | + $Connection->db->rollBack(); |
|
394 | + } |
|
342 | 395 | echo $e->getMessage(); |
343 | 396 | } |
344 | 397 | $sth_check->closeCursor(); |
@@ -377,8 +430,11 @@ discard block |
||
377 | 430 | return "error : ".$e->getMessage(); |
378 | 431 | } |
379 | 432 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
380 | - if ($row['nb'] > 0) return false; |
|
381 | - else return true; |
|
433 | + if ($row['nb'] > 0) { |
|
434 | + return false; |
|
435 | + } else { |
|
436 | + return true; |
|
437 | + } |
|
382 | 438 | } |
383 | 439 | |
384 | 440 | public static function insert_last_accidents_update() { |
@@ -7,7 +7,9 @@ discard block |
||
7 | 7 | public function __construct($dbc = null) { |
8 | 8 | $Connection = new Connection($dbc); |
9 | 9 | $this->db = $Connection->db; |
10 | - if ($this->db === null) die('Error: No DB connection. (Source)'); |
|
10 | + if ($this->db === null) { |
|
11 | + die('Error: No DB connection. (Source)'); |
|
12 | + } |
|
11 | 13 | } |
12 | 14 | |
13 | 15 | public function getAllLocationInfo() { |
@@ -72,7 +74,9 @@ discard block |
||
72 | 74 | $query .= " AND source_location.latitude BETWEEN ".$minlat." AND ".$maxlat." AND source_location.longitude BETWEEN ".$minlong." AND ".$maxlong." AND source_location.latitude <> 0 AND source_location.longitude <> 0"; |
73 | 75 | } |
74 | 76 | $query .= " ORDER BY last_seen DESC"; |
75 | - if ($limit) $query .= " LIMIT 400"; |
|
77 | + if ($limit) { |
|
78 | + $query .= " LIMIT 400"; |
|
79 | + } |
|
76 | 80 | $query_values = array(':type' => $type); |
77 | 81 | try { |
78 | 82 | $sth = $this->db->prepare($query); |
@@ -111,7 +115,9 @@ discard block |
||
111 | 115 | } |
112 | 116 | |
113 | 117 | public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { |
114 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
118 | + if ($last_seen == '') { |
|
119 | + $last_seen = date('Y-m-d H:i:s'); |
|
120 | + } |
|
115 | 121 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; |
116 | 122 | $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
117 | 123 | try { |
@@ -123,7 +129,9 @@ discard block |
||
123 | 129 | } |
124 | 130 | |
125 | 131 | public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { |
126 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
132 | + if ($last_seen == '') { |
|
133 | + $last_seen = date('Y-m-d H:i:s'); |
|
134 | + } |
|
127 | 135 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; |
128 | 136 | $query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
129 | 137 | try { |
@@ -146,7 +154,9 @@ discard block |
||
146 | 154 | } |
147 | 155 | |
148 | 156 | public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { |
149 | - if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); |
|
157 | + if ($last_seen == '') { |
|
158 | + $last_seen = date('Y-m-d H:i:s'); |
|
159 | + } |
|
150 | 160 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; |
151 | 161 | $query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); |
152 | 162 | try { |
@@ -6,7 +6,9 @@ discard block |
||
6 | 6 | public function __construct($dbc = null) { |
7 | 7 | $Connection = new Connection($dbc); |
8 | 8 | $this->db = $Connection->db; |
9 | - if ($this->db === null) die('Error: No DB connection. (SpotterArchive)'); |
|
9 | + if ($this->db === null) { |
|
10 | + die('Error: No DB connection. (SpotterArchive)'); |
|
11 | + } |
|
10 | 12 | } |
11 | 13 | |
12 | 14 | /** |
@@ -27,7 +29,9 @@ discard block |
||
27 | 29 | if (isset($filter[0]['source'])) { |
28 | 30 | $filters = array_merge($filters,$filter); |
29 | 31 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
31 | 35 | $filter_query_join = ''; |
32 | 36 | $filter_query_where = ''; |
33 | 37 | foreach($filters as $flt) { |
@@ -116,8 +120,11 @@ discard block |
||
116 | 120 | } |
117 | 121 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
118 | 122 | } |
119 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
120 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
123 | + if ($filter_query_where == '' && $where) { |
|
124 | + $filter_query_where = ' WHERE'; |
|
125 | + } elseif ($filter_query_where != '' && $and) { |
|
126 | + $filter_query_where .= ' AND'; |
|
127 | + } |
|
121 | 128 | if ($filter_query_where != '') { |
122 | 129 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
123 | 130 | } |
@@ -131,10 +138,17 @@ discard block |
||
131 | 138 | if ($over_country == '') { |
132 | 139 | $Spotter = new Spotter($this->db); |
133 | 140 | $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
134 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
135 | - else $country = ''; |
|
136 | - } else $country = $over_country; |
|
137 | - if ($airline_type === NULL) $airline_type =''; |
|
141 | + if (!empty($data_country)) { |
|
142 | + $country = $data_country['iso2']; |
|
143 | + } else { |
|
144 | + $country = ''; |
|
145 | + } |
|
146 | + } else { |
|
147 | + $country = $over_country; |
|
148 | + } |
|
149 | + if ($airline_type === NULL) { |
|
150 | + $airline_type =''; |
|
151 | + } |
|
138 | 152 | |
139 | 153 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
140 | 154 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
@@ -630,7 +644,9 @@ discard block |
||
630 | 644 | $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
631 | 645 | $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
632 | 646 | $translate = $Translation->ident2icao($q_item); |
633 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
647 | + if ($translate != $q_item) { |
|
648 | + $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
649 | + } |
|
634 | 650 | $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
635 | 651 | $additional_query .= ")"; |
636 | 652 | } |
@@ -846,7 +862,9 @@ discard block |
||
846 | 862 | date_default_timezone_set($globalTimezone); |
847 | 863 | $datetime = new DateTime(); |
848 | 864 | $offset = $datetime->format('P'); |
849 | - } else $offset = '+00:00'; |
|
865 | + } else { |
|
866 | + $offset = '+00:00'; |
|
867 | + } |
|
850 | 868 | if ($date_array[1] != "") |
851 | 869 | { |
852 | 870 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
@@ -1112,9 +1130,13 @@ discard block |
||
1112 | 1130 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1113 | 1131 | } |
1114 | 1132 | } |
1115 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1133 | + if ($sincedate != '') { |
|
1134 | + $query .= "AND date > '".$sincedate."' "; |
|
1135 | + } |
|
1116 | 1136 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1117 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1137 | + if ($limit) { |
|
1138 | + $query .= " LIMIT 0,10"; |
|
1139 | + } |
|
1118 | 1140 | |
1119 | 1141 | |
1120 | 1142 | $sth = $this->db->prepare($query); |
@@ -1158,9 +1180,13 @@ discard block |
||
1158 | 1180 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1159 | 1181 | } |
1160 | 1182 | } |
1161 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1183 | + if ($sincedate != '') { |
|
1184 | + $query .= "AND s.date > '".$sincedate."' "; |
|
1185 | + } |
|
1162 | 1186 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1163 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1187 | + if ($limit) { |
|
1188 | + $query .= " LIMIT 0,10"; |
|
1189 | + } |
|
1164 | 1190 | |
1165 | 1191 | |
1166 | 1192 | $sth = $this->db->prepare($query); |
@@ -6,7 +6,9 @@ discard block |
||
6 | 6 | public function __construct($dbc = null) { |
7 | 7 | $Connection = new Connection($dbc); |
8 | 8 | $this->db = $Connection->db; |
9 | - if ($this->db === null) die('Error: No DB connection. (TrackerArchive)'); |
|
9 | + if ($this->db === null) { |
|
10 | + die('Error: No DB connection. (TrackerArchive)'); |
|
11 | + } |
|
10 | 12 | } |
11 | 13 | |
12 | 14 | /** |
@@ -27,7 +29,9 @@ discard block |
||
27 | 29 | if (isset($filter[0]['source'])) { |
28 | 30 | $filters = array_merge($filters,$filter); |
29 | 31 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
31 | 35 | $filter_query_join = ''; |
32 | 36 | $filter_query_where = ''; |
33 | 37 | foreach($filters as $flt) { |
@@ -73,8 +77,11 @@ discard block |
||
73 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | 78 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
75 | 79 | } |
76 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
77 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
80 | + if ($filter_query_where == '' && $where) { |
|
81 | + $filter_query_where = ' WHERE'; |
|
82 | + } elseif ($filter_query_where != '' && $and) { |
|
83 | + $filter_query_where .= ' AND'; |
|
84 | + } |
|
78 | 85 | if ($filter_query_where != '') { |
79 | 86 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
80 | 87 | } |
@@ -88,9 +95,14 @@ discard block |
||
88 | 95 | if ($over_country == '') { |
89 | 96 | $Tracker = new Tracker($this->db); |
90 | 97 | $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
91 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
92 | - else $country = ''; |
|
93 | - } else $country = $over_country; |
|
98 | + if (!empty($data_country)) { |
|
99 | + $country = $data_country['iso2']; |
|
100 | + } else { |
|
101 | + $country = ''; |
|
102 | + } |
|
103 | + } else { |
|
104 | + $country = $over_country; |
|
105 | + } |
|
94 | 106 | // Route is not added in tracker_archive |
95 | 107 | $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
96 | 108 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -592,7 +604,9 @@ discard block |
||
592 | 604 | $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
593 | 605 | $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
594 | 606 | $translate = $Translation->ident2icao($q_item); |
595 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
607 | + if ($translate != $q_item) { |
|
608 | + $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
609 | + } |
|
596 | 610 | $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
597 | 611 | $additional_query .= ")"; |
598 | 612 | } |
@@ -810,7 +824,9 @@ discard block |
||
810 | 824 | date_default_timezone_set($globalTimezone); |
811 | 825 | $datetime = new DateTime(); |
812 | 826 | $offset = $datetime->format('P'); |
813 | - } else $offset = '+00:00'; |
|
827 | + } else { |
|
828 | + $offset = '+00:00'; |
|
829 | + } |
|
814 | 830 | |
815 | 831 | |
816 | 832 | if ($date_array[1] != "") |
@@ -1086,9 +1102,13 @@ discard block |
||
1086 | 1102 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1087 | 1103 | } |
1088 | 1104 | } |
1089 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1105 | + if ($sincedate != '') { |
|
1106 | + $query .= "AND date > '".$sincedate."' "; |
|
1107 | + } |
|
1090 | 1108 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1091 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1109 | + if ($limit) { |
|
1110 | + $query .= " LIMIT 0,10"; |
|
1111 | + } |
|
1092 | 1112 | |
1093 | 1113 | |
1094 | 1114 | $sth = $this->db->prepare($query); |
@@ -1132,9 +1152,13 @@ discard block |
||
1132 | 1152 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1133 | 1153 | } |
1134 | 1154 | } |
1135 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1155 | + if ($sincedate != '') { |
|
1156 | + $query .= "AND s.date > '".$sincedate."' "; |
|
1157 | + } |
|
1136 | 1158 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1137 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1159 | + if ($limit) { |
|
1160 | + $query .= " LIMIT 0,10"; |
|
1161 | + } |
|
1138 | 1162 | |
1139 | 1163 | |
1140 | 1164 | $sth = $this->db->prepare($query); |
@@ -6,7 +6,9 @@ discard block |
||
6 | 6 | public function __construct($dbc = null) { |
7 | 7 | $Connection = new Connection($dbc); |
8 | 8 | $this->db = $Connection->db; |
9 | - if ($this->db === null) die('Error: No DB connection. (MarineArchive)'); |
|
9 | + if ($this->db === null) { |
|
10 | + die('Error: No DB connection. (MarineArchive)'); |
|
11 | + } |
|
10 | 12 | } |
11 | 13 | |
12 | 14 | /** |
@@ -27,7 +29,9 @@ discard block |
||
27 | 29 | if (isset($filter[0]['source'])) { |
28 | 30 | $filters = array_merge($filters,$filter); |
29 | 31 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
31 | 35 | $filter_query_join = ''; |
32 | 36 | $filter_query_where = ''; |
33 | 37 | foreach($filters as $flt) { |
@@ -73,8 +77,11 @@ discard block |
||
73 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | 78 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
75 | 79 | } |
76 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
77 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
80 | + if ($filter_query_where == '' && $where) { |
|
81 | + $filter_query_where = ' WHERE'; |
|
82 | + } elseif ($filter_query_where != '' && $and) { |
|
83 | + $filter_query_where .= ' AND'; |
|
84 | + } |
|
78 | 85 | if ($filter_query_where != '') { |
79 | 86 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
80 | 87 | } |
@@ -88,9 +95,14 @@ discard block |
||
88 | 95 | if ($over_country == '') { |
89 | 96 | $Marine = new Marine($this->db); |
90 | 97 | $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
91 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
92 | - else $country = ''; |
|
93 | - } else $country = $over_country; |
|
98 | + if (!empty($data_country)) { |
|
99 | + $country = $data_country['iso2']; |
|
100 | + } else { |
|
101 | + $country = ''; |
|
102 | + } |
|
103 | + } else { |
|
104 | + $country = $over_country; |
|
105 | + } |
|
94 | 106 | |
95 | 107 | //$country = $over_country; |
96 | 108 | // Route is not added in marine_archive |
@@ -598,7 +610,9 @@ discard block |
||
598 | 610 | $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
599 | 611 | $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
600 | 612 | $translate = $Translation->ident2icao($q_item); |
601 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
613 | + if ($translate != $q_item) { |
|
614 | + $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
615 | + } |
|
602 | 616 | $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
603 | 617 | $additional_query .= ")"; |
604 | 618 | } |
@@ -816,7 +830,9 @@ discard block |
||
816 | 830 | date_default_timezone_set($globalTimezone); |
817 | 831 | $datetime = new DateTime(); |
818 | 832 | $offset = $datetime->format('P'); |
819 | - } else $offset = '+00:00'; |
|
833 | + } else { |
|
834 | + $offset = '+00:00'; |
|
835 | + } |
|
820 | 836 | |
821 | 837 | |
822 | 838 | if ($date_array[1] != "") |
@@ -1092,9 +1108,13 @@ discard block |
||
1092 | 1108 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1093 | 1109 | } |
1094 | 1110 | } |
1095 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1111 | + if ($sincedate != '') { |
|
1112 | + $query .= "AND date > '".$sincedate."' "; |
|
1113 | + } |
|
1096 | 1114 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1097 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1115 | + if ($limit) { |
|
1116 | + $query .= " LIMIT 0,10"; |
|
1117 | + } |
|
1098 | 1118 | |
1099 | 1119 | |
1100 | 1120 | $sth = $this->db->prepare($query); |
@@ -1138,9 +1158,13 @@ discard block |
||
1138 | 1158 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1139 | 1159 | } |
1140 | 1160 | } |
1141 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1161 | + if ($sincedate != '') { |
|
1162 | + $query .= "AND s.date > '".$sincedate."' "; |
|
1163 | + } |
|
1142 | 1164 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1143 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1165 | + if ($limit) { |
|
1166 | + $query .= " LIMIT 0,10"; |
|
1167 | + } |
|
1144 | 1168 | |
1145 | 1169 | |
1146 | 1170 | $sth = $this->db->prepare($query); |
@@ -7,7 +7,9 @@ discard block |
||
7 | 7 | public function __construct($dbc = null) { |
8 | 8 | $Connection = new Connection($dbc); |
9 | 9 | $this->db = $Connection->db; |
10 | - if ($this->db === null) die('Error: No DB connection. (ATC)'); |
|
10 | + if ($this->db === null) { |
|
11 | + die('Error: No DB connection. (ATC)'); |
|
12 | + } |
|
11 | 13 | } |
12 | 14 | |
13 | 15 | /** |
@@ -20,20 +22,27 @@ discard block |
||
20 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | 24 | foreach($globalStatsFilters[$globalFilterName] as $source) { |
23 | - if (isset($source['source'])) $filter['source'][] = $source['source']; |
|
25 | + if (isset($source['source'])) { |
|
26 | + $filter['source'][] = $source['source']; |
|
27 | + } |
|
24 | 28 | } |
25 | 29 | } else { |
26 | 30 | $filter = $globalStatsFilters[$globalFilterName]; |
27 | 31 | } |
28 | 32 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) { |
|
34 | + $filter = array_merge($filter,$globalFilter); |
|
35 | + } |
|
30 | 36 | $filter_query_join = ''; |
31 | 37 | $filter_query_where = ''; |
32 | 38 | if (isset($filter['source']) && !empty($filter['source'])) { |
33 | 39 | $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
34 | 40 | } |
35 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
36 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
41 | + if ($filter_query_where == '' && $where) { |
|
42 | + $filter_query_where = ' WHERE'; |
|
43 | + } elseif ($filter_query_where != '' && $and) { |
|
44 | + $filter_query_where .= ' AND'; |
|
45 | + } |
|
37 | 46 | $filter_query = $filter_query_join.$filter_query_where; |
38 | 47 | return $filter_query; |
39 | 48 | } |
@@ -90,7 +99,9 @@ discard block |
||
90 | 99 | $info = str_replace('^','<br />',$info); |
91 | 100 | $info = str_replace('&sect;','',$info); |
92 | 101 | $info = str_replace('"','',$info); |
93 | - if ($type == '') $type = NULL; |
|
102 | + if ($type == '') { |
|
103 | + $type = NULL; |
|
104 | + } |
|
94 | 105 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
95 | 106 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
96 | 107 | try { |
@@ -106,7 +117,9 @@ discard block |
||
106 | 117 | $info = str_replace('^','<br />',$info); |
107 | 118 | $info = str_replace('&sect;','',$info); |
108 | 119 | $info = str_replace('"','',$info); |
109 | - if ($type == '') $type = NULL; |
|
120 | + if ($type == '') { |
|
121 | + $type = NULL; |
|
122 | + } |
|
110 | 123 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
111 | 124 | $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
112 | 125 | try { |
@@ -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. (MarineLive)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (MarineLive)'); |
|
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) { |
@@ -77,8 +81,11 @@ discard block |
||
77 | 81 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
78 | 82 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
79 | 83 | } |
80 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
81 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
84 | + if ($filter_query_where == '' && $where) { |
|
85 | + $filter_query_where = ' WHERE'; |
|
86 | + } elseif ($filter_query_where != '' && $and) { |
|
87 | + $filter_query_where .= ' AND'; |
|
88 | + } |
|
82 | 89 | if ($filter_query_where != '') { |
83 | 90 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
84 | 91 | } |
@@ -119,9 +126,13 @@ discard block |
||
119 | 126 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
120 | 127 | } |
121 | 128 | } |
122 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
129 | + if ($orderby_query == '') { |
|
130 | + $orderby_query= ' ORDER BY date DESC'; |
|
131 | + } |
|
123 | 132 | |
124 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
133 | + if (!isset($globalLiveInterval)) { |
|
134 | + $globalLiveInterval = '200'; |
|
135 | + } |
|
125 | 136 | if ($globalDBdriver == 'mysql') { |
126 | 137 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate"; |
127 | 138 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -146,7 +157,9 @@ discard block |
||
146 | 157 | |
147 | 158 | $filter_query = $this->getFilter($filter,true,true); |
148 | 159 | |
149 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
160 | + if (!isset($globalLiveInterval)) { |
|
161 | + $globalLiveInterval = '200'; |
|
162 | + } |
|
150 | 163 | if ($globalDBdriver == 'mysql') { |
151 | 164 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
152 | 165 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0"; |
@@ -187,48 +200,72 @@ discard block |
||
187 | 200 | } |
188 | 201 | $filter_query = $this->getFilter($filter,true,true); |
189 | 202 | |
190 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
191 | - if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
|
203 | + if (!isset($globalLiveInterval)) { |
|
204 | + $globalLiveInterval = '200'; |
|
205 | + } |
|
206 | + if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') { |
|
207 | + $globalMap3DMarinesLimit = '300'; |
|
208 | + } |
|
192 | 209 | if ($globalDBdriver == 'mysql') { |
193 | 210 | if (isset($globalArchive) && $globalArchive === TRUE) { |
194 | 211 | $query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source |
195 | 212 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
196 | - if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
213 | + if ($usecoord) { |
|
214 | + $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
215 | + } |
|
197 | 216 | $query .= "UNION |
198 | 217 | SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
199 | 218 | FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date"; |
200 | - if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
219 | + if ($usecoord) { |
|
220 | + $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
221 | + } |
|
201 | 222 | $query .= ") AS marine |
202 | 223 | WHERE latitude <> '0' AND longitude <> '0' |
203 | 224 | ORDER BY fammarine_id, date"; |
204 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
225 | + if ($limit) { |
|
226 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
227 | + } |
|
205 | 228 | } else { |
206 | 229 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
207 | 230 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date "; |
208 | - if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
231 | + if ($usecoord) { |
|
232 | + $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
233 | + } |
|
209 | 234 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
210 | 235 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
211 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
236 | + if ($limit) { |
|
237 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
238 | + } |
|
212 | 239 | } |
213 | 240 | } else { |
214 | 241 | if (isset($globalArchive) && $globalArchive === TRUE) { |
215 | 242 | $query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source |
216 | 243 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
217 | - if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
244 | + if ($usecoord) { |
|
245 | + $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
246 | + } |
|
218 | 247 | $query .= "UNION |
219 | 248 | SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
220 | 249 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date"; |
221 | - if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
250 | + if ($usecoord) { |
|
251 | + $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
252 | + } |
|
222 | 253 | $query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' "; |
223 | 254 | $query .= "ORDER BY fammarine_id, date"; |
224 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
255 | + if ($limit) { |
|
256 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
257 | + } |
|
225 | 258 | } else { |
226 | 259 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
227 | 260 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date "; |
228 | - if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
261 | + if ($usecoord) { |
|
262 | + $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
263 | + } |
|
229 | 264 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
230 | 265 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
231 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
266 | + if ($limit) { |
|
267 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
268 | + } |
|
232 | 269 | } |
233 | 270 | } |
234 | 271 | try { |
@@ -253,7 +290,9 @@ discard block |
||
253 | 290 | global $globalDBdriver, $globalLiveInterval; |
254 | 291 | $filter_query = $this->getFilter($filter,true,true); |
255 | 292 | |
256 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
293 | + if (!isset($globalLiveInterval)) { |
|
294 | + $globalLiveInterval = '200'; |
|
295 | + } |
|
257 | 296 | if ($globalDBdriver == 'mysql') { |
258 | 297 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
259 | 298 | } else { |
@@ -281,7 +320,9 @@ discard block |
||
281 | 320 | { |
282 | 321 | global $globalDBdriver, $globalLiveInterval; |
283 | 322 | $Marine = new Marine($this->db); |
284 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
323 | + if (!isset($globalLiveInterval)) { |
|
324 | + $globalLiveInterval = '200'; |
|
325 | + } |
|
285 | 326 | $filter_query = $this->getFilter($filter); |
286 | 327 | |
287 | 328 | if (is_array($coord)) { |
@@ -289,7 +330,9 @@ discard block |
||
289 | 330 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
290 | 331 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
291 | 332 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
292 | - } else return array(); |
|
333 | + } else { |
|
334 | + return array(); |
|
335 | + } |
|
293 | 336 | if ($globalDBdriver == 'mysql') { |
294 | 337 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
295 | 338 | } else { |
@@ -309,7 +352,9 @@ discard block |
||
309 | 352 | { |
310 | 353 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
311 | 354 | $Marine = new Marine($this->db); |
312 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
355 | + if (!isset($globalLiveInterval)) { |
|
356 | + $globalLiveInterval = '200'; |
|
357 | + } |
|
313 | 358 | $filter_query = $this->getFilter($filter,true,true); |
314 | 359 | |
315 | 360 | if (is_array($coord)) { |
@@ -317,7 +362,9 @@ discard block |
||
317 | 362 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
318 | 363 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
319 | 364 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
320 | - } else return array(); |
|
365 | + } else { |
|
366 | + return array(); |
|
367 | + } |
|
321 | 368 | /* |
322 | 369 | if ($globalDBdriver == 'mysql') { |
323 | 370 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
@@ -526,11 +573,15 @@ discard block |
||
526 | 573 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
527 | 574 | if ($globalDBdriver == 'mysql') { |
528 | 575 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
529 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
576 | + if ($liveinterval) { |
|
577 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
578 | + } |
|
530 | 579 | $query .= ' ORDER BY date'; |
531 | 580 | } else { |
532 | 581 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
533 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
582 | + if ($liveinterval) { |
|
583 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
584 | + } |
|
534 | 585 | $query .= ' ORDER BY date'; |
535 | 586 | } |
536 | 587 | |
@@ -625,7 +676,9 @@ discard block |
||
625 | 676 | $i++; |
626 | 677 | $j++; |
627 | 678 | if ($j == 30) { |
628 | - if ($globalDebug) echo "."; |
|
679 | + if ($globalDebug) { |
|
680 | + echo "."; |
|
681 | + } |
|
629 | 682 | try { |
630 | 683 | |
631 | 684 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -905,7 +958,9 @@ discard block |
||
905 | 958 | { |
906 | 959 | return false; |
907 | 960 | } |
908 | - } else return ''; |
|
961 | + } else { |
|
962 | + return ''; |
|
963 | + } |
|
909 | 964 | |
910 | 965 | if ($longitude != '') |
911 | 966 | { |
@@ -913,7 +968,9 @@ discard block |
||
913 | 968 | { |
914 | 969 | return false; |
915 | 970 | } |
916 | - } else return ''; |
|
971 | + } else { |
|
972 | + return ''; |
|
973 | + } |
|
917 | 974 | |
918 | 975 | |
919 | 976 | if ($heading != '') |
@@ -922,7 +979,9 @@ discard block |
||
922 | 979 | { |
923 | 980 | return false; |
924 | 981 | } |
925 | - } else $heading = 0; |
|
982 | + } else { |
|
983 | + $heading = 0; |
|
984 | + } |
|
926 | 985 | |
927 | 986 | if ($groundspeed != '') |
928 | 987 | { |
@@ -930,9 +989,13 @@ discard block |
||
930 | 989 | { |
931 | 990 | return false; |
932 | 991 | } |
933 | - } else $groundspeed = 0; |
|
992 | + } else { |
|
993 | + $groundspeed = 0; |
|
994 | + } |
|
934 | 995 | date_default_timezone_set('UTC'); |
935 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
996 | + if ($date == '') { |
|
997 | + $date = date("Y-m-d H:i:s", time()); |
|
998 | + } |
|
936 | 999 | |
937 | 1000 | |
938 | 1001 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -953,12 +1016,20 @@ discard block |
||
953 | 1016 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
954 | 1017 | |
955 | 1018 | |
956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
958 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1019 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1020 | + $groundspeed = 0; |
|
1021 | + } |
|
1022 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1023 | + $heading = 0; |
|
1024 | + } |
|
1025 | + if ($arrival_date == '') { |
|
1026 | + $arrival_date = NULL; |
|
1027 | + } |
|
959 | 1028 | $query = ''; |
960 | 1029 | if ($globalArchive) { |
961 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1030 | + if ($globalDebug) { |
|
1031 | + echo '-- Delete previous data -- '; |
|
1032 | + } |
|
962 | 1033 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
963 | 1034 | } |
964 | 1035 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
@@ -974,10 +1045,14 @@ discard block |
||
974 | 1045 | } |
975 | 1046 | |
976 | 1047 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
977 | - if ($globalDebug) echo '(Add to Marine archive : '; |
|
1048 | + if ($globalDebug) { |
|
1049 | + echo '(Add to Marine archive : '; |
|
1050 | + } |
|
978 | 1051 | $MarineArchive = new MarineArchive($this->db); |
979 | 1052 | $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
980 | - if ($globalDebug) echo $result.')'; |
|
1053 | + if ($globalDebug) { |
|
1054 | + echo $result.')'; |
|
1055 | + } |
|
981 | 1056 | } |
982 | 1057 | return "success"; |
983 | 1058 | } |
@@ -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. (TrackerLive)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (TrackerLive)'); |
|
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) { |
@@ -77,8 +81,11 @@ discard block |
||
77 | 81 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
78 | 82 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
79 | 83 | } |
80 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
81 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
84 | + if ($filter_query_where == '' && $where) { |
|
85 | + $filter_query_where = ' WHERE'; |
|
86 | + } elseif ($filter_query_where != '' && $and) { |
|
87 | + $filter_query_where .= ' AND'; |
|
88 | + } |
|
82 | 89 | if ($filter_query_where != '') { |
83 | 90 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
84 | 91 | } |
@@ -120,7 +127,9 @@ discard block |
||
120 | 127 | } |
121 | 128 | } |
122 | 129 | |
123 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
130 | + if (!isset($globalLiveInterval)) { |
|
131 | + $globalLiveInterval = '200'; |
|
132 | + } |
|
124 | 133 | if ($globalDBdriver == 'mysql') { |
125 | 134 | //$query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate"; |
126 | 135 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -145,7 +154,9 @@ discard block |
||
145 | 154 | |
146 | 155 | $filter_query = $this->getFilter($filter,true,true); |
147 | 156 | |
148 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
157 | + if (!isset($globalLiveInterval)) { |
|
158 | + $globalLiveInterval = '200'; |
|
159 | + } |
|
149 | 160 | if ($globalDBdriver == 'mysql') { |
150 | 161 | $query = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
151 | 162 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0"; |
@@ -190,50 +201,74 @@ discard block |
||
190 | 201 | } |
191 | 202 | $filter_query = $this->getFilter($filter,true,true); |
192 | 203 | |
193 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
194 | - if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300'; |
|
204 | + if (!isset($globalLiveInterval)) { |
|
205 | + $globalLiveInterval = '200'; |
|
206 | + } |
|
207 | + if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') { |
|
208 | + $globalMap3DTrackersLimit = '300'; |
|
209 | + } |
|
195 | 210 | if ($globalDBdriver == 'mysql') { |
196 | 211 | if (isset($globalArchive) && $globalArchive) { |
197 | 212 | $query = "SELECT * FROM ( |
198 | 213 | SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source |
199 | 214 | FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid "; |
200 | - if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
215 | + if ($usecoord) { |
|
216 | + $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
217 | + } |
|
201 | 218 | $query .= "UNION |
202 | 219 | SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
203 | 220 | FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date "; |
204 | - if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
221 | + if ($usecoord) { |
|
222 | + $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
223 | + } |
|
205 | 224 | $query .= ") AS tracker |
206 | 225 | WHERE latitude <> '0' AND longitude <> '0' |
207 | 226 | ORDER BY famtrackid, date"; |
208 | - if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
227 | + if ($limit) { |
|
228 | + $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
229 | + } |
|
209 | 230 | } else { |
210 | 231 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
211 | 232 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date "; |
212 | - if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
233 | + if ($usecoord) { |
|
234 | + $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
235 | + } |
|
213 | 236 | $query .= "AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
214 | 237 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
215 | - if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
238 | + if ($limit) { |
|
239 | + $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
240 | + } |
|
216 | 241 | } |
217 | 242 | } else { |
218 | 243 | if (isset($globalArchive) && $globalArchive) { |
219 | 244 | $query = "SELECT * FROM ( |
220 | 245 | SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source |
221 | 246 | FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid "; |
222 | - if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
247 | + if ($usecoord) { |
|
248 | + $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
249 | + } |
|
223 | 250 | $query .= "UNION |
224 | 251 | SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
225 | 252 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date"; |
226 | - if ($usecoord) $query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
253 | + if ($usecoord) { |
|
254 | + $query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
255 | + } |
|
227 | 256 | $query .= ") AS tracker |
228 | 257 | WHERE latitude <> '0' AND longitude <> '0' |
229 | 258 | ORDER BY famtrackid, date"; |
230 | - if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
259 | + if ($limit) { |
|
260 | + $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
261 | + } |
|
231 | 262 | } else { |
232 | 263 | $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
233 | 264 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' "; |
234 | - if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
265 | + if ($usecoord) { |
|
266 | + $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
267 | + } |
|
235 | 268 | $query .= "ORDER BY tracker_live.famtrackid, tracker_live.date"; |
236 | - if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
269 | + if ($limit) { |
|
270 | + $query .= " LIMIT ".$globalMap3DTrackersLimit; |
|
271 | + } |
|
237 | 272 | } |
238 | 273 | } |
239 | 274 | |
@@ -259,7 +294,9 @@ discard block |
||
259 | 294 | global $globalDBdriver, $globalLiveInterval; |
260 | 295 | $filter_query = $this->getFilter($filter,true,true); |
261 | 296 | |
262 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
297 | + if (!isset($globalLiveInterval)) { |
|
298 | + $globalLiveInterval = '200'; |
|
299 | + } |
|
263 | 300 | if ($globalDBdriver == 'mysql') { |
264 | 301 | $query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
265 | 302 | } else { |
@@ -287,7 +324,9 @@ discard block |
||
287 | 324 | { |
288 | 325 | global $globalDBdriver, $globalLiveInterval; |
289 | 326 | $Tracker = new Tracker($this->db); |
290 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
327 | + if (!isset($globalLiveInterval)) { |
|
328 | + $globalLiveInterval = '200'; |
|
329 | + } |
|
291 | 330 | $filter_query = $this->getFilter($filter); |
292 | 331 | |
293 | 332 | if (is_array($coord)) { |
@@ -295,7 +334,9 @@ discard block |
||
295 | 334 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
296 | 335 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
297 | 336 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
298 | - } else return array(); |
|
337 | + } else { |
|
338 | + return array(); |
|
339 | + } |
|
299 | 340 | if ($globalDBdriver == 'mysql') { |
300 | 341 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
301 | 342 | } else { |
@@ -315,7 +356,9 @@ discard block |
||
315 | 356 | { |
316 | 357 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
317 | 358 | $Tracker = new Tracker($this->db); |
318 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
359 | + if (!isset($globalLiveInterval)) { |
|
360 | + $globalLiveInterval = '200'; |
|
361 | + } |
|
319 | 362 | $filter_query = $this->getFilter($filter,true,true); |
320 | 363 | |
321 | 364 | if (is_array($coord)) { |
@@ -323,7 +366,9 @@ discard block |
||
323 | 366 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
324 | 367 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
325 | 368 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
326 | - } else return array(); |
|
369 | + } else { |
|
370 | + return array(); |
|
371 | + } |
|
327 | 372 | /* |
328 | 373 | if ($globalDBdriver == 'mysql') { |
329 | 374 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
@@ -557,11 +602,15 @@ discard block |
||
557 | 602 | //$query = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date'; |
558 | 603 | if ($globalDBdriver == 'mysql') { |
559 | 604 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
560 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
605 | + if ($liveinterval) { |
|
606 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
607 | + } |
|
561 | 608 | $query .= ' ORDER BY date'; |
562 | 609 | } else { |
563 | 610 | $query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id'; |
564 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
611 | + if ($liveinterval) { |
|
612 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
613 | + } |
|
565 | 614 | $query .= ' ORDER BY date'; |
566 | 615 | } |
567 | 616 | |
@@ -656,7 +705,9 @@ discard block |
||
656 | 705 | $i++; |
657 | 706 | $j++; |
658 | 707 | if ($j == 30) { |
659 | - if ($globalDebug) echo "."; |
|
708 | + if ($globalDebug) { |
|
709 | + echo "."; |
|
710 | + } |
|
660 | 711 | try { |
661 | 712 | |
662 | 713 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -903,7 +954,9 @@ discard block |
||
903 | 954 | { |
904 | 955 | return false; |
905 | 956 | } |
906 | - } else return ''; |
|
957 | + } else { |
|
958 | + return ''; |
|
959 | + } |
|
907 | 960 | |
908 | 961 | if ($longitude != '') |
909 | 962 | { |
@@ -911,7 +964,9 @@ discard block |
||
911 | 964 | { |
912 | 965 | return false; |
913 | 966 | } |
914 | - } else return ''; |
|
967 | + } else { |
|
968 | + return ''; |
|
969 | + } |
|
915 | 970 | |
916 | 971 | if ($altitude != '') |
917 | 972 | { |
@@ -919,7 +974,9 @@ discard block |
||
919 | 974 | { |
920 | 975 | return false; |
921 | 976 | } |
922 | - } else $altitude = 0; |
|
977 | + } else { |
|
978 | + $altitude = 0; |
|
979 | + } |
|
923 | 980 | |
924 | 981 | if ($heading != '') |
925 | 982 | { |
@@ -927,7 +984,9 @@ discard block |
||
927 | 984 | { |
928 | 985 | return false; |
929 | 986 | } |
930 | - } else $heading = 0; |
|
987 | + } else { |
|
988 | + $heading = 0; |
|
989 | + } |
|
931 | 990 | |
932 | 991 | if ($groundspeed != '') |
933 | 992 | { |
@@ -935,9 +994,13 @@ discard block |
||
935 | 994 | { |
936 | 995 | return false; |
937 | 996 | } |
938 | - } else $groundspeed = 0; |
|
997 | + } else { |
|
998 | + $groundspeed = 0; |
|
999 | + } |
|
939 | 1000 | date_default_timezone_set('UTC'); |
940 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1001 | + if ($date == '') { |
|
1002 | + $date = date("Y-m-d H:i:s", time()); |
|
1003 | + } |
|
941 | 1004 | |
942 | 1005 | |
943 | 1006 | $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
@@ -953,12 +1016,18 @@ discard block |
||
953 | 1016 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
954 | 1017 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
955 | 1018 | |
956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1019 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1020 | + $groundspeed = 0; |
|
1021 | + } |
|
1022 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1023 | + $heading = 0; |
|
1024 | + } |
|
958 | 1025 | |
959 | 1026 | $query = ''; |
960 | 1027 | if ($globalArchive) { |
961 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1028 | + if ($globalDebug) { |
|
1029 | + echo '-- Delete previous data -- '; |
|
1030 | + } |
|
962 | 1031 | $query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;'; |
963 | 1032 | } |
964 | 1033 | $query .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
@@ -977,10 +1046,14 @@ discard block |
||
977 | 1046 | echo 'noarchive : '.$noarchive."\n"; |
978 | 1047 | */ |
979 | 1048 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
980 | - if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
1049 | + if ($globalDebug) { |
|
1050 | + echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
1051 | + } |
|
981 | 1052 | $TrackerArchive = new TrackerArchive($this->db); |
982 | 1053 | $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
983 | - if ($globalDebug) echo $result.')'; |
|
1054 | + if ($globalDebug) { |
|
1055 | + echo $result.')'; |
|
1056 | + } |
|
984 | 1057 | } |
985 | 1058 | |
986 | 1059 | return "success"; |
@@ -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) { |