@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | public $db; |
11 | 11 | public $SI; |
12 | 12 | private $fromACARSscript = false; |
13 | - public function __construct($dbc = null,$fromACARSscript = false) { |
|
13 | + public function __construct($dbc = null, $fromACARSscript = false) { |
|
14 | 14 | $Connection = new Connection($dbc); |
15 | 15 | $this->db = $Connection->db(); |
16 | 16 | if ($this->db === null) die('Error: No DB connection. (ACARS)'); |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | * @return String the icao |
27 | 27 | */ |
28 | 28 | public function ident2icao($ident) { |
29 | - if (substr($ident,0,2) == 'AF') { |
|
30 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
31 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
29 | + if (substr($ident, 0, 2) == 'AF') { |
|
30 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
31 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
32 | 32 | } else { |
33 | 33 | $Spotter = new Spotter($this->db); |
34 | - $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
|
34 | + $identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2)); |
|
35 | 35 | if (isset($identicao[0])) { |
36 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
36 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
37 | 37 | } else $icao = $ident; |
38 | 38 | } |
39 | 39 | return $icao; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | $sth = $this->db->prepare($query); |
59 | 59 | $sth->execute(); |
60 | - } catch(PDOException $e) { |
|
60 | + } catch (PDOException $e) { |
|
61 | 61 | return "error"; |
62 | 62 | } |
63 | 63 | return "success"; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | $sth = $this->db->prepare($query); |
83 | 83 | $sth->execute(); |
84 | - } catch(PDOException $e) { |
|
84 | + } catch (PDOException $e) { |
|
85 | 85 | return "error"; |
86 | 86 | } |
87 | 87 | return "success"; |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | $ident = ''; |
107 | 107 | $message = ''; |
108 | 108 | $result = array(); |
109 | - $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
110 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
111 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
112 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
109 | + $n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
110 | + if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
111 | + if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
112 | + if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
113 | 113 | if ($n != 0) { |
114 | - $registration = str_replace('.','',$registration); |
|
115 | - $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
|
114 | + $registration = str_replace('.', '', $registration); |
|
115 | + $result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message); |
|
116 | 116 | if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
117 | 117 | } else $message = $data; |
118 | 118 | $decode = array(); |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | $temp = ''; |
133 | 133 | $n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp); |
134 | 134 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
135 | - $latitude = $la / 10000.0; |
|
136 | - $longitude = $ln / 10000.0; |
|
135 | + $latitude = $la/10000.0; |
|
136 | + $longitude = $ln/10000.0; |
|
137 | 137 | if ($lac == 'S') $latitude = '-'.$latitude; |
138 | 138 | if ($lnc == 'W') $longitude = '-'.$longitude; |
139 | 139 | // Temp not always available |
140 | 140 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
141 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
142 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
141 | + if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt); |
|
142 | + else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C'); |
|
143 | 143 | |
144 | 144 | //$icao = $Translation->checkTranslation($ident); |
145 | 145 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -151,19 +151,19 @@ discard block |
||
151 | 151 | $dhour = ''; |
152 | 152 | $darr = ''; |
153 | 153 | $ahour = ''; |
154 | - $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
|
154 | + $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour); |
|
155 | 155 | if ($n == 4 && strlen($darr) == 4) { |
156 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
157 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
158 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
156 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
157 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
158 | + if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n"; |
|
159 | 159 | //$icao = ACARS->ident2icao($ident); |
160 | 160 | //$icao = $Translation->checkTranslation($ident); |
161 | 161 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
162 | 162 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
163 | 163 | $found = true; |
164 | 164 | } |
165 | - elseif ($n == 2 || $n == 4) { |
|
166 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
165 | + elseif ($n == 2 || $n == 4) { |
|
166 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
167 | 167 | if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
168 | 168 | //$icao = ACARS->ident2icao($ident); |
169 | 169 | //$icao = $Translation->checkTranslation($ident); |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | $ahour = ''; |
222 | 222 | $aair = ''; |
223 | 223 | $apiste = ''; |
224 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
|
224 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste); |
|
225 | 225 | if ($n > 8) { |
226 | - if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
227 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
228 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
226 | + if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
227 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
228 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
229 | 229 | $icao = trim($aident); |
230 | 230 | |
231 | 231 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
251 | 251 | $las = $las.'.'.$lass; |
252 | 252 | $lns = $lns.'.'.$lns; |
253 | - $latitude = $las / 1000.0; |
|
254 | - $longitude = $lns / 1000.0; |
|
253 | + $latitude = $las/1000.0; |
|
254 | + $longitude = $lns/1000.0; |
|
255 | 255 | if ($lac == 'S') $latitude = '-'.$latitude; |
256 | 256 | if ($lnc == 'W') $longitude = '-'.$longitude; |
257 | 257 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
@@ -346,17 +346,17 @@ discard block |
||
346 | 346 | $alt = ''; |
347 | 347 | $fuel = ''; |
348 | 348 | $speed = ''; |
349 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
349 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
350 | 350 | if ($n == 9) { |
351 | 351 | //if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
352 | 352 | $icao = trim($aident); |
353 | 353 | $decode['icao'] = $icao; |
354 | - $latitude = $las / 100.0; |
|
355 | - $longitude = $lns / 100.0; |
|
354 | + $latitude = $las/100.0; |
|
355 | + $longitude = $lns/100.0; |
|
356 | 356 | if ($lac == 'S') $latitude = '-'.$latitude; |
357 | 357 | if ($lnc == 'W') $longitude = '-'.$longitude; |
358 | 358 | |
359 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
|
359 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed); |
|
360 | 360 | $found = true; |
361 | 361 | } |
362 | 362 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | if ($lac == 'S') $latitude = '-'.$latitude; |
376 | 376 | if ($lnc == 'W') $longitude = '-'.$longitude; |
377 | 377 | |
378 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
|
378 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
|
379 | 379 | $found = true; |
380 | 380 | } |
381 | 381 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | $dair = ''; |
409 | 409 | $darr = ''; |
410 | 410 | $aident = ''; |
411 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
411 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
412 | 412 | if ($n == 8) { |
413 | 413 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
414 | 414 | $icao = trim($aident); |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | */ |
441 | 441 | $dair = ''; |
442 | 442 | $darr = ''; |
443 | - $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
|
443 | + $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr); |
|
444 | 444 | if ($n == 3) { |
445 | 445 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
446 | 446 | //$icao = $Translation->checkTranslation($ident); |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | */ |
456 | 456 | $dair = ''; |
457 | 457 | $darr = ''; |
458 | - $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
|
458 | + $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr); |
|
459 | 459 | if ($n == 3) { |
460 | 460 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
461 | 461 | //$icao = $Translation->checkTranslation($ident); |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | } |
466 | 466 | } |
467 | 467 | if (!$found) { |
468 | - $n = sscanf($message,'MET01%4c',$airport); |
|
468 | + $n = sscanf($message, 'MET01%4c', $airport); |
|
469 | 469 | if ($n == 1) { |
470 | 470 | if ($globalDebug) echo 'airport name : '.$airport; |
471 | 471 | $decode = array('Airport/Waypoint name' => $airport); |
@@ -473,241 +473,241 @@ discard block |
||
473 | 473 | } |
474 | 474 | } |
475 | 475 | if ($label == 'H1') { |
476 | - if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
|
477 | - $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
|
476 | + if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) { |
|
477 | + $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode); |
|
478 | 478 | } |
479 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
480 | - $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
|
479 | + elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) { |
|
480 | + $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode); |
|
481 | 481 | } |
482 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
483 | - $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
|
482 | + elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) { |
|
483 | + $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode); |
|
484 | 484 | } |
485 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
486 | - $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
|
485 | + elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) { |
|
486 | + $decode = array_merge(array('Message nature' => 'Weather observation'), $decode); |
|
487 | 487 | } |
488 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
489 | - $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
|
488 | + elseif (preg_match(':^#DFB/PIREP:', $message)) { |
|
489 | + $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode); |
|
490 | 490 | } |
491 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
492 | - $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
|
491 | + elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) { |
|
492 | + $decode = array_merge(array('Message nature' => 'Engine Data'), $decode); |
|
493 | 493 | } |
494 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
495 | - $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
|
494 | + elseif (preg_match(':^#M1AAEP:', $message)) { |
|
495 | + $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode); |
|
496 | 496 | } |
497 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
498 | - $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
|
497 | + elseif (preg_match(':^#M2APWD:', $message)) { |
|
498 | + $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode); |
|
499 | 499 | } |
500 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
501 | - $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
|
500 | + elseif (preg_match(':^#M1BREQPWI:', $message)) { |
|
501 | + $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode); |
|
502 | 502 | } |
503 | - elseif (preg_match(':^#CF:',$message)) { |
|
504 | - $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
|
503 | + elseif (preg_match(':^#CF:', $message)) { |
|
504 | + $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode); |
|
505 | 505 | } |
506 | - elseif (preg_match(':^#DF:',$message)) { |
|
507 | - $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
|
506 | + elseif (preg_match(':^#DF:', $message)) { |
|
507 | + $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode); |
|
508 | 508 | } |
509 | - elseif (preg_match(':^#EC:',$message)) { |
|
510 | - $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
|
509 | + elseif (preg_match(':^#EC:', $message)) { |
|
510 | + $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode); |
|
511 | 511 | } |
512 | - elseif (preg_match(':^#EI:',$message)) { |
|
513 | - $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
|
512 | + elseif (preg_match(':^#EI:', $message)) { |
|
513 | + $decode = array_merge(array('Message nature' => 'Engine Report'), $decode); |
|
514 | 514 | } |
515 | - elseif (preg_match(':^#H1:',$message)) { |
|
516 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
|
515 | + elseif (preg_match(':^#H1:', $message)) { |
|
516 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode); |
|
517 | 517 | } |
518 | - elseif (preg_match(':^#H2:',$message)) { |
|
519 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
|
518 | + elseif (preg_match(':^#H2:', $message)) { |
|
519 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode); |
|
520 | 520 | } |
521 | - elseif (preg_match(':^#HD:',$message)) { |
|
522 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
|
521 | + elseif (preg_match(':^#HD:', $message)) { |
|
522 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode); |
|
523 | 523 | } |
524 | - elseif (preg_match(':^#M1:',$message)) { |
|
525 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
|
524 | + elseif (preg_match(':^#M1:', $message)) { |
|
525 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode); |
|
526 | 526 | } |
527 | - elseif (preg_match(':^#M2:',$message)) { |
|
528 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
|
527 | + elseif (preg_match(':^#M2:', $message)) { |
|
528 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode); |
|
529 | 529 | } |
530 | - elseif (preg_match(':^#M3:',$message)) { |
|
531 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
|
530 | + elseif (preg_match(':^#M3:', $message)) { |
|
531 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode); |
|
532 | 532 | } |
533 | - elseif (preg_match(':^#MD:',$message)) { |
|
534 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
|
533 | + elseif (preg_match(':^#MD:', $message)) { |
|
534 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode); |
|
535 | 535 | } |
536 | - elseif (preg_match(':^#PS:',$message)) { |
|
537 | - $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
|
536 | + elseif (preg_match(':^#PS:', $message)) { |
|
537 | + $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode); |
|
538 | 538 | } |
539 | - elseif (preg_match(':^#S1:',$message)) { |
|
540 | - $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
|
539 | + elseif (preg_match(':^#S1:', $message)) { |
|
540 | + $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode); |
|
541 | 541 | } |
542 | - elseif (preg_match(':^#S2:',$message)) { |
|
543 | - $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
|
542 | + elseif (preg_match(':^#S2:', $message)) { |
|
543 | + $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode); |
|
544 | 544 | } |
545 | - elseif (preg_match(':^#SD:',$message)) { |
|
546 | - $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
|
545 | + elseif (preg_match(':^#SD:', $message)) { |
|
546 | + $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode); |
|
547 | 547 | } |
548 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
549 | - $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
|
548 | + elseif (preg_match(':^#T[0-8]:', $message)) { |
|
549 | + $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode); |
|
550 | 550 | } |
551 | - elseif (preg_match(':^#WO:',$message)) { |
|
552 | - $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
|
551 | + elseif (preg_match(':^#WO:', $message)) { |
|
552 | + $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode); |
|
553 | 553 | } |
554 | - elseif (preg_match(':^#A1:',$message)) { |
|
555 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
|
554 | + elseif (preg_match(':^#A1:', $message)) { |
|
555 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode); |
|
556 | 556 | } |
557 | - elseif (preg_match(':^#A3:',$message)) { |
|
558 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
|
557 | + elseif (preg_match(':^#A3:', $message)) { |
|
558 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode); |
|
559 | 559 | } |
560 | - elseif (preg_match(':^#A4:',$message)) { |
|
561 | - $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
|
560 | + elseif (preg_match(':^#A4:', $message)) { |
|
561 | + $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode); |
|
562 | 562 | } |
563 | - elseif (preg_match(':^#A6:',$message)) { |
|
564 | - $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
|
563 | + elseif (preg_match(':^#A6:', $message)) { |
|
564 | + $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode); |
|
565 | 565 | } |
566 | - elseif (preg_match(':^#A8:',$message)) { |
|
567 | - $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
|
566 | + elseif (preg_match(':^#A8:', $message)) { |
|
567 | + $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode); |
|
568 | 568 | } |
569 | - elseif (preg_match(':^#A9:',$message)) { |
|
570 | - $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
|
569 | + elseif (preg_match(':^#A9:', $message)) { |
|
570 | + $decode = array_merge(array('Message nature' => 'ATIS report'), $decode); |
|
571 | 571 | } |
572 | - elseif (preg_match(':^#A0:',$message)) { |
|
573 | - $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
|
572 | + elseif (preg_match(':^#A0:', $message)) { |
|
573 | + $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode); |
|
574 | 574 | } |
575 | - elseif (preg_match(':^#AA:',$message)) { |
|
576 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
575 | + elseif (preg_match(':^#AA:', $message)) { |
|
576 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
577 | 577 | } |
578 | - elseif (preg_match(':^#AB:',$message)) { |
|
579 | - $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
|
578 | + elseif (preg_match(':^#AB:', $message)) { |
|
579 | + $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode); |
|
580 | 580 | } |
581 | - elseif (preg_match(':^#AC:',$message)) { |
|
582 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
|
581 | + elseif (preg_match(':^#AC:', $message)) { |
|
582 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode); |
|
583 | 583 | } |
584 | - elseif (preg_match(':^#AD:',$message)) { |
|
585 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
|
584 | + elseif (preg_match(':^#AD:', $message)) { |
|
585 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode); |
|
586 | 586 | } |
587 | - elseif (preg_match(':^#AF:',$message)) { |
|
588 | - $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
|
587 | + elseif (preg_match(':^#AF:', $message)) { |
|
588 | + $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode); |
|
589 | 589 | } |
590 | - elseif (preg_match(':^#B1:',$message)) { |
|
591 | - $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
|
590 | + elseif (preg_match(':^#B1:', $message)) { |
|
591 | + $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode); |
|
592 | 592 | } |
593 | - elseif (preg_match(':^#B2:',$message)) { |
|
594 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
|
593 | + elseif (preg_match(':^#B2:', $message)) { |
|
594 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode); |
|
595 | 595 | } |
596 | - elseif (preg_match(':^#B3:',$message)) { |
|
597 | - $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
|
596 | + elseif (preg_match(':^#B3:', $message)) { |
|
597 | + $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode); |
|
598 | 598 | } |
599 | - elseif (preg_match(':^#B4:',$message)) { |
|
600 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
|
599 | + elseif (preg_match(':^#B4:', $message)) { |
|
600 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode); |
|
601 | 601 | } |
602 | - elseif (preg_match(':^#B6:',$message)) { |
|
603 | - $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
|
602 | + elseif (preg_match(':^#B6:', $message)) { |
|
603 | + $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode); |
|
604 | 604 | } |
605 | - elseif (preg_match(':^#B8:',$message)) { |
|
606 | - $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
|
605 | + elseif (preg_match(':^#B8:', $message)) { |
|
606 | + $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode); |
|
607 | 607 | } |
608 | - elseif (preg_match(':^#B9:',$message)) { |
|
609 | - $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
|
608 | + elseif (preg_match(':^#B9:', $message)) { |
|
609 | + $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode); |
|
610 | 610 | } |
611 | - elseif (preg_match(':^#B0:',$message)) { |
|
612 | - $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
|
611 | + elseif (preg_match(':^#B0:', $message)) { |
|
612 | + $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode); |
|
613 | 613 | } |
614 | - elseif (preg_match(':^#BA:',$message)) { |
|
615 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
614 | + elseif (preg_match(':^#BA:', $message)) { |
|
615 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
616 | 616 | } |
617 | - elseif (preg_match(':^#BB:',$message)) { |
|
618 | - $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
|
617 | + elseif (preg_match(':^#BB:', $message)) { |
|
618 | + $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode); |
|
619 | 619 | } |
620 | - elseif (preg_match(':^#BC:',$message)) { |
|
621 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
|
620 | + elseif (preg_match(':^#BC:', $message)) { |
|
621 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode); |
|
622 | 622 | } |
623 | - elseif (preg_match(':^#BD:',$message)) { |
|
624 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
|
623 | + elseif (preg_match(':^#BD:', $message)) { |
|
624 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode); |
|
625 | 625 | } |
626 | - elseif (preg_match(':^#BE:',$message)) { |
|
627 | - $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
|
626 | + elseif (preg_match(':^#BE:', $message)) { |
|
627 | + $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode); |
|
628 | 628 | } |
629 | - elseif (preg_match(':^#BF:',$message)) { |
|
630 | - $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
|
629 | + elseif (preg_match(':^#BF:', $message)) { |
|
630 | + $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode); |
|
631 | 631 | } |
632 | - elseif (preg_match(':^#H3:',$message)) { |
|
633 | - $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
|
632 | + elseif (preg_match(':^#H3:', $message)) { |
|
633 | + $decode = array_merge(array('Message nature' => 'Icing Report'), $decode); |
|
634 | 634 | } |
635 | 635 | } |
636 | 636 | if ($label == '10') { |
637 | - if (preg_match(':^DTO01:',$message)) { |
|
638 | - $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
|
637 | + if (preg_match(':^DTO01:', $message)) { |
|
638 | + $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode); |
|
639 | 639 | } |
640 | - elseif (preg_match(':^AIS01:',$message)) { |
|
641 | - $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
|
640 | + elseif (preg_match(':^AIS01:', $message)) { |
|
641 | + $decode = array_merge(array('Message nature' => 'AIS Request'), $decode); |
|
642 | 642 | } |
643 | - elseif (preg_match(':^FTX01:',$message)) { |
|
644 | - $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
|
643 | + elseif (preg_match(':^FTX01:', $message)) { |
|
644 | + $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode); |
|
645 | 645 | } |
646 | - elseif (preg_match(':^FPL01:',$message)) { |
|
647 | - $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
|
646 | + elseif (preg_match(':^FPL01:', $message)) { |
|
647 | + $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode); |
|
648 | 648 | } |
649 | - elseif (preg_match(':^WAB01:',$message)) { |
|
650 | - $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
|
649 | + elseif (preg_match(':^WAB01:', $message)) { |
|
650 | + $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode); |
|
651 | 651 | } |
652 | - elseif (preg_match(':^MET01:',$message)) { |
|
653 | - $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
|
652 | + elseif (preg_match(':^MET01:', $message)) { |
|
653 | + $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode); |
|
654 | 654 | } |
655 | - elseif (preg_match(':^WAB02:',$message)) { |
|
656 | - $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
|
655 | + elseif (preg_match(':^WAB02:', $message)) { |
|
656 | + $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode); |
|
657 | 657 | } |
658 | 658 | } |
659 | 659 | if ($label == '15') { |
660 | - if (preg_match(':^FST01:',$message)) { |
|
661 | - $decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode); |
|
660 | + if (preg_match(':^FST01:', $message)) { |
|
661 | + $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode); |
|
662 | 662 | } |
663 | 663 | } |
664 | 664 | if (!$found && $label == 'SA') { |
665 | - $n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at); |
|
665 | + $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at); |
|
666 | 666 | if ($n == 4) { |
667 | 667 | $vsta = array('Version' => $version); |
668 | 668 | if ($state == 'E') { |
669 | - $vsta = array_merge($vsta,array('Link state' => 'Established')); |
|
669 | + $vsta = array_merge($vsta, array('Link state' => 'Established')); |
|
670 | 670 | } |
671 | 671 | elseif ($state == 'L') { |
672 | - $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
|
672 | + $vsta = array_merge($vsta, array('Link state' => 'Lost')); |
|
673 | 673 | } |
674 | 674 | else { |
675 | - $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
|
675 | + $vsta = array_merge($vsta, array('Link state' => 'Unknown')); |
|
676 | 676 | } |
677 | 677 | if ($type == 'V') { |
678 | - $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
|
678 | + $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS')); |
|
679 | 679 | } |
680 | 680 | elseif ($type == 'S') { |
681 | - $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
|
681 | + $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM')); |
|
682 | 682 | } |
683 | 683 | elseif ($type == 'H') { |
684 | - $vsta = array_merge($vsta,array('Link type' => 'HF')); |
|
684 | + $vsta = array_merge($vsta, array('Link type' => 'HF')); |
|
685 | 685 | } |
686 | 686 | elseif ($type == 'G') { |
687 | - $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
|
687 | + $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM')); |
|
688 | 688 | } |
689 | 689 | elseif ($type == 'C') { |
690 | - $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
|
690 | + $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM')); |
|
691 | 691 | } |
692 | 692 | elseif ($type == '2') { |
693 | - $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
|
693 | + $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2')); |
|
694 | 694 | } |
695 | 695 | elseif ($type == 'X') { |
696 | - $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
|
696 | + $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero')); |
|
697 | 697 | } |
698 | 698 | elseif ($type == 'I') { |
699 | - $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
|
699 | + $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM')); |
|
700 | 700 | } |
701 | 701 | else { |
702 | - $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
|
702 | + $vsta = array_merge($vsta, array('Link type' => 'Unknown')); |
|
703 | 703 | } |
704 | - $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
|
705 | - $decode = array_merge($vsta,$decode); |
|
704 | + $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2)))); |
|
705 | + $decode = array_merge($vsta, $decode); |
|
706 | 706 | } |
707 | 707 | } |
708 | 708 | |
709 | 709 | $title = $this->getTitlefromLabel($label); |
710 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
710 | + if ($title != '') $decode = array_merge(array('Message title' => $title), $decode); |
|
711 | 711 | /* |
712 | 712 | // Business jets always use GS0001 |
713 | 713 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -735,13 +735,13 @@ discard block |
||
735 | 735 | $Translation = new Translation($this->db); |
736 | 736 | $message = $this->parse($data); |
737 | 737 | if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') { |
738 | - $ident = (string)$message['ident']; |
|
738 | + $ident = (string) $message['ident']; |
|
739 | 739 | $label = $message['label']; |
740 | 740 | $block_id = $message['block_id']; |
741 | 741 | $msg_no = $message['msg_no']; |
742 | 742 | $msg = $message['message']; |
743 | 743 | $decode = $message['decode']; |
744 | - $registration = (string)$message['registration']; |
|
744 | + $registration = (string) $message['registration']; |
|
745 | 745 | if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
746 | 746 | else $latitude = ''; |
747 | 747 | if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
@@ -755,20 +755,20 @@ discard block |
||
755 | 755 | $Image->addSpotterImage($registration); |
756 | 756 | } |
757 | 757 | // Business jets always use GS0001 |
758 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
758 | + if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude); |
|
759 | 759 | if ($globalDebug && isset($info) && $info != '') echo $info; |
760 | 760 | if (count($decode) > 0) $decode_json = json_encode($decode); |
761 | 761 | else $decode_json = ''; |
762 | 762 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
763 | - $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
|
763 | + $Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS'); |
|
764 | 764 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
765 | - $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
|
765 | + $Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS'); |
|
766 | 766 | } |
767 | - $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
768 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
769 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
767 | + $result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
768 | + if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F'); |
|
769 | + if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
770 | 770 | if ($globalDebug && count($decode) > 0) { |
771 | - echo "Human readable data : ".implode(' - ',$decode)."\n"; |
|
771 | + echo "Human readable data : ".implode(' - ', $decode)."\n"; |
|
772 | 772 | } |
773 | 773 | } |
774 | 774 | } |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | * @param String $msg_no Number of the ACARS message |
784 | 784 | * @param String $message ACARS message |
785 | 785 | */ |
786 | - public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
786 | + public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
787 | 787 | global $globalDebug; |
788 | 788 | date_default_timezone_set('UTC'); |
789 | 789 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
@@ -791,21 +791,21 @@ discard block |
||
791 | 791 | $this->db = $Connection->db; |
792 | 792 | if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
793 | 793 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
794 | - $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
|
794 | + $query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message); |
|
795 | 795 | try { |
796 | 796 | $stht = $this->db->prepare($query_test); |
797 | 797 | $stht->execute($query_test_values); |
798 | - } catch(PDOException $e) { |
|
798 | + } catch (PDOException $e) { |
|
799 | 799 | return "error : ".$e->getMessage(); |
800 | 800 | } |
801 | 801 | if ($stht->fetchColumn() == 0) { |
802 | 802 | if ($globalDebug) echo "Add Live ACARS data..."; |
803 | 803 | $query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)"; |
804 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
|
804 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s")); |
|
805 | 805 | try { |
806 | 806 | $sth = $this->db->prepare($query); |
807 | 807 | $sth->execute($query_values); |
808 | - } catch(PDOException $e) { |
|
808 | + } catch (PDOException $e) { |
|
809 | 809 | return "error : ".$e->getMessage(); |
810 | 810 | } |
811 | 811 | } else { |
@@ -827,10 +827,10 @@ discard block |
||
827 | 827 | * @param String $msg_no Number of the ACARS message |
828 | 828 | * @param String $message ACARS message |
829 | 829 | */ |
830 | - public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
830 | + public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
831 | 831 | global $globalDebug; |
832 | 832 | date_default_timezone_set('UTC'); |
833 | - if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) { |
|
833 | + if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) { |
|
834 | 834 | /* |
835 | 835 | if ($globalDebug) echo "Test if not already in Archive ACARS table..."; |
836 | 836 | $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message"; |
@@ -845,11 +845,11 @@ discard block |
||
845 | 845 | */ |
846 | 846 | if ($globalDebug) echo "Add Live ACARS data..."; |
847 | 847 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
848 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
848 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
849 | 849 | try { |
850 | 850 | $sth = $this->db->prepare($query); |
851 | 851 | $sth->execute($query_values); |
852 | - } catch(PDOException $e) { |
|
852 | + } catch (PDOException $e) { |
|
853 | 853 | return "error : ".$e->getMessage(); |
854 | 854 | } |
855 | 855 | if ($globalDebug) echo "Done\n"; |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | try { |
871 | 871 | $sth = $this->db->prepare($query); |
872 | 872 | $sth->execute($query_values); |
873 | - } catch(PDOException $e) { |
|
873 | + } catch (PDOException $e) { |
|
874 | 874 | echo "error : ".$e->getMessage(); |
875 | 875 | return ''; |
876 | 876 | } |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | try { |
891 | 891 | $sth = $this->db->prepare($query); |
892 | 892 | $sth->execute($query_values); |
893 | - } catch(PDOException $e) { |
|
893 | + } catch (PDOException $e) { |
|
894 | 894 | echo "error : ".$e->getMessage(); |
895 | 895 | return array(); |
896 | 896 | } |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | try { |
912 | 912 | $sth = $this->db->prepare($query); |
913 | 913 | $sth->execute($query_values); |
914 | - } catch(PDOException $e) { |
|
914 | + } catch (PDOException $e) { |
|
915 | 915 | echo "error : ".$e->getMessage(); |
916 | 916 | return array(); |
917 | 917 | } |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | * |
926 | 926 | * @return Array Return ACARS data in array |
927 | 927 | */ |
928 | - public function getLatestAcarsData($limit = '',$label = '') { |
|
928 | + public function getLatestAcarsData($limit = '', $label = '') { |
|
929 | 929 | global $globalURL, $globalDBdriver; |
930 | 930 | $Image = new Image($this->db); |
931 | 931 | $Spotter = new Spotter($this->db); |
@@ -936,8 +936,8 @@ discard block |
||
936 | 936 | if ($limit != "") |
937 | 937 | { |
938 | 938 | $limit_array = explode(",", $limit); |
939 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
940 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
939 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
940 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
941 | 941 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
942 | 942 | { |
943 | 943 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -953,46 +953,46 @@ discard block |
||
953 | 953 | try { |
954 | 954 | $sth = $this->db->prepare($query); |
955 | 955 | $sth->execute($query_values); |
956 | - } catch(PDOException $e) { |
|
956 | + } catch (PDOException $e) { |
|
957 | 957 | return "error : ".$e->getMessage(); |
958 | 958 | } |
959 | 959 | $i = 0; |
960 | 960 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
961 | 961 | $data = array(); |
962 | 962 | if ($row['registration'] != '') { |
963 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
963 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
964 | 964 | $image_array = $Image->getSpotterImage($row['registration']); |
965 | - 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'])); |
|
966 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
967 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
965 | + 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'])); |
|
966 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
967 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
968 | 968 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
969 | 969 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
970 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
970 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
971 | 971 | if (isset($identicao[0])) { |
972 | - if (substr($row['ident'],0,2) == 'AF') { |
|
973 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
974 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
975 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
976 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
972 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
973 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
974 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
975 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
976 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
977 | 977 | } else $icao = $row['ident']; |
978 | - $icao = $Translation->checkTranslation($icao,false); |
|
979 | - $decode = json_decode($row['decode'],true); |
|
978 | + $icao = $Translation->checkTranslation($icao, false); |
|
979 | + $decode = json_decode($row['decode'], true); |
|
980 | 980 | $found = false; |
981 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
981 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
982 | 982 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
983 | 983 | if (isset($airport_info[0]['icao'])) { |
984 | 984 | $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
985 | 985 | $found = true; |
986 | 986 | } |
987 | 987 | } |
988 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
988 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
989 | 989 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
990 | 990 | if (isset($airport_info[0]['icao'])) { |
991 | 991 | $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
992 | 992 | $found = true; |
993 | 993 | } |
994 | 994 | } |
995 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
995 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
996 | 996 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
997 | 997 | if (isset($airport_info[0]['icao'])) { |
998 | 998 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | } |
1001 | 1001 | } |
1002 | 1002 | if ($found) $row['decode'] = json_encode($decode); |
1003 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1003 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1004 | 1004 | $result[] = $data; |
1005 | 1005 | $i++; |
1006 | 1006 | } |
@@ -1016,7 +1016,7 @@ discard block |
||
1016 | 1016 | * |
1017 | 1017 | * @return Array Return ACARS data in array |
1018 | 1018 | */ |
1019 | - public function getArchiveAcarsData($limit = '',$label = '') { |
|
1019 | + public function getArchiveAcarsData($limit = '', $label = '') { |
|
1020 | 1020 | global $globalURL, $globalDBdriver; |
1021 | 1021 | $Image = new Image($this->db); |
1022 | 1022 | $Spotter = new Spotter($this->db); |
@@ -1026,8 +1026,8 @@ discard block |
||
1026 | 1026 | if ($limit != "") |
1027 | 1027 | { |
1028 | 1028 | $limit_array = explode(",", $limit); |
1029 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1030 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1029 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1030 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1031 | 1031 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1032 | 1032 | { |
1033 | 1033 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1048,43 +1048,43 @@ discard block |
||
1048 | 1048 | try { |
1049 | 1049 | $sth = $this->db->prepare($query); |
1050 | 1050 | $sth->execute($query_values); |
1051 | - } catch(PDOException $e) { |
|
1051 | + } catch (PDOException $e) { |
|
1052 | 1052 | return "error : ".$e->getMessage(); |
1053 | 1053 | } |
1054 | - $i=0; |
|
1054 | + $i = 0; |
|
1055 | 1055 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
1056 | 1056 | $data = array(); |
1057 | 1057 | if ($row['registration'] != '') { |
1058 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
1058 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
1059 | 1059 | $image_array = $Image->getSpotterImage($row['registration']); |
1060 | - if (count($image_array) > 0) $data = array_merge($data,array('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'])); |
|
1061 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1062 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1060 | + if (count($image_array) > 0) $data = array_merge($data, array('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'])); |
|
1061 | + else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1062 | + } else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1063 | 1063 | $icao = ''; |
1064 | 1064 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
1065 | 1065 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
1066 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
1066 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
1067 | 1067 | if (isset($identicao[0])) { |
1068 | - if (substr($row['ident'],0,2) == 'AF') { |
|
1069 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1070 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1071 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1072 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
1068 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
1069 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1070 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
1071 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
1072 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
1073 | 1073 | } else $icao = $row['ident']; |
1074 | 1074 | $icao = $Translation->checkTranslation($icao); |
1075 | - $decode = json_decode($row['decode'],true); |
|
1075 | + $decode = json_decode($row['decode'], true); |
|
1076 | 1076 | $found = false; |
1077 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
1077 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
1078 | 1078 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1079 | 1079 | if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1080 | 1080 | $found = true; |
1081 | 1081 | } |
1082 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1082 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1083 | 1083 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1084 | 1084 | if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1085 | 1085 | $found = true; |
1086 | 1086 | } |
1087 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1087 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1088 | 1088 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1089 | 1089 | if (isset($airport_info[0]['icao'])) { |
1090 | 1090 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1092,7 +1092,7 @@ discard block |
||
1092 | 1092 | } |
1093 | 1093 | } |
1094 | 1094 | if ($found) $row['decode'] = json_encode($decode); |
1095 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1095 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1096 | 1096 | $result[] = $data; |
1097 | 1097 | $i++; |
1098 | 1098 | } |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | * @param String $icao |
1111 | 1111 | * @param String $ICAOTypeCode |
1112 | 1112 | */ |
1113 | - public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
|
1113 | + public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') { |
|
1114 | 1114 | global $globalDebug, $globalDBdriver; |
1115 | 1115 | $ident = trim($ident); |
1116 | 1116 | $Translation = new Translation($this->db); |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | if ($globalDebug) echo "Ident or registration null, exit\n"; |
1124 | 1124 | return ''; |
1125 | 1125 | } |
1126 | - $registration = str_replace('.','',$registration); |
|
1126 | + $registration = str_replace('.', '', $registration); |
|
1127 | 1127 | $ident = $Translation->ident2icao($ident); |
1128 | 1128 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1129 | 1129 | if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | try { |
1133 | 1133 | $sthsi = $this->db->prepare($querysi); |
1134 | 1134 | $sthsi->execute($querysi_values); |
1135 | - } catch(PDOException $e) { |
|
1135 | + } catch (PDOException $e) { |
|
1136 | 1136 | if ($globalDebug) echo $e->getMessage(); |
1137 | 1137 | return "error : ".$e->getMessage(); |
1138 | 1138 | } |
@@ -1142,8 +1142,8 @@ discard block |
||
1142 | 1142 | $Translation = new Translation($this->db); |
1143 | 1143 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1144 | 1144 | if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
1145 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1146 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1145 | + if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1146 | + elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1147 | 1147 | } else { |
1148 | 1148 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1149 | 1149 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | try { |
1152 | 1152 | $sth = $this->db->prepare($query); |
1153 | 1153 | $sth->execute($query_values); |
1154 | - } catch(PDOException $e) { |
|
1154 | + } catch (PDOException $e) { |
|
1155 | 1155 | if ($globalDebug) echo $e->getMessage(); |
1156 | 1156 | return "error : ".$e->getMessage(); |
1157 | 1157 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | $sth->closeCursor(); |
1160 | 1160 | if (isset($result['modes'])) $hex = $result['modes']; |
1161 | 1161 | else $hex = ''; |
1162 | - $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
|
1162 | + $SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS'); |
|
1163 | 1163 | if ($this->fromACARSscript) $this->SI->add($SI_data); |
1164 | 1164 | } |
1165 | 1165 | } |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | try { |
1170 | 1170 | $sth = $this->db->prepare($query); |
1171 | 1171 | $sth->execute($query_values); |
1172 | - } catch(PDOException $e) { |
|
1172 | + } catch (PDOException $e) { |
|
1173 | 1173 | if ($globalDebug) echo $e->getMessage(); |
1174 | 1174 | return "error : ".$e->getMessage(); |
1175 | 1175 | } |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
1180 | 1180 | else $ModeS = ''; |
1181 | 1181 | if ($ModeS == '') { |
1182 | - $id = explode('-',$result['flightaware_id']); |
|
1182 | + $id = explode('-', $result['flightaware_id']); |
|
1183 | 1183 | $ModeS = $id[0]; |
1184 | 1184 | } |
1185 | 1185 | if ($ModeS != '') { |
@@ -1189,20 +1189,20 @@ discard block |
||
1189 | 1189 | try { |
1190 | 1190 | $sthc = $this->db->prepare($queryc); |
1191 | 1191 | $sthc->execute($queryc_values); |
1192 | - } catch(PDOException $e) { |
|
1192 | + } catch (PDOException $e) { |
|
1193 | 1193 | if ($globalDebug) echo $e->getMessage(); |
1194 | 1194 | return "error : ".$e->getMessage(); |
1195 | 1195 | } |
1196 | 1196 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1197 | 1197 | $sthc->closeCursor(); |
1198 | - if (count($row) == 0) { |
|
1198 | + if (count($row) == 0) { |
|
1199 | 1199 | if ($globalDebug) echo " Add to ModeS table - "; |
1200 | 1200 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1201 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1201 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1202 | 1202 | try { |
1203 | 1203 | $sthi = $this->db->prepare($queryi); |
1204 | 1204 | $sthi->execute($queryi_values); |
1205 | - } catch(PDOException $e) { |
|
1205 | + } catch (PDOException $e) { |
|
1206 | 1206 | if ($globalDebug) echo $e->getMessage(); |
1207 | 1207 | return "error : ".$e->getMessage(); |
1208 | 1208 | } |
@@ -1210,15 +1210,15 @@ discard block |
||
1210 | 1210 | if ($globalDebug) echo " Update ModeS table - "; |
1211 | 1211 | if ($ICAOTypeCode != '') { |
1212 | 1212 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1213 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1213 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1214 | 1214 | } else { |
1215 | 1215 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1216 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration); |
|
1216 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration); |
|
1217 | 1217 | } |
1218 | 1218 | try { |
1219 | 1219 | $sthi = $this->db->prepare($queryi); |
1220 | 1220 | $sthi->execute($queryi_values); |
1221 | - } catch(PDOException $e) { |
|
1221 | + } catch (PDOException $e) { |
|
1222 | 1222 | if ($globalDebug) echo $e->getMessage(); |
1223 | 1223 | return "error : ".$e->getMessage(); |
1224 | 1224 | } |
@@ -1255,12 +1255,12 @@ discard block |
||
1255 | 1255 | elseif ($globalDBdriver == 'pgsql') { |
1256 | 1256 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1257 | 1257 | } |
1258 | - $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
|
1258 | + $queryi_values = array(':Registration' => $registration, ':ident' => $icao); |
|
1259 | 1259 | } |
1260 | 1260 | try { |
1261 | 1261 | $sthi = $this->db->prepare($queryi); |
1262 | 1262 | $sthi->execute($queryi_values); |
1263 | - } catch(PDOException $e) { |
|
1263 | + } catch (PDOException $e) { |
|
1264 | 1264 | if ($globalDebug) echo $e->getMessage(); |
1265 | 1265 | return "error : ".$e->getMessage(); |
1266 | 1266 | } |
@@ -29,31 +29,31 @@ discard block |
||
29 | 29 | |
30 | 30 | private function make_latf($temp) { // unsigned long |
31 | 31 | $flat = 0.0; // float |
32 | - $temp = $temp & 0x07FFFFFF; |
|
33 | - if ($temp & 0x04000000) { |
|
34 | - $temp = $temp ^ 0x07FFFFFF; |
|
32 | + $temp = $temp&0x07FFFFFF; |
|
33 | + if ($temp&0x04000000) { |
|
34 | + $temp = $temp^0x07FFFFFF; |
|
35 | 35 | $temp += 1; |
36 | - $flat = (float)($temp / (60.0 * 10000.0)); |
|
36 | + $flat = (float) ($temp/(60.0*10000.0)); |
|
37 | 37 | $flat *= -1.0; |
38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
38 | + } else $flat = (float) ($temp/(60.0*10000.0)); |
|
39 | 39 | return $flat; // float |
40 | 40 | } |
41 | 41 | |
42 | 42 | private function make_lonf($temp) { // unsigned long |
43 | 43 | $flon = 0.0; // float |
44 | - $temp = $temp & 0x0FFFFFFF; |
|
45 | - if ($temp & 0x08000000) { |
|
46 | - $temp = $temp ^ 0x0FFFFFFF; |
|
44 | + $temp = $temp&0x0FFFFFFF; |
|
45 | + if ($temp&0x08000000) { |
|
46 | + $temp = $temp^0x0FFFFFFF; |
|
47 | 47 | $temp += 1; |
48 | - $flon = (float)($temp / (60.0 * 10000.0)); |
|
48 | + $flon = (float) ($temp/(60.0*10000.0)); |
|
49 | 49 | $flon *= -1.0; |
50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
50 | + } else $flon = (float) ($temp/(60.0*10000.0)); |
|
51 | 51 | return $flon; |
52 | 52 | } |
53 | 53 | |
54 | 54 | private function ascii_2_dec($chr) { |
55 | - $dec=ord($chr);//get decimal ascii code |
|
56 | - $hex=dechex($dec);//convert decimal to hex |
|
55 | + $dec = ord($chr); //get decimal ascii code |
|
56 | + $hex = dechex($dec); //convert decimal to hex |
|
57 | 57 | return ($dec); |
58 | 58 | } |
59 | 59 | |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | //only process in the following range: 48-87, 96-119 |
73 | 73 | if ($ascii < 48) { } |
74 | 74 | else { |
75 | - if($ascii>119) { } |
|
75 | + if ($ascii > 119) { } |
|
76 | 76 | else { |
77 | - if ($ascii>87 && $ascii<96) ; |
|
77 | + if ($ascii > 87 && $ascii < 96); |
|
78 | 78 | else { |
79 | - $ascii=$ascii+40; |
|
80 | - if ($ascii>128){ |
|
81 | - $ascii=$ascii+32; |
|
79 | + $ascii = $ascii + 40; |
|
80 | + if ($ascii > 128) { |
|
81 | + $ascii = $ascii + 32; |
|
82 | 82 | } else { |
83 | - $ascii=$ascii+40; |
|
83 | + $ascii = $ascii + 40; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | private function dec_2_6bit($dec) { |
92 | - $bin=decbin($dec); |
|
92 | + $bin = decbin($dec); |
|
93 | 93 | return(substr($bin, -6)); |
94 | 94 | } |
95 | 95 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | ); |
108 | 108 | // " |
109 | 109 | $rv = ''; |
110 | - if ($_size % 6 == 0) { |
|
111 | - $len = $_size / 6; |
|
112 | - for ($i=0; $i<$len; $i++) { |
|
113 | - $offset = $i * 6; |
|
114 | - $rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ]; |
|
110 | + if ($_size%6 == 0) { |
|
111 | + $len = $_size/6; |
|
112 | + for ($i = 0; $i < $len; $i++) { |
|
113 | + $offset = $i*6; |
|
114 | + $rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))]; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | return $rv; |
@@ -138,93 +138,93 @@ discard block |
||
138 | 138 | $ro->eta_hour = ''; |
139 | 139 | $ro->eta_minute = ''; |
140 | 140 | $ro->ts = time(); |
141 | - $ro->id = bindec(substr($_aisdata,0,6)); |
|
142 | - $ro->mmsi = bindec(substr($_aisdata,8,30)); |
|
141 | + $ro->id = bindec(substr($_aisdata, 0, 6)); |
|
142 | + $ro->mmsi = bindec(substr($_aisdata, 8, 30)); |
|
143 | 143 | if ($ro->id >= 1 && $ro->id <= 3) { |
144 | - $ro->cog = bindec(substr($_aisdata,116,12))/10; |
|
145 | - $ro->sog = bindec(substr($_aisdata,50,10))/10; |
|
146 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
147 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
144 | + $ro->cog = bindec(substr($_aisdata, 116, 12))/10; |
|
145 | + $ro->sog = bindec(substr($_aisdata, 50, 10))/10; |
|
146 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
147 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
148 | 148 | $ro->cls = 1; // class A |
149 | 149 | } else if ($ro->id == 4) { |
150 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28))); |
|
151 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27))); |
|
150 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28))); |
|
151 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27))); |
|
152 | 152 | $ro->cls = 1; // class A |
153 | 153 | } else if ($ro->id == 5) { |
154 | - $ro->imo = bindec(substr($_aisdata,40,30)); |
|
155 | - $ro->callsign = $this->binchar($_aisdata,70,42); |
|
156 | - $ro->name = $this->binchar($_aisdata,112,120); |
|
157 | - $ro->typeid = bindec(substr($_aisdata,232,8)); |
|
154 | + $ro->imo = bindec(substr($_aisdata, 40, 30)); |
|
155 | + $ro->callsign = $this->binchar($_aisdata, 70, 42); |
|
156 | + $ro->name = $this->binchar($_aisdata, 112, 120); |
|
157 | + $ro->typeid = bindec(substr($_aisdata, 232, 8)); |
|
158 | 158 | $ro->type = $this->getShipType($ro->typeid); |
159 | 159 | //$ro->to_bow = bindec(substr($_aisdata,240,9)); |
160 | 160 | //$ro->to_stern = bindec(substr($_aisdata,249,9)); |
161 | 161 | //$ro->to_port = bindec(substr($_aisdata,258,6)); |
162 | 162 | //$ro->to_starboard = bindec(substr($_aisdata,264,6)); |
163 | - $ro->eta_month = bindec(substr($_aisdata,274,4)); |
|
164 | - $ro->eta_day = bindec(substr($_aisdata,278,5)); |
|
165 | - $ro->eta_hour = bindec(substr($_aisdata,283,5)); |
|
166 | - $ro->eta_minute = bindec(substr($_aisdata,288,6)); |
|
163 | + $ro->eta_month = bindec(substr($_aisdata, 274, 4)); |
|
164 | + $ro->eta_day = bindec(substr($_aisdata, 278, 5)); |
|
165 | + $ro->eta_hour = bindec(substr($_aisdata, 283, 5)); |
|
166 | + $ro->eta_minute = bindec(substr($_aisdata, 288, 6)); |
|
167 | 167 | //$ro->draught = bindec(substr($_aisdata,294,8)); |
168 | - $ro->destination = $this->binchar($_aisdata,302,120); |
|
168 | + $ro->destination = $this->binchar($_aisdata, 302, 120); |
|
169 | 169 | $ro->cls = 1; // class A |
170 | 170 | } else if ($ro->id == 9) { |
171 | 171 | // Search and Rescue aircraft position report |
172 | 172 | } else if ($ro->id == 18) { |
173 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
174 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
175 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
|
176 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
|
177 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
173 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
174 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
175 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28))); |
|
176 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27))); |
|
177 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
178 | 178 | if ($ro->heading == 511) $ro->heading = ''; |
179 | 179 | $ro->cls = 2; // class B |
180 | 180 | } else if ($ro->id == 19) { |
181 | - $ro->cog = bindec(substr($_aisdata,112,12))/10; |
|
182 | - $ro->sog = bindec(substr($_aisdata,46,10))/10; |
|
183 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28))); |
|
184 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27))); |
|
185 | - $ro->name = $this->binchar($_aisdata,143,120); |
|
181 | + $ro->cog = bindec(substr($_aisdata, 112, 12))/10; |
|
182 | + $ro->sog = bindec(substr($_aisdata, 46, 10))/10; |
|
183 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28))); |
|
184 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27))); |
|
185 | + $ro->name = $this->binchar($_aisdata, 143, 120); |
|
186 | 186 | $ro->cls = 2; // class B |
187 | - $ro->heading = bindec(substr($_aisdata,124,9)); |
|
187 | + $ro->heading = bindec(substr($_aisdata, 124, 9)); |
|
188 | 188 | if ($ro->heading == 511) $ro->heading = ''; |
189 | - $ro->typeid = bindec(substr($_aisdata,263,8)); |
|
189 | + $ro->typeid = bindec(substr($_aisdata, 263, 8)); |
|
190 | 190 | $ro->type = $this->getShipType($ro->typeid); |
191 | 191 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
192 | 192 | //$ro->to_stern = bindec(substr($_aisdata,280,9)); |
193 | 193 | //$ro->to_port = bindec(substr($_aisdata,289,6)); |
194 | 194 | //$ro->to_starboard = bindec(substr($_aisdata,295,6)); |
195 | 195 | } else if ($ro->id == 21) { |
196 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28))); |
|
197 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27))); |
|
198 | - $ro->name = $this->binchar($_aisdata,43,120); |
|
196 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28))); |
|
197 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27))); |
|
198 | + $ro->name = $this->binchar($_aisdata, 43, 120); |
|
199 | 199 | //$ro->to_bow = bindec(substr($_aisdata,219,9)); |
200 | 200 | //$ro->to_stern = bindec(substr($_aisdata,228,9)); |
201 | 201 | //$ro->to_port = bindec(substr($_aisdata,237,6)); |
202 | 202 | //$ro->to_starboard = bindec(substr($_aisdata,243,6)); |
203 | 203 | $ro->cls = 2; // class B |
204 | 204 | } else if ($ro->id == 24) { |
205 | - $pn = bindec(substr($_aisdata,38,2)); |
|
205 | + $pn = bindec(substr($_aisdata, 38, 2)); |
|
206 | 206 | if ($pn == 0) { |
207 | - $ro->name = $this->binchar($_aisdata,40,120); |
|
207 | + $ro->name = $this->binchar($_aisdata, 40, 120); |
|
208 | 208 | } |
209 | - $ro->typeid = bindec(substr($_aisdata,40,8)); |
|
209 | + $ro->typeid = bindec(substr($_aisdata, 40, 8)); |
|
210 | 210 | $ro->type = $this->getShipType($ro->typeid); |
211 | - $ro->callsign = $this->binchar($_aisdata,90,42); |
|
211 | + $ro->callsign = $this->binchar($_aisdata, 90, 42); |
|
212 | 212 | //$ro->to_bow = bindec(substr($_aisdata,132,9)); |
213 | 213 | //$ro->to_stern = bindec(substr($_aisdata,141,9)); |
214 | 214 | //$ro->to_port = bindec(substr($_aisdata,150,6)); |
215 | 215 | //$ro->to_starboard = bindec(substr($_aisdata,156,6)); |
216 | 216 | $ro->cls = 2; // class B |
217 | 217 | } else if ($ro->id == 27) { |
218 | - $ro->cog = bindec(substr($_aisdata,85,9)); |
|
218 | + $ro->cog = bindec(substr($_aisdata, 85, 9)); |
|
219 | 219 | if ($ro->cog == 511) $ro->cog = 0.0; |
220 | - $ro->sog = bindec(substr($_aisdata,79,6)); |
|
220 | + $ro->sog = bindec(substr($_aisdata, 79, 6)); |
|
221 | 221 | if ($ro->sog == 63) $ro->sog = 0.0; |
222 | - $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
|
223 | - $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
|
222 | + $ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10); |
|
223 | + $ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10); |
|
224 | 224 | $ro->cls = 1; // class A |
225 | 225 | |
226 | 226 | } |
227 | - $ro->statusid = bindec(substr($_aisdata,38,4)); |
|
227 | + $ro->statusid = bindec(substr($_aisdata, 38, 4)); |
|
228 | 228 | $ro->status = $this->getStatus($ro->statusid); |
229 | 229 | //var_dump($ro); // dump results here for demo purpose |
230 | 230 | return $ro; |
@@ -355,14 +355,14 @@ discard block |
||
355 | 355 | global $port; // tcpip port... |
356 | 356 | |
357 | 357 | static $debug_counter = 0; |
358 | - $aisdata168='';//six bit array of ascii characters |
|
358 | + $aisdata168 = ''; //six bit array of ascii characters |
|
359 | 359 | $ais_nmea_array = str_split($_itu); // convert to an array |
360 | 360 | foreach ($ais_nmea_array as $value) { |
361 | 361 | $dec = $this->ascii_2_dec($value); |
362 | 362 | $bit8 = $this->asciidec_2_8bit($dec); |
363 | 363 | $bit6 = $this->dec_2_6bit($bit8); |
364 | 364 | //echo $value ."-" .$bit6 .""; |
365 | - $aisdata168 .=$bit6; |
|
365 | + $aisdata168 .= $bit6; |
|
366 | 366 | } |
367 | 367 | //echo $aisdata168 . "<br/>"; |
368 | 368 | //return $this->decode_ais($aisdata168, $aux); |
@@ -385,24 +385,24 @@ discard block |
||
385 | 385 | // calculate checksum after ! till * |
386 | 386 | // assume 1st ! is valid |
387 | 387 | // find * ensure that it is at correct position |
388 | - $end = strrpos ( $rawdata , '*' ); |
|
388 | + $end = strrpos($rawdata, '*'); |
|
389 | 389 | if ($end === FALSE) return -1; // check for NULLS!!! |
390 | - $cs = substr( $rawdata, $end + 1 ); |
|
391 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
392 | - $dcs = (int)hexdec( $cs ); |
|
393 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
394 | - if ( $chksum == $dcs ) { // NMEA checksum pass |
|
390 | + $cs = substr($rawdata, $end + 1); |
|
391 | + if (strlen($cs) != 2) return -1; // correct cs length |
|
392 | + $dcs = (int) hexdec($cs); |
|
393 | + for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum |
|
394 | + if ($chksum == $dcs) { // NMEA checksum pass |
|
395 | 395 | $pcs = explode(',', $rawdata); |
396 | 396 | // !AI??? identifier |
397 | 397 | if (!isset($pcs[1])) { |
398 | 398 | echo "ERROR,INVALID_DATA ".time()." $rawdata\n"; |
399 | 399 | return -1; |
400 | 400 | } |
401 | - $num_seq = (int)$pcs[1]; // number of sequences |
|
402 | - $seq = (int)$pcs[2]; // get sequence |
|
401 | + $num_seq = (int) $pcs[1]; // number of sequences |
|
402 | + $seq = (int) $pcs[2]; // get sequence |
|
403 | 403 | // get msg sequence id |
404 | 404 | if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
405 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
405 | + else $msg_sid = (int) $pcs[3]; // multipart message |
|
406 | 406 | $ais_ch = $pcs[4]; // get AIS channel |
407 | 407 | // message sequence checking |
408 | 408 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | } |
436 | 436 | } |
437 | 437 | $itu = $itu.$pcs[5]; // get itu message |
438 | - $filler += (int)$pcs[6][0]; // get filler |
|
438 | + $filler += (int) $pcs[6][0]; // get filler |
|
439 | 439 | if ($num_seq == 1 // valid single message |
440 | 440 | || $num_seq == $pseq // valid multi-part message |
441 | 441 | ) { |
@@ -455,13 +455,13 @@ discard block |
||
455 | 455 | $cbuf = $cbuf.$ibuf; |
456 | 456 | $last_pos = 0; |
457 | 457 | $result = new stdClass(); |
458 | - while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) { |
|
458 | + while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) { |
|
459 | 459 | //while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) { |
460 | 460 | //DEBUG echo $cbuf; |
461 | - if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
461 | + if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim? |
|
462 | 462 | $tst = substr($cbuf, $start - 3, ($end - $start + 3)); |
463 | 463 | //DEBUG echo "[$start $end $tst]\n"; |
464 | - $result = $this->process_ais_raw( $tst, "" ); |
|
464 | + $result = $this->process_ais_raw($tst, ""); |
|
465 | 465 | $last_pos = $end + 1; |
466 | 466 | } else break; |
467 | 467 | } |
@@ -473,41 +473,41 @@ discard block |
||
473 | 473 | // incoming data from serial or IP comms |
474 | 474 | public function process_ais_line($cbuf) { |
475 | 475 | $result = new stdClass(); |
476 | - $start = strpos($cbuf,"VDM"); |
|
476 | + $start = strpos($cbuf, "VDM"); |
|
477 | 477 | $tst = substr($cbuf, $start - 3); |
478 | - $result = $this->process_ais_raw( $tst, "" ); |
|
478 | + $result = $this->process_ais_raw($tst, ""); |
|
479 | 479 | return $result; |
480 | 480 | } |
481 | 481 | |
482 | 482 | /* AIS Encoding |
483 | 483 | */ |
484 | - private function mk_ais_lat( $lat ) { |
|
484 | + private function mk_ais_lat($lat) { |
|
485 | 485 | //$lat = 1.2569; |
486 | - if ($lat<0.0) { |
|
486 | + if ($lat < 0.0) { |
|
487 | 487 | $lat = -$lat; |
488 | - $neg=true; |
|
489 | - } else $neg=false; |
|
488 | + $neg = true; |
|
489 | + } else $neg = false; |
|
490 | 490 | $latd = 0x00000000; |
491 | - $latd = intval ($lat * 600000.0); |
|
492 | - if ($neg==true) { |
|
491 | + $latd = intval($lat*600000.0); |
|
492 | + if ($neg == true) { |
|
493 | 493 | $latd = ~$latd; |
494 | - $latd+=1; |
|
494 | + $latd += 1; |
|
495 | 495 | $latd &= 0x07FFFFFF; |
496 | 496 | } |
497 | 497 | return $latd; |
498 | 498 | } |
499 | 499 | |
500 | - private function mk_ais_lon( $lon ) { |
|
500 | + private function mk_ais_lon($lon) { |
|
501 | 501 | //$lon = 103.851; |
502 | - if ($lon<0.0) { |
|
502 | + if ($lon < 0.0) { |
|
503 | 503 | $lon = -$lon; |
504 | - $neg=true; |
|
505 | - } else $neg=false; |
|
504 | + $neg = true; |
|
505 | + } else $neg = false; |
|
506 | 506 | $lond = 0x00000000; |
507 | - $lond = intval ($lon * 600000.0); |
|
508 | - if ($neg==true) { |
|
507 | + $lond = intval($lon*600000.0); |
|
508 | + if ($neg == true) { |
|
509 | 509 | $lond = ~$lond; |
510 | - $lond+=1; |
|
510 | + $lond += 1; |
|
511 | 511 | $lond &= 0x0FFFFFFF; |
512 | 512 | } |
513 | 513 | return $lond; |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | |
516 | 516 | private function char2bin($name, $max_len) { |
517 | 517 | $len = strlen($name); |
518 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
519 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
518 | + if ($len > $max_len) $name = substr($name, 0, $max_len); |
|
519 | + if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6); |
|
520 | 520 | else $pad = ''; |
521 | 521 | $rv = ''; |
522 | 522 | $ais_chars = array( |
@@ -533,26 +533,26 @@ discard block |
||
533 | 533 | if ($_a) foreach ($_a as $_1) { |
534 | 534 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
535 | 535 | else $dec = 0; |
536 | - $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
|
536 | + $bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT); |
|
537 | 537 | $rv .= $bin; |
538 | 538 | //echo "$_1 $dec ($bin)<br/>"; |
539 | 539 | } |
540 | 540 | return $rv.$pad; |
541 | 541 | } |
542 | 542 | |
543 | - private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') { |
|
543 | + private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') { |
|
544 | 544 | $len_bit = strlen($_enc); |
545 | - $rem6 = $len_bit % 6; |
|
545 | + $rem6 = $len_bit%6; |
|
546 | 546 | $pad6_len = 0; |
547 | 547 | if ($rem6) $pad6_len = 6 - $rem6; |
548 | 548 | //echo $pad6_len.'<br>'; |
549 | 549 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
550 | - $len_enc = strlen($_enc) / 6; |
|
550 | + $len_enc = strlen($_enc)/6; |
|
551 | 551 | //echo $_enc.' '.$len_enc.'<br/>'; |
552 | 552 | $itu = ''; |
553 | - for ($i=0; $i<$len_enc; $i++) { |
|
554 | - $offset = $i * 6; |
|
555 | - $dec = bindec(substr($_enc,$offset,6)); |
|
553 | + for ($i = 0; $i < $len_enc; $i++) { |
|
554 | + $offset = $i*6; |
|
555 | + $dec = bindec(substr($_enc, $offset, 6)); |
|
556 | 556 | if ($dec < 40) $dec += 48; |
557 | 557 | else $dec += 56; |
558 | 558 | //echo chr($dec)." $dec<br/>"; |
@@ -562,15 +562,15 @@ discard block |
||
562 | 562 | $chksum = 0; |
563 | 563 | $itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0"; |
564 | 564 | $len_itu = strlen($itu); |
565 | - for ($i=0; $i<$len_itu; $i++) { |
|
566 | - $chksum ^= ord( $itu[$i] ); |
|
565 | + for ($i = 0; $i < $len_itu; $i++) { |
|
566 | + $chksum ^= ord($itu[$i]); |
|
567 | 567 | } |
568 | - $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
|
569 | - $lsb = $chksum & 0x0F; |
|
570 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
568 | + $hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
|
569 | + $lsb = $chksum&0x0F; |
|
570 | + if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb]; |
|
571 | 571 | else $lsbc = '0'; |
572 | - $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
|
573 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
572 | + $msb = (($chksum&0xF0) >> 4)&0x0F; |
|
573 | + if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb]; |
|
574 | 574 | else $msbc = '0'; |
575 | 575 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
576 | 576 | return $itu; |
@@ -595,14 +595,14 @@ discard block |
||
595 | 595 | |
596 | 596 | public function mmsitype($mmsi) { |
597 | 597 | if (strlen($mmsi) == 9) { |
598 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
599 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
600 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
601 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
602 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
603 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
604 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
605 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
598 | + if (substr($mmsi, 0, 3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
599 | + elseif (substr($mmsi, 0, 3) == '972') return 'MOB (Man Overboard) device'; |
|
600 | + elseif (substr($mmsi, 0, 3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
601 | + elseif (substr($mmsi, 0, 3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
602 | + elseif (substr($mmsi, 0, 2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
603 | + elseif (substr($mmsi, 0, 2) == '99') return 'Aids to Navigation'; |
|
604 | + elseif (substr($mmsi, 0, 2) == '00') return 'Coastal stations'; |
|
605 | + elseif (substr($mmsi, 0, 1) == '0') return 'Group of ships'; |
|
606 | 606 | else return 'Ship'; |
607 | 607 | } |
608 | 608 | |
@@ -613,19 +613,19 @@ discard block |
||
613 | 613 | global $globalDebug; |
614 | 614 | $result = array(); |
615 | 615 | $data = new stdClass(); |
616 | - $start = strpos($buffer,"VDM"); |
|
616 | + $start = strpos($buffer, "VDM"); |
|
617 | 617 | $tst = substr($buffer, $start - 3); |
618 | - $data = $this->process_ais_raw( $tst, "" ); |
|
618 | + $data = $this->process_ais_raw($tst, ""); |
|
619 | 619 | if (!is_object($data)) { |
620 | 620 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
621 | 621 | return array(); |
622 | 622 | } |
623 | 623 | if ($data->lon != 0) $result['longitude'] = $data->lon; |
624 | 624 | if ($data->lat != 0) $result['latitude'] = $data->lat; |
625 | - $result['ident'] = trim(str_replace('@','',$data->name)); |
|
625 | + $result['ident'] = trim(str_replace('@', '', $data->name)); |
|
626 | 626 | $result['timestamp'] = $data->ts; |
627 | 627 | $result['mmsi'] = $data->mmsi; |
628 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
628 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'], 0, 3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
629 | 629 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
630 | 630 | if ($data->sog != -1.0) $result['speed'] = $data->sog; |
631 | 631 | if ($data->heading !== '') $result['heading'] = $data->heading; |
@@ -635,16 +635,16 @@ discard block |
||
635 | 635 | if ($data->type !== '') $result['type'] = $data->type; |
636 | 636 | if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
637 | 637 | if ($data->imo !== '') $result['imo'] = $data->imo; |
638 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
638 | + if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@', '', $data->callsign)); |
|
639 | 639 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
640 | - $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
|
640 | + $eta_ts = strtotime(date('Y').'-'.sprintf("%02d", $data->eta_month).'-'.sprintf("%02d", $data->eta_day).' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00'); |
|
641 | 641 | if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
642 | 642 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
643 | - $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
|
643 | + $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00'); |
|
644 | 644 | if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
645 | 645 | } |
646 | 646 | if ($data->destination != '') { |
647 | - $dest = trim(str_replace('@','',$data->destination)); |
|
647 | + $dest = trim(str_replace('@', '', $data->destination)); |
|
648 | 648 | if ($dest != '') $result['destination'] = $dest; |
649 | 649 | } |
650 | 650 | $result['all'] = (array) $data; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 60 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
61 | 61 | $Marine = new Marine($this->db); |
62 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
62 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | 73 | if (isset($flight['lastupdate'])) { |
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
74 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
75 | 75 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 76 | if (isset($this->all_tracked[$key]['id'])) { |
77 | 77 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | //$real_arrival = $this->arrival($key); |
84 | 84 | $Marine = new Marine($this->db); |
85 | 85 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | - $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
86 | + $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | 88 | } |
89 | 89 | // Put in archive |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | public function add($line) { |
100 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
|
100 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine; |
|
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
103 | 103 | $dataFound = false; |
104 | 104 | $send = false; |
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | - if(is_array($line) && isset($line['mmsi'])) { |
|
107 | + if (is_array($line) && isset($line['mmsi'])) { |
|
108 | 108 | //print_r($line); |
109 | 109 | if (isset($line['mmsi'])) { |
110 | 110 | |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | 131 | $this->all_tracked[$id] = array(); |
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'status_id' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => '')); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
135 | 135 | if (!isset($line['id'])) { |
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
137 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
139 | 139 | if ($globalAllTracked !== FALSE) $dataFound = true; |
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
144 | 144 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
@@ -154,64 +154,64 @@ discard block |
||
154 | 154 | } |
155 | 155 | } |
156 | 156 | if (isset($line['type_id'])) { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id'])); |
|
159 | 159 | } |
160 | 160 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
161 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
162 | 162 | } |
163 | 163 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
165 | 165 | } |
166 | 166 | if (isset($line['imo']) && $line['imo'] != '') { |
167 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
167 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
168 | 168 | } |
169 | 169 | if (isset($line['callsign']) && $line['callsign'] != '') { |
170 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
170 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
171 | 171 | } |
172 | 172 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
173 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
173 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
174 | 174 | } |
175 | 175 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
176 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
176 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
180 | 180 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
181 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
181 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
182 | 182 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
183 | 183 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
184 | 184 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
185 | 185 | $timeelapsed = microtime(true); |
186 | 186 | $Marine = new Marine($this->db); |
187 | 187 | $fromsource = NULL; |
188 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
188 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
189 | 189 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
190 | 190 | $Marine->db = null; |
191 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
191 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
195 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
196 | 196 | } |
197 | 197 | |
198 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
|
198 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
199 | 199 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
200 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
200 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
201 | 201 | } else { |
202 | 202 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
203 | 203 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
204 | 204 | return ''; |
205 | 205 | } |
206 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
|
206 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) { |
|
207 | 207 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
208 | 208 | return ''; |
209 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
|
209 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) { |
|
210 | 210 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
211 | 211 | return ''; |
212 | 212 | } elseif (!isset($line['datetime'])) { |
213 | 213 | date_default_timezone_set('UTC'); |
214 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
214 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
215 | 215 | } else { |
216 | 216 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
217 | 217 | return ''; |
@@ -219,24 +219,24 @@ discard block |
||
219 | 219 | |
220 | 220 | |
221 | 221 | if (isset($line['speed'])) { |
222 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
223 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
222 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
223 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
224 | 224 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
225 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
225 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
226 | 226 | if ($distance > 1000 && $distance < 10000) { |
227 | 227 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
228 | 228 | $speed = $speed*3.6; |
229 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
229 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
230 | 230 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
234 | 234 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
235 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
235 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
236 | 236 | else unset($timediff); |
237 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
237 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) { |
|
238 | 238 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
239 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
239 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
240 | 240 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
241 | 241 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
242 | 242 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | $timeelapsed = microtime(true); |
246 | 246 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
247 | 247 | $Marine = new Marine($this->db); |
248 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
248 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
249 | 249 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
250 | 250 | $Marine->db = null; |
251 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
251 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
252 | 252 | } |
253 | 253 | $this->tmd = 0; |
254 | 254 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -257,52 +257,52 @@ discard block |
||
257 | 257 | |
258 | 258 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
259 | 259 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
260 | - if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
260 | + if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
261 | 261 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
262 | 262 | $dataFound = true; |
263 | 263 | $this->all_tracked[$id]['time_last_coord'] = time(); |
264 | 264 | } |
265 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
265 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
266 | 266 | } |
267 | 267 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
268 | 268 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
269 | 269 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
270 | - if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
270 | + if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
|
271 | 271 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
272 | 272 | $dataFound = true; |
273 | 273 | $this->all_tracked[$id]['time_last_coord'] = time(); |
274 | 274 | } |
275 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
275 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | } else if ($globalDebug && $timediff > 20) { |
279 | 279 | $this->tmd = $this->tmd + 1; |
280 | 280 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
281 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
282 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
281 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
282 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
283 | 283 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
284 | 284 | } |
285 | 285 | } |
286 | 286 | if (isset($line['last_update']) && $line['last_update'] != '') { |
287 | 287 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
288 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
288 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
289 | 289 | } |
290 | 290 | if (isset($line['format_source']) && $line['format_source'] != '') { |
291 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
291 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
292 | 292 | } |
293 | 293 | if (isset($line['source_name']) && $line['source_name'] != '') { |
294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
295 | 295 | } |
296 | 296 | if (isset($line['status']) && $line['status'] != '') { |
297 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
297 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
298 | 298 | } |
299 | 299 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
300 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
300 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id'])); |
|
301 | 301 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
302 | 302 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
303 | 303 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
304 | 304 | $Marine = new Marine($this->db); |
305 | - $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
|
305 | + $Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']); |
|
306 | 306 | unset($Marine); |
307 | 307 | } |
308 | 308 | } |
@@ -310,18 +310,18 @@ discard block |
||
310 | 310 | } |
311 | 311 | |
312 | 312 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
313 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
313 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | if (isset($line['heading']) && $line['heading'] != '') { |
317 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
318 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
319 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
317 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
318 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
319 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
320 | 320 | //$dataFound = true; |
321 | 321 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
322 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
323 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
324 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
322 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
323 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
324 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
325 | 325 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
326 | 326 | } |
327 | 327 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
332 | 332 | $this->all_tracked[$id]['lastupdate'] = time(); |
333 | 333 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
334 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
334 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
335 | 335 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
336 | 336 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
337 | 337 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
@@ -339,37 +339,37 @@ discard block |
||
339 | 339 | $MarineLive = new MarineLive($this->db); |
340 | 340 | if (isset($line['id'])) { |
341 | 341 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
342 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
342 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
343 | 343 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
344 | 344 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
345 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
345 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
346 | 346 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
347 | 347 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
348 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
348 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
349 | 349 | } else $recent_ident = ''; |
350 | - $MarineLive->db=null; |
|
350 | + $MarineLive->db = null; |
|
351 | 351 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
352 | 352 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
353 | 353 | } else $recent_ident = ''; |
354 | 354 | } else { |
355 | 355 | $recent_ident = ''; |
356 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
356 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
357 | 357 | } |
358 | 358 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
359 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
359 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
360 | 360 | { |
361 | 361 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
362 | 362 | //adds the spotter data for the archive |
363 | 363 | $highlight = ''; |
364 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
364 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
365 | 365 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
366 | 366 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
367 | 367 | $timeelapsed = microtime(true); |
368 | 368 | $Marine = new Marine($this->db); |
369 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
369 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
370 | 370 | $Marine->db = null; |
371 | 371 | if ($globalDebug && isset($result)) echo $result."\n"; |
372 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
372 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
@@ -377,15 +377,15 @@ discard block |
||
377 | 377 | $Stats = new Stats($this->db); |
378 | 378 | if (!empty($this->stats)) { |
379 | 379 | if ($globalDebug) echo 'Add source stats : '; |
380 | - foreach($this->stats as $date => $data) { |
|
381 | - foreach($data as $source => $sourced) { |
|
380 | + foreach ($this->stats as $date => $data) { |
|
381 | + foreach ($data as $source => $sourced) { |
|
382 | 382 | //print_r($sourced); |
383 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
384 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
383 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date); |
|
384 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date); |
|
385 | 385 | if (isset($sourced['msg'])) { |
386 | 386 | if (time() - $sourced['msg']['date'] > 10) { |
387 | 387 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
388 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
388 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date); |
|
389 | 389 | unset($this->stats[$date][$source]['msg']); |
390 | 390 | } |
391 | 391 | } |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
410 | 410 | $MarineLive = new MarineLive($this->db); |
411 | 411 | $MarineLive->deleteLiveMarineData(); |
412 | - $MarineLive->db=null; |
|
412 | + $MarineLive->db = null; |
|
413 | 413 | if ($globalDebug) echo " Done\n"; |
414 | 414 | } |
415 | 415 | $this->last_delete = time(); |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
421 | 421 | if (isset($globalDaemon) && !$globalDaemon) { |
422 | 422 | $Marine = new Marine($this->db); |
423 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
423 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
424 | 424 | $Marine->db = null; |
425 | 425 | } |
426 | 426 | } |
@@ -435,20 +435,20 @@ discard block |
||
435 | 435 | $ignoreImport = false; |
436 | 436 | |
437 | 437 | if (!$ignoreImport) { |
438 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
438 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
439 | 439 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
440 | 440 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
441 | 441 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
442 | 442 | $timeelapsed = microtime(true); |
443 | 443 | $MarineLive = new MarineLive($this->db); |
444 | - $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
444 | + $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
445 | 445 | $MarineLive->db = null; |
446 | 446 | if ($globalDebug) echo $result."\n"; |
447 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
447 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
451 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
451 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
452 | 452 | } |
453 | 453 | $this->all_tracked[$id]['putinarchive'] = false; |
454 | 454 | |
@@ -467,19 +467,19 @@ discard block |
||
467 | 467 | $latitude = $globalCenterLatitude; |
468 | 468 | $longitude = $globalCenterLongitude; |
469 | 469 | } |
470 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
470 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
471 | 471 | } else { |
472 | 472 | $latitude = $this->source_location[$source]['latitude']; |
473 | 473 | $longitude = $this->source_location[$source]['longitude']; |
474 | 474 | } |
475 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
475 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
476 | 476 | //$stats_heading = $stats_heading%22.5; |
477 | 477 | $stats_heading = round($stats_heading/22.5); |
478 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
478 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
479 | 479 | $current_date = date('Y-m-d'); |
480 | 480 | if ($stats_heading == 16) $stats_heading = 0; |
481 | 481 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
482 | - for ($i=0;$i<=15;$i++) { |
|
482 | + for ($i = 0; $i <= 15; $i++) { |
|
483 | 483 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
484 | 484 | } |
485 | 485 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -494,9 +494,9 @@ discard block |
||
494 | 494 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
495 | 495 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
496 | 496 | end($this->stats[$current_date][$source]['hist']); |
497 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
497 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
498 | 498 | } else $mini = 0; |
499 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
499 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
500 | 500 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
501 | 501 | } |
502 | 502 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | |
509 | 509 | $this->all_tracked[$id]['lastupdate'] = time(); |
510 | 510 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
511 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
511 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
512 | 512 | //$this->del(); |
513 | 513 | |
514 | 514 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
19 | 19 | |
20 | 20 | $spotter_array = $Spotter->getAllFlightsforSitemap(); |
21 | - foreach($spotter_array as $spotter_item) |
|
21 | + foreach ($spotter_array as $spotter_item) |
|
22 | 22 | { |
23 | 23 | $output .= '<url>'; |
24 | 24 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/flightid/'.$spotter_item['spotter_id'].'</loc>'; |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | $output .= '</urlset>'; |
30 | 30 | |
31 | 31 | |
32 | -} else if (isset($_GET['type']) && $_GET['type'] == "aircraft"){ |
|
32 | +} else if (isset($_GET['type']) && $_GET['type'] == "aircraft") { |
|
33 | 33 | |
34 | 34 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
35 | 35 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
36 | 36 | $aircraft_types = $Stats->getAllAircraftTypes(); |
37 | 37 | if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes(); |
38 | - foreach($aircraft_types as $aircraft_item) |
|
38 | + foreach ($aircraft_types as $aircraft_item) |
|
39 | 39 | { |
40 | 40 | $output .= '<url>'; |
41 | 41 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/aircraft/'.urlencode($aircraft_item['aircraft_icao']).'</loc>'; |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | $output .= '</urlset>'; |
47 | 47 | |
48 | 48 | |
49 | -} else if (isset($_GET['type']) && $_GET['type'] == "registration"){ |
|
49 | +} else if (isset($_GET['type']) && $_GET['type'] == "registration") { |
|
50 | 50 | |
51 | 51 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
52 | 52 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
53 | 53 | |
54 | 54 | $aircraft_registrations = $Spotter->getAllAircraftRegistrations(); |
55 | - foreach($aircraft_registrations as $aircraft_item) |
|
55 | + foreach ($aircraft_registrations as $aircraft_item) |
|
56 | 56 | { |
57 | 57 | $output .= '<url>'; |
58 | 58 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/registration/'.urlencode($aircraft_item['registration']).'</loc>'; |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | } |
63 | 63 | $output .= '</urlset>'; |
64 | 64 | |
65 | -} else if (isset($_GET['type']) && $_GET['type'] == "airline"){ |
|
65 | +} else if (isset($_GET['type']) && $_GET['type'] == "airline") { |
|
66 | 66 | |
67 | 67 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
68 | 68 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
69 | 69 | |
70 | 70 | $airline_names = $Stats->getAllAirlineNames(); |
71 | - foreach($airline_names as $airline_item) |
|
71 | + foreach ($airline_names as $airline_item) |
|
72 | 72 | { |
73 | 73 | $output .= '<url>'; |
74 | 74 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airline/'.urlencode($airline_item['airline_icao']).'</loc>'; |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | } |
79 | 79 | $output .= '</urlset>'; |
80 | 80 | |
81 | -} else if (isset($_GET['type']) && $_GET['type'] == "airport"){ |
|
81 | +} else if (isset($_GET['type']) && $_GET['type'] == "airport") { |
|
82 | 82 | |
83 | 83 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
84 | 84 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
85 | 85 | |
86 | 86 | $airport_names = $Stats->getAllAirportNames(); |
87 | 87 | if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
88 | - foreach($airport_names as $airport_item) |
|
88 | + foreach ($airport_names as $airport_item) |
|
89 | 89 | { |
90 | 90 | $output .= '<url>'; |
91 | 91 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airport/'.$airport_item['airport_icao'].'</loc>'; |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | } |
96 | 96 | $output .= '</urlset>'; |
97 | 97 | |
98 | -} else if (isset($_GET['type']) && $_GET['type'] == "manufacturer"){ |
|
98 | +} else if (isset($_GET['type']) && $_GET['type'] == "manufacturer") { |
|
99 | 99 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
100 | 100 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
101 | 101 | $manufacturer_names = $Stats->getAllManufacturers(); |
102 | 102 | if (empty($manufacturer_names)) $manufacturer_names = $Spotter->getAllManufacturers(); |
103 | - foreach($manufacturer_names as $manufacturer_item) |
|
103 | + foreach ($manufacturer_names as $manufacturer_item) |
|
104 | 104 | { |
105 | 105 | $output .= '<url>'; |
106 | 106 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/manufacturer/'.urlencode(strtolower(str_replace(" ", "-", $manufacturer_item['aircraft_manufacturer']))).'</loc>'; |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | $output .= '</url>'; |
110 | 110 | } |
111 | 111 | $output .= '</urlset>'; |
112 | -} else if (isset($_GET['type']) && $_GET['type'] == "country"){ |
|
112 | +} else if (isset($_GET['type']) && $_GET['type'] == "country") { |
|
113 | 113 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
114 | 114 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
115 | 115 | $country_names = $Spotter->getAllCountries(); |
116 | - foreach($country_names as $country_item) |
|
116 | + foreach ($country_names as $country_item) |
|
117 | 117 | { |
118 | 118 | $output .= '<url>'; |
119 | 119 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/country/'.urlencode(strtolower(str_replace(" ", "-", $country_item['country']))).'</loc>'; |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | $output .= '</url>'; |
123 | 123 | } |
124 | 124 | $output .= '</urlset>'; |
125 | -} else if (isset($_GET['type']) && $_GET['type'] == "ident"){ |
|
125 | +} else if (isset($_GET['type']) && $_GET['type'] == "ident") { |
|
126 | 126 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
127 | 127 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
128 | 128 | $ident_names = $Spotter->getAllIdents(); |
129 | - foreach($ident_names as $ident_item) |
|
129 | + foreach ($ident_names as $ident_item) |
|
130 | 130 | { |
131 | 131 | if (ctype_alnum($ident_item['ident'])) { |
132 | 132 | $output .= '<url>'; |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | } |
138 | 138 | } |
139 | 139 | $output .= '</urlset>'; |
140 | -} else if (isset($_GET['type']) && $_GET['type'] == "marine-ident"){ |
|
140 | +} else if (isset($_GET['type']) && $_GET['type'] == "marine-ident") { |
|
141 | 141 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
142 | 142 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
143 | 143 | $ident_names = $Marine->getAllIdents(); |
144 | - foreach($ident_names as $ident_item) |
|
144 | + foreach ($ident_names as $ident_item) |
|
145 | 145 | { |
146 | 146 | if (ctype_alnum($ident_item['ident'])) { |
147 | 147 | $output .= '<url>'; |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | } |
153 | 153 | } |
154 | 154 | $output .= '</urlset>'; |
155 | -} else if (isset($_GET['type']) && $_GET['type'] == "date"){ |
|
155 | +} else if (isset($_GET['type']) && $_GET['type'] == "date") { |
|
156 | 156 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
157 | 157 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
158 | 158 | $date_names = $Spotter->getAllDates(); |
159 | - foreach($date_names as $date_item) |
|
159 | + foreach ($date_names as $date_item) |
|
160 | 160 | { |
161 | 161 | $output .= '<url>'; |
162 | 162 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/date/'.date("Y-m-d", strtotime($date_item['date'])).'</loc>'; |
@@ -165,11 +165,11 @@ discard block |
||
165 | 165 | $output .= '</url>'; |
166 | 166 | } |
167 | 167 | $output .= '</urlset>'; |
168 | -} else if (isset($_GET['type']) && $_GET['type'] == "marine-date"){ |
|
168 | +} else if (isset($_GET['type']) && $_GET['type'] == "marine-date") { |
|
169 | 169 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
170 | 170 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
171 | 171 | $date_names = $Marine->getAllDates(); |
172 | - foreach($date_names as $date_item) |
|
172 | + foreach ($date_names as $date_item) |
|
173 | 173 | { |
174 | 174 | $output .= '<url>'; |
175 | 175 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/marine/date/'.date("Y-m-d", strtotime($date_item['date'])).'</loc>'; |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | $output .= '</url>'; |
179 | 179 | } |
180 | 180 | $output .= '</urlset>'; |
181 | -} else if (isset($_GET['type']) && $_GET['type'] == "tracker-date"){ |
|
181 | +} else if (isset($_GET['type']) && $_GET['type'] == "tracker-date") { |
|
182 | 182 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
183 | 183 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
184 | 184 | $date_names = $Tracker->getAllDates(); |
185 | - foreach($date_names as $date_item) |
|
185 | + foreach ($date_names as $date_item) |
|
186 | 186 | { |
187 | 187 | $output .= '<url>'; |
188 | 188 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/tracker/date/'.date("Y-m-d", strtotime($date_item['date'])).'</loc>'; |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | $output .= '</url>'; |
192 | 192 | } |
193 | 193 | $output .= '</urlset>'; |
194 | -} else if (isset($_GET['type']) && $_GET['type'] == "route"){ |
|
194 | +} else if (isset($_GET['type']) && $_GET['type'] == "route") { |
|
195 | 195 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
196 | 196 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
197 | 197 | $route_names = $Spotter->getAllRoutes(); |
198 | - foreach($route_names as $route_item) |
|
198 | + foreach ($route_names as $route_item) |
|
199 | 199 | { |
200 | 200 | $output .= '<url>'; |
201 | 201 | $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/route/'.$route_item['airport_departure_icao'].'/'.$route_item['airport_arrival_icao'].'</loc>'; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $output .= '</url>'; |
205 | 205 | } |
206 | 206 | $output .= '</urlset>'; |
207 | -} else if (isset($_GET['type']) && $_GET['type'] == "static"){ |
|
207 | +} else if (isset($_GET['type']) && $_GET['type'] == "static") { |
|
208 | 208 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
209 | 209 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
210 | 210 | /* STATIC PAGES */ |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $output .= '<changefreq>daily</changefreq>'; |
323 | 323 | $output .= '</url>'; |
324 | 324 | $output .= '</urlset>'; |
325 | -} else if (isset($_GET['type']) && $_GET['type'] == "marine-static"){ |
|
325 | +} else if (isset($_GET['type']) && $_GET['type'] == "marine-static") { |
|
326 | 326 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
327 | 327 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
328 | 328 | /* STATIC PAGES */ |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | $output .= '<changefreq>daily</changefreq>'; |
349 | 349 | $output .= '</url>'; |
350 | 350 | $output .= '</urlset>'; |
351 | -} else if (isset($_GET['type']) && $_GET['type'] == "tracker-static"){ |
|
351 | +} else if (isset($_GET['type']) && $_GET['type'] == "tracker-static") { |
|
352 | 352 | $output .= '<?xml version="1.0" encoding="UTF-8"?>'; |
353 | 353 | $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">'; |
354 | 354 | /* STATIC PAGES */ |
@@ -14,33 +14,33 @@ discard block |
||
14 | 14 | * @param Array $filter the filter |
15 | 15 | * @return Array the SQL part |
16 | 16 | */ |
17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | 22 | $filters = $globalStatsFilters[$globalFilterName]; |
23 | 23 | } else { |
24 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
24 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | if (isset($filter[0]['source'])) { |
28 | - $filters = array_merge($filters,$filter); |
|
28 | + $filters = array_merge($filters, $filter); |
|
29 | 29 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
30 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
31 | 31 | $filter_query_join = ''; |
32 | 32 | $filter_query_where = ''; |
33 | - foreach($filters as $flt) { |
|
33 | + foreach ($filters as $flt) { |
|
34 | 34 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
35 | 35 | if (isset($flt['source'])) { |
36 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
36 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
37 | 37 | } else { |
38 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | if (isset($filter['source']) && !empty($filter['source'])) { |
43 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
43 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
44 | 44 | } |
45 | 45 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
46 | 46 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -68,38 +68,38 @@ discard block |
||
68 | 68 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'"; |
69 | 69 | } |
70 | 70 | } |
71 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid"; |
|
71 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid"; |
|
72 | 72 | } |
73 | 73 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
74 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
75 | 75 | } |
76 | 76 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
77 | 77 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
78 | 78 | if ($filter_query_where != '') { |
79 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
79 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
80 | 80 | } |
81 | 81 | $filter_query = $filter_query_join.$filter_query_where; |
82 | 82 | return $filter_query; |
83 | 83 | } |
84 | 84 | |
85 | 85 | // tracker_archive |
86 | - public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { |
|
86 | + public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
87 | 87 | require_once(dirname(__FILE__).'/class.Tracker.php'); |
88 | 88 | if ($over_country == '') { |
89 | 89 | $Tracker = new Tracker($this->db); |
90 | - $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
90 | + $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
91 | 91 | if (!empty($data_country)) $country = $data_country['iso2']; |
92 | 92 | else $country = ''; |
93 | 93 | } else $country = $over_country; |
94 | 94 | // Route is not added in tracker_archive |
95 | - $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
95 | + $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
96 | 96 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
97 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':comment' => $comment,':type' => $type); |
|
97 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':comment' => $comment, ':type' => $type); |
|
98 | 98 | try { |
99 | 99 | $sth = $this->db->prepare($query); |
100 | 100 | $sth->execute($query_values); |
101 | 101 | $sth->closeCursor(); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | return "error : ".$e->getMessage(); |
104 | 104 | } |
105 | 105 | return "success"; |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | |
120 | 120 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
121 | 121 | //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
122 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
122 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
123 | 123 | |
124 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
124 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident)); |
|
125 | 125 | |
126 | 126 | return $spotter_array; |
127 | 127 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
141 | 141 | //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
142 | 142 | //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
143 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
143 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
144 | 144 | |
145 | 145 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
146 | 146 | /* |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } |
154 | 154 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
155 | 155 | */ |
156 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
156 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id)); |
|
157 | 157 | |
158 | 158 | return $spotter_array; |
159 | 159 | } |
@@ -168,14 +168,14 @@ discard block |
||
168 | 168 | { |
169 | 169 | date_default_timezone_set('UTC'); |
170 | 170 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
171 | - $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
171 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
172 | 172 | |
173 | 173 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
174 | 174 | |
175 | 175 | try { |
176 | 176 | $sth = $this->db->prepare($query); |
177 | 177 | $sth->execute(array(':id' => $id)); |
178 | - } catch(PDOException $e) { |
|
178 | + } catch (PDOException $e) { |
|
179 | 179 | echo $e->getMessage(); |
180 | 180 | die; |
181 | 181 | } |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | { |
195 | 195 | date_default_timezone_set('UTC'); |
196 | 196 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
197 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
197 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
198 | 198 | |
199 | 199 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
200 | 200 | |
201 | 201 | try { |
202 | 202 | $sth = $this->db->prepare($query); |
203 | 203 | $sth->execute(array(':id' => $id)); |
204 | - } catch(PDOException $e) { |
|
204 | + } catch (PDOException $e) { |
|
205 | 205 | echo $e->getMessage(); |
206 | 206 | die; |
207 | 207 | } |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | date_default_timezone_set('UTC'); |
224 | 224 | |
225 | 225 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
226 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
226 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
227 | 227 | |
228 | 228 | try { |
229 | 229 | $sth = $this->db->prepare($query); |
230 | 230 | $sth->execute(array(':ident' => $ident)); |
231 | - } catch(PDOException $e) { |
|
231 | + } catch (PDOException $e) { |
|
232 | 232 | echo $e->getMessage(); |
233 | 233 | die; |
234 | 234 | } |
@@ -249,12 +249,12 @@ discard block |
||
249 | 249 | date_default_timezone_set('UTC'); |
250 | 250 | |
251 | 251 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
252 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
252 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
253 | 253 | |
254 | 254 | try { |
255 | 255 | $sth = $this->db->prepare($query); |
256 | 256 | $sth->execute(array(':id' => $id)); |
257 | - } catch(PDOException $e) { |
|
257 | + } catch (PDOException $e) { |
|
258 | 258 | echo $e->getMessage(); |
259 | 259 | die; |
260 | 260 | } |
@@ -275,12 +275,12 @@ discard block |
||
275 | 275 | date_default_timezone_set('UTC'); |
276 | 276 | |
277 | 277 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
278 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
278 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
279 | 279 | |
280 | 280 | try { |
281 | 281 | $sth = $this->db->prepare($query); |
282 | 282 | $sth->execute(array(':id' => $id)); |
283 | - } catch(PDOException $e) { |
|
283 | + } catch (PDOException $e) { |
|
284 | 284 | echo $e->getMessage(); |
285 | 285 | die; |
286 | 286 | } |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | date_default_timezone_set('UTC'); |
303 | 303 | |
304 | 304 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
305 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
305 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
306 | 306 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
307 | 307 | |
308 | 308 | try { |
309 | 309 | $sth = $this->db->prepare($query); |
310 | 310 | $sth->execute(array(':ident' => $ident)); |
311 | - } catch(PDOException $e) { |
|
311 | + } catch (PDOException $e) { |
|
312 | 312 | echo $e->getMessage(); |
313 | 313 | die; |
314 | 314 | } |
@@ -325,13 +325,13 @@ discard block |
||
325 | 325 | * @return Array the spotter information |
326 | 326 | * |
327 | 327 | */ |
328 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
328 | + public function getTrackerArchiveData($ident, $famtrackid, $date) |
|
329 | 329 | { |
330 | 330 | $Tracker = new Tracker($this->db); |
331 | 331 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
332 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
332 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
333 | 333 | |
334 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
334 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%')); |
|
335 | 335 | |
336 | 336 | return $spotter_array; |
337 | 337 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | try { |
348 | 348 | $sth = $this->db->prepare($query); |
349 | 349 | $sth->execute(); |
350 | - } catch(PDOException $e) { |
|
350 | + } catch (PDOException $e) { |
|
351 | 351 | echo $e->getMessage(); |
352 | 352 | die; |
353 | 353 | } |
@@ -359,24 +359,24 @@ discard block |
||
359 | 359 | * @return Array the spotter information |
360 | 360 | * |
361 | 361 | */ |
362 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
362 | + public function getMinLiveTrackerData($begindate, $enddate, $filter = array()) |
|
363 | 363 | { |
364 | 364 | global $globalDBdriver, $globalLiveInterval; |
365 | 365 | date_default_timezone_set('UTC'); |
366 | 366 | |
367 | 367 | $filter_query = ''; |
368 | 368 | if (isset($filter['source']) && !empty($filter['source'])) { |
369 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
369 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
370 | 370 | } |
371 | 371 | // Use spotter_output also ? |
372 | 372 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
373 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
373 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
374 | 374 | } |
375 | 375 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
376 | 376 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
377 | 377 | } |
378 | 378 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
379 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
379 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -395,14 +395,14 @@ discard block |
||
395 | 395 | GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid |
396 | 396 | AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
397 | 397 | */ |
398 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
398 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
399 | 399 | FROM tracker_archive |
400 | 400 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
401 | 401 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
402 | 402 | '.$filter_query.' ORDER BY famtrackid'; |
403 | 403 | } else { |
404 | 404 | //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
405 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
405 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
406 | 406 | FROM tracker_archive |
407 | 407 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
408 | 408 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | try { |
413 | 413 | $sth = $this->db->prepare($query); |
414 | 414 | $sth->execute(); |
415 | - } catch(PDOException $e) { |
|
415 | + } catch (PDOException $e) { |
|
416 | 416 | echo $e->getMessage(); |
417 | 417 | die; |
418 | 418 | } |
@@ -427,24 +427,24 @@ discard block |
||
427 | 427 | * @return Array the spotter information |
428 | 428 | * |
429 | 429 | */ |
430 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
430 | + public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array()) |
|
431 | 431 | { |
432 | 432 | global $globalDBdriver, $globalLiveInterval; |
433 | 433 | date_default_timezone_set('UTC'); |
434 | 434 | |
435 | 435 | $filter_query = ''; |
436 | 436 | if (isset($filter['source']) && !empty($filter['source'])) { |
437 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
437 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
438 | 438 | } |
439 | 439 | // Should use spotter_output also ? |
440 | 440 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
441 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
441 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
442 | 442 | } |
443 | 443 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
444 | 444 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
445 | 445 | } |
446 | 446 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
447 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
447 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | FROM tracker_archive |
455 | 455 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
456 | 456 | */ |
457 | - $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk |
|
457 | + $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk |
|
458 | 458 | FROM tracker_archive_output |
459 | 459 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao |
460 | 460 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
470 | 470 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
471 | 471 | */ |
472 | - $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
472 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
473 | 473 | FROM tracker_archive_output |
474 | 474 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
475 | 475 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | try { |
482 | 482 | $sth = $this->db->prepare($query); |
483 | 483 | $sth->execute(); |
484 | - } catch(PDOException $e) { |
|
484 | + } catch (PDOException $e) { |
|
485 | 485 | echo $e->getMessage(); |
486 | 486 | die; |
487 | 487 | } |
@@ -496,23 +496,23 @@ discard block |
||
496 | 496 | * @return Array the spotter information |
497 | 497 | * |
498 | 498 | */ |
499 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
499 | + public function getLiveTrackerCount($begindate, $enddate, $filter = array()) |
|
500 | 500 | { |
501 | 501 | global $globalDBdriver, $globalLiveInterval; |
502 | 502 | date_default_timezone_set('UTC'); |
503 | 503 | |
504 | 504 | $filter_query = ''; |
505 | 505 | if (isset($filter['source']) && !empty($filter['source'])) { |
506 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
506 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
507 | 507 | } |
508 | 508 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
509 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
509 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
510 | 510 | } |
511 | 511 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
512 | 512 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
513 | 513 | } |
514 | 514 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
515 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
515 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $this->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | echo $e->getMessage(); |
532 | 532 | die; |
533 | 533 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | * @return Array the spotter information |
548 | 548 | * |
549 | 549 | */ |
550 | - public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
550 | + public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
551 | 551 | { |
552 | 552 | global $globalTimezone, $globalDBdriver; |
553 | 553 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | |
570 | 570 | $q_array = explode(" ", $q); |
571 | 571 | |
572 | - foreach ($q_array as $q_item){ |
|
572 | + foreach ($q_array as $q_item) { |
|
573 | 573 | $additional_query .= " AND ("; |
574 | 574 | $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
575 | 575 | $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | |
602 | 602 | if ($registration != "") |
603 | 603 | { |
604 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
604 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
605 | 605 | if (!is_string($registration)) |
606 | 606 | { |
607 | 607 | return false; |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | if ($aircraft_icao != "") |
614 | 614 | { |
615 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
615 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
616 | 616 | if (!is_string($aircraft_icao)) |
617 | 617 | { |
618 | 618 | return false; |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | |
624 | 624 | if ($aircraft_manufacturer != "") |
625 | 625 | { |
626 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
626 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
627 | 627 | if (!is_string($aircraft_manufacturer)) |
628 | 628 | { |
629 | 629 | return false; |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | |
645 | 645 | if ($airline_icao != "") |
646 | 646 | { |
647 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
647 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
648 | 648 | if (!is_string($airline_icao)) |
649 | 649 | { |
650 | 650 | return false; |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | |
656 | 656 | if ($airline_country != "") |
657 | 657 | { |
658 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
658 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
659 | 659 | if (!is_string($airline_country)) |
660 | 660 | { |
661 | 661 | return false; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | |
667 | 667 | if ($airline_type != "") |
668 | 668 | { |
669 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
669 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
670 | 670 | if (!is_string($airline_type)) |
671 | 671 | { |
672 | 672 | return false; |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | |
689 | 689 | if ($airport != "") |
690 | 690 | { |
691 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
691 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
692 | 692 | if (!is_string($airport)) |
693 | 693 | { |
694 | 694 | return false; |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | |
700 | 700 | if ($airport_country != "") |
701 | 701 | { |
702 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
702 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
703 | 703 | if (!is_string($airport_country)) |
704 | 704 | { |
705 | 705 | return false; |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | |
711 | 711 | if ($callsign != "") |
712 | 712 | { |
713 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
713 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
714 | 714 | if (!is_string($callsign)) |
715 | 715 | { |
716 | 716 | return false; |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | $translate = $Translation->ident2icao($callsign); |
719 | 719 | if ($translate != $callsign) { |
720 | 720 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
721 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
721 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
722 | 722 | } else { |
723 | 723 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
724 | 724 | } |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | |
728 | 728 | if ($owner != "") |
729 | 729 | { |
730 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
730 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
731 | 731 | if (!is_string($owner)) |
732 | 732 | { |
733 | 733 | return false; |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | |
739 | 739 | if ($pilot_name != "") |
740 | 740 | { |
741 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
741 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
742 | 742 | if (!is_string($pilot_name)) |
743 | 743 | { |
744 | 744 | return false; |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | |
750 | 750 | if ($pilot_id != "") |
751 | 751 | { |
752 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
752 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
753 | 753 | if (!is_string($pilot_id)) |
754 | 754 | { |
755 | 755 | return false; |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | |
761 | 761 | if ($departure_airport_route != "") |
762 | 762 | { |
763 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
763 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
764 | 764 | if (!is_string($departure_airport_route)) |
765 | 765 | { |
766 | 766 | return false; |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | |
772 | 772 | if ($arrival_airport_route != "") |
773 | 773 | { |
774 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
774 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
775 | 775 | if (!is_string($arrival_airport_route)) |
776 | 776 | { |
777 | 777 | return false; |
@@ -784,8 +784,8 @@ discard block |
||
784 | 784 | { |
785 | 785 | $altitude_array = explode(",", $altitude); |
786 | 786 | |
787 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
787 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
788 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
789 | 789 | |
790 | 790 | |
791 | 791 | if ($altitude_array[1] != "") |
@@ -803,8 +803,8 @@ discard block |
||
803 | 803 | { |
804 | 804 | $date_array = explode(",", $date_posted); |
805 | 805 | |
806 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
807 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
806 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
807 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
808 | 808 | |
809 | 809 | if ($globalTimezone != '') { |
810 | 810 | date_default_timezone_set($globalTimezone); |
@@ -836,8 +836,8 @@ discard block |
||
836 | 836 | { |
837 | 837 | $limit_array = explode(",", $limit); |
838 | 838 | |
839 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
840 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
839 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
840 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
841 | 841 | |
842 | 842 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
843 | 843 | { |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | |
849 | 849 | |
850 | 850 | if ($origLat != "" && $origLon != "" && $dist != "") { |
851 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
852 | - $query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
851 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
852 | + $query = "SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
853 | 853 | FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
854 | 854 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
855 | 855 | } else { |
@@ -866,12 +866,12 @@ discard block |
||
866 | 866 | $additional_query .= " AND (tracker_archive_output.waypoints <> '')"; |
867 | 867 | } |
868 | 868 | |
869 | - $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
869 | + $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
870 | 870 | WHERE tracker_archive_output.ident <> '' |
871 | 871 | ".$additional_query." |
872 | 872 | ".$filter_query.$orderby_query; |
873 | 873 | } |
874 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
|
874 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
875 | 875 | |
876 | 876 | return $spotter_array; |
877 | 877 | } |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | try { |
889 | 889 | $sth = $this->db->prepare($query); |
890 | 890 | $sth->execute(); |
891 | - } catch(PDOException $e) { |
|
891 | + } catch (PDOException $e) { |
|
892 | 892 | return "error"; |
893 | 893 | } |
894 | 894 | } |
@@ -925,8 +925,8 @@ discard block |
||
925 | 925 | { |
926 | 926 | $limit_array = explode(",", $limit); |
927 | 927 | |
928 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
929 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
928 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
929 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
930 | 930 | |
931 | 931 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
932 | 932 | { |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | $query_values = array(); |
968 | 968 | $limit_query = ''; |
969 | 969 | $additional_query = ''; |
970 | - $filter_query = $this->getFilter($filter,true,true); |
|
970 | + $filter_query = $this->getFilter($filter, true, true); |
|
971 | 971 | |
972 | 972 | if ($owner != "") |
973 | 973 | { |
@@ -984,8 +984,8 @@ discard block |
||
984 | 984 | { |
985 | 985 | $limit_array = explode(",", $limit); |
986 | 986 | |
987 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
988 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
987 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
988 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
989 | 989 | |
990 | 990 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
991 | 991 | { |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | $query_values = array(); |
1026 | 1026 | $limit_query = ''; |
1027 | 1027 | $additional_query = ''; |
1028 | - $filter_query = $this->getFilter($filter,true,true); |
|
1028 | + $filter_query = $this->getFilter($filter, true, true); |
|
1029 | 1029 | |
1030 | 1030 | if ($pilot != "") |
1031 | 1031 | { |
@@ -1037,8 +1037,8 @@ discard block |
||
1037 | 1037 | { |
1038 | 1038 | $limit_array = explode(",", $limit); |
1039 | 1039 | |
1040 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1040 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1041 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1042 | 1042 | |
1043 | 1043 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1044 | 1044 | { |
@@ -1068,7 +1068,7 @@ discard block |
||
1068 | 1068 | * @return Array the airline country list |
1069 | 1069 | * |
1070 | 1070 | */ |
1071 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1071 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1072 | 1072 | { |
1073 | 1073 | global $globalDBdriver; |
1074 | 1074 | /* |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | $flight_array = array(); |
1098 | 1098 | $temp_array = array(); |
1099 | 1099 | |
1100 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1100 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1101 | 1101 | { |
1102 | 1102 | $temp_array['flight_count'] = $row['nb']; |
1103 | 1103 | $temp_array['flight_country'] = $row['name']; |
@@ -1114,7 +1114,7 @@ discard block |
||
1114 | 1114 | * @return Array the airline country list |
1115 | 1115 | * |
1116 | 1116 | */ |
1117 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1117 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1118 | 1118 | { |
1119 | 1119 | global $globalDBdriver; |
1120 | 1120 | /* |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | $flight_array = array(); |
1144 | 1144 | $temp_array = array(); |
1145 | 1145 | |
1146 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1146 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1147 | 1147 | { |
1148 | 1148 | $temp_array['airline_icao'] = $row['airline_icao']; |
1149 | 1149 | $temp_array['flight_count'] = $row['nb']; |
@@ -1161,14 +1161,14 @@ discard block |
||
1161 | 1161 | * @return Array the spotter information |
1162 | 1162 | * |
1163 | 1163 | */ |
1164 | - public function getDateArchiveTrackerDataById($id,$date) |
|
1164 | + public function getDateArchiveTrackerDataById($id, $date) |
|
1165 | 1165 | { |
1166 | 1166 | $Tracker = new Tracker($this->db); |
1167 | 1167 | date_default_timezone_set('UTC'); |
1168 | 1168 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1169 | - $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
1170 | - $date = date('c',$date); |
|
1171 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1169 | + $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
1170 | + $date = date('c', $date); |
|
1171 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1172 | 1172 | return $spotter_array; |
1173 | 1173 | } |
1174 | 1174 | |
@@ -1178,14 +1178,14 @@ discard block |
||
1178 | 1178 | * @return Array the spotter information |
1179 | 1179 | * |
1180 | 1180 | */ |
1181 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1181 | + public function getDateArchiveTrackerDataByIdent($ident, $date) |
|
1182 | 1182 | { |
1183 | 1183 | $Tracker = new Tracker($this->db); |
1184 | 1184 | date_default_timezone_set('UTC'); |
1185 | 1185 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1186 | - $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
1187 | - $date = date('c',$date); |
|
1188 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1186 | + $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
1187 | + $date = date('c', $date); |
|
1188 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1189 | 1189 | return $spotter_array; |
1190 | 1190 | } |
1191 | 1191 | |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | * @return Array the spotter information |
1196 | 1196 | * |
1197 | 1197 | */ |
1198 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1198 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1199 | 1199 | { |
1200 | 1200 | global $global_query; |
1201 | 1201 | $Tracker = new Tracker($this->db); |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | $query_values = array(); |
1204 | 1204 | $limit_query = ''; |
1205 | 1205 | $additional_query = ''; |
1206 | - $filter_query = $this->getFilter($filters,true,true); |
|
1206 | + $filter_query = $this->getFilter($filters, true, true); |
|
1207 | 1207 | |
1208 | 1208 | if ($airport != "") |
1209 | 1209 | { |
@@ -1220,8 +1220,8 @@ discard block |
||
1220 | 1220 | { |
1221 | 1221 | $limit_array = explode(",", $limit); |
1222 | 1222 | |
1223 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1224 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1223 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1224 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1225 | 1225 | |
1226 | 1226 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1227 | 1227 | { |
@@ -14,33 +14,33 @@ discard block |
||
14 | 14 | * @param Array $filter the filter |
15 | 15 | * @return Array the SQL part |
16 | 16 | */ |
17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | 22 | $filters = $globalStatsFilters[$globalFilterName]; |
23 | 23 | } else { |
24 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
24 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | if (isset($filter[0]['source'])) { |
28 | - $filters = array_merge($filters,$filter); |
|
28 | + $filters = array_merge($filters, $filter); |
|
29 | 29 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
30 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
31 | 31 | $filter_query_join = ''; |
32 | 32 | $filter_query_where = ''; |
33 | - foreach($filters as $flt) { |
|
33 | + foreach ($filters as $flt) { |
|
34 | 34 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
35 | 35 | if (isset($flt['source'])) { |
36 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
36 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
37 | 37 | } else { |
38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | if (isset($filter['source']) && !empty($filter['source'])) { |
43 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
43 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
44 | 44 | } |
45 | 45 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
46 | 46 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -68,42 +68,42 @@ discard block |
||
68 | 68 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'"; |
69 | 69 | } |
70 | 70 | } |
71 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
71 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
72 | 72 | } |
73 | 73 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
74 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
75 | 75 | } |
76 | 76 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
77 | 77 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
78 | 78 | if ($filter_query_where != '') { |
79 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
79 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
80 | 80 | } |
81 | 81 | $filter_query = $filter_query_join.$filter_query_where; |
82 | 82 | return $filter_query; |
83 | 83 | } |
84 | 84 | |
85 | 85 | // marine_archive |
86 | - public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { |
|
86 | + public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
87 | 87 | require_once(dirname(__FILE__).'/class.Marine.php'); |
88 | 88 | if ($over_country == '') { |
89 | 89 | $Marine = new Marine($this->db); |
90 | - $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
90 | + $data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
91 | 91 | if (!empty($data_country)) $country = $data_country['iso2']; |
92 | 92 | else $country = ''; |
93 | 93 | } else $country = $over_country; |
94 | 94 | |
95 | 95 | //$country = $over_country; |
96 | 96 | // Route is not added in marine_archive |
97 | - $query = 'INSERT INTO marine_archive (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) |
|
97 | + $query = 'INSERT INTO marine_archive (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) |
|
98 | 98 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
99 | 99 | |
100 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
100 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
101 | 101 | |
102 | 102 | try { |
103 | 103 | $sth = $this->db->prepare($query); |
104 | 104 | $sth->execute($query_values); |
105 | 105 | $sth->closeCursor(); |
106 | - } catch(PDOException $e) { |
|
106 | + } catch (PDOException $e) { |
|
107 | 107 | return "error : ".$e->getMessage(); |
108 | 108 | } |
109 | 109 | return "success"; |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | |
124 | 124 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
125 | 125 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
126 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
126 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
127 | 127 | |
128 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
128 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident)); |
|
129 | 129 | |
130 | 130 | return $spotter_array; |
131 | 131 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
145 | 145 | //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
146 | 146 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
147 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
147 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
148 | 148 | |
149 | 149 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
150 | 150 | /* |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | } |
158 | 158 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
159 | 159 | */ |
160 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
160 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id)); |
|
161 | 161 | |
162 | 162 | return $spotter_array; |
163 | 163 | } |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | { |
173 | 173 | date_default_timezone_set('UTC'); |
174 | 174 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
175 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
175 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
176 | 176 | |
177 | 177 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
178 | 178 | |
179 | 179 | try { |
180 | 180 | $sth = $this->db->prepare($query); |
181 | 181 | $sth->execute(array(':id' => $id)); |
182 | - } catch(PDOException $e) { |
|
182 | + } catch (PDOException $e) { |
|
183 | 183 | echo $e->getMessage(); |
184 | 184 | die; |
185 | 185 | } |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | { |
199 | 199 | date_default_timezone_set('UTC'); |
200 | 200 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
201 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
201 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
202 | 202 | |
203 | 203 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
204 | 204 | |
205 | 205 | try { |
206 | 206 | $sth = $this->db->prepare($query); |
207 | 207 | $sth->execute(array(':id' => $id)); |
208 | - } catch(PDOException $e) { |
|
208 | + } catch (PDOException $e) { |
|
209 | 209 | echo $e->getMessage(); |
210 | 210 | die; |
211 | 211 | } |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | date_default_timezone_set('UTC'); |
228 | 228 | |
229 | 229 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
230 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
230 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
231 | 231 | |
232 | 232 | try { |
233 | 233 | $sth = $this->db->prepare($query); |
234 | 234 | $sth->execute(array(':ident' => $ident)); |
235 | - } catch(PDOException $e) { |
|
235 | + } catch (PDOException $e) { |
|
236 | 236 | echo $e->getMessage(); |
237 | 237 | die; |
238 | 238 | } |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | date_default_timezone_set('UTC'); |
254 | 254 | |
255 | 255 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
256 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
256 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
257 | 257 | |
258 | 258 | try { |
259 | 259 | $sth = $this->db->prepare($query); |
260 | 260 | $sth->execute(array(':id' => $id)); |
261 | - } catch(PDOException $e) { |
|
261 | + } catch (PDOException $e) { |
|
262 | 262 | echo $e->getMessage(); |
263 | 263 | die; |
264 | 264 | } |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | date_default_timezone_set('UTC'); |
280 | 280 | |
281 | 281 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
282 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
282 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
283 | 283 | |
284 | 284 | try { |
285 | 285 | $sth = $this->db->prepare($query); |
286 | 286 | $sth->execute(array(':id' => $id)); |
287 | - } catch(PDOException $e) { |
|
287 | + } catch (PDOException $e) { |
|
288 | 288 | echo $e->getMessage(); |
289 | 289 | die; |
290 | 290 | } |
@@ -306,13 +306,13 @@ discard block |
||
306 | 306 | date_default_timezone_set('UTC'); |
307 | 307 | |
308 | 308 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
309 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
309 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
310 | 310 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
311 | 311 | |
312 | 312 | try { |
313 | 313 | $sth = $this->db->prepare($query); |
314 | 314 | $sth->execute(array(':ident' => $ident)); |
315 | - } catch(PDOException $e) { |
|
315 | + } catch (PDOException $e) { |
|
316 | 316 | echo $e->getMessage(); |
317 | 317 | die; |
318 | 318 | } |
@@ -329,12 +329,12 @@ discard block |
||
329 | 329 | * @return Array the spotter information |
330 | 330 | * |
331 | 331 | */ |
332 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
332 | + public function getMarineArchiveData($ident, $fammarine_id, $date) |
|
333 | 333 | { |
334 | 334 | $Marine = new Marine($this->db); |
335 | 335 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
336 | 336 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
337 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
337 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); |
|
338 | 338 | return $spotter_array; |
339 | 339 | } |
340 | 340 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | try { |
354 | 354 | $sth = $this->db->prepare($query); |
355 | 355 | $sth->execute(); |
356 | - } catch(PDOException $e) { |
|
356 | + } catch (PDOException $e) { |
|
357 | 357 | echo $e->getMessage(); |
358 | 358 | die; |
359 | 359 | } |
@@ -365,24 +365,24 @@ discard block |
||
365 | 365 | * @return Array the spotter information |
366 | 366 | * |
367 | 367 | */ |
368 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
368 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array()) |
|
369 | 369 | { |
370 | 370 | global $globalDBdriver, $globalLiveInterval; |
371 | 371 | date_default_timezone_set('UTC'); |
372 | 372 | |
373 | 373 | $filter_query = ''; |
374 | 374 | if (isset($filter['source']) && !empty($filter['source'])) { |
375 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
375 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
376 | 376 | } |
377 | 377 | // Use spotter_output also ? |
378 | 378 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
379 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
379 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
380 | 380 | } |
381 | 381 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
382 | 382 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
383 | 383 | } |
384 | 384 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
385 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
385 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -401,14 +401,14 @@ discard block |
||
401 | 401 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
402 | 402 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
403 | 403 | */ |
404 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
404 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
405 | 405 | FROM marine_archive |
406 | 406 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
407 | 407 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
408 | 408 | '.$filter_query.' ORDER BY fammarine_id'; |
409 | 409 | } else { |
410 | 410 | //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
411 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
411 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
412 | 412 | FROM marine_archive |
413 | 413 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
414 | 414 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | try { |
419 | 419 | $sth = $this->db->prepare($query); |
420 | 420 | $sth->execute(); |
421 | - } catch(PDOException $e) { |
|
421 | + } catch (PDOException $e) { |
|
422 | 422 | echo $e->getMessage(); |
423 | 423 | die; |
424 | 424 | } |
@@ -433,24 +433,24 @@ discard block |
||
433 | 433 | * @return Array the spotter information |
434 | 434 | * |
435 | 435 | */ |
436 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
436 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array()) |
|
437 | 437 | { |
438 | 438 | global $globalDBdriver, $globalLiveInterval; |
439 | 439 | date_default_timezone_set('UTC'); |
440 | 440 | |
441 | 441 | $filter_query = ''; |
442 | 442 | if (isset($filter['source']) && !empty($filter['source'])) { |
443 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
443 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
444 | 444 | } |
445 | 445 | // Should use spotter_output also ? |
446 | 446 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
447 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
447 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
448 | 448 | } |
449 | 449 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
450 | 450 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
451 | 451 | } |
452 | 452 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
453 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
453 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | FROM marine_archive |
461 | 461 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
462 | 462 | */ |
463 | - $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
463 | + $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
464 | 464 | FROM marine_archive_output |
465 | 465 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
466 | 466 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
476 | 476 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
477 | 477 | */ |
478 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
478 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
479 | 479 | FROM marine_archive_output |
480 | 480 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
481 | 481 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | try { |
488 | 488 | $sth = $this->db->prepare($query); |
489 | 489 | $sth->execute(); |
490 | - } catch(PDOException $e) { |
|
490 | + } catch (PDOException $e) { |
|
491 | 491 | echo $e->getMessage(); |
492 | 492 | die; |
493 | 493 | } |
@@ -502,23 +502,23 @@ discard block |
||
502 | 502 | * @return Array the spotter information |
503 | 503 | * |
504 | 504 | */ |
505 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
505 | + public function getLiveMarineCount($begindate, $enddate, $filter = array()) |
|
506 | 506 | { |
507 | 507 | global $globalDBdriver, $globalLiveInterval; |
508 | 508 | date_default_timezone_set('UTC'); |
509 | 509 | |
510 | 510 | $filter_query = ''; |
511 | 511 | if (isset($filter['source']) && !empty($filter['source'])) { |
512 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
512 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
513 | 513 | } |
514 | 514 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
515 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
515 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
516 | 516 | } |
517 | 517 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
518 | 518 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
519 | 519 | } |
520 | 520 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
521 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
521 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | try { |
534 | 534 | $sth = $this->db->prepare($query); |
535 | 535 | $sth->execute(); |
536 | - } catch(PDOException $e) { |
|
536 | + } catch (PDOException $e) { |
|
537 | 537 | echo $e->getMessage(); |
538 | 538 | die; |
539 | 539 | } |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | * @return Array the spotter information |
554 | 554 | * |
555 | 555 | */ |
556 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
556 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array()) |
|
557 | 557 | { |
558 | 558 | global $globalTimezone, $globalDBdriver; |
559 | 559 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | |
576 | 576 | $q_array = explode(" ", $q); |
577 | 577 | |
578 | - foreach ($q_array as $q_item){ |
|
578 | + foreach ($q_array as $q_item) { |
|
579 | 579 | $additional_query .= " AND ("; |
580 | 580 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
581 | 581 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | |
608 | 608 | if ($registration != "") |
609 | 609 | { |
610 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
610 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
611 | 611 | if (!is_string($registration)) |
612 | 612 | { |
613 | 613 | return false; |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | |
619 | 619 | if ($aircraft_icao != "") |
620 | 620 | { |
621 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
621 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
622 | 622 | if (!is_string($aircraft_icao)) |
623 | 623 | { |
624 | 624 | return false; |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | |
630 | 630 | if ($aircraft_manufacturer != "") |
631 | 631 | { |
632 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
632 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
633 | 633 | if (!is_string($aircraft_manufacturer)) |
634 | 634 | { |
635 | 635 | return false; |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | |
651 | 651 | if ($airline_icao != "") |
652 | 652 | { |
653 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
653 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
654 | 654 | if (!is_string($airline_icao)) |
655 | 655 | { |
656 | 656 | return false; |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | |
662 | 662 | if ($airline_country != "") |
663 | 663 | { |
664 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
664 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
665 | 665 | if (!is_string($airline_country)) |
666 | 666 | { |
667 | 667 | return false; |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | |
673 | 673 | if ($airline_type != "") |
674 | 674 | { |
675 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
675 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
676 | 676 | if (!is_string($airline_type)) |
677 | 677 | { |
678 | 678 | return false; |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | |
695 | 695 | if ($airport != "") |
696 | 696 | { |
697 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
697 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
698 | 698 | if (!is_string($airport)) |
699 | 699 | { |
700 | 700 | return false; |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | |
706 | 706 | if ($airport_country != "") |
707 | 707 | { |
708 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
708 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
709 | 709 | if (!is_string($airport_country)) |
710 | 710 | { |
711 | 711 | return false; |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | |
717 | 717 | if ($callsign != "") |
718 | 718 | { |
719 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
719 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
720 | 720 | if (!is_string($callsign)) |
721 | 721 | { |
722 | 722 | return false; |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | $translate = $Translation->ident2icao($callsign); |
725 | 725 | if ($translate != $callsign) { |
726 | 726 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
727 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
727 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
728 | 728 | } else { |
729 | 729 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
730 | 730 | } |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | |
734 | 734 | if ($owner != "") |
735 | 735 | { |
736 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
736 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
737 | 737 | if (!is_string($owner)) |
738 | 738 | { |
739 | 739 | return false; |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | |
745 | 745 | if ($pilot_name != "") |
746 | 746 | { |
747 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
747 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
748 | 748 | if (!is_string($pilot_name)) |
749 | 749 | { |
750 | 750 | return false; |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | |
756 | 756 | if ($pilot_id != "") |
757 | 757 | { |
758 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
758 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
759 | 759 | if (!is_string($pilot_id)) |
760 | 760 | { |
761 | 761 | return false; |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | |
767 | 767 | if ($departure_airport_route != "") |
768 | 768 | { |
769 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
769 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
770 | 770 | if (!is_string($departure_airport_route)) |
771 | 771 | { |
772 | 772 | return false; |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | |
778 | 778 | if ($arrival_airport_route != "") |
779 | 779 | { |
780 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
780 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
781 | 781 | if (!is_string($arrival_airport_route)) |
782 | 782 | { |
783 | 783 | return false; |
@@ -790,8 +790,8 @@ discard block |
||
790 | 790 | { |
791 | 791 | $altitude_array = explode(",", $altitude); |
792 | 792 | |
793 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
794 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
793 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
794 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
795 | 795 | |
796 | 796 | |
797 | 797 | if ($altitude_array[1] != "") |
@@ -809,8 +809,8 @@ discard block |
||
809 | 809 | { |
810 | 810 | $date_array = explode(",", $date_posted); |
811 | 811 | |
812 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
813 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
812 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
813 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
814 | 814 | |
815 | 815 | if ($globalTimezone != '') { |
816 | 816 | date_default_timezone_set($globalTimezone); |
@@ -842,8 +842,8 @@ discard block |
||
842 | 842 | { |
843 | 843 | $limit_array = explode(",", $limit); |
844 | 844 | |
845 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
846 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
845 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
846 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
847 | 847 | |
848 | 848 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
849 | 849 | { |
@@ -854,8 +854,8 @@ discard block |
||
854 | 854 | |
855 | 855 | |
856 | 856 | if ($origLat != "" && $origLon != "" && $dist != "") { |
857 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
858 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
857 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
858 | + $query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
859 | 859 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
860 | 860 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
861 | 861 | } else { |
@@ -872,12 +872,12 @@ discard block |
||
872 | 872 | $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
873 | 873 | } |
874 | 874 | |
875 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
875 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
876 | 876 | WHERE marine_archive_output.ident <> '' |
877 | 877 | ".$additional_query." |
878 | 878 | ".$filter_query.$orderby_query; |
879 | 879 | } |
880 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
880 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
881 | 881 | |
882 | 882 | return $spotter_array; |
883 | 883 | } |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | try { |
895 | 895 | $sth = $this->db->prepare($query); |
896 | 896 | $sth->execute(); |
897 | - } catch(PDOException $e) { |
|
897 | + } catch (PDOException $e) { |
|
898 | 898 | return "error"; |
899 | 899 | } |
900 | 900 | } |
@@ -931,8 +931,8 @@ discard block |
||
931 | 931 | { |
932 | 932 | $limit_array = explode(",", $limit); |
933 | 933 | |
934 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
935 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
934 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
935 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
936 | 936 | |
937 | 937 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
938 | 938 | { |
@@ -973,7 +973,7 @@ discard block |
||
973 | 973 | $query_values = array(); |
974 | 974 | $limit_query = ''; |
975 | 975 | $additional_query = ''; |
976 | - $filter_query = $this->getFilter($filter,true,true); |
|
976 | + $filter_query = $this->getFilter($filter, true, true); |
|
977 | 977 | |
978 | 978 | if ($owner != "") |
979 | 979 | { |
@@ -990,8 +990,8 @@ discard block |
||
990 | 990 | { |
991 | 991 | $limit_array = explode(",", $limit); |
992 | 992 | |
993 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
994 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
993 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
994 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
995 | 995 | |
996 | 996 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
997 | 997 | { |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | $query_values = array(); |
1032 | 1032 | $limit_query = ''; |
1033 | 1033 | $additional_query = ''; |
1034 | - $filter_query = $this->getFilter($filter,true,true); |
|
1034 | + $filter_query = $this->getFilter($filter, true, true); |
|
1035 | 1035 | |
1036 | 1036 | if ($pilot != "") |
1037 | 1037 | { |
@@ -1043,8 +1043,8 @@ discard block |
||
1043 | 1043 | { |
1044 | 1044 | $limit_array = explode(",", $limit); |
1045 | 1045 | |
1046 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1047 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1046 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1047 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1048 | 1048 | |
1049 | 1049 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1050 | 1050 | { |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | * @return Array the airline country list |
1075 | 1075 | * |
1076 | 1076 | */ |
1077 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1077 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1078 | 1078 | { |
1079 | 1079 | global $globalDBdriver; |
1080 | 1080 | /* |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | $flight_array = array(); |
1104 | 1104 | $temp_array = array(); |
1105 | 1105 | |
1106 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1106 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1107 | 1107 | { |
1108 | 1108 | $temp_array['flight_count'] = $row['nb']; |
1109 | 1109 | $temp_array['flight_country'] = $row['name']; |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | * @return Array the airline country list |
1121 | 1121 | * |
1122 | 1122 | */ |
1123 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1123 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1124 | 1124 | { |
1125 | 1125 | global $globalDBdriver; |
1126 | 1126 | /* |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | $flight_array = array(); |
1150 | 1150 | $temp_array = array(); |
1151 | 1151 | |
1152 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1152 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1153 | 1153 | { |
1154 | 1154 | $temp_array['airline_icao'] = $row['airline_icao']; |
1155 | 1155 | $temp_array['flight_count'] = $row['nb']; |
@@ -1167,14 +1167,14 @@ discard block |
||
1167 | 1167 | * @return Array the spotter information |
1168 | 1168 | * |
1169 | 1169 | */ |
1170 | - public function getDateArchiveMarineDataById($id,$date) |
|
1170 | + public function getDateArchiveMarineDataById($id, $date) |
|
1171 | 1171 | { |
1172 | 1172 | $Marine = new Marine($this->db); |
1173 | 1173 | date_default_timezone_set('UTC'); |
1174 | 1174 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1175 | 1175 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
1176 | - $date = date('c',$date); |
|
1177 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1176 | + $date = date('c', $date); |
|
1177 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1178 | 1178 | return $spotter_array; |
1179 | 1179 | } |
1180 | 1180 | |
@@ -1184,14 +1184,14 @@ discard block |
||
1184 | 1184 | * @return Array the spotter information |
1185 | 1185 | * |
1186 | 1186 | */ |
1187 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1187 | + public function getDateArchiveMarineDataByIdent($ident, $date) |
|
1188 | 1188 | { |
1189 | 1189 | $Marine = new Marine($this->db); |
1190 | 1190 | date_default_timezone_set('UTC'); |
1191 | 1191 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1192 | 1192 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
1193 | - $date = date('c',$date); |
|
1194 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1193 | + $date = date('c', $date); |
|
1194 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1195 | 1195 | return $spotter_array; |
1196 | 1196 | } |
1197 | 1197 | |
@@ -1201,7 +1201,7 @@ discard block |
||
1201 | 1201 | * @return Array the spotter information |
1202 | 1202 | * |
1203 | 1203 | */ |
1204 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1204 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1205 | 1205 | { |
1206 | 1206 | global $global_query; |
1207 | 1207 | $Marine = new Marine($this->db); |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | $query_values = array(); |
1210 | 1210 | $limit_query = ''; |
1211 | 1211 | $additional_query = ''; |
1212 | - $filter_query = $this->getFilter($filters,true,true); |
|
1212 | + $filter_query = $this->getFilter($filters, true, true); |
|
1213 | 1213 | |
1214 | 1214 | if ($airport != "") |
1215 | 1215 | { |
@@ -1226,8 +1226,8 @@ discard block |
||
1226 | 1226 | { |
1227 | 1227 | $limit_array = explode(",", $limit); |
1228 | 1228 | |
1229 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1230 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1229 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1230 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1231 | 1231 | |
1232 | 1232 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1233 | 1233 | { |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | } else { |
20 | 20 | $title = _("Statistics").' - '._("Most common Country a flight was over"); |
21 | 21 | } |
22 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
22 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
23 | 23 | if ($airline_icao == '' && isset($globalFilter)) { |
24 | 24 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
25 | 25 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | if ($type == 'aircraft') { |
51 | - $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name); |
|
51 | + $flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name); |
|
52 | 52 | } elseif ($type == 'marine') { |
53 | 53 | $flightover_array = $Marine->countAllMarineOverCountries(); |
54 | 54 | } elseif ($type == 'tracker') { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
63 | 63 | print 'var series = ['; |
64 | 64 | $flightover_data = ''; |
65 | -foreach($flightover_array as $flightover_item) |
|
65 | +foreach ($flightover_array as $flightover_item) |
|
66 | 66 | { |
67 | 67 | if ($type == 'aircraft') $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],'; |
68 | 68 | elseif ($type == 'marine') $flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],'; |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | print '</thead>'; |
114 | 114 | print '<tbody>'; |
115 | 115 | $i = 1; |
116 | - array_splice($flightover_array,10); |
|
117 | - foreach($flightover_array as $flightover_item) |
|
116 | + array_splice($flightover_array, 10); |
|
117 | + foreach ($flightover_array as $flightover_item) |
|
118 | 118 | { |
119 | 119 | print '<tr>'; |
120 | 120 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | try { |
15 | 15 | $sth = $Connection->db->prepare($query); |
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch (PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | 19 | } |
20 | 20 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
21 | + $Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | try { |
51 | 51 | $sth = $Connection->db->prepare($query); |
52 | 52 | $sth->execute(); |
53 | - } catch(PDOException $e) { |
|
53 | + } catch (PDOException $e) { |
|
54 | 54 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
55 | 55 | } |
56 | 56 | // Copy schedules data to routes table |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | try { |
61 | 61 | $sth = $Connection->db->prepare($query); |
62 | 62 | $sth->execute(); |
63 | - } catch(PDOException $e) { |
|
63 | + } catch (PDOException $e) { |
|
64 | 64 | return "error (delete schedule table) : ".$e->getMessage()."\n"; |
65 | 65 | } |
66 | 66 | // Add source column |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | try { |
69 | 69 | $sth = $Connection->db->prepare($query); |
70 | 70 | $sth->execute(); |
71 | - } catch(PDOException $e) { |
|
71 | + } catch (PDOException $e) { |
|
72 | 72 | return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
73 | 73 | } |
74 | 74 | // Delete unused column |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | try { |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
81 | 81 | } |
82 | 82 | // Add ModeS column |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | try { |
85 | 85 | $sth = $Connection->db->prepare($query); |
86 | 86 | $sth->execute(); |
87 | - } catch(PDOException $e) { |
|
87 | + } catch (PDOException $e) { |
|
88 | 88 | return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
89 | 89 | } |
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | 91 | try { |
92 | 92 | $sth = $Connection->db->prepare($query); |
93 | 93 | $sth->execute(); |
94 | - } catch(PDOException $e) { |
|
94 | + } catch (PDOException $e) { |
|
95 | 95 | return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
96 | 96 | } |
97 | 97 | // Add auto_increment for aircraft_modes |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | try { |
100 | 100 | $sth = $Connection->db->prepare($query); |
101 | 101 | $sth->execute(); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
104 | 104 | } |
105 | 105 | $error = ''; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | try { |
111 | 111 | $sth = $Connection->db->prepare($query); |
112 | 112 | $sth->execute(); |
113 | - } catch(PDOException $e) { |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
115 | 115 | } |
116 | 116 | return $error; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | try { |
124 | 124 | $sth = $Connection->db->prepare($query); |
125 | 125 | $sth->execute(); |
126 | - } catch(PDOException $e) { |
|
126 | + } catch (PDOException $e) { |
|
127 | 127 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
128 | 128 | } |
129 | 129 | $error = ''; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | try { |
135 | 135 | $sth = $Connection->db->prepare($query); |
136 | 136 | $sth->execute(); |
137 | - } catch(PDOException $e) { |
|
137 | + } catch (PDOException $e) { |
|
138 | 138 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
139 | 139 | } |
140 | 140 | return $error; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | try { |
148 | 148 | $sth = $Connection->db->prepare($query); |
149 | 149 | $sth->execute(); |
150 | - } catch(PDOException $e) { |
|
150 | + } catch (PDOException $e) { |
|
151 | 151 | return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
152 | 152 | } |
153 | 153 | // Add image_source_website column to spotter_image |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | try { |
156 | 156 | $sth = $Connection->db->prepare($query); |
157 | 157 | $sth->execute(); |
158 | - } catch(PDOException $e) { |
|
158 | + } catch (PDOException $e) { |
|
159 | 159 | return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
160 | 160 | } |
161 | 161 | $error = ''; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $sth = $Connection->db->prepare($query); |
166 | 166 | $sth->execute(); |
167 | - } catch(PDOException $e) { |
|
167 | + } catch (PDOException $e) { |
|
168 | 168 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
169 | 169 | } |
170 | 170 | return $error; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | try { |
183 | 183 | $sth = $Connection->db->prepare($query); |
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch (PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | 187 | } |
188 | 188 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $Connection->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
201 | 201 | } |
202 | 202 | // Add aircraft_shadow column to aircraft |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | try { |
205 | 205 | $sth = $Connection->db->prepare($query); |
206 | 206 | $sth->execute(); |
207 | - } catch(PDOException $e) { |
|
207 | + } catch (PDOException $e) { |
|
208 | 208 | return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
209 | 209 | } |
210 | 210 | // Add aircraft_shadow column to spotter_live |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | $sth = $Connection->db->prepare($query); |
214 | 214 | $sth->execute(); |
215 | - } catch(PDOException $e) { |
|
215 | + } catch (PDOException $e) { |
|
216 | 216 | return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
217 | 217 | } |
218 | 218 | $error = ''; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | try { |
226 | 226 | $sth = $Connection->db->prepare($query); |
227 | 227 | $sth->execute(); |
228 | - } catch(PDOException $e) { |
|
228 | + } catch (PDOException $e) { |
|
229 | 229 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
230 | 230 | } |
231 | 231 | return $error; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | 235 | $Connection = new Connection(); |
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
236 | + if (!$Connection->indexExists('spotter_output', 'flightaware_id')) { |
|
237 | 237 | $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | 255 | } |
256 | 256 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | try { |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | 267 | $sth->execute(); |
268 | - } catch(PDOException $e) { |
|
268 | + } catch (PDOException $e) { |
|
269 | 269 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
270 | 270 | } |
271 | 271 | return $error; |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | 276 | $Connection = new Connection(); |
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
277 | + $query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | 279 | try { |
280 | 280 | $sth = $Connection->db->prepare($query); |
281 | 281 | $sth->execute(); |
282 | - } catch(PDOException $e) { |
|
282 | + } catch (PDOException $e) { |
|
283 | 283 | return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
284 | 284 | } |
285 | 285 | if ($globalDBdriver == 'mysql') { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | try { |
288 | 288 | $sth = $Connection->db->prepare($query); |
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch (PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | 292 | } |
293 | 293 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | 301 | } else { |
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
302 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | 303 | } |
304 | 304 | } else { |
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
305 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | 306 | } |
307 | 307 | try { |
308 | 308 | $sth = $Connection->db->prepare($query); |
309 | 309 | $sth->execute(); |
310 | - } catch(PDOException $e) { |
|
310 | + } catch (PDOException $e) { |
|
311 | 311 | return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
312 | 312 | } |
313 | 313 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | try { |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | 322 | $sth->execute(); |
323 | - } catch(PDOException $e) { |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
325 | 325 | } |
326 | 326 | return $error; |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | try { |
340 | 340 | $sth = $Connection->db->prepare($query); |
341 | 341 | $sth->execute(); |
342 | - } catch(PDOException $e) { |
|
342 | + } catch (PDOException $e) { |
|
343 | 343 | return "error (insert last_update values) : ".$e->getMessage()."\n"; |
344 | 344 | } |
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | 346 | try { |
347 | 347 | $sth = $Connection->db->prepare($query); |
348 | 348 | $sth->execute(); |
349 | - } catch(PDOException $e) { |
|
349 | + } catch (PDOException $e) { |
|
350 | 350 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
351 | 351 | } |
352 | 352 | return $error; |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | 356 | $Connection = new Connection(); |
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
357 | + $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | 359 | try { |
360 | 360 | $sth = $Connection->db->prepare($query); |
361 | 361 | $sth->execute(); |
362 | - } catch(PDOException $e) { |
|
362 | + } catch (PDOException $e) { |
|
363 | 363 | return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
364 | 364 | } |
365 | 365 | $error = ''; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | try { |
372 | 372 | $sth = $Connection->db->prepare($query); |
373 | 373 | $sth->execute(); |
374 | - } catch(PDOException $e) { |
|
374 | + } catch (PDOException $e) { |
|
375 | 375 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
376 | 376 | } |
377 | 377 | return $error; |
@@ -379,11 +379,11 @@ discard block |
||
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | 381 | $Connection = new Connection(); |
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
382 | + $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | 383 | try { |
384 | 384 | $sth = $Connection->db->prepare($query); |
385 | 385 | $sth->execute(); |
386 | - } catch(PDOException $e) { |
|
386 | + } catch (PDOException $e) { |
|
387 | 387 | return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
388 | 388 | } |
389 | 389 | $error = ''; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | try { |
402 | 402 | $sth = $Connection->db->prepare($query); |
403 | 403 | $sth->execute(); |
404 | - } catch(PDOException $e) { |
|
404 | + } catch (PDOException $e) { |
|
405 | 405 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
406 | 406 | } |
407 | 407 | return $error; |
@@ -410,18 +410,18 @@ discard block |
||
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | 412 | $Connection = new Connection(); |
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
413 | + $query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | 414 | try { |
415 | 415 | $sth = $Connection->db->prepare($query); |
416 | 416 | $sth->execute(); |
417 | - } catch(PDOException $e) { |
|
417 | + } catch (PDOException $e) { |
|
418 | 418 | return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
419 | 419 | } |
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
420 | + $query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | 421 | try { |
422 | 422 | $sth = $Connection->db->prepare($query); |
423 | 423 | $sth->execute(); |
424 | - } catch(PDOException $e) { |
|
424 | + } catch (PDOException $e) { |
|
425 | 425 | return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
426 | 426 | } |
427 | 427 | if ($globalDBdriver == 'mysql') { |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | try { |
430 | 430 | $sth = $Connection->db->prepare($query); |
431 | 431 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
432 | + } catch (PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | 434 | } |
435 | 435 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -441,15 +441,15 @@ discard block |
||
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | 443 | } else { |
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
444 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | 445 | } |
446 | 446 | } else { |
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
447 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | 448 | } |
449 | 449 | try { |
450 | 450 | $sth = $Connection->db->prepare($query); |
451 | 451 | $sth->execute(); |
452 | - } catch(PDOException $e) { |
|
452 | + } catch (PDOException $e) { |
|
453 | 453 | return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
454 | 454 | } |
455 | 455 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | try { |
460 | 460 | $sth = $Connection->db->prepare($query); |
461 | 461 | $sth->execute(); |
462 | - } catch(PDOException $e) { |
|
462 | + } catch (PDOException $e) { |
|
463 | 463 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
464 | 464 | } |
465 | 465 | return $error; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | try { |
488 | 488 | $sth = $Connection->db->prepare($query); |
489 | 489 | $sth->execute(); |
490 | - } catch(PDOException $e) { |
|
490 | + } catch (PDOException $e) { |
|
491 | 491 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
492 | 492 | } |
493 | 493 | return $error; |
@@ -495,12 +495,12 @@ discard block |
||
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | 497 | $Connection = new Connection(); |
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) { |
|
499 | + $query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch (PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | 505 | } |
506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | try { |
510 | 510 | $sth = $Connection->db->prepare($query); |
511 | 511 | $sth->execute(); |
512 | - } catch(PDOException $e) { |
|
512 | + } catch (PDOException $e) { |
|
513 | 513 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
514 | 514 | } |
515 | 515 | return $error; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $Connection->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
532 | 532 | } |
533 | 533 | return $error; |
@@ -538,11 +538,11 @@ discard block |
||
538 | 538 | $Connection = new Connection(); |
539 | 539 | $error = ''; |
540 | 540 | // Add tables |
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
541 | + $query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | 542 | try { |
543 | 543 | $sth = $Connection->db->prepare($query); |
544 | 544 | $sth->execute(); |
545 | - } catch(PDOException $e) { |
|
545 | + } catch (PDOException $e) { |
|
546 | 546 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 547 | } |
548 | 548 | if ($error != '') return $error; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | try { |
551 | 551 | $sth = $Connection->db->prepare($query); |
552 | 552 | $sth->execute(); |
553 | - } catch(PDOException $e) { |
|
553 | + } catch (PDOException $e) { |
|
554 | 554 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
555 | 555 | } |
556 | 556 | return $error; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | try { |
572 | 572 | $sth = $Connection->db->prepare($query); |
573 | 573 | $sth->execute(); |
574 | - } catch(PDOException $e) { |
|
574 | + } catch (PDOException $e) { |
|
575 | 575 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
576 | 576 | } |
577 | 577 | return $error; |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | try { |
590 | 590 | $sth = $Connection->db->prepare($query); |
591 | 591 | $sth->execute(); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
594 | 594 | } |
595 | 595 | return $error; |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | $Connection = new Connection(); |
599 | 599 | $error = ''; |
600 | 600 | // Modify stats_airport table |
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
601 | + if (!$Connection->checkColumnName('stats_airport', 'airport_name')) { |
|
602 | 602 | $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
603 | 603 | try { |
604 | 604 | $sth = $Connection->db->prepare($query); |
605 | 605 | $sth->execute(); |
606 | - } catch(PDOException $e) { |
|
606 | + } catch (PDOException $e) { |
|
607 | 607 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 608 | } |
609 | 609 | } |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | try { |
613 | 613 | $sth = $Connection->db->prepare($query); |
614 | 614 | $sth->execute(); |
615 | - } catch(PDOException $e) { |
|
615 | + } catch (PDOException $e) { |
|
616 | 616 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
617 | 617 | } |
618 | 618 | return $error; |
@@ -629,73 +629,73 @@ discard block |
||
629 | 629 | try { |
630 | 630 | $sth = $Connection->db->prepare($query); |
631 | 631 | $sth->execute(); |
632 | - } catch(PDOException $e) { |
|
632 | + } catch (PDOException $e) { |
|
633 | 633 | return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
634 | 634 | } |
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | 636 | try { |
637 | 637 | $sth = $Connection->db->prepare($query); |
638 | 638 | $sth->execute(); |
639 | - } catch(PDOException $e) { |
|
639 | + } catch (PDOException $e) { |
|
640 | 640 | return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
641 | 641 | } |
642 | - if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
|
642 | + if (!$Connection->checkColumnName('spotter_archive', 'over_country')) { |
|
643 | 643 | // Add column over_country |
644 | 644 | $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
645 | 645 | try { |
646 | 646 | $sth = $Connection->db->prepare($query); |
647 | 647 | $sth->execute(); |
648 | - } catch(PDOException $e) { |
|
648 | + } catch (PDOException $e) { |
|
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
650 | 650 | } |
651 | 651 | } |
652 | - if (!$Connection->checkColumnName('spotter_live','over_country')) { |
|
652 | + if (!$Connection->checkColumnName('spotter_live', 'over_country')) { |
|
653 | 653 | // Add column over_country |
654 | 654 | $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
655 | 655 | try { |
656 | 656 | $sth = $Connection->db->prepare($query); |
657 | 657 | $sth->execute(); |
658 | - } catch(PDOException $e) { |
|
658 | + } catch (PDOException $e) { |
|
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
660 | 660 | } |
661 | 661 | } |
662 | - if (!$Connection->checkColumnName('spotter_output','source_name')) { |
|
662 | + if (!$Connection->checkColumnName('spotter_output', 'source_name')) { |
|
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | 664 | $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | - } catch(PDOException $e) { |
|
668 | + } catch (PDOException $e) { |
|
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | 670 | } |
671 | 671 | } |
672 | - if (!$Connection->checkColumnName('spotter_live','source_name')) { |
|
672 | + if (!$Connection->checkColumnName('spotter_live', 'source_name')) { |
|
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | 674 | $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | - } catch(PDOException $e) { |
|
678 | + } catch (PDOException $e) { |
|
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | 680 | } |
681 | 681 | } |
682 | - if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
|
682 | + if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) { |
|
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | 684 | $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | - } catch(PDOException $e) { |
|
688 | + } catch (PDOException $e) { |
|
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | 690 | } |
691 | 691 | } |
692 | - if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
|
692 | + if (!$Connection->checkColumnName('spotter_archive', 'source_name')) { |
|
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | 694 | $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | - } catch(PDOException $e) { |
|
698 | + } catch (PDOException $e) { |
|
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 700 | } |
701 | 701 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | try { |
705 | 705 | $sth = $Connection->db->prepare($query); |
706 | 706 | $sth->execute(); |
707 | - } catch(PDOException $e) { |
|
707 | + } catch (PDOException $e) { |
|
708 | 708 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
709 | 709 | } |
710 | 710 | return $error; |
@@ -719,13 +719,13 @@ discard block |
||
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | - if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
|
722 | + if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) { |
|
723 | 723 | // Add column over_country |
724 | 724 | $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
725 | 725 | try { |
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | - } catch(PDOException $e) { |
|
728 | + } catch (PDOException $e) { |
|
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 730 | } |
731 | 731 | } |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | try { |
742 | 742 | $sth = $Connection->db->prepare($query); |
743 | 743 | $sth->execute(); |
744 | - } catch(PDOException $e) { |
|
744 | + } catch (PDOException $e) { |
|
745 | 745 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
746 | 746 | } |
747 | 747 | return $error; |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | private static function update_from_21() { |
751 | 751 | $Connection = new Connection(); |
752 | 752 | $error = ''; |
753 | - if (!$Connection->checkColumnName('stats_airport','stats_type')) { |
|
753 | + if (!$Connection->checkColumnName('stats_airport', 'stats_type')) { |
|
754 | 754 | // Rename type to stats_type |
755 | 755 | $query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; |
756 | 756 | try { |
757 | 757 | $sth = $Connection->db->prepare($query); |
758 | 758 | $sth->execute(); |
759 | - } catch(PDOException $e) { |
|
759 | + } catch (PDOException $e) { |
|
760 | 760 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 761 | } |
762 | 762 | if ($error != '') return $error; |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | try { |
766 | 766 | $sth = $Connection->db->prepare($query); |
767 | 767 | $sth->execute(); |
768 | - } catch(PDOException $e) { |
|
768 | + } catch (PDOException $e) { |
|
769 | 769 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
770 | 770 | } |
771 | 771 | return $error; |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | try { |
789 | 789 | $sth = $Connection->db->prepare($query); |
790 | 790 | $sth->execute(); |
791 | - } catch(PDOException $e) { |
|
791 | + } catch (PDOException $e) { |
|
792 | 792 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
793 | 793 | } |
794 | 794 | return $error; |
@@ -814,17 +814,17 @@ discard block |
||
814 | 814 | try { |
815 | 815 | $sth = $Connection->db->prepare($query); |
816 | 816 | $sth->execute(); |
817 | - } catch(PDOException $e) { |
|
817 | + } catch (PDOException $e) { |
|
818 | 818 | return "error (create index on spotter_archive) : ".$e->getMessage()."\n"; |
819 | 819 | } |
820 | 820 | } |
821 | - if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
|
821 | + if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) { |
|
822 | 822 | // Add aircraft_manufacturer to stats_aircraft |
823 | 823 | $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
824 | 824 | try { |
825 | 825 | $sth = $Connection->db->prepare($query); |
826 | 826 | $sth->execute(); |
827 | - } catch(PDOException $e) { |
|
827 | + } catch (PDOException $e) { |
|
828 | 828 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
829 | 829 | } |
830 | 830 | } |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | try { |
834 | 834 | $sth = $Connection->db->prepare($query); |
835 | 835 | $sth->execute(); |
836 | - } catch(PDOException $e) { |
|
836 | + } catch (PDOException $e) { |
|
837 | 837 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
838 | 838 | } |
839 | 839 | return $error; |
@@ -849,23 +849,23 @@ discard block |
||
849 | 849 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
850 | 850 | } |
851 | 851 | if ($error != '') return 'Import airlines.sql : '.$error; |
852 | - if (!$Connection->checkColumnName('airlines','forsource')) { |
|
852 | + if (!$Connection->checkColumnName('airlines', 'forsource')) { |
|
853 | 853 | // Add forsource to airlines |
854 | 854 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
855 | 855 | try { |
856 | 856 | $sth = $Connection->db->prepare($query); |
857 | 857 | $sth->execute(); |
858 | - } catch(PDOException $e) { |
|
858 | + } catch (PDOException $e) { |
|
859 | 859 | return "error (add forsource column) : ".$e->getMessage()."\n"; |
860 | 860 | } |
861 | 861 | } |
862 | - if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) { |
|
862 | + if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) { |
|
863 | 863 | // Add forsource to airlines |
864 | 864 | $query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
865 | 865 | try { |
866 | 866 | $sth = $Connection->db->prepare($query); |
867 | 867 | $sth->execute(); |
868 | - } catch(PDOException $e) { |
|
868 | + } catch (PDOException $e) { |
|
869 | 869 | return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n"; |
870 | 870 | } |
871 | 871 | // Add unique key |
@@ -877,17 +877,17 @@ discard block |
||
877 | 877 | try { |
878 | 878 | $sth = $Connection->db->prepare($query); |
879 | 879 | $sth->execute(); |
880 | - } catch(PDOException $e) { |
|
880 | + } catch (PDOException $e) { |
|
881 | 881 | return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n"; |
882 | 882 | } |
883 | 883 | } |
884 | - if (!$Connection->checkColumnName('stats_airport','stats_airline')) { |
|
884 | + if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) { |
|
885 | 885 | // Add forsource to airlines |
886 | 886 | $query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
887 | 887 | try { |
888 | 888 | $sth = $Connection->db->prepare($query); |
889 | 889 | $sth->execute(); |
890 | - } catch(PDOException $e) { |
|
890 | + } catch (PDOException $e) { |
|
891 | 891 | return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n"; |
892 | 892 | } |
893 | 893 | // Add unique key |
@@ -899,17 +899,17 @@ discard block |
||
899 | 899 | try { |
900 | 900 | $sth = $Connection->db->prepare($query); |
901 | 901 | $sth->execute(); |
902 | - } catch(PDOException $e) { |
|
902 | + } catch (PDOException $e) { |
|
903 | 903 | return "error (add unique key in stats_airport) : ".$e->getMessage()."\n"; |
904 | 904 | } |
905 | 905 | } |
906 | - if (!$Connection->checkColumnName('stats_country','stats_airline')) { |
|
906 | + if (!$Connection->checkColumnName('stats_country', 'stats_airline')) { |
|
907 | 907 | // Add forsource to airlines |
908 | 908 | $query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
909 | 909 | try { |
910 | 910 | $sth = $Connection->db->prepare($query); |
911 | 911 | $sth->execute(); |
912 | - } catch(PDOException $e) { |
|
912 | + } catch (PDOException $e) { |
|
913 | 913 | return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n"; |
914 | 914 | } |
915 | 915 | // Add unique key |
@@ -921,36 +921,36 @@ discard block |
||
921 | 921 | try { |
922 | 922 | $sth = $Connection->db->prepare($query); |
923 | 923 | $sth->execute(); |
924 | - } catch(PDOException $e) { |
|
924 | + } catch (PDOException $e) { |
|
925 | 925 | return "error (add unique key in stats_airline) : ".$e->getMessage()."\n"; |
926 | 926 | } |
927 | 927 | } |
928 | - if (!$Connection->checkColumnName('stats_flight','stats_airline')) { |
|
928 | + if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) { |
|
929 | 929 | // Add forsource to airlines |
930 | 930 | $query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
931 | 931 | try { |
932 | 932 | $sth = $Connection->db->prepare($query); |
933 | 933 | $sth->execute(); |
934 | - } catch(PDOException $e) { |
|
934 | + } catch (PDOException $e) { |
|
935 | 935 | return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n"; |
936 | 936 | } |
937 | 937 | } |
938 | - if (!$Connection->checkColumnName('stats','stats_airline')) { |
|
938 | + if (!$Connection->checkColumnName('stats', 'stats_airline')) { |
|
939 | 939 | // Add forsource to airlines |
940 | 940 | $query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
941 | 941 | try { |
942 | 942 | $sth = $Connection->db->prepare($query); |
943 | 943 | $sth->execute(); |
944 | - } catch(PDOException $e) { |
|
944 | + } catch (PDOException $e) { |
|
945 | 945 | return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n"; |
946 | 946 | } |
947 | - if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) { |
|
947 | + if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) { |
|
948 | 948 | // Add unique key |
949 | 949 | $query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);"; |
950 | 950 | try { |
951 | 951 | $sth = $Connection->db->prepare($query); |
952 | 952 | $sth->execute(); |
953 | - } catch(PDOException $e) { |
|
953 | + } catch (PDOException $e) { |
|
954 | 954 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
955 | 955 | } |
956 | 956 | } else { |
@@ -963,18 +963,18 @@ discard block |
||
963 | 963 | try { |
964 | 964 | $sth = $Connection->db->prepare($query); |
965 | 965 | $sth->execute(); |
966 | - } catch(PDOException $e) { |
|
966 | + } catch (PDOException $e) { |
|
967 | 967 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
968 | 968 | } |
969 | 969 | } |
970 | 970 | } |
971 | - if (!$Connection->checkColumnName('stats_registration','stats_airline')) { |
|
971 | + if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) { |
|
972 | 972 | // Add forsource to airlines |
973 | 973 | $query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
974 | 974 | try { |
975 | 975 | $sth = $Connection->db->prepare($query); |
976 | 976 | $sth->execute(); |
977 | - } catch(PDOException $e) { |
|
977 | + } catch (PDOException $e) { |
|
978 | 978 | return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n"; |
979 | 979 | } |
980 | 980 | // Add unique key |
@@ -986,17 +986,17 @@ discard block |
||
986 | 986 | try { |
987 | 987 | $sth = $Connection->db->prepare($query); |
988 | 988 | $sth->execute(); |
989 | - } catch(PDOException $e) { |
|
989 | + } catch (PDOException $e) { |
|
990 | 990 | return "error (add unique key in stats_registration) : ".$e->getMessage()."\n"; |
991 | 991 | } |
992 | 992 | } |
993 | - if (!$Connection->checkColumnName('stats_callsign','filter_name')) { |
|
993 | + if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) { |
|
994 | 994 | // Add forsource to airlines |
995 | 995 | $query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
996 | 996 | try { |
997 | 997 | $sth = $Connection->db->prepare($query); |
998 | 998 | $sth->execute(); |
999 | - } catch(PDOException $e) { |
|
999 | + } catch (PDOException $e) { |
|
1000 | 1000 | return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n"; |
1001 | 1001 | } |
1002 | 1002 | // Add unique key |
@@ -1008,17 +1008,17 @@ discard block |
||
1008 | 1008 | try { |
1009 | 1009 | $sth = $Connection->db->prepare($query); |
1010 | 1010 | $sth->execute(); |
1011 | - } catch(PDOException $e) { |
|
1011 | + } catch (PDOException $e) { |
|
1012 | 1012 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1013 | 1013 | } |
1014 | 1014 | } |
1015 | - if (!$Connection->checkColumnName('stats_airline','filter_name')) { |
|
1015 | + if (!$Connection->checkColumnName('stats_airline', 'filter_name')) { |
|
1016 | 1016 | // Add forsource to airlines |
1017 | 1017 | $query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1018 | 1018 | try { |
1019 | 1019 | $sth = $Connection->db->prepare($query); |
1020 | 1020 | $sth->execute(); |
1021 | - } catch(PDOException $e) { |
|
1021 | + } catch (PDOException $e) { |
|
1022 | 1022 | return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n"; |
1023 | 1023 | } |
1024 | 1024 | // Add unique key |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | try { |
1031 | 1031 | $sth = $Connection->db->prepare($query); |
1032 | 1032 | $sth->execute(); |
1033 | - } catch(PDOException $e) { |
|
1033 | + } catch (PDOException $e) { |
|
1034 | 1034 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1035 | 1035 | } |
1036 | 1036 | } |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | try { |
1040 | 1040 | $sth = $Connection->db->prepare($query); |
1041 | 1041 | $sth->execute(); |
1042 | - } catch(PDOException $e) { |
|
1042 | + } catch (PDOException $e) { |
|
1043 | 1043 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1044 | 1044 | } |
1045 | 1045 | return $error; |
@@ -1049,13 +1049,13 @@ discard block |
||
1049 | 1049 | global $globalDBdriver; |
1050 | 1050 | $Connection = new Connection(); |
1051 | 1051 | $error = ''; |
1052 | - if (!$Connection->checkColumnName('stats_owner','stats_airline')) { |
|
1052 | + if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) { |
|
1053 | 1053 | // Add forsource to airlines |
1054 | 1054 | $query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1055 | 1055 | try { |
1056 | 1056 | $sth = $Connection->db->prepare($query); |
1057 | 1057 | $sth->execute(); |
1058 | - } catch(PDOException $e) { |
|
1058 | + } catch (PDOException $e) { |
|
1059 | 1059 | return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n"; |
1060 | 1060 | } |
1061 | 1061 | // Add unique key |
@@ -1067,17 +1067,17 @@ discard block |
||
1067 | 1067 | try { |
1068 | 1068 | $sth = $Connection->db->prepare($query); |
1069 | 1069 | $sth->execute(); |
1070 | - } catch(PDOException $e) { |
|
1070 | + } catch (PDOException $e) { |
|
1071 | 1071 | return "error (add unique key in stats_owner) : ".$e->getMessage()."\n"; |
1072 | 1072 | } |
1073 | 1073 | } |
1074 | - if (!$Connection->checkColumnName('stats_pilot','stats_airline')) { |
|
1074 | + if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) { |
|
1075 | 1075 | // Add forsource to airlines |
1076 | 1076 | $query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1077 | 1077 | try { |
1078 | 1078 | $sth = $Connection->db->prepare($query); |
1079 | 1079 | $sth->execute(); |
1080 | - } catch(PDOException $e) { |
|
1080 | + } catch (PDOException $e) { |
|
1081 | 1081 | return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n"; |
1082 | 1082 | } |
1083 | 1083 | // Add unique key |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | try { |
1090 | 1090 | $sth = $Connection->db->prepare($query); |
1091 | 1091 | $sth->execute(); |
1092 | - } catch(PDOException $e) { |
|
1092 | + } catch (PDOException $e) { |
|
1093 | 1093 | return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1094 | 1094 | } |
1095 | 1095 | } |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | try { |
1098 | 1098 | $sth = $Connection->db->prepare($query); |
1099 | 1099 | $sth->execute(); |
1100 | - } catch(PDOException $e) { |
|
1100 | + } catch (PDOException $e) { |
|
1101 | 1101 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1102 | 1102 | } |
1103 | 1103 | return $error; |
@@ -1107,12 +1107,12 @@ discard block |
||
1107 | 1107 | global $globalDBdriver; |
1108 | 1108 | $Connection = new Connection(); |
1109 | 1109 | $error = ''; |
1110 | - if (!$Connection->checkColumnName('atc','format_source')) { |
|
1110 | + if (!$Connection->checkColumnName('atc', 'format_source')) { |
|
1111 | 1111 | $query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL"; |
1112 | 1112 | try { |
1113 | 1113 | $sth = $Connection->db->prepare($query); |
1114 | 1114 | $sth->execute(); |
1115 | - } catch(PDOException $e) { |
|
1115 | + } catch (PDOException $e) { |
|
1116 | 1116 | return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n"; |
1117 | 1117 | } |
1118 | 1118 | } |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | try { |
1121 | 1121 | $sth = $Connection->db->prepare($query); |
1122 | 1122 | $sth->execute(); |
1123 | - } catch(PDOException $e) { |
|
1123 | + } catch (PDOException $e) { |
|
1124 | 1124 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1125 | 1125 | } |
1126 | 1126 | return $error; |
@@ -1130,13 +1130,13 @@ discard block |
||
1130 | 1130 | global $globalDBdriver; |
1131 | 1131 | $Connection = new Connection(); |
1132 | 1132 | $error = ''; |
1133 | - if (!$Connection->checkColumnName('stats_pilot','format_source')) { |
|
1133 | + if (!$Connection->checkColumnName('stats_pilot', 'format_source')) { |
|
1134 | 1134 | // Add forsource to airlines |
1135 | 1135 | $query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''"; |
1136 | 1136 | try { |
1137 | 1137 | $sth = $Connection->db->prepare($query); |
1138 | 1138 | $sth->execute(); |
1139 | - } catch(PDOException $e) { |
|
1139 | + } catch (PDOException $e) { |
|
1140 | 1140 | return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n"; |
1141 | 1141 | } |
1142 | 1142 | // Add unique key |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | try { |
1149 | 1149 | $sth = $Connection->db->prepare($query); |
1150 | 1150 | $sth->execute(); |
1151 | - } catch(PDOException $e) { |
|
1151 | + } catch (PDOException $e) { |
|
1152 | 1152 | return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1153 | 1153 | } |
1154 | 1154 | } |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | try { |
1157 | 1157 | $sth = $Connection->db->prepare($query); |
1158 | 1158 | $sth->execute(); |
1159 | - } catch(PDOException $e) { |
|
1159 | + } catch (PDOException $e) { |
|
1160 | 1160 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1161 | 1161 | } |
1162 | 1162 | return $error; |
@@ -1166,23 +1166,23 @@ discard block |
||
1166 | 1166 | global $globalDBdriver; |
1167 | 1167 | $Connection = new Connection(); |
1168 | 1168 | $error = ''; |
1169 | - if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) { |
|
1169 | + if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) { |
|
1170 | 1170 | // Add unique key |
1171 | 1171 | $query = "alter table spotter_live add index(latitude,longitude)"; |
1172 | 1172 | try { |
1173 | 1173 | $sth = $Connection->db->prepare($query); |
1174 | 1174 | $sth->execute(); |
1175 | - } catch(PDOException $e) { |
|
1175 | + } catch (PDOException $e) { |
|
1176 | 1176 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; |
1177 | 1177 | } |
1178 | 1178 | } |
1179 | - if (!$Connection->checkColumnName('aircraft','mfr')) { |
|
1179 | + if (!$Connection->checkColumnName('aircraft', 'mfr')) { |
|
1180 | 1180 | // Add mfr to aircraft |
1181 | 1181 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; |
1182 | 1182 | try { |
1183 | 1183 | $sth = $Connection->db->prepare($query); |
1184 | 1184 | $sth->execute(); |
1185 | - } catch(PDOException $e) { |
|
1185 | + } catch (PDOException $e) { |
|
1186 | 1186 | return "error (add mfr column in aircraft) : ".$e->getMessage()."\n"; |
1187 | 1187 | } |
1188 | 1188 | } |
@@ -1198,7 +1198,7 @@ discard block |
||
1198 | 1198 | try { |
1199 | 1199 | $sth = $Connection->db->prepare($query); |
1200 | 1200 | $sth->execute(); |
1201 | - } catch(PDOException $e) { |
|
1201 | + } catch (PDOException $e) { |
|
1202 | 1202 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1203 | 1203 | } |
1204 | 1204 | return $error; |
@@ -1208,13 +1208,13 @@ discard block |
||
1208 | 1208 | global $globalDBdriver; |
1209 | 1209 | $Connection = new Connection(); |
1210 | 1210 | $error = ''; |
1211 | - if ($Connection->checkColumnName('aircraft','mfr')) { |
|
1211 | + if ($Connection->checkColumnName('aircraft', 'mfr')) { |
|
1212 | 1212 | // drop mfr to aircraft |
1213 | 1213 | $query = "ALTER TABLE aircraft DROP COLUMN mfr"; |
1214 | 1214 | try { |
1215 | 1215 | $sth = $Connection->db->prepare($query); |
1216 | 1216 | $sth->execute(); |
1217 | - } catch(PDOException $e) { |
|
1217 | + } catch (PDOException $e) { |
|
1218 | 1218 | return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n"; |
1219 | 1219 | } |
1220 | 1220 | } |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | try { |
1231 | 1231 | $sth = $Connection->db->prepare($query); |
1232 | 1232 | $sth->execute(); |
1233 | - } catch(PDOException $e) { |
|
1233 | + } catch (PDOException $e) { |
|
1234 | 1234 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1235 | 1235 | } |
1236 | 1236 | return $error; |
@@ -1240,33 +1240,33 @@ discard block |
||
1240 | 1240 | global $globalDBdriver; |
1241 | 1241 | $Connection = new Connection(); |
1242 | 1242 | $error = ''; |
1243 | - if (!$Connection->indexExists('notam','ref_idx')) { |
|
1243 | + if (!$Connection->indexExists('notam', 'ref_idx')) { |
|
1244 | 1244 | // Add index key |
1245 | 1245 | $query = "create index ref_idx on notam (ref)"; |
1246 | 1246 | try { |
1247 | 1247 | $sth = $Connection->db->prepare($query); |
1248 | 1248 | $sth->execute(); |
1249 | - } catch(PDOException $e) { |
|
1249 | + } catch (PDOException $e) { |
|
1250 | 1250 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; |
1251 | 1251 | } |
1252 | 1252 | } |
1253 | - if (!$Connection->indexExists('accidents','registration_idx')) { |
|
1253 | + if (!$Connection->indexExists('accidents', 'registration_idx')) { |
|
1254 | 1254 | // Add index key |
1255 | 1255 | $query = "create index registration_idx on accidents (registration)"; |
1256 | 1256 | try { |
1257 | 1257 | $sth = $Connection->db->prepare($query); |
1258 | 1258 | $sth->execute(); |
1259 | - } catch(PDOException $e) { |
|
1259 | + } catch (PDOException $e) { |
|
1260 | 1260 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; |
1261 | 1261 | } |
1262 | 1262 | } |
1263 | - if (!$Connection->indexExists('accidents','rdts')) { |
|
1263 | + if (!$Connection->indexExists('accidents', 'rdts')) { |
|
1264 | 1264 | // Add index key |
1265 | 1265 | $query = "create index rdts on accidents (registration,date,type,source)"; |
1266 | 1266 | try { |
1267 | 1267 | $sth = $Connection->db->prepare($query); |
1268 | 1268 | $sth->execute(); |
1269 | - } catch(PDOException $e) { |
|
1269 | + } catch (PDOException $e) { |
|
1270 | 1270 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; |
1271 | 1271 | } |
1272 | 1272 | } |
@@ -1275,7 +1275,7 @@ discard block |
||
1275 | 1275 | try { |
1276 | 1276 | $sth = $Connection->db->prepare($query); |
1277 | 1277 | $sth->execute(); |
1278 | - } catch(PDOException $e) { |
|
1278 | + } catch (PDOException $e) { |
|
1279 | 1279 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1280 | 1280 | } |
1281 | 1281 | return $error; |
@@ -1285,23 +1285,23 @@ discard block |
||
1285 | 1285 | global $globalDBdriver; |
1286 | 1286 | $Connection = new Connection(); |
1287 | 1287 | $error = ''; |
1288 | - if (!$Connection->checkColumnName('accidents','airline_name')) { |
|
1288 | + if (!$Connection->checkColumnName('accidents', 'airline_name')) { |
|
1289 | 1289 | // Add airline_name to accidents |
1290 | 1290 | $query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL"; |
1291 | 1291 | try { |
1292 | 1292 | $sth = $Connection->db->prepare($query); |
1293 | 1293 | $sth->execute(); |
1294 | - } catch(PDOException $e) { |
|
1294 | + } catch (PDOException $e) { |
|
1295 | 1295 | return "error (add airline_name column in accidents) : ".$e->getMessage()."\n"; |
1296 | 1296 | } |
1297 | 1297 | } |
1298 | - if (!$Connection->checkColumnName('accidents','airline_icao')) { |
|
1298 | + if (!$Connection->checkColumnName('accidents', 'airline_icao')) { |
|
1299 | 1299 | // Add airline_icao to accidents |
1300 | 1300 | $query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL"; |
1301 | 1301 | try { |
1302 | 1302 | $sth = $Connection->db->prepare($query); |
1303 | 1303 | $sth->execute(); |
1304 | - } catch(PDOException $e) { |
|
1304 | + } catch (PDOException $e) { |
|
1305 | 1305 | return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n"; |
1306 | 1306 | } |
1307 | 1307 | } |
@@ -1309,7 +1309,7 @@ discard block |
||
1309 | 1309 | try { |
1310 | 1310 | $sth = $Connection->db->prepare($query); |
1311 | 1311 | $sth->execute(); |
1312 | - } catch(PDOException $e) { |
|
1312 | + } catch (PDOException $e) { |
|
1313 | 1313 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1314 | 1314 | } |
1315 | 1315 | return $error; |
@@ -1319,13 +1319,13 @@ discard block |
||
1319 | 1319 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
1320 | 1320 | $Connection = new Connection(); |
1321 | 1321 | $error = ''; |
1322 | - if (!$Connection->checkColumnName('airlines','alliance')) { |
|
1322 | + if (!$Connection->checkColumnName('airlines', 'alliance')) { |
|
1323 | 1323 | // Add alliance to airlines |
1324 | 1324 | $query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL"; |
1325 | 1325 | try { |
1326 | 1326 | $sth = $Connection->db->prepare($query); |
1327 | 1327 | $sth->execute(); |
1328 | - } catch(PDOException $e) { |
|
1328 | + } catch (PDOException $e) { |
|
1329 | 1329 | return "error (add alliance column in airlines) : ".$e->getMessage()."\n"; |
1330 | 1330 | } |
1331 | 1331 | } |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | try { |
1353 | 1353 | $sth = $Connection->db->prepare($query); |
1354 | 1354 | $sth->execute(); |
1355 | - } catch(PDOException $e) { |
|
1355 | + } catch (PDOException $e) { |
|
1356 | 1356 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1357 | 1357 | } |
1358 | 1358 | return $error; |
@@ -1362,13 +1362,13 @@ discard block |
||
1362 | 1362 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
1363 | 1363 | $Connection = new Connection(); |
1364 | 1364 | $error = ''; |
1365 | - if (!$Connection->checkColumnName('airlines','ban_eu')) { |
|
1365 | + if (!$Connection->checkColumnName('airlines', 'ban_eu')) { |
|
1366 | 1366 | // Add ban_eu to airlines |
1367 | 1367 | $query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'"; |
1368 | 1368 | try { |
1369 | 1369 | $sth = $Connection->db->prepare($query); |
1370 | 1370 | $sth->execute(); |
1371 | - } catch(PDOException $e) { |
|
1371 | + } catch (PDOException $e) { |
|
1372 | 1372 | return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n"; |
1373 | 1373 | } |
1374 | 1374 | } |
@@ -1376,7 +1376,7 @@ discard block |
||
1376 | 1376 | try { |
1377 | 1377 | $sth = $Connection->db->prepare($query); |
1378 | 1378 | $sth->execute(); |
1379 | - } catch(PDOException $e) { |
|
1379 | + } catch (PDOException $e) { |
|
1380 | 1380 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1381 | 1381 | } |
1382 | 1382 | return $error; |
@@ -1387,19 +1387,19 @@ discard block |
||
1387 | 1387 | $Connection = new Connection(); |
1388 | 1388 | $error = ''; |
1389 | 1389 | if ($globalDBdriver == 'mysql') { |
1390 | - if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') { |
|
1390 | + if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') { |
|
1391 | 1391 | $query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL"; |
1392 | 1392 | try { |
1393 | 1393 | $sth = $Connection->db->prepare($query); |
1394 | 1394 | $sth->execute(); |
1395 | - } catch(PDOException $e) { |
|
1395 | + } catch (PDOException $e) { |
|
1396 | 1396 | return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n"; |
1397 | 1397 | } |
1398 | 1398 | $query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()"; |
1399 | 1399 | try { |
1400 | 1400 | $sth = $Connection->db->prepare($query); |
1401 | 1401 | $sth->execute(); |
1402 | - } catch(PDOException $e) { |
|
1402 | + } catch (PDOException $e) { |
|
1403 | 1403 | return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n"; |
1404 | 1404 | } |
1405 | 1405 | |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | try { |
1408 | 1408 | $sth = $Connection->db->prepare($query); |
1409 | 1409 | $sth->execute(); |
1410 | - } catch(PDOException $e) { |
|
1410 | + } catch (PDOException $e) { |
|
1411 | 1411 | return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n"; |
1412 | 1412 | } |
1413 | 1413 | /*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150"; |
@@ -1458,7 +1458,7 @@ discard block |
||
1458 | 1458 | try { |
1459 | 1459 | $sth = $Connection->db->prepare($query); |
1460 | 1460 | $sth->execute(); |
1461 | - } catch(PDOException $e) { |
|
1461 | + } catch (PDOException $e) { |
|
1462 | 1462 | return "error (fix date) : ".$e->getMessage()."\n"; |
1463 | 1463 | } |
1464 | 1464 | } |
@@ -1543,7 +1543,7 @@ discard block |
||
1543 | 1543 | try { |
1544 | 1544 | $sth = $Connection->db->prepare($query); |
1545 | 1545 | $sth->execute(); |
1546 | - } catch(PDOException $e) { |
|
1546 | + } catch (PDOException $e) { |
|
1547 | 1547 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1548 | 1548 | } |
1549 | 1549 | return $error; |
@@ -1552,13 +1552,13 @@ discard block |
||
1552 | 1552 | global $globalDBdriver; |
1553 | 1553 | $Connection = new Connection(); |
1554 | 1554 | $error = ''; |
1555 | - if (!$Connection->indexExists('accidents','type')) { |
|
1555 | + if (!$Connection->indexExists('accidents', 'type')) { |
|
1556 | 1556 | // Add index key |
1557 | 1557 | $query = "create index type on accidents (type,date)"; |
1558 | 1558 | try { |
1559 | 1559 | $sth = $Connection->db->prepare($query); |
1560 | 1560 | $sth->execute(); |
1561 | - } catch(PDOException $e) { |
|
1561 | + } catch (PDOException $e) { |
|
1562 | 1562 | return "error (add index type on accidents) : ".$e->getMessage()."\n"; |
1563 | 1563 | } |
1564 | 1564 | } |
@@ -1566,7 +1566,7 @@ discard block |
||
1566 | 1566 | try { |
1567 | 1567 | $sth = $Connection->db->prepare($query); |
1568 | 1568 | $sth->execute(); |
1569 | - } catch(PDOException $e) { |
|
1569 | + } catch (PDOException $e) { |
|
1570 | 1570 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1571 | 1571 | } |
1572 | 1572 | return $error; |
@@ -1576,12 +1576,12 @@ discard block |
||
1576 | 1576 | global $globalDBdriver; |
1577 | 1577 | $Connection = new Connection(); |
1578 | 1578 | $error = ''; |
1579 | - if (!$Connection->checkColumnName('aircraft_modes','source_type')) { |
|
1579 | + if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) { |
|
1580 | 1580 | $query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'"; |
1581 | 1581 | try { |
1582 | 1582 | $sth = $Connection->db->prepare($query); |
1583 | 1583 | $sth->execute(); |
1584 | - } catch(PDOException $e) { |
|
1584 | + } catch (PDOException $e) { |
|
1585 | 1585 | return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n"; |
1586 | 1586 | } |
1587 | 1587 | } |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | try { |
1648 | 1648 | $sth = $Connection->db->prepare($query); |
1649 | 1649 | $sth->execute(); |
1650 | - } catch(PDOException $e) { |
|
1650 | + } catch (PDOException $e) { |
|
1651 | 1651 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1652 | 1652 | } |
1653 | 1653 | return $error; |
@@ -1699,7 +1699,7 @@ discard block |
||
1699 | 1699 | try { |
1700 | 1700 | $sth = $Connection->db->prepare($query); |
1701 | 1701 | $sth->execute(); |
1702 | - } catch(PDOException $e) { |
|
1702 | + } catch (PDOException $e) { |
|
1703 | 1703 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
1704 | 1704 | } |
1705 | 1705 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1708,18 +1708,18 @@ discard block |
||
1708 | 1708 | try { |
1709 | 1709 | $sth = $Connection->db->prepare($query); |
1710 | 1710 | $sth->execute(); |
1711 | - } catch(PDOException $e) { |
|
1711 | + } catch (PDOException $e) { |
|
1712 | 1712 | return "error (Change table format from archive to InnoDB for spotter_archive) : ".$e->getMessage()."\n"; |
1713 | 1713 | } |
1714 | 1714 | } |
1715 | 1715 | } |
1716 | - if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) { |
|
1716 | + if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) { |
|
1717 | 1717 | // Add index key |
1718 | 1718 | $query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)"; |
1719 | 1719 | try { |
1720 | 1720 | $sth = $Connection->db->prepare($query); |
1721 | 1721 | $sth->execute(); |
1722 | - } catch(PDOException $e) { |
|
1722 | + } catch (PDOException $e) { |
|
1723 | 1723 | return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n"; |
1724 | 1724 | } |
1725 | 1725 | } |
@@ -1727,7 +1727,7 @@ discard block |
||
1727 | 1727 | try { |
1728 | 1728 | $sth = $Connection->db->prepare($query); |
1729 | 1729 | $sth->execute(); |
1730 | - } catch(PDOException $e) { |
|
1730 | + } catch (PDOException $e) { |
|
1731 | 1731 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1732 | 1732 | } |
1733 | 1733 | return $error; |
@@ -1738,148 +1738,148 @@ discard block |
||
1738 | 1738 | $Connection = new Connection(); |
1739 | 1739 | $error = ''; |
1740 | 1740 | if ($globalDBdriver == 'mysql') { |
1741 | - if (!$Connection->checkColumnName('marine_output','type_id')) { |
|
1741 | + if (!$Connection->checkColumnName('marine_output', 'type_id')) { |
|
1742 | 1742 | $query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL"; |
1743 | 1743 | try { |
1744 | 1744 | $sth = $Connection->db->prepare($query); |
1745 | 1745 | $sth->execute(); |
1746 | - } catch(PDOException $e) { |
|
1746 | + } catch (PDOException $e) { |
|
1747 | 1747 | return "error (add column type_id in marine_output) : ".$e->getMessage()."\n"; |
1748 | 1748 | } |
1749 | 1749 | } |
1750 | - if (!$Connection->checkColumnName('marine_live','type_id')) { |
|
1750 | + if (!$Connection->checkColumnName('marine_live', 'type_id')) { |
|
1751 | 1751 | $query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL"; |
1752 | 1752 | try { |
1753 | 1753 | $sth = $Connection->db->prepare($query); |
1754 | 1754 | $sth->execute(); |
1755 | - } catch(PDOException $e) { |
|
1755 | + } catch (PDOException $e) { |
|
1756 | 1756 | return "error (add column type_id in marine_live) : ".$e->getMessage()."\n"; |
1757 | 1757 | } |
1758 | 1758 | } |
1759 | - if (!$Connection->checkColumnName('marine_archive','type_id')) { |
|
1759 | + if (!$Connection->checkColumnName('marine_archive', 'type_id')) { |
|
1760 | 1760 | $query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL"; |
1761 | 1761 | try { |
1762 | 1762 | $sth = $Connection->db->prepare($query); |
1763 | 1763 | $sth->execute(); |
1764 | - } catch(PDOException $e) { |
|
1764 | + } catch (PDOException $e) { |
|
1765 | 1765 | return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n"; |
1766 | 1766 | } |
1767 | 1767 | } |
1768 | - if (!$Connection->checkColumnName('marine_archive_output','type_id')) { |
|
1768 | + if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) { |
|
1769 | 1769 | $query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL"; |
1770 | 1770 | try { |
1771 | 1771 | $sth = $Connection->db->prepare($query); |
1772 | 1772 | $sth->execute(); |
1773 | - } catch(PDOException $e) { |
|
1773 | + } catch (PDOException $e) { |
|
1774 | 1774 | return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1775 | 1775 | } |
1776 | 1776 | } |
1777 | - if (!$Connection->checkColumnName('marine_output','status_id')) { |
|
1777 | + if (!$Connection->checkColumnName('marine_output', 'status_id')) { |
|
1778 | 1778 | $query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL"; |
1779 | 1779 | try { |
1780 | 1780 | $sth = $Connection->db->prepare($query); |
1781 | 1781 | $sth->execute(); |
1782 | - } catch(PDOException $e) { |
|
1782 | + } catch (PDOException $e) { |
|
1783 | 1783 | return "error (add column status_id in marine_output) : ".$e->getMessage()."\n"; |
1784 | 1784 | } |
1785 | 1785 | } |
1786 | - if (!$Connection->checkColumnName('marine_live','status_id')) { |
|
1786 | + if (!$Connection->checkColumnName('marine_live', 'status_id')) { |
|
1787 | 1787 | $query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL"; |
1788 | 1788 | try { |
1789 | 1789 | $sth = $Connection->db->prepare($query); |
1790 | 1790 | $sth->execute(); |
1791 | - } catch(PDOException $e) { |
|
1791 | + } catch (PDOException $e) { |
|
1792 | 1792 | return "error (add column status_id in marine_live) : ".$e->getMessage()."\n"; |
1793 | 1793 | } |
1794 | 1794 | } |
1795 | - if (!$Connection->checkColumnName('marine_archive','status_id')) { |
|
1795 | + if (!$Connection->checkColumnName('marine_archive', 'status_id')) { |
|
1796 | 1796 | $query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL"; |
1797 | 1797 | try { |
1798 | 1798 | $sth = $Connection->db->prepare($query); |
1799 | 1799 | $sth->execute(); |
1800 | - } catch(PDOException $e) { |
|
1800 | + } catch (PDOException $e) { |
|
1801 | 1801 | return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n"; |
1802 | 1802 | } |
1803 | 1803 | } |
1804 | - if (!$Connection->checkColumnName('marine_archive_output','status_id')) { |
|
1804 | + if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) { |
|
1805 | 1805 | $query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL"; |
1806 | 1806 | try { |
1807 | 1807 | $sth = $Connection->db->prepare($query); |
1808 | 1808 | $sth->execute(); |
1809 | - } catch(PDOException $e) { |
|
1809 | + } catch (PDOException $e) { |
|
1810 | 1810 | return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1811 | 1811 | } |
1812 | 1812 | } |
1813 | 1813 | } else { |
1814 | - if (!$Connection->checkColumnName('marine_output','type_id')) { |
|
1814 | + if (!$Connection->checkColumnName('marine_output', 'type_id')) { |
|
1815 | 1815 | $query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL"; |
1816 | 1816 | try { |
1817 | 1817 | $sth = $Connection->db->prepare($query); |
1818 | 1818 | $sth->execute(); |
1819 | - } catch(PDOException $e) { |
|
1819 | + } catch (PDOException $e) { |
|
1820 | 1820 | return "error (add column type_id in marine_output) : ".$e->getMessage()."\n"; |
1821 | 1821 | } |
1822 | 1822 | } |
1823 | - if (!$Connection->checkColumnName('marine_live','type_id')) { |
|
1823 | + if (!$Connection->checkColumnName('marine_live', 'type_id')) { |
|
1824 | 1824 | $query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL"; |
1825 | 1825 | try { |
1826 | 1826 | $sth = $Connection->db->prepare($query); |
1827 | 1827 | $sth->execute(); |
1828 | - } catch(PDOException $e) { |
|
1828 | + } catch (PDOException $e) { |
|
1829 | 1829 | return "error (add column type_id in marine_live) : ".$e->getMessage()."\n"; |
1830 | 1830 | } |
1831 | 1831 | } |
1832 | - if (!$Connection->checkColumnName('marine_archive','type_id')) { |
|
1832 | + if (!$Connection->checkColumnName('marine_archive', 'type_id')) { |
|
1833 | 1833 | $query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL"; |
1834 | 1834 | try { |
1835 | 1835 | $sth = $Connection->db->prepare($query); |
1836 | 1836 | $sth->execute(); |
1837 | - } catch(PDOException $e) { |
|
1837 | + } catch (PDOException $e) { |
|
1838 | 1838 | return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n"; |
1839 | 1839 | } |
1840 | 1840 | } |
1841 | - if (!$Connection->checkColumnName('marine_archive_output','type_id')) { |
|
1841 | + if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) { |
|
1842 | 1842 | $query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL"; |
1843 | 1843 | try { |
1844 | 1844 | $sth = $Connection->db->prepare($query); |
1845 | 1845 | $sth->execute(); |
1846 | - } catch(PDOException $e) { |
|
1846 | + } catch (PDOException $e) { |
|
1847 | 1847 | return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1848 | 1848 | } |
1849 | 1849 | } |
1850 | - if (!$Connection->checkColumnName('marine_output','status_id')) { |
|
1850 | + if (!$Connection->checkColumnName('marine_output', 'status_id')) { |
|
1851 | 1851 | $query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL"; |
1852 | 1852 | try { |
1853 | 1853 | $sth = $Connection->db->prepare($query); |
1854 | 1854 | $sth->execute(); |
1855 | - } catch(PDOException $e) { |
|
1855 | + } catch (PDOException $e) { |
|
1856 | 1856 | return "error (add column status_id in marine_output) : ".$e->getMessage()."\n"; |
1857 | 1857 | } |
1858 | 1858 | } |
1859 | - if (!$Connection->checkColumnName('marine_live','status_id')) { |
|
1859 | + if (!$Connection->checkColumnName('marine_live', 'status_id')) { |
|
1860 | 1860 | $query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL"; |
1861 | 1861 | try { |
1862 | 1862 | $sth = $Connection->db->prepare($query); |
1863 | 1863 | $sth->execute(); |
1864 | - } catch(PDOException $e) { |
|
1864 | + } catch (PDOException $e) { |
|
1865 | 1865 | return "error (add column status_id in marine_live) : ".$e->getMessage()."\n"; |
1866 | 1866 | } |
1867 | 1867 | } |
1868 | - if (!$Connection->checkColumnName('marine_archive','status_id')) { |
|
1868 | + if (!$Connection->checkColumnName('marine_archive', 'status_id')) { |
|
1869 | 1869 | $query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL"; |
1870 | 1870 | try { |
1871 | 1871 | $sth = $Connection->db->prepare($query); |
1872 | 1872 | $sth->execute(); |
1873 | - } catch(PDOException $e) { |
|
1873 | + } catch (PDOException $e) { |
|
1874 | 1874 | return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n"; |
1875 | 1875 | } |
1876 | 1876 | } |
1877 | - if (!$Connection->checkColumnName('marine_archive_output','status_id')) { |
|
1877 | + if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) { |
|
1878 | 1878 | $query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL"; |
1879 | 1879 | try { |
1880 | 1880 | $sth = $Connection->db->prepare($query); |
1881 | 1881 | $sth->execute(); |
1882 | - } catch(PDOException $e) { |
|
1882 | + } catch (PDOException $e) { |
|
1883 | 1883 | return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1884 | 1884 | } |
1885 | 1885 | } |
@@ -1888,7 +1888,7 @@ discard block |
||
1888 | 1888 | try { |
1889 | 1889 | $sth = $Connection->db->prepare($query); |
1890 | 1890 | $sth->execute(); |
1891 | - } catch(PDOException $e) { |
|
1891 | + } catch (PDOException $e) { |
|
1892 | 1892 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1893 | 1893 | } |
1894 | 1894 | return $error; |
@@ -1903,14 +1903,14 @@ discard block |
||
1903 | 1903 | try { |
1904 | 1904 | $sth = $Connection->db->prepare($query); |
1905 | 1905 | $sth->execute(); |
1906 | - } catch(PDOException $e) { |
|
1906 | + } catch (PDOException $e) { |
|
1907 | 1907 | return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n"; |
1908 | 1908 | } |
1909 | 1909 | $query = "ALTER TABLE marine_identity MODIFY COLUMN mmsi varchar(255) DEFAULT NULL"; |
1910 | 1910 | try { |
1911 | 1911 | $sth = $Connection->db->prepare($query); |
1912 | 1912 | $sth->execute(); |
1913 | - } catch(PDOException $e) { |
|
1913 | + } catch (PDOException $e) { |
|
1914 | 1914 | return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n"; |
1915 | 1915 | } |
1916 | 1916 | } else { |
@@ -1918,14 +1918,14 @@ discard block |
||
1918 | 1918 | try { |
1919 | 1919 | $sth = $Connection->db->prepare($query); |
1920 | 1920 | $sth->execute(); |
1921 | - } catch(PDOException $e) { |
|
1921 | + } catch (PDOException $e) { |
|
1922 | 1922 | return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n"; |
1923 | 1923 | } |
1924 | 1924 | $query = "alter table marine_identity alter column mmsi type varchar(255)"; |
1925 | 1925 | try { |
1926 | 1926 | $sth = $Connection->db->prepare($query); |
1927 | 1927 | $sth->execute(); |
1928 | - } catch(PDOException $e) { |
|
1928 | + } catch (PDOException $e) { |
|
1929 | 1929 | return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n"; |
1930 | 1930 | } |
1931 | 1931 | } |
@@ -1933,7 +1933,7 @@ discard block |
||
1933 | 1933 | try { |
1934 | 1934 | $sth = $Connection->db->prepare($query); |
1935 | 1935 | $sth->execute(); |
1936 | - } catch(PDOException $e) { |
|
1936 | + } catch (PDOException $e) { |
|
1937 | 1937 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1938 | 1938 | } |
1939 | 1939 | return $error; |
@@ -1943,32 +1943,32 @@ discard block |
||
1943 | 1943 | global $globalDBdriver; |
1944 | 1944 | $Connection = new Connection(); |
1945 | 1945 | $error = ''; |
1946 | - if (!$Connection->checkColumnName('source_location','last_seen')) { |
|
1946 | + if (!$Connection->checkColumnName('source_location', 'last_seen')) { |
|
1947 | 1947 | $query = "ALTER TABLE source_location ADD COLUMN last_seen timestamp NULL DEFAULT NULL"; |
1948 | 1948 | try { |
1949 | 1949 | $sth = $Connection->db->prepare($query); |
1950 | 1950 | $sth->execute(); |
1951 | - } catch(PDOException $e) { |
|
1951 | + } catch (PDOException $e) { |
|
1952 | 1952 | return "error (add column last_seen in source_location) : ".$e->getMessage()."\n"; |
1953 | 1953 | } |
1954 | 1954 | } |
1955 | 1955 | if ($globalDBdriver == 'mysql') { |
1956 | - if (!$Connection->checkColumnName('source_location','location_id')) { |
|
1956 | + if (!$Connection->checkColumnName('source_location', 'location_id')) { |
|
1957 | 1957 | $query = "ALTER TABLE source_location ADD COLUMN location_id int(11) DEFAULT NULL"; |
1958 | 1958 | try { |
1959 | 1959 | $sth = $Connection->db->prepare($query); |
1960 | 1960 | $sth->execute(); |
1961 | - } catch(PDOException $e) { |
|
1961 | + } catch (PDOException $e) { |
|
1962 | 1962 | return "error (add column location_id in source_location) : ".$e->getMessage()."\n"; |
1963 | 1963 | } |
1964 | 1964 | } |
1965 | 1965 | } else { |
1966 | - if (!$Connection->checkColumnName('source_location','location_id')) { |
|
1966 | + if (!$Connection->checkColumnName('source_location', 'location_id')) { |
|
1967 | 1967 | $query = "ALTER TABLE source_location ADD COLUMN location_id integer DEFAULT NULL"; |
1968 | 1968 | try { |
1969 | 1969 | $sth = $Connection->db->prepare($query); |
1970 | 1970 | $sth->execute(); |
1971 | - } catch(PDOException $e) { |
|
1971 | + } catch (PDOException $e) { |
|
1972 | 1972 | return "error (add column location_id in source_location) : ".$e->getMessage()."\n"; |
1973 | 1973 | } |
1974 | 1974 | } |
@@ -1977,7 +1977,7 @@ discard block |
||
1977 | 1977 | try { |
1978 | 1978 | $sth = $Connection->db->prepare($query); |
1979 | 1979 | $sth->execute(); |
1980 | - } catch(PDOException $e) { |
|
1980 | + } catch (PDOException $e) { |
|
1981 | 1981 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1982 | 1982 | } |
1983 | 1983 | return $error; |
@@ -1987,12 +1987,12 @@ discard block |
||
1987 | 1987 | global $globalDBdriver; |
1988 | 1988 | $Connection = new Connection(); |
1989 | 1989 | $error = ''; |
1990 | - if (!$Connection->checkColumnName('source_location','description')) { |
|
1990 | + if (!$Connection->checkColumnName('source_location', 'description')) { |
|
1991 | 1991 | $query = "ALTER TABLE source_location ADD COLUMN description text DEFAULT NULL"; |
1992 | 1992 | try { |
1993 | 1993 | $sth = $Connection->db->prepare($query); |
1994 | 1994 | $sth->execute(); |
1995 | - } catch(PDOException $e) { |
|
1995 | + } catch (PDOException $e) { |
|
1996 | 1996 | return "error (add column description in source_location) : ".$e->getMessage()."\n"; |
1997 | 1997 | } |
1998 | 1998 | } |
@@ -2000,7 +2000,7 @@ discard block |
||
2000 | 2000 | try { |
2001 | 2001 | $sth = $Connection->db->prepare($query); |
2002 | 2002 | $sth->execute(); |
2003 | - } catch(PDOException $e) { |
|
2003 | + } catch (PDOException $e) { |
|
2004 | 2004 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2005 | 2005 | } |
2006 | 2006 | return $error; |
@@ -2010,39 +2010,39 @@ discard block |
||
2010 | 2010 | global $globalDBdriver; |
2011 | 2011 | $Connection = new Connection(); |
2012 | 2012 | $error = ''; |
2013 | - if (!$Connection->checkColumnName('spotter_live','real_altitude')) { |
|
2013 | + if (!$Connection->checkColumnName('spotter_live', 'real_altitude')) { |
|
2014 | 2014 | $query = "ALTER TABLE spotter_live ADD COLUMN real_altitude float DEFAULT NULL"; |
2015 | 2015 | try { |
2016 | 2016 | $sth = $Connection->db->prepare($query); |
2017 | 2017 | $sth->execute(); |
2018 | - } catch(PDOException $e) { |
|
2018 | + } catch (PDOException $e) { |
|
2019 | 2019 | return "error (add column real_altitude in spotter_live) : ".$e->getMessage()."\n"; |
2020 | 2020 | } |
2021 | 2021 | } |
2022 | - if (!$Connection->checkColumnName('spotter_output','real_altitude')) { |
|
2022 | + if (!$Connection->checkColumnName('spotter_output', 'real_altitude')) { |
|
2023 | 2023 | $query = "ALTER TABLE spotter_output ADD COLUMN real_altitude float DEFAULT NULL"; |
2024 | 2024 | try { |
2025 | 2025 | $sth = $Connection->db->prepare($query); |
2026 | 2026 | $sth->execute(); |
2027 | - } catch(PDOException $e) { |
|
2027 | + } catch (PDOException $e) { |
|
2028 | 2028 | return "error (add column real_altitude in spotter_output) : ".$e->getMessage()."\n"; |
2029 | 2029 | } |
2030 | 2030 | } |
2031 | - if (!$Connection->checkColumnName('spotter_archive_output','real_altitude')) { |
|
2031 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_altitude')) { |
|
2032 | 2032 | $query = "ALTER TABLE spotter_archive_output ADD COLUMN real_altitude float DEFAULT NULL"; |
2033 | 2033 | try { |
2034 | 2034 | $sth = $Connection->db->prepare($query); |
2035 | 2035 | $sth->execute(); |
2036 | - } catch(PDOException $e) { |
|
2036 | + } catch (PDOException $e) { |
|
2037 | 2037 | return "error (add column real_altitude in spotter_archive_output) : ".$e->getMessage()."\n"; |
2038 | 2038 | } |
2039 | 2039 | } |
2040 | - if (!$Connection->checkColumnName('spotter_archive','real_altitude')) { |
|
2040 | + if (!$Connection->checkColumnName('spotter_archive', 'real_altitude')) { |
|
2041 | 2041 | $query = "ALTER TABLE spotter_archive ADD COLUMN real_altitude float DEFAULT NULL"; |
2042 | 2042 | try { |
2043 | 2043 | $sth = $Connection->db->prepare($query); |
2044 | 2044 | $sth->execute(); |
2045 | - } catch(PDOException $e) { |
|
2045 | + } catch (PDOException $e) { |
|
2046 | 2046 | return "error (add column real_altitude in spotter_archive) : ".$e->getMessage()."\n"; |
2047 | 2047 | } |
2048 | 2048 | } |
@@ -2050,7 +2050,7 @@ discard block |
||
2050 | 2050 | try { |
2051 | 2051 | $sth = $Connection->db->prepare($query); |
2052 | 2052 | $sth->execute(); |
2053 | - } catch(PDOException $e) { |
|
2053 | + } catch (PDOException $e) { |
|
2054 | 2054 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2055 | 2055 | } |
2056 | 2056 | return $error; |
@@ -2072,14 +2072,14 @@ discard block |
||
2072 | 2072 | try { |
2073 | 2073 | $sth = $Connection->db->prepare($query); |
2074 | 2074 | $sth->execute(); |
2075 | - } catch(PDOException $e) { |
|
2075 | + } catch (PDOException $e) { |
|
2076 | 2076 | return "error (modify column altitude in tracker_*) : ".$e->getMessage()."\n"; |
2077 | 2077 | } |
2078 | 2078 | $query = "UPDATE config SET value = '44' WHERE name = 'schema_version'"; |
2079 | 2079 | try { |
2080 | 2080 | $sth = $Connection->db->prepare($query); |
2081 | 2081 | $sth->execute(); |
2082 | - } catch(PDOException $e) { |
|
2082 | + } catch (PDOException $e) { |
|
2083 | 2083 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2084 | 2084 | } |
2085 | 2085 | return $error; |
@@ -2120,7 +2120,7 @@ discard block |
||
2120 | 2120 | try { |
2121 | 2121 | $sth = $Connection->db->prepare($query); |
2122 | 2122 | $sth->execute(); |
2123 | - } catch(PDOException $e) { |
|
2123 | + } catch (PDOException $e) { |
|
2124 | 2124 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2125 | 2125 | } |
2126 | 2126 | return $error; |
@@ -2143,7 +2143,7 @@ discard block |
||
2143 | 2143 | try { |
2144 | 2144 | $sth = $Connection->db->prepare($query); |
2145 | 2145 | $sth->execute(); |
2146 | - } catch(PDOException $e) { |
|
2146 | + } catch (PDOException $e) { |
|
2147 | 2147 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2148 | 2148 | } |
2149 | 2149 | return $error; |
@@ -2193,7 +2193,7 @@ discard block |
||
2193 | 2193 | try { |
2194 | 2194 | $sth = $Connection->db->prepare($query); |
2195 | 2195 | $sth->execute(); |
2196 | - } catch(PDOException $e) { |
|
2196 | + } catch (PDOException $e) { |
|
2197 | 2197 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2198 | 2198 | } |
2199 | 2199 | return $error; |
@@ -2216,7 +2216,7 @@ discard block |
||
2216 | 2216 | try { |
2217 | 2217 | $sth = $Connection->db->prepare($query); |
2218 | 2218 | $sth->execute(); |
2219 | - } catch(PDOException $e) { |
|
2219 | + } catch (PDOException $e) { |
|
2220 | 2220 | return "error (check_version): ".$e->getMessage()."\n"; |
2221 | 2221 | } |
2222 | 2222 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -26,24 +26,24 @@ discard block |
||
26 | 26 | $sql_date = ''; |
27 | 27 | if (isset($_GET['start_date'])) { |
28 | 28 | //for the date manipulation into the query |
29 | - if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
|
29 | + if ($_GET['start_date'] != "" && $_GET['end_date'] != "") { |
|
30 | 30 | if (strtotime($_GET['start_date']) !== false && strtotime($_GET['end_date']) !== false) { |
31 | 31 | //$start_date = $_GET['start_date']." 00:00:00"; |
32 | - $start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00"; |
|
32 | + $start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00"; |
|
33 | 33 | //$end_date = $_GET['end_date']." 00:00:00"; |
34 | - $end_date = date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00"; |
|
34 | + $end_date = date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00"; |
|
35 | 35 | $sql_date = $start_date.",".$end_date; |
36 | 36 | } |
37 | - } else if($_GET['start_date'] != ""){ |
|
37 | + } else if ($_GET['start_date'] != "") { |
|
38 | 38 | if (strtotime($_GET['start_date']) !== false) { |
39 | 39 | //$start_date = $_GET['start_date']." 00:00:00"; |
40 | - $start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00"; |
|
40 | + $start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00"; |
|
41 | 41 | $sql_date = $start_date; |
42 | 42 | } |
43 | - } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
|
43 | + } else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") { |
|
44 | 44 | if (strtotime($_GET['end_date']) !== false) { |
45 | 45 | //$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date']." 00:00:00"; |
46 | - $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00"; |
|
46 | + $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00"; |
|
47 | 47 | $sql_date = $end_date; |
48 | 48 | } |
49 | 49 | } else $sql_date = ''; |
@@ -51,21 +51,21 @@ discard block |
||
51 | 51 | |
52 | 52 | if (isset($_GET['highest_altitude'])) { |
53 | 53 | //for altitude manipulation |
54 | - if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
|
55 | - $end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT); |
|
56 | - $start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT); |
|
54 | + if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") { |
|
55 | + $end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT); |
|
56 | + $start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT); |
|
57 | 57 | $sql_altitude = $start_altitude.",".$end_altitude; |
58 | - } else if($_GET['highest_altitude'] != ""){ |
|
59 | - $end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT); |
|
58 | + } else if ($_GET['highest_altitude'] != "") { |
|
59 | + $end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT); |
|
60 | 60 | $sql_altitude = $end_altitude; |
61 | - } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
|
62 | - $start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000"; |
|
61 | + } else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") { |
|
62 | + $start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT).",60000"; |
|
63 | 63 | $sql_altitude = $start_altitude; |
64 | 64 | } else $sql_altitude = ''; |
65 | 65 | } else $sql_altitude = ''; |
66 | 66 | |
67 | 67 | //calculuation for the pagination |
68 | -if(!isset($_GET['limit'])) |
|
68 | +if (!isset($_GET['limit'])) |
|
69 | 69 | { |
70 | 70 | if (!isset($_GET['number_results'])) |
71 | 71 | { |
@@ -73,17 +73,17 @@ discard block |
||
73 | 73 | $limit_end = 25; |
74 | 74 | $absolute_difference = 25; |
75 | 75 | } else { |
76 | - if ($_GET['number_results'] > 1000){ |
|
76 | + if ($_GET['number_results'] > 1000) { |
|
77 | 77 | $_GET['number_results'] = 1000; |
78 | 78 | } |
79 | 79 | $limit_start = 0; |
80 | - $limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT); |
|
81 | - $absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT); |
|
80 | + $limit_end = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT); |
|
81 | + $absolute_difference = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT); |
|
82 | 82 | } |
83 | -} else { |
|
83 | +} else { |
|
84 | 84 | $limit_explode = explode(",", $_GET['limit']); |
85 | - $limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT); |
|
86 | - $limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT); |
|
85 | + $limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT); |
|
86 | + $limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT); |
|
87 | 87 | } |
88 | 88 | $absolute_difference = abs($limit_start - $limit_end); |
89 | 89 | $limit_next = $limit_end + $absolute_difference; |
@@ -112,31 +112,31 @@ discard block |
||
112 | 112 | ((isset($_GET['origlat']) && $_GET['origlat'] != '') && |
113 | 113 | (isset($_GET['origlon']) && $_GET['origlon'] != '') && |
114 | 114 | (isset($_GET['dist']) && $_GET['dist'] != '')) |
115 | - ){ |
|
116 | - $q = filter_input(INPUT_GET, 'q',FILTER_SANITIZE_STRING); |
|
117 | - $registration = filter_input(INPUT_GET, 'registration',FILTER_SANITIZE_STRING); |
|
118 | - $aircraft = filter_input(INPUT_GET, 'aircraft',FILTER_SANITIZE_STRING); |
|
119 | - $manufacturer = filter_input(INPUT_GET, 'manufacturer',FILTER_SANITIZE_STRING); |
|
120 | - $highlights = filter_input(INPUT_GET, 'highlights',FILTER_SANITIZE_STRING); |
|
121 | - $airline = filter_input(INPUT_GET, 'airline',FILTER_SANITIZE_STRING); |
|
122 | - $airline_country = filter_input(INPUT_GET, 'airline_country',FILTER_SANITIZE_STRING); |
|
123 | - $airline_type = filter_input(INPUT_GET, 'airline_type',FILTER_SANITIZE_STRING); |
|
124 | - $airport = filter_input(INPUT_GET, 'airport',FILTER_SANITIZE_STRING); |
|
125 | - $airport_country = filter_input(INPUT_GET, 'airport_country',FILTER_SANITIZE_STRING); |
|
126 | - $callsign = filter_input(INPUT_GET, 'callsign',FILTER_SANITIZE_STRING); |
|
127 | - $owner = filter_input(INPUT_GET, 'owner',FILTER_SANITIZE_STRING); |
|
128 | - $pilot_name = filter_input(INPUT_GET, 'pilot_name',FILTER_SANITIZE_STRING); |
|
129 | - $pilot_id = filter_input(INPUT_GET, 'pilot_id',FILTER_SANITIZE_STRING); |
|
130 | - $mmsi = filter_input(INPUT_GET, 'mmsi',FILTER_SANITIZE_NUMBER_INT); |
|
131 | - $imo = filter_input(INPUT_GET, 'imo',FILTER_SANITIZE_NUMBER_INT); |
|
132 | - $departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route',FILTER_SANITIZE_STRING); |
|
133 | - $arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route',FILTER_SANITIZE_STRING); |
|
134 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
135 | - $archive = filter_input(INPUT_GET,'archive',FILTER_SANITIZE_NUMBER_INT); |
|
136 | - $origlat = filter_input(INPUT_GET,'origlat',FILTER_SANITIZE_NUMBER_FLOAT); |
|
137 | - $origlon = filter_input(INPUT_GET,'origlon',FILTER_SANITIZE_NUMBER_FLOAT); |
|
138 | - $dist = filter_input(INPUT_GET,'dist',FILTER_SANITIZE_NUMBER_INT); |
|
139 | - $number_results = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT); |
|
115 | + ) { |
|
116 | + $q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING); |
|
117 | + $registration = filter_input(INPUT_GET, 'registration', FILTER_SANITIZE_STRING); |
|
118 | + $aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING); |
|
119 | + $manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING); |
|
120 | + $highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING); |
|
121 | + $airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
122 | + $airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING); |
|
123 | + $airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING); |
|
124 | + $airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING); |
|
125 | + $airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING); |
|
126 | + $callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING); |
|
127 | + $owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING); |
|
128 | + $pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING); |
|
129 | + $pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING); |
|
130 | + $mmsi = filter_input(INPUT_GET, 'mmsi', FILTER_SANITIZE_NUMBER_INT); |
|
131 | + $imo = filter_input(INPUT_GET, 'imo', FILTER_SANITIZE_NUMBER_INT); |
|
132 | + $departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING); |
|
133 | + $arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING); |
|
134 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
135 | + $archive = filter_input(INPUT_GET, 'archive', FILTER_SANITIZE_NUMBER_INT); |
|
136 | + $origlat = filter_input(INPUT_GET, 'origlat', FILTER_SANITIZE_NUMBER_FLOAT); |
|
137 | + $origlon = filter_input(INPUT_GET, 'origlon', FILTER_SANITIZE_NUMBER_FLOAT); |
|
138 | + $dist = filter_input(INPUT_GET, 'dist', FILTER_SANITIZE_NUMBER_INT); |
|
139 | + $number_results = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT); |
|
140 | 140 | if ($dist != '') { |
141 | 141 | if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') $dist = $dist*1.60934; |
142 | 142 | elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') $dist = $dist*1.852; |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | if ($archive == 1) { |
146 | 146 | if ($type == 'aircraft') { |
147 | 147 | $SpotterArchive = new SpotterArchive(); |
148 | - $spotter_array = $SpotterArchive->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist); |
|
148 | + $spotter_array = $SpotterArchive->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '', $origlat, $origlon, $dist); |
|
149 | 149 | } |
150 | 150 | } else { |
151 | 151 | if ($type == 'aircraft') { |
152 | - $spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist); |
|
152 | + $spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '', $origlat, $origlon, $dist); |
|
153 | 153 | } elseif ($type == 'tracker') { |
154 | - $spotter_array = $Tracker->searchTrackerData($q,$callsign,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist); |
|
154 | + $spotter_array = $Tracker->searchTrackerData($q, $callsign, $sql_date, $limit_start.",".$absolute_difference, $sort, '', $origlat, $origlon, $dist); |
|
155 | 155 | } elseif ($type == 'marine') { |
156 | - $spotter_array = $Marine->searchMarineData($q,$callsign,$mmsi,$imo,$sql_date,$limit_start.",".$absolute_difference,$sort,'',$origlat,$origlon,$dist); |
|
156 | + $spotter_array = $Marine->searchMarineData($q, $callsign, $mmsi, $imo, $sql_date, $limit_start.",".$absolute_difference, $sort, '', $origlat, $origlon, $dist); |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
@@ -189,12 +189,12 @@ discard block |
||
189 | 189 | //remove 3D=true parameter |
190 | 190 | $no3D = str_replace("&3D=true", "", $_SERVER['QUERY_STRING']); |
191 | 191 | $kmlURL = str_replace("http://", "kml://", $globalURL); |
192 | - if (!isset($_GET['3D'])){ |
|
192 | + if (!isset($_GET['3D'])) { |
|
193 | 193 | print '<li><a href="'.$globalURL.'/search?'.$no3D.'" class="active"><i class="fa fa-table"></i> '._("Table").'</a></li>'; |
194 | 194 | } else { |
195 | 195 | print '<li><span class="notablet"><a href="'.$globalURL.'/search?'.$no3D.'"><i class="fa fa-table"></i> '._("Table").'</a></span></li>'; |
196 | 196 | } |
197 | - if (isset($_GET['3D'])){ |
|
197 | + if (isset($_GET['3D'])) { |
|
198 | 198 | print '<li><a href="'.$globalURL.'/search?'.$no3D.'&3D=true" class="active"><i class="fa fa-globe"></i> '._("3D Map").'</a></li>'; |
199 | 199 | } else { |
200 | 200 | print '<li ><a href="'.$globalURL.'/search?'.$no3D.'&3D=true" class="notablet nomobile"><i class="fa fa-globe"></i> '._("3D Map").'</a><a href="'.$kmlURL.'/search/kml?'.htmlentities($_SERVER['QUERY_STRING']).'" class="tablet mobile"><i class="fa fa-globe"></i> 3D Map</a></li>'; |
@@ -215,32 +215,32 @@ discard block |
||
215 | 215 | print '<div class="column">'; |
216 | 216 | print '<div class="info">'; |
217 | 217 | print '<h1>'._("Search Results for").' '; |
218 | - if (isset($_GET['q']) && $_GET['q'] != ""){ print _("Keyword:").' <span>'.$q.'</span> '; } |
|
219 | - if (isset($_GET['aircraft']) && $_GET['aircraft'] != ""){ print _("Aircraft:").' <span>'.$aircraft.'</span> '; } |
|
220 | - if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != ""){ print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; } |
|
221 | - if (isset($_GET['registration']) && $_GET['registration'] != ""){ print _("Registration:").' <span>'.$registration.'</span> '; } |
|
222 | - if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> '; } |
|
223 | - if (isset($_GET['airline']) && $_GET['airline'] != ""){ print _("Airline:").' <span>'.$airline.'</span> '; } |
|
224 | - if (isset($_GET['airline_country']) && $_GET['airline_country'] != ""){ print _("Airline country:").' <span>'.$airline_country.'</span> '; } |
|
225 | - if (isset($_GET['airline_type']) && $_GET['airline_type'] != ""){ print _("Airline type:").' <span>'.$airline_type.'</span> '; } |
|
226 | - if (isset($_GET['airport']) && $_GET['airport'] != ""){ print _("Airport:").' <span>'.$airport.'</span> '; } |
|
227 | - if (isset($_GET['airport_country']) && $_GET['airport_country'] != ""){ print _("Airport country:").' <span>'.$airport_country.'</span> '; } |
|
228 | - if (isset($_GET['callsign']) && $_GET['callsign'] != ""){ print _("Callsign:").' <span>'.$callsign.'</span> '; } |
|
229 | - if (isset($_GET['owner']) && $_GET['owner'] != ""){ print _("Owner:").' <span>'.$owner.'</span> '; } |
|
230 | - if (isset($_GET['pilot_id']) && $_GET['pilot_id'] != ""){ print _("Pilot id:").' <span>'.$pilot_id.'</span> '; } |
|
231 | - if (isset($_GET['pilot_name']) && $_GET['pilot_name'] != ""){ print _("Pilot name:").' <span>'.$pilot_name.'</span> '; } |
|
232 | - if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && (!isset($_GET['arrival_airport_route']) || $_GET['arrival_airport_route'] == "")){ print _("Route out of:").' <span>'.$departure_airport_route.'</span> '; } |
|
233 | - if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] == "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != ""){ print _("Route into:").' <span>'.$arrival_airport_route.'</span> '; } |
|
234 | - if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != ""){ print _("Route between:").' <span>'.$departure_airport_route.'</span> and <span>'.$_GET['arrival_airport_route'].'</span> '; } |
|
235 | - if (isset($_GET['mmsi']) && $_GET['mmsi'] != ""){ print _("MMSI:").' <span>'.$mmsi.'</span> '; } |
|
236 | - if (isset($_GET['imo']) && $_GET['imo'] != ""){ print _("IMO:").' <span>'.$imo.'</span> '; } |
|
237 | - if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] == ""){ print _("Date starting at:").' <span>'.$start_date.'</span> '; } |
|
238 | - if (isset($_GET['start_date']) && $_GET['start_date'] == "" && isset($_GET['end_date']) && $_GET['end_date'] != ""){ print _("Date ending at:").' <span>'.$end_date.'</span> '; } |
|
239 | - if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] != ""){ print _("Date between:").' <span>'.$start_date.'</span> and <span>'.$end_date.'</span> '; } |
|
240 | - if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == ""){ print _("Altitude starting at:").' <span>'.number_format($lowest_altitude).' feet</span> '; } |
|
241 | - if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != ""){ print _("Altitude ending at:").' <span>'.number_format($highest_altitude).' feet</span> '; } |
|
242 | - if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != ""){ print _("Altitude between:").' <span>'.number_format($lowest_altitude).' feet</span> '._("and").' <span>'.number_format($highest_altitude).' feet</span> '; } |
|
243 | - if (isset($_GET['number_results']) && $_GET['number_results'] != ""){ print _("limit per page:").' <span>'.$number_results.'</span> '; } |
|
218 | + if (isset($_GET['q']) && $_GET['q'] != "") { print _("Keyword:").' <span>'.$q.'</span> '; } |
|
219 | + if (isset($_GET['aircraft']) && $_GET['aircraft'] != "") { print _("Aircraft:").' <span>'.$aircraft.'</span> '; } |
|
220 | + if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != "") { print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; } |
|
221 | + if (isset($_GET['registration']) && $_GET['registration'] != "") { print _("Registration:").' <span>'.$registration.'</span> '; } |
|
222 | + if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true") { print _("Highlights:").' <span>'.$highlights.'</span> '; } |
|
223 | + if (isset($_GET['airline']) && $_GET['airline'] != "") { print _("Airline:").' <span>'.$airline.'</span> '; } |
|
224 | + if (isset($_GET['airline_country']) && $_GET['airline_country'] != "") { print _("Airline country:").' <span>'.$airline_country.'</span> '; } |
|
225 | + if (isset($_GET['airline_type']) && $_GET['airline_type'] != "") { print _("Airline type:").' <span>'.$airline_type.'</span> '; } |
|
226 | + if (isset($_GET['airport']) && $_GET['airport'] != "") { print _("Airport:").' <span>'.$airport.'</span> '; } |
|
227 | + if (isset($_GET['airport_country']) && $_GET['airport_country'] != "") { print _("Airport country:").' <span>'.$airport_country.'</span> '; } |
|
228 | + if (isset($_GET['callsign']) && $_GET['callsign'] != "") { print _("Callsign:").' <span>'.$callsign.'</span> '; } |
|
229 | + if (isset($_GET['owner']) && $_GET['owner'] != "") { print _("Owner:").' <span>'.$owner.'</span> '; } |
|
230 | + if (isset($_GET['pilot_id']) && $_GET['pilot_id'] != "") { print _("Pilot id:").' <span>'.$pilot_id.'</span> '; } |
|
231 | + if (isset($_GET['pilot_name']) && $_GET['pilot_name'] != "") { print _("Pilot name:").' <span>'.$pilot_name.'</span> '; } |
|
232 | + if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && (!isset($_GET['arrival_airport_route']) || $_GET['arrival_airport_route'] == "")) { print _("Route out of:").' <span>'.$departure_airport_route.'</span> '; } |
|
233 | + if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] == "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != "") { print _("Route into:").' <span>'.$arrival_airport_route.'</span> '; } |
|
234 | + if (isset($_GET['departure_airport_route']) && $_GET['departure_airport_route'] != "" && isset($_GET['arrival_airport_route']) && $_GET['arrival_airport_route'] != "") { print _("Route between:").' <span>'.$departure_airport_route.'</span> and <span>'.$_GET['arrival_airport_route'].'</span> '; } |
|
235 | + if (isset($_GET['mmsi']) && $_GET['mmsi'] != "") { print _("MMSI:").' <span>'.$mmsi.'</span> '; } |
|
236 | + if (isset($_GET['imo']) && $_GET['imo'] != "") { print _("IMO:").' <span>'.$imo.'</span> '; } |
|
237 | + if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] == "") { print _("Date starting at:").' <span>'.$start_date.'</span> '; } |
|
238 | + if (isset($_GET['start_date']) && $_GET['start_date'] == "" && isset($_GET['end_date']) && $_GET['end_date'] != "") { print _("Date ending at:").' <span>'.$end_date.'</span> '; } |
|
239 | + if (isset($_GET['start_date']) && $_GET['start_date'] != "" && isset($_GET['end_date']) && $_GET['end_date'] != "") { print _("Date between:").' <span>'.$start_date.'</span> and <span>'.$end_date.'</span> '; } |
|
240 | + if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == "") { print _("Altitude starting at:").' <span>'.number_format($lowest_altitude).' feet</span> '; } |
|
241 | + if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != "") { print _("Altitude ending at:").' <span>'.number_format($highest_altitude).' feet</span> '; } |
|
242 | + if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] != "" && isset($_GET['highest_altitude']) && $_GET['highest_altitude'] != "") { print _("Altitude between:").' <span>'.number_format($lowest_altitude).' feet</span> '._("and").' <span>'.number_format($highest_altitude).' feet</span> '; } |
|
243 | + if (isset($_GET['number_results']) && $_GET['number_results'] != "") { print _("limit per page:").' <span>'.$number_results.'</span> '; } |
|
244 | 244 | print '</h1>'; |
245 | 245 | print '</div>'; |
246 | 246 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | </select> |
375 | 375 | </div> |
376 | 376 | </div> |
377 | - <script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) print $manufacturer; ?>')</script> |
|
377 | + <script type="text/javascript">getSelect('manufacturer','<?php if (isset($_GET['manufacturer'])) print $manufacturer; ?>')</script> |
|
378 | 378 | <div class="form-group"> |
379 | 379 | <label class="control-label col-sm-2"><?php echo _("Type"); ?></label> |
380 | 380 | <div class="col-sm-10"> |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | </select> |
384 | 384 | </div> |
385 | 385 | </div> |
386 | - <script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script> |
|
386 | + <script type="text/javascript">getSelect('aircrafttypes','<?php if (isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script> |
|
387 | 387 | <div class="form-group"> |
388 | 388 | <label class="control-label col-sm-2"><?php echo _("Registration"); ?></label> |
389 | 389 | <div class="col-sm-10"> |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | </div> |
407 | 407 | </div> |
408 | 408 | <?php |
409 | - }else { |
|
409 | + } else { |
|
410 | 410 | ?> |
411 | 411 | <div class="form-group"> |
412 | 412 | <label class="control-label col-sm-2"><?php echo _("Owner name"); ?></label> |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | ?> |
420 | 420 | <div class="form-group"> |
421 | 421 | <div class="col-sm-offset-2 col-sm-10"> |
422 | - <!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>--> |
|
423 | - <label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label> |
|
422 | + <!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true") { print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>--> |
|
423 | + <label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true") { print 'checked="checked"'; } ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label> |
|
424 | 424 | </div> |
425 | 425 | </div> |
426 | 426 | </fieldset> |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | </select> |
435 | 435 | </div> |
436 | 436 | </div> |
437 | - <script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) print $airline; ?>');</script> |
|
437 | + <script type="text/javascript">getSelect('airlinenames','<?php if (isset($_GET['airline'])) print $airline; ?>');</script> |
|
438 | 438 | <div class="form-group"> |
439 | 439 | <label class="control-label col-sm-2"><?php echo _("Country"); ?></label> |
440 | 440 | <div class="col-sm-10"> |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | </select> |
444 | 444 | </div> |
445 | 445 | </div> |
446 | - <script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) print $airline_country; ?>');</script> |
|
446 | + <script type="text/javascript">getSelect('airlinecountries','<?php if (isset($_GET['airline_country'])) print $airline_country; ?>');</script> |
|
447 | 447 | <div class="form-group"> |
448 | 448 | <label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> |
449 | 449 | <div class="col-sm-10"> |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | </div> |
453 | 453 | <div class="form-group"> |
454 | 454 | <div class="col-sm-offset-2 col-sm-10"> |
455 | - <label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all"){ print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label> |
|
456 | - <label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label> |
|
457 | - <label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label> |
|
458 | - <label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label> |
|
455 | + <label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all") { print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label> |
|
456 | + <label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger") { print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label> |
|
457 | + <label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "cargo") { print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label> |
|
458 | + <label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "military") { print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label> |
|
459 | 459 | </div> |
460 | 460 | </div> |
461 | 461 | </fieldset> |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | </select> |
470 | 470 | </div> |
471 | 471 | </div> |
472 | - <script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) print $airport_icao; ?>');</script> |
|
472 | + <script type="text/javascript">getSelect('airportnames','<?php if (isset($_GET['airport_icao'])) print $airport_icao; ?>');</script> |
|
473 | 473 | <div class="form-group"> |
474 | 474 | <label class="control-label col-sm-2"><?php echo _("Country"); ?></label> |
475 | 475 | <div class="col-sm-10"> |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | </select> |
479 | 479 | </div> |
480 | 480 | </div> |
481 | - <script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) print $airport_country; ?>');</script> |
|
481 | + <script type="text/javascript">getSelect('airportcountries','<?php if (isset($_GET['airport_country'])) print $airport_country; ?>');</script> |
|
482 | 482 | </fieldset> |
483 | 483 | <fieldset> |
484 | 484 | <legend><?php echo _("Route"); ?></legend> |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | </select> |
491 | 491 | </div> |
492 | 492 | </div> |
493 | - <script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script> |
|
493 | + <script type="text/javascript">getSelect('departureairportnames','<?php if (isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script> |
|
494 | 494 | <div class="form-group"> |
495 | 495 | <label class="control-label col-sm-2"><?php echo _("Arrival Airport"); ?></label> |
496 | 496 | <div class="col-sm-10"> |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | </select> |
500 | 500 | </div> |
501 | 501 | </div> |
502 | - <script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script> |
|
502 | + <script type="text/javascript">getSelect('arrivalairportnames','<?php if (isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script> |
|
503 | 503 | </fieldset> |
504 | 504 | <fieldset> |
505 | 505 | <legend>Altitude</legend> |
@@ -510,9 +510,9 @@ discard block |
||
510 | 510 | <option></option> |
511 | 511 | <?php |
512 | 512 | $altitude_array = Array(1000, 5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000); |
513 | -foreach($altitude_array as $altitude) |
|
513 | +foreach ($altitude_array as $altitude) |
|
514 | 514 | { |
515 | - if(isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == $altitude) |
|
515 | + if (isset($_GET['lowest_altitude']) && $_GET['lowest_altitude'] == $altitude) |
|
516 | 516 | { |
517 | 517 | print '<option value="'.$altitude.'" selected="selected">'.number_format($altitude).' feet</option>'; |
518 | 518 | } else { |
@@ -530,9 +530,9 @@ discard block |
||
530 | 530 | <option></option> |
531 | 531 | <?php |
532 | 532 | $altitude_array = Array(1000, 5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000); |
533 | - foreach($altitude_array as $altitude) |
|
533 | + foreach ($altitude_array as $altitude) |
|
534 | 534 | { |
535 | - if(isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == $altitude) |
|
535 | + if (isset($_GET['highest_altitude']) && $_GET['highest_altitude'] == $altitude) |
|
536 | 536 | { |
537 | 537 | print '<option value="'.$altitude.'" selected="selected">'.number_format($altitude).' feet</option>'; |
538 | 538 | } else { |
@@ -655,10 +655,10 @@ discard block |
||
655 | 655 | <div class="col-sm-10"> |
656 | 656 | <select class="form-control" name="number_results"> |
657 | 657 | <?php |
658 | -$number_results_array = Array(25, 50, 100, 150, 200, 250, 300, 400, 500, 600, 700, 800, 900, 1000); |
|
659 | -foreach($number_results_array as $number) |
|
658 | +$number_results_array = Array(25, 50, 100, 150, 200, 250, 300, 400, 500, 600, 700, 800, 900, 1000); |
|
659 | +foreach ($number_results_array as $number) |
|
660 | 660 | { |
661 | - if(isset($_GET['number_results']) && $_GET['number_results'] == $number) |
|
661 | + if (isset($_GET['number_results']) && $_GET['number_results'] == $number) |
|
662 | 662 | { |
663 | 663 | print '<option value="'.$number.'" selected="selected">'.$number.'</option>'; |
664 | 664 | } else { |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | <fieldset> |
678 | 678 | <div class="form-group"> |
679 | 679 | <div class="col-sm-offset-2 col-sm-10"> |
680 | - <label class="checkbox-inline"><input type="checkbox" name="archive" value="1" disabled /><?php echo sprintf(_("Search in archive (older than %s months)"),$globalArchiveKeepMonths); ?></label> |
|
680 | + <label class="checkbox-inline"><input type="checkbox" name="archive" value="1" disabled /><?php echo sprintf(_("Search in archive (older than %s months)"), $globalArchiveKeepMonths); ?></label> |
|
681 | 681 | <p class="help-block">Disabled in demo</p> |
682 | 682 | </div> |
683 | 683 | </div> |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | <fieldset> |
689 | 689 | <div class="form-group"> |
690 | 690 | <div class="col-sm-offset-2 col-sm-10"> |
691 | - <label class="checkbox-inline"><input type="checkbox" name="archive" value="1" /><?php echo sprintf(_("Search in archive (older than %s months)"),$globalArchiveKeepMonths); ?></label> |
|
691 | + <label class="checkbox-inline"><input type="checkbox" name="archive" value="1" /><?php echo sprintf(_("Search in archive (older than %s months)"), $globalArchiveKeepMonths); ?></label> |
|
692 | 692 | </div> |
693 | 693 | </div> |
694 | 694 | </fieldset> |