@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /* |
22 | 22 | * Initialize DB connection |
23 | 23 | */ |
24 | - public function __construct($dbc = null,$fromACARSscript = false) { |
|
24 | + public function __construct($dbc = null, $fromACARSscript = false) { |
|
25 | 25 | $Connection = new Connection($dbc); |
26 | 26 | $this->db = $Connection->db(); |
27 | 27 | if ($this->db === null) die('Error: No DB connection. (ACARS)'); |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | * @return String the icao |
39 | 39 | */ |
40 | 40 | public function ident2icao($ident) { |
41 | - if (substr($ident,0,2) == 'AF') { |
|
42 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
43 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
41 | + if (substr($ident, 0, 2) == 'AF') { |
|
42 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
43 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
44 | 44 | } else { |
45 | 45 | $Spotter = new Spotter($this->db); |
46 | - $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
|
46 | + $identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2)); |
|
47 | 47 | if (isset($identicao[0])) { |
48 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
48 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
49 | 49 | } else $icao = $ident; |
50 | 50 | } |
51 | 51 | return $icao; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | $sth = $this->db->prepare($query); |
71 | 71 | $sth->execute(); |
72 | - } catch(PDOException $e) { |
|
72 | + } catch (PDOException $e) { |
|
73 | 73 | return "error"; |
74 | 74 | } |
75 | 75 | return "success"; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | $sth = $this->db->prepare($query); |
95 | 95 | $sth->execute(); |
96 | - } catch(PDOException $e) { |
|
96 | + } catch (PDOException $e) { |
|
97 | 97 | return "error"; |
98 | 98 | } |
99 | 99 | return "success"; |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | $ident = ''; |
119 | 119 | $message = ''; |
120 | 120 | $result = array(); |
121 | - $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); |
|
122 | - 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); |
|
123 | - 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); |
|
124 | - 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); |
|
121 | + $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); |
|
122 | + 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); |
|
123 | + 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); |
|
124 | + 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); |
|
125 | 125 | if ($n != 0) { |
126 | - $registration = str_replace('.','',$registration); |
|
127 | - $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
|
126 | + $registration = str_replace('.', '', $registration); |
|
127 | + $result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message); |
|
128 | 128 | if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
129 | 129 | } else $message = $data; |
130 | 130 | $decode = array(); |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | $temp = ''; |
145 | 145 | $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); |
146 | 146 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
147 | - $latitude = $la / 10000.0; |
|
148 | - $longitude = $ln / 10000.0; |
|
147 | + $latitude = $la/10000.0; |
|
148 | + $longitude = $ln/10000.0; |
|
149 | 149 | if ($lac == 'S') $latitude = '-'.$latitude; |
150 | 150 | if ($lnc == 'W') $longitude = '-'.$longitude; |
151 | 151 | // Temp not always available |
152 | 152 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
153 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
154 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
153 | + if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt); |
|
154 | + else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C'); |
|
155 | 155 | |
156 | 156 | //$icao = $Translation->checkTranslation($ident); |
157 | 157 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -163,19 +163,19 @@ discard block |
||
163 | 163 | $dhour = ''; |
164 | 164 | $darr = ''; |
165 | 165 | $ahour = ''; |
166 | - $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
|
166 | + $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour); |
|
167 | 167 | if ($n == 4 && strlen($darr) == 4) { |
168 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
169 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
170 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
168 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
169 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
170 | + if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n"; |
|
171 | 171 | //$icao = ACARS->ident2icao($ident); |
172 | 172 | //$icao = $Translation->checkTranslation($ident); |
173 | 173 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
174 | 174 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
175 | 175 | $found = true; |
176 | 176 | } |
177 | - elseif ($n == 2 || $n == 4) { |
|
178 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
177 | + elseif ($n == 2 || $n == 4) { |
|
178 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
179 | 179 | if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
180 | 180 | //$icao = ACARS->ident2icao($ident); |
181 | 181 | //$icao = $Translation->checkTranslation($ident); |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | $ahour = ''; |
234 | 234 | $aair = ''; |
235 | 235 | $apiste = ''; |
236 | - $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); |
|
236 | + $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); |
|
237 | 237 | if ($n > 8) { |
238 | - 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"; |
|
239 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
240 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
238 | + 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"; |
|
239 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
240 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
241 | 241 | $icao = trim($aident); |
242 | 242 | |
243 | 243 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
263 | 263 | $las = $las.'.'.$lass; |
264 | 264 | $lns = $lns.'.'.$lns; |
265 | - $latitude = $las / 1000.0; |
|
266 | - $longitude = $lns / 1000.0; |
|
265 | + $latitude = $las/1000.0; |
|
266 | + $longitude = $lns/1000.0; |
|
267 | 267 | if ($lac == 'S') $latitude = '-'.$latitude; |
268 | 268 | if ($lnc == 'W') $longitude = '-'.$longitude; |
269 | 269 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
@@ -358,17 +358,17 @@ discard block |
||
358 | 358 | $alt = ''; |
359 | 359 | $fuel = ''; |
360 | 360 | $speed = ''; |
361 | - $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); |
|
361 | + $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); |
|
362 | 362 | if ($n == 9) { |
363 | 363 | //if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
364 | 364 | $icao = trim($aident); |
365 | 365 | $decode['icao'] = $icao; |
366 | - $latitude = $las / 100.0; |
|
367 | - $longitude = $lns / 100.0; |
|
366 | + $latitude = $las/100.0; |
|
367 | + $longitude = $lns/100.0; |
|
368 | 368 | if ($lac == 'S') $latitude = '-'.$latitude; |
369 | 369 | if ($lnc == 'W') $longitude = '-'.$longitude; |
370 | 370 | |
371 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
|
371 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed); |
|
372 | 372 | $found = true; |
373 | 373 | } |
374 | 374 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | if ($lac == 'S') $latitude = '-'.$latitude; |
388 | 388 | if ($lnc == 'W') $longitude = '-'.$longitude; |
389 | 389 | |
390 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
|
390 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
|
391 | 391 | $found = true; |
392 | 392 | } |
393 | 393 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | $dair = ''; |
421 | 421 | $darr = ''; |
422 | 422 | $aident = ''; |
423 | - $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); |
|
423 | + $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); |
|
424 | 424 | if ($n == 8) { |
425 | 425 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
426 | 426 | $icao = trim($aident); |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | */ |
453 | 453 | $dair = ''; |
454 | 454 | $darr = ''; |
455 | - $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
|
455 | + $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr); |
|
456 | 456 | if ($n == 3) { |
457 | 457 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
458 | 458 | //$icao = $Translation->checkTranslation($ident); |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | */ |
468 | 468 | $dair = ''; |
469 | 469 | $darr = ''; |
470 | - $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
|
470 | + $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr); |
|
471 | 471 | if ($n == 3) { |
472 | 472 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
473 | 473 | //$icao = $Translation->checkTranslation($ident); |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | } |
478 | 478 | } |
479 | 479 | if (!$found) { |
480 | - $n = sscanf($message,'MET01%4c',$airport); |
|
480 | + $n = sscanf($message, 'MET01%4c', $airport); |
|
481 | 481 | if ($n == 1) { |
482 | 482 | if ($globalDebug) echo 'airport name : '.$airport; |
483 | 483 | $decode = array('Airport/Waypoint name' => $airport); |
@@ -485,241 +485,241 @@ discard block |
||
485 | 485 | } |
486 | 486 | } |
487 | 487 | if ($label == 'H1') { |
488 | - if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
|
489 | - $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
|
488 | + if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) { |
|
489 | + $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode); |
|
490 | 490 | } |
491 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
492 | - $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
|
491 | + elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) { |
|
492 | + $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode); |
|
493 | 493 | } |
494 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
495 | - $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
|
494 | + elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) { |
|
495 | + $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode); |
|
496 | 496 | } |
497 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
498 | - $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
|
497 | + elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) { |
|
498 | + $decode = array_merge(array('Message nature' => 'Weather observation'), $decode); |
|
499 | 499 | } |
500 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
501 | - $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
|
500 | + elseif (preg_match(':^#DFB/PIREP:', $message)) { |
|
501 | + $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode); |
|
502 | 502 | } |
503 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
504 | - $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
|
503 | + elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) { |
|
504 | + $decode = array_merge(array('Message nature' => 'Engine Data'), $decode); |
|
505 | 505 | } |
506 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
507 | - $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
|
506 | + elseif (preg_match(':^#M1AAEP:', $message)) { |
|
507 | + $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode); |
|
508 | 508 | } |
509 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
510 | - $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
|
509 | + elseif (preg_match(':^#M2APWD:', $message)) { |
|
510 | + $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode); |
|
511 | 511 | } |
512 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
513 | - $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
|
512 | + elseif (preg_match(':^#M1BREQPWI:', $message)) { |
|
513 | + $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode); |
|
514 | 514 | } |
515 | - elseif (preg_match(':^#CF:',$message)) { |
|
516 | - $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
|
515 | + elseif (preg_match(':^#CF:', $message)) { |
|
516 | + $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode); |
|
517 | 517 | } |
518 | - elseif (preg_match(':^#DF:',$message)) { |
|
519 | - $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
|
518 | + elseif (preg_match(':^#DF:', $message)) { |
|
519 | + $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode); |
|
520 | 520 | } |
521 | - elseif (preg_match(':^#EC:',$message)) { |
|
522 | - $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
|
521 | + elseif (preg_match(':^#EC:', $message)) { |
|
522 | + $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode); |
|
523 | 523 | } |
524 | - elseif (preg_match(':^#EI:',$message)) { |
|
525 | - $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
|
524 | + elseif (preg_match(':^#EI:', $message)) { |
|
525 | + $decode = array_merge(array('Message nature' => 'Engine Report'), $decode); |
|
526 | 526 | } |
527 | - elseif (preg_match(':^#H1:',$message)) { |
|
528 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
|
527 | + elseif (preg_match(':^#H1:', $message)) { |
|
528 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode); |
|
529 | 529 | } |
530 | - elseif (preg_match(':^#H2:',$message)) { |
|
531 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
|
530 | + elseif (preg_match(':^#H2:', $message)) { |
|
531 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode); |
|
532 | 532 | } |
533 | - elseif (preg_match(':^#HD:',$message)) { |
|
534 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
|
533 | + elseif (preg_match(':^#HD:', $message)) { |
|
534 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode); |
|
535 | 535 | } |
536 | - elseif (preg_match(':^#M1:',$message)) { |
|
537 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
|
536 | + elseif (preg_match(':^#M1:', $message)) { |
|
537 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode); |
|
538 | 538 | } |
539 | - elseif (preg_match(':^#M2:',$message)) { |
|
540 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
|
539 | + elseif (preg_match(':^#M2:', $message)) { |
|
540 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode); |
|
541 | 541 | } |
542 | - elseif (preg_match(':^#M3:',$message)) { |
|
543 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
|
542 | + elseif (preg_match(':^#M3:', $message)) { |
|
543 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode); |
|
544 | 544 | } |
545 | - elseif (preg_match(':^#MD:',$message)) { |
|
546 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
|
545 | + elseif (preg_match(':^#MD:', $message)) { |
|
546 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode); |
|
547 | 547 | } |
548 | - elseif (preg_match(':^#PS:',$message)) { |
|
549 | - $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
|
548 | + elseif (preg_match(':^#PS:', $message)) { |
|
549 | + $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode); |
|
550 | 550 | } |
551 | - elseif (preg_match(':^#S1:',$message)) { |
|
552 | - $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
|
551 | + elseif (preg_match(':^#S1:', $message)) { |
|
552 | + $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode); |
|
553 | 553 | } |
554 | - elseif (preg_match(':^#S2:',$message)) { |
|
555 | - $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
|
554 | + elseif (preg_match(':^#S2:', $message)) { |
|
555 | + $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode); |
|
556 | 556 | } |
557 | - elseif (preg_match(':^#SD:',$message)) { |
|
558 | - $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
|
557 | + elseif (preg_match(':^#SD:', $message)) { |
|
558 | + $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode); |
|
559 | 559 | } |
560 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
561 | - $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
|
560 | + elseif (preg_match(':^#T[0-8]:', $message)) { |
|
561 | + $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode); |
|
562 | 562 | } |
563 | - elseif (preg_match(':^#WO:',$message)) { |
|
564 | - $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
|
563 | + elseif (preg_match(':^#WO:', $message)) { |
|
564 | + $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode); |
|
565 | 565 | } |
566 | - elseif (preg_match(':^#A1:',$message)) { |
|
567 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
|
566 | + elseif (preg_match(':^#A1:', $message)) { |
|
567 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode); |
|
568 | 568 | } |
569 | - elseif (preg_match(':^#A3:',$message)) { |
|
570 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
|
569 | + elseif (preg_match(':^#A3:', $message)) { |
|
570 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode); |
|
571 | 571 | } |
572 | - elseif (preg_match(':^#A4:',$message)) { |
|
573 | - $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
|
572 | + elseif (preg_match(':^#A4:', $message)) { |
|
573 | + $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode); |
|
574 | 574 | } |
575 | - elseif (preg_match(':^#A6:',$message)) { |
|
576 | - $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
|
575 | + elseif (preg_match(':^#A6:', $message)) { |
|
576 | + $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode); |
|
577 | 577 | } |
578 | - elseif (preg_match(':^#A8:',$message)) { |
|
579 | - $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
|
578 | + elseif (preg_match(':^#A8:', $message)) { |
|
579 | + $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode); |
|
580 | 580 | } |
581 | - elseif (preg_match(':^#A9:',$message)) { |
|
582 | - $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
|
581 | + elseif (preg_match(':^#A9:', $message)) { |
|
582 | + $decode = array_merge(array('Message nature' => 'ATIS report'), $decode); |
|
583 | 583 | } |
584 | - elseif (preg_match(':^#A0:',$message)) { |
|
585 | - $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
|
584 | + elseif (preg_match(':^#A0:', $message)) { |
|
585 | + $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode); |
|
586 | 586 | } |
587 | - elseif (preg_match(':^#AA:',$message)) { |
|
588 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
587 | + elseif (preg_match(':^#AA:', $message)) { |
|
588 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
589 | 589 | } |
590 | - elseif (preg_match(':^#AB:',$message)) { |
|
591 | - $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
|
590 | + elseif (preg_match(':^#AB:', $message)) { |
|
591 | + $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode); |
|
592 | 592 | } |
593 | - elseif (preg_match(':^#AC:',$message)) { |
|
594 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
|
593 | + elseif (preg_match(':^#AC:', $message)) { |
|
594 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode); |
|
595 | 595 | } |
596 | - elseif (preg_match(':^#AD:',$message)) { |
|
597 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
|
596 | + elseif (preg_match(':^#AD:', $message)) { |
|
597 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode); |
|
598 | 598 | } |
599 | - elseif (preg_match(':^#AF:',$message)) { |
|
600 | - $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
|
599 | + elseif (preg_match(':^#AF:', $message)) { |
|
600 | + $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode); |
|
601 | 601 | } |
602 | - elseif (preg_match(':^#B1:',$message)) { |
|
603 | - $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
|
602 | + elseif (preg_match(':^#B1:', $message)) { |
|
603 | + $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode); |
|
604 | 604 | } |
605 | - elseif (preg_match(':^#B2:',$message)) { |
|
606 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
|
605 | + elseif (preg_match(':^#B2:', $message)) { |
|
606 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode); |
|
607 | 607 | } |
608 | - elseif (preg_match(':^#B3:',$message)) { |
|
609 | - $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
|
608 | + elseif (preg_match(':^#B3:', $message)) { |
|
609 | + $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode); |
|
610 | 610 | } |
611 | - elseif (preg_match(':^#B4:',$message)) { |
|
612 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
|
611 | + elseif (preg_match(':^#B4:', $message)) { |
|
612 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode); |
|
613 | 613 | } |
614 | - elseif (preg_match(':^#B6:',$message)) { |
|
615 | - $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
|
614 | + elseif (preg_match(':^#B6:', $message)) { |
|
615 | + $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode); |
|
616 | 616 | } |
617 | - elseif (preg_match(':^#B8:',$message)) { |
|
618 | - $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
|
617 | + elseif (preg_match(':^#B8:', $message)) { |
|
618 | + $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode); |
|
619 | 619 | } |
620 | - elseif (preg_match(':^#B9:',$message)) { |
|
621 | - $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
|
620 | + elseif (preg_match(':^#B9:', $message)) { |
|
621 | + $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode); |
|
622 | 622 | } |
623 | - elseif (preg_match(':^#B0:',$message)) { |
|
624 | - $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
|
623 | + elseif (preg_match(':^#B0:', $message)) { |
|
624 | + $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode); |
|
625 | 625 | } |
626 | - elseif (preg_match(':^#BA:',$message)) { |
|
627 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
626 | + elseif (preg_match(':^#BA:', $message)) { |
|
627 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
628 | 628 | } |
629 | - elseif (preg_match(':^#BB:',$message)) { |
|
630 | - $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
|
629 | + elseif (preg_match(':^#BB:', $message)) { |
|
630 | + $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode); |
|
631 | 631 | } |
632 | - elseif (preg_match(':^#BC:',$message)) { |
|
633 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
|
632 | + elseif (preg_match(':^#BC:', $message)) { |
|
633 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode); |
|
634 | 634 | } |
635 | - elseif (preg_match(':^#BD:',$message)) { |
|
636 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
|
635 | + elseif (preg_match(':^#BD:', $message)) { |
|
636 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode); |
|
637 | 637 | } |
638 | - elseif (preg_match(':^#BE:',$message)) { |
|
639 | - $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
|
638 | + elseif (preg_match(':^#BE:', $message)) { |
|
639 | + $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode); |
|
640 | 640 | } |
641 | - elseif (preg_match(':^#BF:',$message)) { |
|
642 | - $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
|
641 | + elseif (preg_match(':^#BF:', $message)) { |
|
642 | + $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode); |
|
643 | 643 | } |
644 | - elseif (preg_match(':^#H3:',$message)) { |
|
645 | - $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
|
644 | + elseif (preg_match(':^#H3:', $message)) { |
|
645 | + $decode = array_merge(array('Message nature' => 'Icing Report'), $decode); |
|
646 | 646 | } |
647 | 647 | } |
648 | 648 | if ($label == '10') { |
649 | - if (preg_match(':^DTO01:',$message)) { |
|
650 | - $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
|
649 | + if (preg_match(':^DTO01:', $message)) { |
|
650 | + $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode); |
|
651 | 651 | } |
652 | - elseif (preg_match(':^AIS01:',$message)) { |
|
653 | - $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
|
652 | + elseif (preg_match(':^AIS01:', $message)) { |
|
653 | + $decode = array_merge(array('Message nature' => 'AIS Request'), $decode); |
|
654 | 654 | } |
655 | - elseif (preg_match(':^FTX01:',$message)) { |
|
656 | - $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
|
655 | + elseif (preg_match(':^FTX01:', $message)) { |
|
656 | + $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode); |
|
657 | 657 | } |
658 | - elseif (preg_match(':^FPL01:',$message)) { |
|
659 | - $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
|
658 | + elseif (preg_match(':^FPL01:', $message)) { |
|
659 | + $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode); |
|
660 | 660 | } |
661 | - elseif (preg_match(':^WAB01:',$message)) { |
|
662 | - $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
|
661 | + elseif (preg_match(':^WAB01:', $message)) { |
|
662 | + $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode); |
|
663 | 663 | } |
664 | - elseif (preg_match(':^MET01:',$message)) { |
|
665 | - $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
|
664 | + elseif (preg_match(':^MET01:', $message)) { |
|
665 | + $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode); |
|
666 | 666 | } |
667 | - elseif (preg_match(':^WAB02:',$message)) { |
|
668 | - $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
|
667 | + elseif (preg_match(':^WAB02:', $message)) { |
|
668 | + $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode); |
|
669 | 669 | } |
670 | 670 | } |
671 | 671 | if ($label == '15') { |
672 | - if (preg_match(':^FST01:',$message)) { |
|
673 | - $decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode); |
|
672 | + if (preg_match(':^FST01:', $message)) { |
|
673 | + $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode); |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | if (!$found && $label == 'SA') { |
677 | - $n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at); |
|
677 | + $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at); |
|
678 | 678 | if ($n == 4) { |
679 | 679 | $vsta = array('Version' => $version); |
680 | 680 | if ($state == 'E') { |
681 | - $vsta = array_merge($vsta,array('Link state' => 'Established')); |
|
681 | + $vsta = array_merge($vsta, array('Link state' => 'Established')); |
|
682 | 682 | } |
683 | 683 | elseif ($state == 'L') { |
684 | - $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
|
684 | + $vsta = array_merge($vsta, array('Link state' => 'Lost')); |
|
685 | 685 | } |
686 | 686 | else { |
687 | - $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
|
687 | + $vsta = array_merge($vsta, array('Link state' => 'Unknown')); |
|
688 | 688 | } |
689 | 689 | if ($type == 'V') { |
690 | - $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
|
690 | + $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS')); |
|
691 | 691 | } |
692 | 692 | elseif ($type == 'S') { |
693 | - $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
|
693 | + $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM')); |
|
694 | 694 | } |
695 | 695 | elseif ($type == 'H') { |
696 | - $vsta = array_merge($vsta,array('Link type' => 'HF')); |
|
696 | + $vsta = array_merge($vsta, array('Link type' => 'HF')); |
|
697 | 697 | } |
698 | 698 | elseif ($type == 'G') { |
699 | - $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
|
699 | + $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM')); |
|
700 | 700 | } |
701 | 701 | elseif ($type == 'C') { |
702 | - $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
|
702 | + $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM')); |
|
703 | 703 | } |
704 | 704 | elseif ($type == '2') { |
705 | - $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
|
705 | + $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2')); |
|
706 | 706 | } |
707 | 707 | elseif ($type == 'X') { |
708 | - $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
|
708 | + $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero')); |
|
709 | 709 | } |
710 | 710 | elseif ($type == 'I') { |
711 | - $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
|
711 | + $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM')); |
|
712 | 712 | } |
713 | 713 | else { |
714 | - $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
|
714 | + $vsta = array_merge($vsta, array('Link type' => 'Unknown')); |
|
715 | 715 | } |
716 | - $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
|
717 | - $decode = array_merge($vsta,$decode); |
|
716 | + $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2)))); |
|
717 | + $decode = array_merge($vsta, $decode); |
|
718 | 718 | } |
719 | 719 | } |
720 | 720 | |
721 | 721 | $title = $this->getTitlefromLabel($label); |
722 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
722 | + if ($title != '') $decode = array_merge(array('Message title' => $title), $decode); |
|
723 | 723 | /* |
724 | 724 | // Business jets always use GS0001 |
725 | 725 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -747,13 +747,13 @@ discard block |
||
747 | 747 | $Translation = new Translation($this->db); |
748 | 748 | $message = $this->parse($data); |
749 | 749 | if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') { |
750 | - $ident = (string)$message['ident']; |
|
750 | + $ident = (string) $message['ident']; |
|
751 | 751 | $label = $message['label']; |
752 | 752 | $block_id = $message['block_id']; |
753 | 753 | $msg_no = $message['msg_no']; |
754 | 754 | $msg = $message['message']; |
755 | 755 | $decode = $message['decode']; |
756 | - $registration = (string)$message['registration']; |
|
756 | + $registration = (string) $message['registration']; |
|
757 | 757 | if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
758 | 758 | else $latitude = ''; |
759 | 759 | if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
@@ -767,20 +767,20 @@ discard block |
||
767 | 767 | $Image->addSpotterImage($registration); |
768 | 768 | } |
769 | 769 | // Business jets always use GS0001 |
770 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
770 | + if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude); |
|
771 | 771 | if ($globalDebug && isset($info) && $info != '') echo $info; |
772 | 772 | if (count($decode) > 0) $decode_json = json_encode($decode); |
773 | 773 | else $decode_json = ''; |
774 | 774 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
775 | - $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
|
775 | + $Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS'); |
|
776 | 776 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
777 | - $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
|
777 | + $Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS'); |
|
778 | 778 | } |
779 | - $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
780 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
781 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
779 | + $result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
780 | + if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F'); |
|
781 | + if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
782 | 782 | if ($globalDebug && count($decode) > 0) { |
783 | - echo "Human readable data : ".implode(' - ',$decode)."\n"; |
|
783 | + echo "Human readable data : ".implode(' - ', $decode)."\n"; |
|
784 | 784 | } |
785 | 785 | } |
786 | 786 | } |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | * @param String $msg_no Number of the ACARS message |
796 | 796 | * @param String $message ACARS message |
797 | 797 | */ |
798 | - public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
798 | + public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
799 | 799 | global $globalDebug; |
800 | 800 | date_default_timezone_set('UTC'); |
801 | 801 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
@@ -803,21 +803,21 @@ discard block |
||
803 | 803 | $this->db = $Connection->db; |
804 | 804 | if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
805 | 805 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
806 | - $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
|
806 | + $query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message); |
|
807 | 807 | try { |
808 | 808 | $stht = $this->db->prepare($query_test); |
809 | 809 | $stht->execute($query_test_values); |
810 | - } catch(PDOException $e) { |
|
810 | + } catch (PDOException $e) { |
|
811 | 811 | return "error : ".$e->getMessage(); |
812 | 812 | } |
813 | 813 | if ($stht->fetchColumn() == 0) { |
814 | 814 | if ($globalDebug) echo "Add Live ACARS data..."; |
815 | 815 | $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)"; |
816 | - $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")); |
|
816 | + $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")); |
|
817 | 817 | try { |
818 | 818 | $sth = $this->db->prepare($query); |
819 | 819 | $sth->execute($query_values); |
820 | - } catch(PDOException $e) { |
|
820 | + } catch (PDOException $e) { |
|
821 | 821 | return "error : ".$e->getMessage(); |
822 | 822 | } |
823 | 823 | } else { |
@@ -839,10 +839,10 @@ discard block |
||
839 | 839 | * @param String $msg_no Number of the ACARS message |
840 | 840 | * @param String $message ACARS message |
841 | 841 | */ |
842 | - public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
842 | + public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
843 | 843 | global $globalDebug; |
844 | 844 | date_default_timezone_set('UTC'); |
845 | - 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) { |
|
845 | + 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) { |
|
846 | 846 | /* |
847 | 847 | if ($globalDebug) echo "Test if not already in Archive ACARS table..."; |
848 | 848 | $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message"; |
@@ -857,11 +857,11 @@ discard block |
||
857 | 857 | */ |
858 | 858 | if ($globalDebug) echo "Add Live ACARS data..."; |
859 | 859 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
860 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
860 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
861 | 861 | try { |
862 | 862 | $sth = $this->db->prepare($query); |
863 | 863 | $sth->execute($query_values); |
864 | - } catch(PDOException $e) { |
|
864 | + } catch (PDOException $e) { |
|
865 | 865 | return "error : ".$e->getMessage(); |
866 | 866 | } |
867 | 867 | if ($globalDebug) echo "Done\n"; |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | try { |
883 | 883 | $sth = $this->db->prepare($query); |
884 | 884 | $sth->execute($query_values); |
885 | - } catch(PDOException $e) { |
|
885 | + } catch (PDOException $e) { |
|
886 | 886 | echo "error : ".$e->getMessage(); |
887 | 887 | return ''; |
888 | 888 | } |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | try { |
903 | 903 | $sth = $this->db->prepare($query); |
904 | 904 | $sth->execute($query_values); |
905 | - } catch(PDOException $e) { |
|
905 | + } catch (PDOException $e) { |
|
906 | 906 | echo "error : ".$e->getMessage(); |
907 | 907 | return array(); |
908 | 908 | } |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | try { |
924 | 924 | $sth = $this->db->prepare($query); |
925 | 925 | $sth->execute($query_values); |
926 | - } catch(PDOException $e) { |
|
926 | + } catch (PDOException $e) { |
|
927 | 927 | echo "error : ".$e->getMessage(); |
928 | 928 | return array(); |
929 | 929 | } |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | * |
938 | 938 | * @return Array Return ACARS data in array |
939 | 939 | */ |
940 | - public function getLatestAcarsData($limit = '',$label = '') { |
|
940 | + public function getLatestAcarsData($limit = '', $label = '') { |
|
941 | 941 | global $globalURL, $globalDBdriver; |
942 | 942 | $Image = new Image($this->db); |
943 | 943 | $Spotter = new Spotter($this->db); |
@@ -948,8 +948,8 @@ discard block |
||
948 | 948 | if ($limit != "") |
949 | 949 | { |
950 | 950 | $limit_array = explode(",", $limit); |
951 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
952 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
951 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
952 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
953 | 953 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
954 | 954 | { |
955 | 955 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -965,46 +965,46 @@ discard block |
||
965 | 965 | try { |
966 | 966 | $sth = $this->db->prepare($query); |
967 | 967 | $sth->execute($query_values); |
968 | - } catch(PDOException $e) { |
|
968 | + } catch (PDOException $e) { |
|
969 | 969 | return "error : ".$e->getMessage(); |
970 | 970 | } |
971 | 971 | $i = 0; |
972 | 972 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
973 | 973 | $data = array(); |
974 | 974 | if ($row['registration'] != '') { |
975 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
975 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
976 | 976 | $image_array = $Image->getSpotterImage($row['registration']); |
977 | - 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'])); |
|
978 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
979 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
977 | + 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'])); |
|
978 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
979 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
980 | 980 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
981 | 981 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
982 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
982 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
983 | 983 | if (isset($identicao[0])) { |
984 | - if (substr($row['ident'],0,2) == 'AF') { |
|
985 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
986 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
987 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
988 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
984 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
985 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
986 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
987 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
988 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
989 | 989 | } else $icao = $row['ident']; |
990 | - $icao = $Translation->checkTranslation($icao,false); |
|
991 | - $decode = json_decode($row['decode'],true); |
|
990 | + $icao = $Translation->checkTranslation($icao, false); |
|
991 | + $decode = json_decode($row['decode'], true); |
|
992 | 992 | $found = false; |
993 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
993 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
994 | 994 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
995 | 995 | if (isset($airport_info[0]['icao'])) { |
996 | 996 | $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
997 | 997 | $found = true; |
998 | 998 | } |
999 | 999 | } |
1000 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1000 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1001 | 1001 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1002 | 1002 | if (isset($airport_info[0]['icao'])) { |
1003 | 1003 | $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1004 | 1004 | $found = true; |
1005 | 1005 | } |
1006 | 1006 | } |
1007 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1007 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1008 | 1008 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1009 | 1009 | if (isset($airport_info[0]['icao'])) { |
1010 | 1010 | $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>'; |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | } |
1013 | 1013 | } |
1014 | 1014 | if ($found) $row['decode'] = json_encode($decode); |
1015 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1015 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1016 | 1016 | $result[] = $data; |
1017 | 1017 | $i++; |
1018 | 1018 | } |
@@ -1028,7 +1028,7 @@ discard block |
||
1028 | 1028 | * |
1029 | 1029 | * @return Array Return ACARS data in array |
1030 | 1030 | */ |
1031 | - public function getArchiveAcarsData($limit = '',$label = '') { |
|
1031 | + public function getArchiveAcarsData($limit = '', $label = '') { |
|
1032 | 1032 | global $globalURL, $globalDBdriver; |
1033 | 1033 | $Image = new Image($this->db); |
1034 | 1034 | $Spotter = new Spotter($this->db); |
@@ -1038,8 +1038,8 @@ discard block |
||
1038 | 1038 | if ($limit != "") |
1039 | 1039 | { |
1040 | 1040 | $limit_array = explode(",", $limit); |
1041 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1042 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1042 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1043 | 1043 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1044 | 1044 | { |
1045 | 1045 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1060,43 +1060,43 @@ discard block |
||
1060 | 1060 | try { |
1061 | 1061 | $sth = $this->db->prepare($query); |
1062 | 1062 | $sth->execute($query_values); |
1063 | - } catch(PDOException $e) { |
|
1063 | + } catch (PDOException $e) { |
|
1064 | 1064 | return "error : ".$e->getMessage(); |
1065 | 1065 | } |
1066 | - $i=0; |
|
1066 | + $i = 0; |
|
1067 | 1067 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
1068 | 1068 | $data = array(); |
1069 | 1069 | if ($row['registration'] != '') { |
1070 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
1070 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
1071 | 1071 | $image_array = $Image->getSpotterImage($row['registration']); |
1072 | - 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'])); |
|
1073 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1074 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1072 | + 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'])); |
|
1073 | + else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1074 | + } else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1075 | 1075 | $icao = ''; |
1076 | 1076 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
1077 | 1077 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
1078 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
1078 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
1079 | 1079 | if (isset($identicao[0])) { |
1080 | - if (substr($row['ident'],0,2) == 'AF') { |
|
1081 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1082 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1083 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1084 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
1080 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
1081 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1082 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
1083 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
1084 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
1085 | 1085 | } else $icao = $row['ident']; |
1086 | 1086 | $icao = $Translation->checkTranslation($icao); |
1087 | - $decode = json_decode($row['decode'],true); |
|
1087 | + $decode = json_decode($row['decode'], true); |
|
1088 | 1088 | $found = false; |
1089 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
1089 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
1090 | 1090 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1091 | 1091 | 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>'; |
1092 | 1092 | $found = true; |
1093 | 1093 | } |
1094 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1094 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1095 | 1095 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1096 | 1096 | 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>'; |
1097 | 1097 | $found = true; |
1098 | 1098 | } |
1099 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1099 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1100 | 1100 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1101 | 1101 | if (isset($airport_info[0]['icao'])) { |
1102 | 1102 | $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>'; |
@@ -1104,7 +1104,7 @@ discard block |
||
1104 | 1104 | } |
1105 | 1105 | } |
1106 | 1106 | if ($found) $row['decode'] = json_encode($decode); |
1107 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1107 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1108 | 1108 | $result[] = $data; |
1109 | 1109 | $i++; |
1110 | 1110 | } |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | * @param String $icao |
1123 | 1123 | * @param String $ICAOTypeCode |
1124 | 1124 | */ |
1125 | - public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
|
1125 | + public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') { |
|
1126 | 1126 | global $globalDebug, $globalDBdriver; |
1127 | 1127 | $ident = trim($ident); |
1128 | 1128 | $Translation = new Translation($this->db); |
@@ -1135,7 +1135,7 @@ discard block |
||
1135 | 1135 | if ($globalDebug) echo "Ident or registration null, exit\n"; |
1136 | 1136 | return ''; |
1137 | 1137 | } |
1138 | - $registration = str_replace('.','',$registration); |
|
1138 | + $registration = str_replace('.', '', $registration); |
|
1139 | 1139 | $ident = $Translation->ident2icao($ident); |
1140 | 1140 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1141 | 1141 | if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | try { |
1145 | 1145 | $sthsi = $this->db->prepare($querysi); |
1146 | 1146 | $sthsi->execute($querysi_values); |
1147 | - } catch(PDOException $e) { |
|
1147 | + } catch (PDOException $e) { |
|
1148 | 1148 | if ($globalDebug) echo $e->getMessage(); |
1149 | 1149 | return "error : ".$e->getMessage(); |
1150 | 1150 | } |
@@ -1154,8 +1154,8 @@ discard block |
||
1154 | 1154 | $Translation = new Translation($this->db); |
1155 | 1155 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1156 | 1156 | if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
1157 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1158 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1157 | + if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1158 | + elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1159 | 1159 | } else { |
1160 | 1160 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1161 | 1161 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | try { |
1164 | 1164 | $sth = $this->db->prepare($query); |
1165 | 1165 | $sth->execute($query_values); |
1166 | - } catch(PDOException $e) { |
|
1166 | + } catch (PDOException $e) { |
|
1167 | 1167 | if ($globalDebug) echo $e->getMessage(); |
1168 | 1168 | return "error : ".$e->getMessage(); |
1169 | 1169 | } |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | $sth->closeCursor(); |
1172 | 1172 | if (isset($result['modes'])) $hex = $result['modes']; |
1173 | 1173 | else $hex = ''; |
1174 | - $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
|
1174 | + $SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS'); |
|
1175 | 1175 | if ($this->fromACARSscript) $this->SI->add($SI_data); |
1176 | 1176 | } |
1177 | 1177 | } |
@@ -1181,7 +1181,7 @@ discard block |
||
1181 | 1181 | try { |
1182 | 1182 | $sth = $this->db->prepare($query); |
1183 | 1183 | $sth->execute($query_values); |
1184 | - } catch(PDOException $e) { |
|
1184 | + } catch (PDOException $e) { |
|
1185 | 1185 | if ($globalDebug) echo $e->getMessage(); |
1186 | 1186 | return "error : ".$e->getMessage(); |
1187 | 1187 | } |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
1192 | 1192 | else $ModeS = ''; |
1193 | 1193 | if ($ModeS == '') { |
1194 | - $id = explode('-',$result['flightaware_id']); |
|
1194 | + $id = explode('-', $result['flightaware_id']); |
|
1195 | 1195 | $ModeS = $id[0]; |
1196 | 1196 | } |
1197 | 1197 | if ($ModeS != '') { |
@@ -1201,20 +1201,20 @@ discard block |
||
1201 | 1201 | try { |
1202 | 1202 | $sthc = $this->db->prepare($queryc); |
1203 | 1203 | $sthc->execute($queryc_values); |
1204 | - } catch(PDOException $e) { |
|
1204 | + } catch (PDOException $e) { |
|
1205 | 1205 | if ($globalDebug) echo $e->getMessage(); |
1206 | 1206 | return "error : ".$e->getMessage(); |
1207 | 1207 | } |
1208 | 1208 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1209 | 1209 | $sthc->closeCursor(); |
1210 | - if (count($row) == 0) { |
|
1210 | + if (count($row) == 0) { |
|
1211 | 1211 | if ($globalDebug) echo " Add to ModeS table - "; |
1212 | 1212 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
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 | try { |
1215 | 1215 | $sthi = $this->db->prepare($queryi); |
1216 | 1216 | $sthi->execute($queryi_values); |
1217 | - } catch(PDOException $e) { |
|
1217 | + } catch (PDOException $e) { |
|
1218 | 1218 | if ($globalDebug) echo $e->getMessage(); |
1219 | 1219 | return "error : ".$e->getMessage(); |
1220 | 1220 | } |
@@ -1222,15 +1222,15 @@ discard block |
||
1222 | 1222 | if ($globalDebug) echo " Update ModeS table - "; |
1223 | 1223 | if ($ICAOTypeCode != '') { |
1224 | 1224 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1225 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1225 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1226 | 1226 | } else { |
1227 | 1227 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1228 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration); |
|
1228 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration); |
|
1229 | 1229 | } |
1230 | 1230 | try { |
1231 | 1231 | $sthi = $this->db->prepare($queryi); |
1232 | 1232 | $sthi->execute($queryi_values); |
1233 | - } catch(PDOException $e) { |
|
1233 | + } catch (PDOException $e) { |
|
1234 | 1234 | if ($globalDebug) echo $e->getMessage(); |
1235 | 1235 | return "error : ".$e->getMessage(); |
1236 | 1236 | } |
@@ -1267,12 +1267,12 @@ discard block |
||
1267 | 1267 | elseif ($globalDBdriver == 'pgsql') { |
1268 | 1268 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1269 | 1269 | } |
1270 | - $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
|
1270 | + $queryi_values = array(':Registration' => $registration, ':ident' => $icao); |
|
1271 | 1271 | } |
1272 | 1272 | try { |
1273 | 1273 | $sthi = $this->db->prepare($queryi); |
1274 | 1274 | $sthi->execute($queryi_values); |
1275 | - } catch(PDOException $e) { |
|
1275 | + } catch (PDOException $e) { |
|
1276 | 1276 | if ($globalDebug) echo $e->getMessage(); |
1277 | 1277 | return "error : ".$e->getMessage(); |
1278 | 1278 | } |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | |
4 | -class Connection{ |
|
4 | +class Connection { |
|
5 | 5 | public $db = null; |
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 50; |
8 | 8 | |
9 | - public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
|
9 | + public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) { |
|
10 | 10 | global $globalNoDB; |
11 | 11 | if (isset($globalNoDB) && $globalNoDB === TRUE) { |
12 | 12 | $this->db = null; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | if ($user === null && $pass === null) { |
17 | 17 | $this->createDBConnection(); |
18 | 18 | } else { |
19 | - $this->createDBConnection(null,$user,$pass); |
|
19 | + $this->createDBConnection(null, $user, $pass); |
|
20 | 20 | } |
21 | 21 | } else { |
22 | 22 | $this->createDBConnection($dbname); |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | while (true) { |
101 | 101 | try { |
102 | 102 | if ($globalDBSdriver == 'mysql') { |
103 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
103 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
104 | 104 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
105 | 105 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
106 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
107 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
108 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
109 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
110 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
106 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
107 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500); |
|
108 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
109 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
110 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
111 | 111 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
112 | 112 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
113 | 113 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -117,19 +117,19 @@ discard block |
||
117 | 117 | $this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"'); |
118 | 118 | //$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"'); |
119 | 119 | } else { |
120 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
120 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
121 | 121 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
122 | 122 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
123 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
124 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
125 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
126 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
127 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
123 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
124 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
125 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
126 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
127 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
128 | 128 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
129 | 129 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
130 | 130 | } |
131 | 131 | break; |
132 | - } catch(PDOException $e) { |
|
132 | + } catch (PDOException $e) { |
|
133 | 133 | $i++; |
134 | 134 | if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
135 | 135 | //exit; |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | try { |
155 | 155 | //$Connection = new Connection(); |
156 | 156 | $results = $this->db->query($query); |
157 | - } catch(PDOException $e) { |
|
157 | + } catch (PDOException $e) { |
|
158 | 158 | return false; |
159 | 159 | } |
160 | - if($results->rowCount()>0) { |
|
160 | + if ($results->rowCount() > 0) { |
|
161 | 161 | return true; |
162 | 162 | } |
163 | 163 | else return false; |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | |
182 | - } catch(PDOException $e) { |
|
183 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
182 | + } catch (PDOException $e) { |
|
183 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
184 | 184 | throw $e; |
185 | 185 | } |
186 | 186 | //echo 'error ! '.$e->getMessage(); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | /* |
193 | 193 | * Check if index exist |
194 | 194 | */ |
195 | - public function indexExists($table,$index) |
|
195 | + public function indexExists($table, $index) |
|
196 | 196 | { |
197 | 197 | global $globalDBdriver, $globalDBname; |
198 | 198 | if ($globalDBdriver == 'mysql') { |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | try { |
204 | 204 | //$Connection = new Connection(); |
205 | 205 | $results = $this->db->query($query); |
206 | - } catch(PDOException $e) { |
|
206 | + } catch (PDOException $e) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
210 | - if($nb[0]['nb'] > 0) { |
|
210 | + if ($nb[0]['nb'] > 0) { |
|
211 | 211 | return true; |
212 | 212 | } |
213 | 213 | else return false; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
223 | 223 | try { |
224 | 224 | $results = $this->db->query($query); |
225 | - } catch(PDOException $e) { |
|
225 | + } catch (PDOException $e) { |
|
226 | 226 | return "error : ".$e->getMessage()."\n"; |
227 | 227 | } |
228 | 228 | $columns = array(); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | return $columns; |
235 | 235 | } |
236 | 236 | |
237 | - public function getColumnType($table,$column) { |
|
237 | + public function getColumnType($table, $column) { |
|
238 | 238 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
239 | 239 | $tomet = $select->getColumnMeta(0); |
240 | 240 | return $tomet['native_type']; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * Check if a column name exist in a table |
245 | 245 | * @return Boolean column exist or not |
246 | 246 | */ |
247 | - public function checkColumnName($table,$name) |
|
247 | + public function checkColumnName($table, $name) |
|
248 | 248 | { |
249 | 249 | global $globalDBdriver, $globalDBname; |
250 | 250 | if ($globalDBdriver == 'mysql') { |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | } |
255 | 255 | try { |
256 | 256 | $sth = $this->db()->prepare($query); |
257 | - $sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name)); |
|
258 | - } catch(PDOException $e) { |
|
257 | + $sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name)); |
|
258 | + } catch (PDOException $e) { |
|
259 | 259 | echo "error : ".$e->getMessage()."\n"; |
260 | 260 | } |
261 | 261 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | try { |
295 | 295 | $sth = $this->db->prepare($query); |
296 | 296 | $sth->execute(); |
297 | - } catch(PDOException $e) { |
|
297 | + } catch (PDOException $e) { |
|
298 | 298 | return "error : ".$e->getMessage()."\n"; |
299 | 299 | } |
300 | 300 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | $gpx .= '<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpsies="http://www.gpsies.com/GPX/1/0" creator="GPSies http://www.gpsies.com - Sendl.-O&apos;sch-heim" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.gpsies.com/GPX/1/0 http://www.gpsies.com/gpsies.xsd">'; |
42 | 42 | $gpx .= '<trk>'; |
43 | 43 | $gpx .= '<trkseg>'; |
44 | - foreach($spotter_history_array as $spotter_data) { |
|
45 | - $gpx .= '<trkpt lat="'.sprintf("%.8f",$spotter_data['latitude']).'" lon="'.sprintf("%.8f",$spotter_data['longitude']).'">'; |
|
46 | - $gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>'; |
|
47 | - $gpx .= '<time>'.date("Y-m-d\TH:i:s\Z",strtotime($spotter_data['date'])).'</time>'; |
|
44 | + foreach ($spotter_history_array as $spotter_data) { |
|
45 | + $gpx .= '<trkpt lat="'.sprintf("%.8f", $spotter_data['latitude']).'" lon="'.sprintf("%.8f", $spotter_data['longitude']).'">'; |
|
46 | + $gpx .= '<ele>'.sprintf("%.6f", $spotter_data['altitude']).'</ele>'; |
|
47 | + $gpx .= '<time>'.date("Y-m-d\TH:i:s\Z", strtotime($spotter_data['date'])).'</time>'; |
|
48 | 48 | $gpx .= '</trkpt>'; |
49 | 49 | } |
50 | 50 | $gpx .= '</trkseg>'; |
@@ -81,18 +81,18 @@ discard block |
||
81 | 81 | global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId; |
82 | 82 | if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100; |
83 | 83 | if (count($spotter_history_array) < 2) return $spotter_history_array; |
84 | - if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
84 | + if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts); |
|
85 | 85 | $data = $this->create_gpx($spotter_history_array); |
86 | 86 | $url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true'; |
87 | 87 | $Common = new Common(); |
88 | - $matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml','Accept: application/json')); |
|
89 | - $matching = json_decode($matching,true); |
|
88 | + $matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml', 'Accept: application/json')); |
|
89 | + $matching = json_decode($matching, true); |
|
90 | 90 | if (isset($matching['diary']['entries'][0]['route']['links'])) { |
91 | 91 | $spotter_history_array = array(); |
92 | 92 | foreach ($matching['diary']['entries'][0]['route']['links'] as $match) { |
93 | 93 | if (isset($match['wpts'])) { |
94 | 94 | foreach ($match['wpts'] as $coord) { |
95 | - $spotter_history_array[] = array('longitude' => $coord['x'],'latitude' => $coord['y']); |
|
95 | + $spotter_history_array[] = array('longitude' => $coord['x'], 'latitude' => $coord['y']); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |
@@ -111,22 +111,22 @@ discard block |
||
111 | 111 | if (count($spotter_history_array) < 2) return $spotter_history_array; |
112 | 112 | $spotter_history_initial_array = array(); |
113 | 113 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
114 | - $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
115 | - $spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts); |
|
114 | + $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts); |
|
115 | + $spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts); |
|
116 | 116 | } |
117 | 117 | $data = $this->create_gpx($spotter_history_array); |
118 | 118 | $url = 'https://graphhopper.com/api/1/match?vehicle=car&points_encoded=0&key='.$globalGraphHopperKey; |
119 | 119 | $Common = new Common(); |
120 | - $matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml')); |
|
121 | - $matching = json_decode($matching,true); |
|
120 | + $matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml')); |
|
121 | + $matching = json_decode($matching, true); |
|
122 | 122 | if (isset($matching['paths'][0]['points']['coordinates'])) { |
123 | 123 | $spotter_history_array = array(); |
124 | 124 | foreach ($matching['paths'][0]['points']['coordinates'] as $match) { |
125 | 125 | $coord = $match; |
126 | - $spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]); |
|
126 | + $spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]); |
|
127 | 127 | } |
128 | 128 | } |
129 | - $spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array); |
|
129 | + $spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array); |
|
130 | 130 | return $spotter_history_array; |
131 | 131 | } |
132 | 132 | |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | if (count($spotter_history_array) < 2) return $spotter_history_array; |
142 | 142 | $spotter_history_initial_array = array(); |
143 | 143 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
144 | - $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
145 | - $spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts); |
|
144 | + $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts); |
|
145 | + $spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts); |
|
146 | 146 | } |
147 | 147 | $coord = ''; |
148 | 148 | $ts = ''; |
@@ -158,15 +158,15 @@ discard block |
||
158 | 158 | $url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore'; |
159 | 159 | $Common = new Common(); |
160 | 160 | $matching = $Common->getData($url); |
161 | - $matching = json_decode($matching,true); |
|
161 | + $matching = json_decode($matching, true); |
|
162 | 162 | if (isset($matching['matchings'][0]['geometry']['coordinates'])) { |
163 | 163 | $spotter_history_array = array(); |
164 | 164 | foreach ($matching['matchings'][0]['geometry']['coordinates'] as $match) { |
165 | 165 | $coord = $match; |
166 | - $spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]); |
|
166 | + $spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]); |
|
167 | 167 | } |
168 | 168 | } |
169 | - $spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array); |
|
169 | + $spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array); |
|
170 | 170 | return $spotter_history_array; |
171 | 171 | } |
172 | 172 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | if (count($spotter_history_array) < 2) return $spotter_history_array; |
182 | 182 | $spotter_history_initial_array = array(); |
183 | 183 | if (count($spotter_history_array) > $globalMapMatchingMaxPts) { |
184 | - $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts); |
|
185 | - $spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts); |
|
184 | + $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts); |
|
185 | + $spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts); |
|
186 | 186 | } |
187 | 187 | $coord = ''; |
188 | 188 | $ts = ''; |
@@ -199,15 +199,15 @@ discard block |
||
199 | 199 | $url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'×tamps='.$ts.'&overview=full&tidy=true&geometries=geojson'; |
200 | 200 | $Common = new Common(); |
201 | 201 | $matching = $Common->getData($url); |
202 | - $matching = json_decode($matching,true); |
|
202 | + $matching = json_decode($matching, true); |
|
203 | 203 | if (isset($matching['matchings'][0]['geometry']['coordinates'])) { |
204 | 204 | $spotter_history_array = array(); |
205 | 205 | foreach ($matching['matchings'][0]['geometry']['coordinates'] as $match) { |
206 | 206 | $coord = $match; |
207 | - $spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]); |
|
207 | + $spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]); |
|
208 | 208 | } |
209 | 209 | } |
210 | - $spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array); |
|
210 | + $spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array); |
|
211 | 211 | return $spotter_history_array; |
212 | 212 | } |
213 | 213 |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @param String $arrival_airport_time arrival airport time |
36 | 36 | / @param String $source source of data |
37 | 37 | */ |
38 | - public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
|
38 | + public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') { |
|
39 | 39 | date_default_timezone_set('UTC'); |
40 | - $date = date("Y-m-d H:i:s",time()); |
|
40 | + $date = date("Y-m-d H:i:s", time()); |
|
41 | 41 | //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
42 | 42 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
43 | 43 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
@@ -45,69 +45,69 @@ discard block |
||
45 | 45 | try { |
46 | 46 | $sth = $this->db->prepare($query); |
47 | 47 | $sth->execute($query_values); |
48 | - } catch(PDOException $e) { |
|
48 | + } catch (PDOException $e) { |
|
49 | 49 | return "error : ".$e->getMessage(); |
50 | 50 | } |
51 | 51 | if ($sth->fetchColumn() > 0) { |
52 | 52 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
53 | 53 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
54 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
54 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao); |
|
55 | 55 | } elseif ($arrival_airport_time == '') { |
56 | 56 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
57 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
57 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao); |
|
58 | 58 | } elseif ($departure_airport_time == '') { |
59 | 59 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
60 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
60 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
61 | 61 | } else { |
62 | 62 | //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
63 | 63 | $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
64 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
64 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time); |
|
65 | 65 | } |
66 | 66 | try { |
67 | 67 | $sth = $this->db->prepare($query); |
68 | 68 | $sth->execute($query_values); |
69 | - } catch(PDOException $e) { |
|
69 | + } catch (PDOException $e) { |
|
70 | 70 | return "error : ".$e->getMessage(); |
71 | 71 | } |
72 | 72 | if ($sth->fetchColumn() == 0) { |
73 | 73 | //$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident'; |
74 | 74 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
75 | 75 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
76 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
76 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
77 | 77 | } elseif ($arrival_airport_time == '') { |
78 | 78 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
79 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
79 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
80 | 80 | } elseif ($departure_airport_time == '') { |
81 | 81 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
82 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
82 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
83 | 83 | } else { |
84 | 84 | $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
85 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
85 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
86 | 86 | } |
87 | 87 | try { |
88 | 88 | $sth = $this->db->prepare($query); |
89 | 89 | $sth->execute($query_values); |
90 | - } catch(PDOException $e) { |
|
90 | + } catch (PDOException $e) { |
|
91 | 91 | return "error : ".$e->getMessage(); |
92 | 92 | } |
93 | 93 | } else { |
94 | 94 | //$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident'; |
95 | 95 | $query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident'; |
96 | - $query_values = array(':ident' => $ident,':date' => $date); |
|
96 | + $query_values = array(':ident' => $ident, ':date' => $date); |
|
97 | 97 | try { |
98 | 98 | $sth = $this->db->prepare($query); |
99 | 99 | $sth->execute($query_values); |
100 | - } catch(PDOException $e) { |
|
100 | + } catch (PDOException $e) { |
|
101 | 101 | return "error : ".$e->getMessage(); |
102 | 102 | } |
103 | 103 | } |
104 | 104 | } else { |
105 | 105 | $query = 'INSERT INTO routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source) VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)'; |
106 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
106 | + $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
107 | 107 | try { |
108 | 108 | $sth = $this->db->prepare($query); |
109 | 109 | $sth->execute($query_values); |
110 | - } catch(PDOException $e) { |
|
110 | + } catch (PDOException $e) { |
|
111 | 111 | return "error : ".$e->getMessage(); |
112 | 112 | } |
113 | 113 | } |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function getSchedule($ident) { |
122 | 122 | $Translation = new Translation($this->db); |
123 | - $operator = $Translation->checkTranslation($ident,false); |
|
123 | + $operator = $Translation->checkTranslation($ident, false); |
|
124 | 124 | if ($ident != $operator) { |
125 | 125 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1"; |
126 | - $query_values = array(':ident' => $ident,'operator' => $operator); |
|
126 | + $query_values = array(':ident' => $ident, 'operator' => $operator); |
|
127 | 127 | } else { |
128 | 128 | $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1"; |
129 | 129 | $query_values = array(':ident' => $ident); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | try { |
132 | 132 | $sth = $this->db->prepare($query); |
133 | 133 | $sth->execute($query_values); |
134 | - } catch(PDOException $e) { |
|
134 | + } catch (PDOException $e) { |
|
135 | 135 | return "error : ".$e->getMessage(); |
136 | 136 | } |
137 | 137 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | try { |
161 | 161 | $sth = $this->db->prepare($query); |
162 | 162 | $sth->execute($query_values); |
163 | - } catch(PDOException $e) { |
|
163 | + } catch (PDOException $e) { |
|
164 | 164 | return "error : ".$e->getMessage(); |
165 | 165 | } |
166 | 166 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -175,16 +175,16 @@ discard block |
||
175 | 175 | * @param String $carrier IATA code |
176 | 176 | * @return Flight departure and arrival airports and time |
177 | 177 | */ |
178 | - private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
|
178 | + private function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') { |
|
179 | 179 | $Common = new Common(); |
180 | 180 | $check_date = new Datetime($date); |
181 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
182 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
181 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
182 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
183 | 183 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
184 | 184 | $json = $Common->getData($url); |
185 | 185 | |
186 | 186 | $parsed_json = json_decode($json); |
187 | - if (property_exists($parsed_json,'errors') === false) { |
|
187 | + if (property_exists($parsed_json, 'errors') === false) { |
|
188 | 188 | //$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'}; |
189 | 189 | $originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'}; |
190 | 190 | //$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'}; |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | //$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'}; |
195 | 195 | $arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'}; |
196 | 196 | |
197 | - preg_match('/\((.*?)\)/',$originShort,$originiata); |
|
197 | + preg_match('/\((.*?)\)/', $originShort, $originiata); |
|
198 | 198 | $DepartureAirportIata = $originiata[1]; |
199 | - preg_match('/\((.*?)\)/',$destinationShort,$destinationiata); |
|
199 | + preg_match('/\((.*?)\)/', $destinationShort, $destinationiata); |
|
200 | 200 | $ArrivalAirportIata = $destinationiata[1]; |
201 | 201 | |
202 | 202 | /* |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $arrivalTime = gmdate('H:i',strtotime($arrivalTime)); |
206 | 206 | */ |
207 | 207 | |
208 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
|
208 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance'); |
|
209 | 209 | } else return array(); |
210 | 210 | } |
211 | 211 | |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | $Common = new Common(); |
221 | 221 | date_default_timezone_set($globalTimezone); |
222 | 222 | $check_date = new Datetime($date); |
223 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
224 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
223 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
224 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
225 | 225 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
226 | 226 | $json = $Common->getData($url); |
227 | 227 | $parsed_json = json_decode($json); |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'}; |
234 | 234 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
235 | 235 | |
236 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
|
236 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet'); |
|
237 | 237 | } else return array(); |
238 | 238 | } |
239 | 239 | |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | */ |
245 | 245 | private function getRyanair($callsign) { |
246 | 246 | $Common = new Common(); |
247 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
248 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
247 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
248 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
249 | 249 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
250 | 250 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
251 | - $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
|
252 | - $json = $Common->getData($url,'post',$post,$headers); |
|
251 | + $headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post)); |
|
252 | + $json = $Common->getData($url, 'post', $post, $headers); |
|
253 | 253 | $parsed_json = json_decode($json); |
254 | 254 | if (isset($parsed_json->{'flightInfo'})) { |
255 | 255 | $flights = $parsed_json->{'flightInfo'}; |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | $ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name |
259 | 259 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
260 | 260 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
261 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
261 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
|
262 | 262 | } else return array(); |
263 | 263 | } else return array(); |
264 | 264 | } |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | */ |
271 | 271 | private function getSwiss($callsign) { |
272 | 272 | $Common = new Common(); |
273 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
274 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
273 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
274 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
275 | 275 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
276 | 276 | $json = $Common->getData($url); |
277 | 277 | $parsed_json = json_decode($json); |
@@ -285,12 +285,12 @@ discard block |
||
285 | 285 | if ($flight->{'no'} == "Vol LX ".$numvol) { |
286 | 286 | $DepartureAirportIata = $flight->{'from'}->{'code'}; //city |
287 | 287 | $ArrivalAirportIata = $flight->{'to'}->{'code'}; //city |
288 | - $departureTime = substr($flight->{'from'}->{'hour'},0,5); |
|
289 | - $arrivalTime = substr($flight->{'to'}->{'hour'},0,5); |
|
288 | + $departureTime = substr($flight->{'from'}->{'hour'},0, 5); |
|
289 | + $arrivalTime = substr($flight->{'to'}->{'hour'},0, 5); |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) { |
293 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
|
293 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss'); |
|
294 | 294 | } else return array(); |
295 | 295 | } else return array(); |
296 | 296 | } |
@@ -305,21 +305,21 @@ discard block |
||
305 | 305 | global $globalBritishAirwaysKey; |
306 | 306 | $Common = new Common(); |
307 | 307 | $check_date = new Datetime($date); |
308 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
309 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
308 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
309 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
310 | 310 | if ($globalBritishAirwaysKey == '') return array(); |
311 | 311 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
312 | 312 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
313 | - $json = $Common->getData($url,'get','',$headers); |
|
313 | + $json = $Common->getData($url, 'get', '', $headers); |
|
314 | 314 | if ($json == '') return array(); |
315 | 315 | $parsed_json = json_decode($json); |
316 | 316 | $flights = $parsed_json->{'FlightsResponse'}; |
317 | 317 | if (count($flights) > 0) { |
318 | 318 | $DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'}; |
319 | 319 | $ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'}; |
320 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
321 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
322 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
|
320 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
|
321 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
|
322 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways'); |
|
323 | 323 | } else return array(); |
324 | 324 | } |
325 | 325 | |
@@ -333,27 +333,27 @@ discard block |
||
333 | 333 | global $globalLufthansaKey; |
334 | 334 | $Common = new Common(); |
335 | 335 | $check_date = new Datetime($date); |
336 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
337 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
336 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
337 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
338 | 338 | if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
339 | 339 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
340 | - $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
|
341 | - $data = $Common->getData($url,'post',$post); |
|
340 | + $post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials'); |
|
341 | + $data = $Common->getData($url, 'post', $post); |
|
342 | 342 | $parsed_data = json_decode($data); |
343 | 343 | if (!isset($parsed_data->{'access_token'})) return array(); |
344 | 344 | $token = $parsed_data->{'access_token'}; |
345 | 345 | |
346 | 346 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
347 | - $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
|
348 | - $json = $Common->getData($url,'get','',$headers); |
|
347 | + $headers = array('Authorization: Bearer '.$token, 'Accept: application/json'); |
|
348 | + $json = $Common->getData($url, 'get', '', $headers); |
|
349 | 349 | if ($json == '') return array(); |
350 | 350 | $parsed_json = json_decode($json); |
351 | 351 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
352 | 352 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
353 | - $departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
353 | + $departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
354 | 354 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
355 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
356 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
|
355 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
|
356 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa'); |
|
357 | 357 | } else return array(); |
358 | 358 | } |
359 | 359 | |
@@ -367,23 +367,23 @@ discard block |
||
367 | 367 | global $globalTransaviaKey; |
368 | 368 | $Common = new Common(); |
369 | 369 | $check_date = new Datetime($date); |
370 | - $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
|
371 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
370 | + $numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign)); |
|
371 | + if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array(); |
|
372 | 372 | if ($globalTransaviaKey == '') return array(); |
373 | 373 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
374 | 374 | //$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
375 | 375 | $headers = array('apikey: '.$globalTransaviaKey); |
376 | - $json = $Common->getData($url,'get','',$headers); |
|
376 | + $json = $Common->getData($url, 'get', '', $headers); |
|
377 | 377 | //echo 'result : '.$json; |
378 | 378 | if ($json == '') return array(); |
379 | 379 | $parsed_json = json_decode($json); |
380 | 380 | |
381 | 381 | if (isset($parsed_json->{'data'}[0])) { |
382 | 382 | $DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'}; |
383 | - $departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
383 | + $departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'})); |
|
384 | 384 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
385 | - $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
386 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
|
385 | + $arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
|
386 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia'); |
|
387 | 387 | } else return array(); |
388 | 388 | } |
389 | 389 | |
@@ -394,14 +394,14 @@ discard block |
||
394 | 394 | */ |
395 | 395 | public function getTunisair($callsign) { |
396 | 396 | $Common = new Common(); |
397 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
398 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
397 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
398 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
399 | 399 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
400 | 400 | $data = $Common->getData($url); |
401 | 401 | $table = $Common->table2array($data); |
402 | 402 | foreach ($table as $flight) { |
403 | - if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) { |
|
404 | - return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair'); |
|
403 | + if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) { |
|
404 | + return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair'); |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | return array(); |
@@ -412,21 +412,21 @@ discard block |
||
412 | 412 | * @param String $callsign The callsign |
413 | 413 | * @return Flight departure and arrival airports and time |
414 | 414 | */ |
415 | - public function getVueling($callsign,$date = 'NOW') { |
|
415 | + public function getVueling($callsign, $date = 'NOW') { |
|
416 | 416 | $Common = new Common(); |
417 | 417 | $check_date = new Datetime($date); |
418 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
419 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
420 | - $final_date = str_replace('/','%2F',$check_date->format('d/m/Y')); |
|
418 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
419 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
420 | + $final_date = str_replace('/', '%2F', $check_date->format('d/m/Y')); |
|
421 | 421 | $url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB"; |
422 | 422 | $data = $Common->getData($url); |
423 | - $data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data)); |
|
423 | + $data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data)); |
|
424 | 424 | if ($data != '') { |
425 | - preg_match('/flightOri=[A-Z]{3}/',$data,$result); |
|
426 | - $DepartureAirportIata = str_replace('flightOri=','',$result[0]); |
|
427 | - preg_match('/flightDest=[A-Z]{3}/',$data,$result); |
|
428 | - $ArrivalAirportIata = str_replace('flightDest=','',$result[0]); |
|
429 | - if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling'); |
|
425 | + preg_match('/flightOri=[A-Z]{3}/', $data, $result); |
|
426 | + $DepartureAirportIata = str_replace('flightOri=', '', $result[0]); |
|
427 | + preg_match('/flightDest=[A-Z]{3}/', $data, $result); |
|
428 | + $ArrivalAirportIata = str_replace('flightDest=', '', $result[0]); |
|
429 | + if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling'); |
|
430 | 430 | else return array(); |
431 | 431 | } |
432 | 432 | return array(); |
@@ -440,27 +440,27 @@ discard block |
||
440 | 440 | */ |
441 | 441 | public function getIberia($callsign, $date = 'NOW') { |
442 | 442 | $Common = new Common(); |
443 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
443 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
444 | 444 | $check_date = new Datetime($date); |
445 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
445 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
446 | 446 | $url = "https://www.iberia.com/web/flightDetail.do"; |
447 | - $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
|
448 | - $data = $Common->getData($url,'post',$post); |
|
447 | + $post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB'); |
|
448 | + $data = $Common->getData($url, 'post', $post); |
|
449 | 449 | if ($data != '') { |
450 | 450 | $table = $Common->table2array($data); |
451 | 451 | //print_r($table); |
452 | 452 | if (count($table) > 0) { |
453 | 453 | $flight = $table; |
454 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
455 | - preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch); |
|
454 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
455 | + preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch); |
|
456 | 456 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
457 | 457 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
458 | - $departureTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[3][2]))),0,5); |
|
459 | - $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
|
458 | + $departureTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[3][2]))), 0, 5); |
|
459 | + $arrivalTime = trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][1]))); |
|
460 | 460 | if ($arrivalTime == 'Hora estimada de llegada') { |
461 | - $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
|
462 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
463 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
|
461 | + $arrivalTime = substr(trim(str_replace(' lunes', '', str_replace(' ', '', $flight[5][2]))), 0, 5); |
|
462 | + } else $arrivalTime = substr($arrivalTime, 0, 5); |
|
463 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia'); |
|
464 | 464 | } |
465 | 465 | } |
466 | 466 | return array(); |
@@ -473,11 +473,11 @@ discard block |
||
473 | 473 | * @return Flight departure and arrival airports and time |
474 | 474 | */ |
475 | 475 | |
476 | - private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
|
476 | + private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') { |
|
477 | 477 | $Common = new Common(); |
478 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
478 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
479 | 479 | $check_date = new Datetime($date); |
480 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
480 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
481 | 481 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
482 | 482 | $data = $Common->getData($url); |
483 | 483 | if ($data != '') { |
@@ -486,13 +486,13 @@ discard block |
||
486 | 486 | $flight = $table; |
487 | 487 | //print_r($table); |
488 | 488 | if (isset($flight[25]) && isset($flight[29])) { |
489 | - preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch); |
|
490 | - preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch); |
|
489 | + preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch); |
|
490 | + preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch); |
|
491 | 491 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
492 | 492 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
493 | - $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
|
494 | - $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
|
495 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
|
493 | + $departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5); |
|
494 | + $arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5); |
|
495 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance'); |
|
496 | 496 | } else return array(); |
497 | 497 | } |
498 | 498 | |
@@ -510,10 +510,10 @@ discard block |
||
510 | 510 | */ |
511 | 511 | private function getAlitalia($callsign, $date = 'NOW') { |
512 | 512 | $Common = new Common(); |
513 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
513 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
514 | 514 | $check_date = new Datetime($date); |
515 | - $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
516 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
515 | + $url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
|
516 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
517 | 517 | $data = $Common->getData($url); |
518 | 518 | if ($data != '') { |
519 | 519 | $table = $Common->text2array($data); |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | $ArrivalAirportIata = ''; |
522 | 522 | $departureTime = $table[4]; |
523 | 523 | $arrivalTime = $table[5]; |
524 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia'); |
|
524 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia'); |
|
525 | 525 | } |
526 | 526 | } |
527 | 527 | |
@@ -533,21 +533,21 @@ discard block |
||
533 | 533 | */ |
534 | 534 | private function getBrussels($callsign, $date = 'NOW') { |
535 | 535 | $Common = new Common(); |
536 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
536 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
537 | 537 | $check_date = new Datetime($date); |
538 | - $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
538 | + $url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
|
539 | 539 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
540 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
540 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
541 | 541 | $data = $Common->getData($url); |
542 | 542 | if ($data != '') { |
543 | 543 | //echo $data; |
544 | - $parsed_json = json_decode($data,true); |
|
544 | + $parsed_json = json_decode($data, true); |
|
545 | 545 | if (isset($parsed_json[0]['FromAirportCode'])) { |
546 | 546 | $DepartureAirportIata = $parsed_json[0]['FromAirportCode']; |
547 | 547 | $ArrivalAirportIata = $parsed_json[0]['ToAirportCode']; |
548 | - $departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
|
549 | - $arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
|
550 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
|
548 | + $departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate'])); |
|
549 | + $arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate'])); |
|
550 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels'); |
|
551 | 551 | } |
552 | 552 | } |
553 | 553 | } |
@@ -624,21 +624,21 @@ discard block |
||
624 | 624 | */ |
625 | 625 | private function getFlyTap($callsign) { |
626 | 626 | $Common = new Common(); |
627 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
628 | - $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
627 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
628 | + $url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
|
629 | 629 | //$check_date = new Datetime($date); |
630 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
631 | - $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
|
632 | - $data = $Common->getData($url,'post',$post); |
|
630 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
631 | + $post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1'); |
|
632 | + $data = $Common->getData($url, 'post', $post); |
|
633 | 633 | if ($data != '') { |
634 | 634 | $table = $Common->table2array($data); |
635 | - $departureTime = trim(substr($table[15][0],0,5)); |
|
636 | - $arrivalTime = trim(substr($table[35][0],0,5)); |
|
637 | - preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch); |
|
638 | - preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch); |
|
635 | + $departureTime = trim(substr($table[15][0], 0, 5)); |
|
636 | + $arrivalTime = trim(substr($table[35][0], 0, 5)); |
|
637 | + preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch); |
|
638 | + preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch); |
|
639 | 639 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
640 | 640 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
641 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap'); |
|
641 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap'); |
|
642 | 642 | } |
643 | 643 | return array(); |
644 | 644 | } |
@@ -660,10 +660,10 @@ discard block |
||
660 | 660 | } |
661 | 661 | } |
662 | 662 | if ($airline_icao == '') return array(); |
663 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
664 | - $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
663 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
664 | + $url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
|
665 | 665 | //$check_date = new Datetime($date); |
666 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
666 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
667 | 667 | $data = $Common->getData($url); |
668 | 668 | if ($data != '') { |
669 | 669 | $table = $Common->table2array($data); |
@@ -673,13 +673,13 @@ discard block |
||
673 | 673 | $darr = ''; |
674 | 674 | $ahour = ''; |
675 | 675 | $aarr = ''; |
676 | - $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
|
676 | + $n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr); |
|
677 | 677 | if ($n == 7) { |
678 | 678 | $departureTime = $dhour; |
679 | 679 | $arrivalTime = $ahour; |
680 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
681 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
682 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
680 | + $DepartureAirportIata = str_replace(array('(', ')'), '', $darr); |
|
681 | + $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr); |
|
682 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper'); |
|
683 | 683 | } |
684 | 684 | } |
685 | 685 | } |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | $url = 'http://'.$globalFlightAwareUsername.':'.$globalFlightAwarePassword.'@flightxml.flightaware.com/json/FlightXML3/FlightInfoStatus?ident='.$callsign; |
712 | 712 | $data = $Common->getData($url); |
713 | 713 | if ($data != '') { |
714 | - $result = json_decode($data,true); |
|
714 | + $result = json_decode($data, true); |
|
715 | 715 | $flight = $result['FlightInfoStatusResult']['flights'][0]; |
716 | 716 | if (isset($flight['origin'])) { |
717 | 717 | return array( |
@@ -724,18 +724,18 @@ discard block |
||
724 | 724 | } |
725 | 725 | } |
726 | 726 | |
727 | - $url= "http://flightaware.com/live/flight/".$callsign; |
|
727 | + $url = "http://flightaware.com/live/flight/".$callsign; |
|
728 | 728 | $data = $Common->getData($url); |
729 | 729 | if ($data != '') { |
730 | - preg_match(':<script>var trackpollBootstrap = (.*?);</script>:',$data,$result); |
|
731 | - $flights = json_decode($result[1],true); |
|
730 | + preg_match(':<script>var trackpollBootstrap = (.*?);</script>:', $data, $result); |
|
731 | + $flights = json_decode($result[1], true); |
|
732 | 732 | $flight = reset($flights['flights']); |
733 | 733 | if (isset($flight['activityLog']['flights'][0]['origin'])) { |
734 | 734 | return array( |
735 | 735 | 'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'], |
736 | - 'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']), |
|
736 | + 'DepartureTime' => date('H:i', $flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']), |
|
737 | 737 | 'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'], |
738 | - 'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']), |
|
738 | + 'ArrivalTime' => date('H:i', $flight['activityLog']['flights'][0]['landingTimes']['scheduled']), |
|
739 | 739 | 'Source' => 'website_flightaware'); |
740 | 740 | } |
741 | 741 | } |
@@ -749,20 +749,20 @@ discard block |
||
749 | 749 | */ |
750 | 750 | public function getCostToTravel($callsign) { |
751 | 751 | $Common = new Common(); |
752 | - $url= "http://www.costtotravel.com/flight-number/".$callsign; |
|
752 | + $url = "http://www.costtotravel.com/flight-number/".$callsign; |
|
753 | 753 | //$check_date = new Datetime($date); |
754 | 754 | //if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
755 | 755 | $data = $Common->getData($url); |
756 | 756 | if ($data != '') { |
757 | 757 | $table = $Common->table2array($data); |
758 | 758 | if (isset($table[11][1])) { |
759 | - if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5); |
|
759 | + if (is_numeric(substr($table[11][1], 0, 1))) $departureTime = substr($table[11][1], 0, 5); |
|
760 | 760 | else $departureTime = ''; |
761 | - if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5); |
|
761 | + if (is_numeric(substr($table[17][1], 0, 1))) $arrivalTime = substr($table[17][1], 0, 5); |
|
762 | 762 | else $arrivalTime = ''; |
763 | - $DepartureAirportIata = substr($table[13][1],0,3); |
|
764 | - $ArrivalAirportIata = substr($table[15][1],0,3); |
|
765 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel'); |
|
763 | + $DepartureAirportIata = substr($table[13][1], 0, 3); |
|
764 | + $ArrivalAirportIata = substr($table[15][1], 0, 3); |
|
765 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel'); |
|
766 | 766 | } |
767 | 767 | } |
768 | 768 | return array(); |
@@ -774,14 +774,14 @@ discard block |
||
774 | 774 | * @param String $date date we want flight number info |
775 | 775 | * @return Flight departure and arrival airports and time |
776 | 776 | */ |
777 | - private function getAirCanada($callsign,$date = 'NOW') { |
|
777 | + private function getAirCanada($callsign, $date = 'NOW') { |
|
778 | 778 | $Common = new Common(); |
779 | 779 | if (class_exists("DomDocument") === FALSE) return array(); |
780 | 780 | date_default_timezone_set('UTC'); |
781 | 781 | $check_date = new Datetime($date); |
782 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
783 | - $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
784 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
782 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
783 | + $url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
|
784 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
785 | 785 | $data = $Common->getData($url); |
786 | 786 | $dom = new DomDocument(); |
787 | 787 | $dom->loadXML($data); |
@@ -789,11 +789,11 @@ discard block |
||
789 | 789 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
790 | 790 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
791 | 791 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
792 | - $departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
792 | + $departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
793 | 793 | $arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0); |
794 | 794 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
795 | - $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
796 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
|
795 | + $arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
|
796 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada'); |
|
797 | 797 | } else return array(); |
798 | 798 | } |
799 | 799 | |
@@ -805,21 +805,21 @@ discard block |
||
805 | 805 | */ |
806 | 806 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
807 | 807 | $Common = new Common(); |
808 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
808 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
809 | 809 | $check_date = new Datetime($date); |
810 | - $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
811 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
810 | + $url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
|
811 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
812 | 812 | $data = $Common->getData($url); |
813 | 813 | if ($data != '') { |
814 | 814 | $table = $Common->table2array($data); |
815 | 815 | $flight = $table; |
816 | - preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch); |
|
817 | - preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch); |
|
816 | + preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch); |
|
817 | + preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch); |
|
818 | 818 | $DepartureAirportIata = $DepartureAirportIataMatch[0]; |
819 | 819 | $ArrivalAirportIata = $ArrivalAirportIataMatch[0]; |
820 | 820 | $departureTime = $flight[5][1]; |
821 | 821 | $arrivalTime = $flight[23][1]; |
822 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines'); |
|
822 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines'); |
|
823 | 823 | } |
824 | 824 | } |
825 | 825 | |
@@ -830,16 +830,16 @@ discard block |
||
830 | 830 | * @param String $carrier airline code |
831 | 831 | * @return Flight departure and arrival airports and time |
832 | 832 | */ |
833 | - private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
|
833 | + private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') { |
|
834 | 834 | $Common = new Common(); |
835 | 835 | date_default_timezone_set('UTC'); |
836 | 836 | //AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair |
837 | - $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
|
837 | + $numvol = preg_replace('/^[A-Z]*/', '', $callsign); |
|
838 | 838 | $check_date = new Datetime($date); |
839 | - $url= "http://www.airberlin.com/en-US/site/aims.php"; |
|
840 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
841 | - $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier); |
|
842 | - $data = $Common->getData($url,'post',$post); |
|
839 | + $url = "http://www.airberlin.com/en-US/site/aims.php"; |
|
840 | + if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array(); |
|
841 | + $post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier); |
|
842 | + $data = $Common->getData($url, 'post', $post); |
|
843 | 843 | //echo $data; |
844 | 844 | $DepartureAirportIata = ''; |
845 | 845 | $ArrivalAirportIata = ''; |
@@ -852,8 +852,8 @@ discard block |
||
852 | 852 | if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
853 | 853 | else $departureAirport = ''; |
854 | 854 | } else return array(); |
855 | - $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
|
856 | - $data = $Common->getData($url,'post',$post); |
|
855 | + $post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB'); |
|
856 | + $data = $Common->getData($url, 'post', $post); |
|
857 | 857 | if ($data != '') { |
858 | 858 | $table = $Common->table2array($data); |
859 | 859 | $flight = $table; |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | } |
882 | 882 | } |
883 | 883 | if (isset($DepartureAirportIata)) { |
884 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
|
884 | + return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin'); |
|
885 | 885 | } else return array(); |
886 | 886 | } |
887 | 887 | |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | * @param String $date Date |
892 | 892 | * @return Array Schedules info |
893 | 893 | */ |
894 | - public function fetchSchedule($ident,$date = 'NOW') { |
|
894 | + public function fetchSchedule($ident, $date = 'NOW') { |
|
895 | 895 | global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline; |
896 | 896 | //$Common = new Common(); |
897 | 897 | if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array(); |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | // Brussels Airlines |
962 | 962 | case "BEL": |
963 | 963 | case "SN": |
964 | - return $this->getBrussels($ident,$date); |
|
964 | + return $this->getBrussels($ident, $date); |
|
965 | 965 | /* |
966 | 966 | // Copa Airlines |
967 | 967 | case "CMP": |
@@ -1046,17 +1046,17 @@ discard block |
||
1046 | 1046 | // Air France |
1047 | 1047 | case "AF": |
1048 | 1048 | case "AFR": |
1049 | - return $this->getAirFrance($ident,$date,'AF'); |
|
1049 | + return $this->getAirFrance($ident, $date, 'AF'); |
|
1050 | 1050 | // HOP |
1051 | 1051 | case "A5": |
1052 | 1052 | case "HOP": |
1053 | - return $this->getAirFrance($ident,$date,'A5'); |
|
1053 | + return $this->getAirFrance($ident, $date, 'A5'); |
|
1054 | 1054 | // EasyJet |
1055 | 1055 | case "U2": |
1056 | 1056 | case "DS": |
1057 | 1057 | case "EZY": |
1058 | 1058 | case "EZS": |
1059 | - return $this->getEasyJet($ident,$date); |
|
1059 | + return $this->getEasyJet($ident, $date); |
|
1060 | 1060 | // Ryanair |
1061 | 1061 | case "FR": |
1062 | 1062 | case "RYR": |
@@ -1106,25 +1106,25 @@ discard block |
||
1106 | 1106 | return $this->getIberia($ident); |
1107 | 1107 | // Vietnam Airlines |
1108 | 1108 | case "HVN": |
1109 | - return $this->getVietnamAirlines($ident,$date); |
|
1109 | + return $this->getVietnamAirlines($ident, $date); |
|
1110 | 1110 | // Air Berlin |
1111 | 1111 | case "AB": |
1112 | 1112 | case "BER": |
1113 | - return $this->getAirBerlin($ident,$date,'AB'); |
|
1113 | + return $this->getAirBerlin($ident, $date, 'AB'); |
|
1114 | 1114 | // NIKI |
1115 | 1115 | case "HG": |
1116 | 1116 | case "NLY": |
1117 | - return $this->getAirBerlin($ident,$date,'HG'); |
|
1117 | + return $this->getAirBerlin($ident, $date, 'HG'); |
|
1118 | 1118 | // BelAir |
1119 | 1119 | case "4T": |
1120 | 1120 | case "BHP": |
1121 | - return $this->getAirBerlin($ident,$date,'4T'); |
|
1121 | + return $this->getAirBerlin($ident, $date, '4T'); |
|
1122 | 1122 | default: |
1123 | 1123 | // Randomly use a generic function to get hours |
1124 | 1124 | if (strlen($airline_icao) == 2) { |
1125 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1125 | + if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware'); |
|
1126 | 1126 | if (count($globalSchedulesSources) > 0) { |
1127 | - $rand = mt_rand(0,count($globalSchedulesSources)-1); |
|
1127 | + $rand = mt_rand(0, count($globalSchedulesSources) - 1); |
|
1128 | 1128 | $source = $globalSchedulesSources[$rand]; |
1129 | 1129 | if ($source == 'flightmapper') return $this->getFlightMapper($ident); |
1130 | 1130 | elseif ($source == 'costtotravel') return $this->getCostToTravel($ident); |
@@ -18,82 +18,82 @@ discard block |
||
18 | 18 | public function parse($buffer) { |
19 | 19 | // Not yet finished, no CRC checks |
20 | 20 | $data = array(); |
21 | - $typehex = substr($buffer,0,1); |
|
22 | - if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1); |
|
23 | - elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13); |
|
24 | - else $hex = substr($buffer,1,-1); |
|
25 | - $bin = gmp_strval( gmp_init($hex,16), 2); |
|
21 | + $typehex = substr($buffer, 0, 1); |
|
22 | + if ($typehex == '*' || $typehex == ':') $hex = substr($buffer, 1, -1); |
|
23 | + elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer, 13, -13); |
|
24 | + else $hex = substr($buffer, 1, -1); |
|
25 | + $bin = gmp_strval(gmp_init($hex, 16), 2); |
|
26 | 26 | //if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) { |
27 | 27 | if (strlen($hex) == 28) { |
28 | - $df = intval(substr($bin,0,5),2); |
|
28 | + $df = intval(substr($bin, 0, 5), 2); |
|
29 | 29 | //$ca = intval(substr($bin,5,3),2); |
30 | 30 | // Only support DF17 for now |
31 | 31 | //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) { |
32 | - if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) { |
|
33 | - $icao = substr($hex,2,6); |
|
32 | + if (($df == 17 || $df == 18) && ($this->parityCheck($hex, $bin) || $typehex == '@')) { |
|
33 | + $icao = substr($hex, 2, 6); |
|
34 | 34 | $data['hex'] = $icao; |
35 | - $tc = intval(substr($bin,32,5),2); |
|
35 | + $tc = intval(substr($bin, 32, 5), 2); |
|
36 | 36 | if ($tc >= 1 && $tc <= 4) { |
37 | 37 | //callsign |
38 | - $csbin = substr($bin,40,56); |
|
38 | + $csbin = substr($bin, 40, 56); |
|
39 | 39 | $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######'); |
40 | 40 | $cs = ''; |
41 | - $cs .= $charset[intval(substr($csbin,0,6),2)]; |
|
42 | - $cs .= $charset[intval(substr($csbin,6,6),2)]; |
|
43 | - $cs .= $charset[intval(substr($csbin,12,6),2)]; |
|
44 | - $cs .= $charset[intval(substr($csbin,18,6),2)]; |
|
45 | - $cs .= $charset[intval(substr($csbin,24,6),2)]; |
|
46 | - $cs .= $charset[intval(substr($csbin,30,6),2)]; |
|
47 | - $cs .= $charset[intval(substr($csbin,36,6),2)]; |
|
48 | - $cs .= $charset[intval(substr($csbin,42,6),2)]; |
|
49 | - $cs = str_replace('_','',$cs); |
|
50 | - $cs = str_replace('#','',$cs); |
|
41 | + $cs .= $charset[intval(substr($csbin, 0, 6), 2)]; |
|
42 | + $cs .= $charset[intval(substr($csbin, 6, 6), 2)]; |
|
43 | + $cs .= $charset[intval(substr($csbin, 12, 6), 2)]; |
|
44 | + $cs .= $charset[intval(substr($csbin, 18, 6), 2)]; |
|
45 | + $cs .= $charset[intval(substr($csbin, 24, 6), 2)]; |
|
46 | + $cs .= $charset[intval(substr($csbin, 30, 6), 2)]; |
|
47 | + $cs .= $charset[intval(substr($csbin, 36, 6), 2)]; |
|
48 | + $cs .= $charset[intval(substr($csbin, 42, 6), 2)]; |
|
49 | + $cs = str_replace('_', '', $cs); |
|
50 | + $cs = str_replace('#', '', $cs); |
|
51 | 51 | $callsign = $cs; |
52 | 52 | $data['ident'] = $callsign; |
53 | 53 | } elseif ($tc >= 9 && $tc <= 18) { |
54 | 54 | // Check Q-bit |
55 | - $q = substr($bin,47,1); |
|
55 | + $q = substr($bin, 47, 1); |
|
56 | 56 | if ($q) { |
57 | - $n = intval(substr($bin,40,7).substr($bin,48,4),2); |
|
58 | - $alt = $n*25-1000; |
|
57 | + $n = intval(substr($bin, 40, 7).substr($bin, 48, 4), 2); |
|
58 | + $alt = $n*25 - 1000; |
|
59 | 59 | $data['altitude'] = $alt; |
60 | 60 | } |
61 | 61 | // Check odd/even flag |
62 | - $oe = substr($bin,53,1); |
|
62 | + $oe = substr($bin, 53, 1); |
|
63 | 63 | //if ($oe) => odd else even |
64 | 64 | // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
65 | - $cprlat = intval(substr($bin,54,17),2)/131072.0; |
|
66 | - $cprlon = intval(substr($bin,71,17),2)/131072.0; |
|
67 | - if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
65 | + $cprlat = intval(substr($bin, 54, 17), 2)/131072.0; |
|
66 | + $cprlon = intval(substr($bin, 71, 17), 2)/131072.0; |
|
67 | + if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat, 'longitude' => $cprlon, 'created' => time()); |
|
68 | 68 | elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
69 | 69 | $cprlat_odd = $cprlat; |
70 | 70 | $cprlon_odd = $cprlon; |
71 | 71 | $cprlat_even = $this::$latlon[$icao]['latitude']; |
72 | 72 | $cprlon_even = $this::$latlon[$icao]['longitude']; |
73 | - $j = 59*$cprlat_even-60*$cprlat_odd+0.5; |
|
74 | - $lat_even = (360.0/60)*($j%60+$cprlat_even); |
|
75 | - $lat_odd = (360.0/59)*($j%59+$cprlat_odd); |
|
73 | + $j = 59*$cprlat_even - 60*$cprlat_odd + 0.5; |
|
74 | + $lat_even = (360.0/60)*($j%60 + $cprlat_even); |
|
75 | + $lat_odd = (360.0/59)*($j%59 + $cprlat_odd); |
|
76 | 76 | if ($lat_even >= 270) $lat_even = $lat_even - 360; |
77 | 77 | if ($lat_odd >= 270) $lat_odd = $lat_odd - 360; |
78 | 78 | // check latitude zone |
79 | 79 | if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) { |
80 | 80 | if ($this::$latlon[$icao]['created'] > time()) { |
81 | - $ni = $this->cprN($lat_even,0); |
|
82 | - $m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5); |
|
83 | - $lon = (360.0/$ni)*($m%$ni+$cprlon_even); |
|
81 | + $ni = $this->cprN($lat_even, 0); |
|
82 | + $m = floor($cprlon_even*($this->cprNL($lat_even) - 1) - $cprlon_odd*$this->cprNL($lat_even) + 0.5); |
|
83 | + $lon = (360.0/$ni)*($m%$ni + $cprlon_even); |
|
84 | 84 | $lat = $lat_even; |
85 | - if ($lon > 180) $lon = $lon -360; |
|
85 | + if ($lon > 180) $lon = $lon - 360; |
|
86 | 86 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
87 | 87 | //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
88 | 88 | $data['latitude'] = $lat; |
89 | 89 | $data['longitude'] = $lon; |
90 | 90 | } |
91 | 91 | } else { |
92 | - $ni = $this->cprN($lat_odd,1); |
|
93 | - $m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5); |
|
94 | - $lon = (360.0/$ni)*($m%$ni+$cprlon_odd); |
|
92 | + $ni = $this->cprN($lat_odd, 1); |
|
93 | + $m = floor($cprlon_even*($this->cprNL($lat_odd) - 1) - $cprlon_odd*$this->cprNL($lat_odd) + 0.5); |
|
94 | + $lon = (360.0/$ni)*($m%$ni + $cprlon_odd); |
|
95 | 95 | $lat = $lat_odd; |
96 | - if ($lon > 180) $lon = $lon -360; |
|
96 | + if ($lon > 180) $lon = $lon - 360; |
|
97 | 97 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
98 | 98 | //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
99 | 99 | $data['latitude'] = $lat; |
@@ -105,15 +105,15 @@ discard block |
||
105 | 105 | } |
106 | 106 | } elseif ($tc == 19) { |
107 | 107 | // speed & heading |
108 | - $v_ew_dir = intval(substr($bin,45,1)); |
|
109 | - $v_ew = intval(substr($bin,46,10),2); |
|
110 | - $v_ns_dir = intval(substr($bin,56,1)); |
|
111 | - $v_ns = intval(substr($bin,57,10),2); |
|
108 | + $v_ew_dir = intval(substr($bin, 45, 1)); |
|
109 | + $v_ew = intval(substr($bin, 46, 10), 2); |
|
110 | + $v_ns_dir = intval(substr($bin, 56, 1)); |
|
111 | + $v_ns = intval(substr($bin, 57, 10), 2); |
|
112 | 112 | if ($v_ew_dir) $v_ew = -1*$v_ew; |
113 | 113 | if ($v_ns_dir) $v_ns = -1*$v_ns; |
114 | - $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
|
115 | - $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
|
116 | - if ($heading <0) $heading = $heading+360; |
|
114 | + $speed = sqrt($v_ns*$v_ns + $v_ew*$v_ew); |
|
115 | + $heading = atan2($v_ew, $v_ns)*360.0/(2*pi()); |
|
116 | + if ($heading < 0) $heading = $heading + 360; |
|
117 | 117 | $data['speed'] = $speed; |
118 | 118 | $data['heading'] = $heading; |
119 | 119 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * Lookup table to convert the latitude to index. |
129 | 129 | */ |
130 | 130 | private function cprNL($lat) { |
131 | - if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
131 | + if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
132 | 132 | if ($lat < 10.47047130) return 59; |
133 | 133 | if ($lat < 14.82817437) return 58; |
134 | 134 | if ($lat < 18.18626357) return 57; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | return 1; |
191 | 191 | } |
192 | 192 | |
193 | - private function cprN($lat,$isodd) { |
|
193 | + private function cprN($lat, $isodd) { |
|
194 | 194 | $nl = $this->cprNL($lat) - $isodd; |
195 | 195 | if ($nl > 1) return $nl; |
196 | 196 | else return 1; |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000 |
215 | 215 | ); |
216 | 216 | $crc = 0; |
217 | - $checksum = intval(substr($msg,22,6),16); |
|
217 | + $checksum = intval(substr($msg, 22, 6), 16); |
|
218 | 218 | for ($j = 0; $j < strlen($bin); $j++) { |
219 | - if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
219 | + if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j], 0); |
|
220 | 220 | } |
221 | 221 | if ($crc == $checksum) return true; |
222 | 222 | else { |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | $msg['aircraftid'] = hexdec($data['address']); |
239 | 239 | $msg['hex'] = $data['address']; |
240 | 240 | $msg['flightid'] = hexdec($data['address']); |
241 | - $msg['date_gen'] = date('Y/m/d',$data['timestamp']); |
|
242 | - $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180'; |
|
243 | - $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
|
244 | - $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
|
241 | + $msg['date_gen'] = date('Y/m/d', $data['timestamp']); |
|
242 | + $msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180'; |
|
243 | + $msg['date_log'] = date('Y/m/d', $data['timestamp']); |
|
244 | + $msg['time_log'] = date('H:i:s', $data['timestamp']).'.180'; |
|
245 | 245 | $msg['callsign'] = $data['ident']; |
246 | 246 | $msg['altitude'] = ''; |
247 | 247 | $msg['speed'] = ''; |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $msg['emergency'] = ''; |
255 | 255 | $msg['SPI'] = ''; |
256 | 256 | $msg['ground'] = ''; |
257 | - $result[] = implode(',',$msg); |
|
257 | + $result[] = implode(',', $msg); |
|
258 | 258 | } |
259 | 259 | if (isset($data['latitude']) && $data['latitude'] != 0) { |
260 | 260 | $msg = array(); |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | $msg['aircraftid'] = hexdec($data['address']); |
265 | 265 | $msg['hex'] = $data['address']; |
266 | 266 | $msg['flightid'] = hexdec($data['address']); |
267 | - $msg['date_gen'] = date('Y/m/d',$data['timestamp']); |
|
268 | - $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180'; |
|
269 | - $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
|
270 | - $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
|
267 | + $msg['date_gen'] = date('Y/m/d', $data['timestamp']); |
|
268 | + $msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180'; |
|
269 | + $msg['date_log'] = date('Y/m/d', $data['timestamp']); |
|
270 | + $msg['time_log'] = date('H:i:s', $data['timestamp']).'.180'; |
|
271 | 271 | $msg['callsign'] = ''; |
272 | 272 | if (isset($data['altitude'])) $msg['altitude'] = $data['altitude']; |
273 | 273 | else $msg['altitude'] = ''; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $msg['SPI'] = 0; |
286 | 286 | if (isset($data['ground'])) $msg['ground'] = 1; |
287 | 287 | else $msg['ground'] = 0; |
288 | - $result[] = implode(',',$msg); |
|
288 | + $result[] = implode(',', $msg); |
|
289 | 289 | } |
290 | 290 | return $result; |
291 | 291 | } |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | $globalDebug = FALSE; |
71 | 71 | $dbroot = $_SESSION['database_root']; |
72 | 72 | $dbrootpass = $_SESSION['database_rootpass']; |
73 | - $error .= create_db::create_database($dbroot,$dbrootpass,$globalDBuser,$globalDBpass,$globalDBname,$globalDBdriver,$globalDBhost); |
|
73 | + $error .= create_db::create_database($dbroot, $dbrootpass, $globalDBuser, $globalDBpass, $globalDBname, $globalDBdriver, $globalDBhost); |
|
74 | 74 | sleep(5); |
75 | 75 | if ($error != '') { |
76 | 76 | $_SESSION['error'] = $error; |
77 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create database')); |
|
78 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database')); |
|
77 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Create database')); |
|
78 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Create database')); |
|
79 | 79 | $_SESSION['install'] = 'database_import'; |
80 | 80 | $_SESSION['next'] = 'Create and import tables'; |
81 | - $result = array('error' => $error,'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
81 | + $result = array('error' => $error, 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
82 | 82 | print json_encode($result); |
83 | 83 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'database_import') { |
84 | 84 | $globalDebug = FALSE; |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | } |
93 | 93 | if ($error != '') { |
94 | 94 | $_SESSION['error'] = $error; |
95 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
|
96 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables')); |
|
95 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Create and import tables')); |
|
96 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Create and import tables')); |
|
97 | 97 | if ($globalSBS1 && !$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
98 | 98 | $_SESSION['install'] = 'populate'; |
99 | 99 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B'; |
@@ -101,24 +101,24 @@ discard block |
||
101 | 101 | $_SESSION['install'] = 'sources'; |
102 | 102 | $_SESSION['next'] = 'Insert data in source table'; |
103 | 103 | } |
104 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
104 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
105 | 105 | print json_encode($result); |
106 | 106 | } elseif (!is_numeric($check_version)) { |
107 | 107 | $error .= $check_version; |
108 | 108 | $_SESSION['error'] = $error; |
109 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
|
109 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Create and import tables')); |
|
110 | 110 | if (!isset($_SESSION['next'])) $_SESSION['next'] = ''; |
111 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
111 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
112 | 112 | print json_encode($result); |
113 | 113 | } else { |
114 | 114 | $error .= update_schema::check_version(true); |
115 | 115 | if ($error != '') { |
116 | 116 | $_SESSION['error'] = $error; |
117 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Update schema if needed')); |
|
118 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed')); |
|
117 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Update schema if needed')); |
|
118 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Update schema if needed')); |
|
119 | 119 | $_SESSION['install'] = 'sources'; |
120 | 120 | $_SESSION['next'] = 'Insert data in source table'; |
121 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
121 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
122 | 122 | print json_encode($result); |
123 | 123 | } |
124 | 124 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'waypoints') { |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | $error .= update_db::update_waypoints(); |
128 | 128 | if ($error != '') { |
129 | 129 | $_SESSION['error'] = $error; |
130 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate waypoints database')); |
|
131 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database')); |
|
130 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate waypoints database')); |
|
131 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate waypoints database')); |
|
132 | 132 | /* |
133 | 133 | $_SESSION['install'] = 'airspace'; |
134 | 134 | $_SESSION['next'] = 'Populate airspace table'; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | $_SESSION['install'] = 'countries'; |
147 | 147 | $_SESSION['next'] = 'Populate countries table'; |
148 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
148 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
149 | 149 | print json_encode($result); |
150 | 150 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'countries') { |
151 | 151 | include_once('class.update_db.php'); |
@@ -153,12 +153,12 @@ discard block |
||
153 | 153 | $error .= update_db::update_countries(); |
154 | 154 | if ($error != '') { |
155 | 155 | $_SESSION['error'] = $error; |
156 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database')); |
|
157 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database')); |
|
156 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate countries database')); |
|
157 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate countries database')); |
|
158 | 158 | if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
159 | 159 | $_SESSION['install'] = 'notam'; |
160 | 160 | $_SESSION['next'] = 'Populate NOTAM table with externals data'; |
161 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
161 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
162 | 162 | print json_encode($result); |
163 | 163 | /* |
164 | 164 | } elseif (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) { |
@@ -171,15 +171,15 @@ discard block |
||
171 | 171 | } else { |
172 | 172 | $_SESSION['install'] = 'sources'; |
173 | 173 | $_SESSION['next'] = 'Insert data in source table'; |
174 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
174 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
175 | 175 | print json_encode($result); |
176 | 176 | } |
177 | 177 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'populate') { |
178 | 178 | if (!is_writable('tmp')) { |
179 | 179 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
180 | 180 | $_SESSION['error'] = $error; |
181 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
182 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
181 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for ADS-B')); |
|
182 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
183 | 183 | print json_encode($result); |
184 | 184 | } else { |
185 | 185 | include_once('class.update_db.php'); |
@@ -187,19 +187,19 @@ discard block |
||
187 | 187 | $error .= update_db::update_ModeS_fam(); |
188 | 188 | if ($error != '') { |
189 | 189 | $_SESSION['error'] = $error; |
190 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
191 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
190 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for ADS-B')); |
|
191 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate aircraft_modes table with externals data for ADS-B')); |
|
192 | 192 | $_SESSION['install'] = 'populate_flarm'; |
193 | 193 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for FLARM'; |
194 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
194 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
195 | 195 | print json_encode($result); |
196 | 196 | } |
197 | 197 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'populate_flarm') { |
198 | 198 | if (!is_writable('tmp')) { |
199 | 199 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
200 | 200 | $_SESSION['error'] = $error; |
201 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
202 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
201 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for FLARM')); |
|
202 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
203 | 203 | print json_encode($result); |
204 | 204 | } else { |
205 | 205 | include_once('class.update_db.php'); |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | $error .= update_db::update_ModeS_ogn(); |
209 | 209 | if ($error != '') { |
210 | 210 | $_SESSION['error'] = $error; |
211 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
212 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
211 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for FLARM')); |
|
212 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate aircraft_modes table with externals data for FLARM')); |
|
213 | 213 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
214 | 214 | $_SESSION['install'] = 'vatsim'; |
215 | 215 | if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
@@ -228,15 +228,15 @@ discard block |
||
228 | 228 | $_SESSION['install'] = 'routes'; |
229 | 229 | $_SESSION['next'] = 'Populate routes table with externals data'; |
230 | 230 | } |
231 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
231 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
232 | 232 | print json_encode($result); |
233 | 233 | } |
234 | 234 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'routes') { |
235 | 235 | if (!is_writable('tmp')) { |
236 | 236 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
237 | 237 | $_SESSION['error'] = $error; |
238 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
239 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
238 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for ADS-B')); |
|
239 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
240 | 240 | print json_encode($result); |
241 | 241 | } else { |
242 | 242 | include_once('class.update_db.php'); |
@@ -244,19 +244,19 @@ discard block |
||
244 | 244 | $error .= update_db::update_routes_fam(); |
245 | 245 | if ($error != '') { |
246 | 246 | $_SESSION['error'] = $error; |
247 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate routes table with externals data')); |
|
248 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data')); |
|
247 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate routes table with externals data')); |
|
248 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate routes table with externals data')); |
|
249 | 249 | $_SESSION['install'] = 'translation'; |
250 | 250 | $_SESSION['next'] = 'Populate translation table with externals data'; |
251 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
251 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
252 | 252 | print json_encode($result); |
253 | 253 | } |
254 | 254 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'translation') { |
255 | 255 | if (!is_writable('tmp')) { |
256 | 256 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
257 | 257 | $_SESSION['error'] = $error; |
258 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data')); |
|
259 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
258 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate translation table with externals data')); |
|
259 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
260 | 260 | print json_encode($result); |
261 | 261 | } else { |
262 | 262 | include_once('class.update_db.php'); |
@@ -264,8 +264,8 @@ discard block |
||
264 | 264 | $error .= update_db::update_translation_fam(); |
265 | 265 | if ($error != '') { |
266 | 266 | $_SESSION['error'] = $error; |
267 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data')); |
|
268 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data')); |
|
267 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate translation table with externals data')); |
|
268 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate translation table with externals data')); |
|
269 | 269 | if ($_SESSION['waypoints'] == 1) { |
270 | 270 | $_SESSION['install'] = 'waypoints'; |
271 | 271 | $_SESSION['next'] = 'Populate waypoints table'; |
@@ -283,15 +283,15 @@ discard block |
||
283 | 283 | $_SESSION['install'] = 'sources'; |
284 | 284 | $_SESSION['next'] = 'Insert data in source table'; |
285 | 285 | } |
286 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
286 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
287 | 287 | print json_encode($result); |
288 | 288 | } |
289 | 289 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'owner') { |
290 | 290 | if (!is_writable('tmp')) { |
291 | 291 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
292 | 292 | $_SESSION['error'] = $error; |
293 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data')); |
|
294 | - $result = array('error' => $error,'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
293 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate owner table with externals data')); |
|
294 | + $result = array('error' => $error, 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
295 | 295 | print json_encode($result); |
296 | 296 | } else { |
297 | 297 | include_once('class.update_db.php'); |
@@ -299,19 +299,19 @@ discard block |
||
299 | 299 | $error = update_db::update_owner_fam(); |
300 | 300 | if ($error != '') { |
301 | 301 | $_SESSION['error'] = $error; |
302 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data')); |
|
303 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data')); |
|
302 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate owner table with externals data')); |
|
303 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate owner table with externals data')); |
|
304 | 304 | $_SESSION['install'] = 'sources'; |
305 | 305 | $_SESSION['next'] = 'Insert data in source table'; |
306 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
306 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
307 | 307 | print json_encode($result); |
308 | 308 | } |
309 | 309 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'notam') { |
310 | 310 | if (!is_writable('tmp')) { |
311 | 311 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
312 | 312 | $_SESSION['error'] = $error; |
313 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data')); |
|
314 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
313 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate notam table with externals data')); |
|
314 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
315 | 315 | print json_encode($result); |
316 | 316 | } else { |
317 | 317 | include_once('class.update_db.php'); |
@@ -320,13 +320,13 @@ discard block |
||
320 | 320 | $error .= update_db::update_notam(); |
321 | 321 | if ($error != '') { |
322 | 322 | $_SESSION['error'] = $error; |
323 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data')); |
|
324 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data')); |
|
323 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate notam table with externals data')); |
|
324 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate notam table with externals data')); |
|
325 | 325 | } else { |
326 | 326 | if ($error != '') { |
327 | 327 | $_SESSION['error'] = $error; |
328 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data (no source defined)')); |
|
329 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)')); |
|
328 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate notam table with externals data (no source defined)')); |
|
329 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate notam table with externals data (no source defined)')); |
|
330 | 330 | } |
331 | 331 | /* |
332 | 332 | if (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) { |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | $_SESSION['install'] = 'sources'; |
341 | 341 | $_SESSION['next'] = 'Insert data in source table'; |
342 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
342 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
343 | 343 | print json_encode($result); |
344 | 344 | //} |
345 | 345 | } |
@@ -376,9 +376,9 @@ discard block |
||
376 | 376 | $Source = new Source(); |
377 | 377 | $Source->deleteAllLocation(); |
378 | 378 | foreach ($sources as $src) { |
379 | - if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png'); |
|
379 | + if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'], $src['latitude'], $src['longitude'], $src['altitude'], $src['city'], $src['country'], $src['source'], 'antenna.png'); |
|
380 | 380 | } |
381 | - $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert data in source table')); |
|
381 | + $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert data in source table')); |
|
382 | 382 | unset($_SESSION['sources']); |
383 | 383 | } |
384 | 384 | /* |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | $_SESSION['install'] = 'finish'; |
404 | 404 | $_SESSION['next'] = 'finish'; |
405 | 405 | } |
406 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
406 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
407 | 407 | print json_encode($result); |
408 | 408 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'vatsim') { |
409 | 409 | include_once('../install/class.create_db.php'); |
@@ -415,48 +415,48 @@ discard block |
||
415 | 415 | $error .= update_db::update_IVAO(); |
416 | 416 | if ($error != '') { |
417 | 417 | $_SESSION['error'] = $error; |
418 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
|
419 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
418 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert IVAO data')); |
|
419 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert IVAO data')); |
|
420 | 420 | } else { |
421 | 421 | $error .= update_db::update_vatsim(); |
422 | 422 | if ($error != '') { |
423 | 423 | $_SESSION['error'] = $error; |
424 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
|
425 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
424 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert VATSIM data')); |
|
425 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert VATSIM data')); |
|
426 | 426 | } |
427 | 427 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
428 | 428 | $error .= update_db::update_vatsim(); |
429 | 429 | if ($error != '') { |
430 | 430 | $_SESSION['error'] = $error; |
431 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
|
432 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
431 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert VATSIM data')); |
|
432 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert VATSIM data')); |
|
433 | 433 | } elseif (isset($globalIVAO) && $globalIVAO) { |
434 | 434 | if (file_exists('tmp/ivae_feb2013.zip')) { |
435 | 435 | $error .= update_db::update_IVAO(); |
436 | 436 | if ($error != '') { |
437 | 437 | $_SESSION['error'] = $error; |
438 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
|
439 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
438 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert IVAO data')); |
|
439 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert IVAO data')); |
|
440 | 440 | } else { |
441 | 441 | $error .= update_db::update_vatsim(); |
442 | 442 | if ($error != '') { |
443 | 443 | $_SESSION['error'] = $error; |
444 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data (IVAO not found)')); |
|
445 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)')); |
|
444 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert VATSIM data (IVAO not found)')); |
|
445 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert VATSIM data (IVAO not found)')); |
|
446 | 446 | } |
447 | 447 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
448 | - $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert phpVMS data')); |
|
448 | + $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert phpVMS data')); |
|
449 | 449 | } |
450 | 450 | //$_SESSION['install'] = 'routes'; |
451 | 451 | //$_SESSION['next'] = 'Populate routes table with externals data'; |
452 | 452 | $_SESSION['install'] = 'finish'; |
453 | 453 | $_SESSION['next'] = 'finish'; |
454 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
454 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
455 | 455 | print json_encode($result); |
456 | 456 | } else { |
457 | 457 | //unset($_SESSION['install']); |
458 | 458 | $_SESSION['error'] = 'Unknwon task : '.$_SESSION['install']; |
459 | - $result = array('error' => 'Unknwon task : '.$_SESSION['install'],'done' => $_SESSION['done'],'next' => 'finish','install' => 'finish'); |
|
459 | + $result = array('error' => 'Unknwon task : '.$_SESSION['install'], 'done' => $_SESSION['done'], 'next' => 'finish', 'install' => 'finish'); |
|
460 | 460 | print json_encode($result); |
461 | 461 | } |
462 | 462 | ?> |
463 | 463 | \ No newline at end of file |
@@ -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 (update schema_version) : ".$e->getMessage()."\n"; |
2221 | 2221 | } |
2222 | 2222 | return $error; |
@@ -2239,7 +2239,7 @@ discard block |
||
2239 | 2239 | try { |
2240 | 2240 | $sth = $Connection->db->prepare($query); |
2241 | 2241 | $sth->execute(); |
2242 | - } catch(PDOException $e) { |
|
2242 | + } catch (PDOException $e) { |
|
2243 | 2243 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2244 | 2244 | } |
2245 | 2245 | return $error; |
@@ -2260,7 +2260,7 @@ discard block |
||
2260 | 2260 | try { |
2261 | 2261 | $sth = $Connection->db->prepare($query); |
2262 | 2262 | $sth->execute(); |
2263 | - } catch(PDOException $e) { |
|
2263 | + } catch (PDOException $e) { |
|
2264 | 2264 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2265 | 2265 | } |
2266 | 2266 | return $error; |
@@ -2283,7 +2283,7 @@ discard block |
||
2283 | 2283 | try { |
2284 | 2284 | $sth = $Connection->db->prepare($query); |
2285 | 2285 | $sth->execute(); |
2286 | - } catch(PDOException $e) { |
|
2286 | + } catch (PDOException $e) { |
|
2287 | 2287 | return "error (check_version): ".$e->getMessage()."\n"; |
2288 | 2288 | } |
2289 | 2289 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | header('Content-Type: text/javascript'); |
18 | 18 | |
19 | 19 | |
20 | -$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d')); |
|
20 | +$polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d')); |
|
21 | 21 | $output = '{"type": "FeatureCollection","features": ['; |
22 | 22 | if (!empty($polar)) { |
23 | - foreach($polar as $eachpolar) { |
|
23 | + foreach ($polar as $eachpolar) { |
|
24 | 24 | $data = json_decode($eachpolar['source_data']); |
25 | 25 | $name = $eachpolar['source_name']; |
26 | 26 | $coord = $Location->getLocationInfobySourceName($name); |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | $initial_longitude = $globalCenterLongitude; |
34 | 34 | } |
35 | 35 | $first = ''; |
36 | - foreach($data as $value => $key) { |
|
37 | - $final_coord = $Common->getCoordfromDistanceBearing($initial_latitude,$initial_longitude,$value*22.5,$key); |
|
38 | - if ($first == '') $first = '['.round($final_coord['longitude'],5).','.round($final_coord['latitude'],5).']'; |
|
36 | + foreach ($data as $value => $key) { |
|
37 | + $final_coord = $Common->getCoordfromDistanceBearing($initial_latitude, $initial_longitude, $value*22.5, $key); |
|
38 | + if ($first == '') $first = '['.round($final_coord['longitude'], 5).','.round($final_coord['latitude'], 5).']'; |
|
39 | 39 | $output .= '['.$final_coord['longitude'].','.$final_coord['latitude'].'],'; |
40 | 40 | } |
41 | 41 | $output .= $first; |
42 | 42 | $output .= ']]}},'; |
43 | 43 | } |
44 | - $output = substr($output, 0, -1); |
|
44 | + $output = substr($output, 0, -1); |
|
45 | 45 | } |
46 | 46 | $output .= ']}'; |
47 | 47 | print $output; |
@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | die; |
51 | 51 | } |
52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
53 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
53 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
|
57 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine')); |
|
58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 60 | if (isset($options['s'])) { |
61 | 61 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
63 | 63 | else $globalSources[] = array('host' => $options['s']); |
64 | 64 | } elseif (isset($options['source'])) { |
65 | 65 | $globalSources = array(); |
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
67 | 67 | else $globalSources[] = array('host' => $options['source']); |
68 | 68 | } |
69 | 69 | if (isset($options['aprsserverhost'])) { |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | else $id_source = 1; |
105 | 105 | if (isset($globalServer) && $globalServer) { |
106 | 106 | if ($globalDebug) echo "Using Server Mode\n"; |
107 | - $SI=new SpotterServer(); |
|
107 | + $SI = new SpotterServer(); |
|
108 | 108 | /* |
109 | 109 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 110 | $SI = new adsb2aprs(); |
111 | 111 | $SI->connect(); |
112 | 112 | */ |
113 | -} else $SI=new SpotterImport($Connection->db); |
|
113 | +} else $SI = new SpotterImport($Connection->db); |
|
114 | 114 | |
115 | 115 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
116 | 116 | if (isset($globalMarine) && $globalMarine) { |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | $MI = new MarineImport($Connection->db); |
125 | 125 | } |
126 | 126 | //$APRS=new APRS($Connection->db); |
127 | -$SBS=new SBS(); |
|
127 | +$SBS = new SBS(); |
|
128 | 128 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
129 | - $ACARS=new ACARS($Connection->db,true); |
|
130 | - $Source=new Source($Connection->db); |
|
129 | + $ACARS = new ACARS($Connection->db, true); |
|
130 | + $Source = new Source($Connection->db); |
|
131 | 131 | } |
132 | -$Common=new Common(); |
|
132 | +$Common = new Common(); |
|
133 | 133 | date_default_timezone_set('UTC'); |
134 | 134 | //$servertz = system('date +%Z'); |
135 | 135 | // signal handler - playing nice with sockets and dump1090 |
136 | 136 | if (function_exists('pcntl_fork')) { |
137 | - pcntl_signal(SIGINT, function() { |
|
137 | + pcntl_signal(SIGINT, function() { |
|
138 | 138 | global $sockets; |
139 | 139 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
140 | 140 | die("Bye!\n"); |
@@ -150,35 +150,35 @@ discard block |
||
150 | 150 | |
151 | 151 | function connect_all($hosts) { |
152 | 152 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
153 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
153 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
154 | 154 | $reset++; |
155 | 155 | if ($globalDebug) echo 'Connect to all...'."\n"; |
156 | 156 | foreach ($hosts as $id => $value) { |
157 | 157 | $host = $value['host']; |
158 | 158 | $globalSources[$id]['last_exec'] = 0; |
159 | 159 | // Here we check type of source(s) |
160 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
161 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
160 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
161 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
162 | 162 | //$formats[$id] = 'deltadbtxt'; |
163 | 163 | $globalSources[$id]['format'] = 'deltadbtxt'; |
164 | 164 | //$last_exec['deltadbtxt'] = 0; |
165 | 165 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
166 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
166 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
167 | 167 | //$formats[$id] = 'vatsimtxt'; |
168 | 168 | $globalSources[$id]['format'] = 'vatsimtxt'; |
169 | 169 | //$last_exec['vatsimtxt'] = 0; |
170 | 170 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
171 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
171 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
172 | 172 | //$formats[$id] = 'aircraftlistjson'; |
173 | 173 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
174 | 174 | //$last_exec['aircraftlistjson'] = 0; |
175 | 175 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
176 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
176 | + } else if (preg_match('/aircraft.json$/i', $host)) { |
|
177 | 177 | //$formats[$id] = 'aircraftjson'; |
178 | 178 | $globalSources[$id]['format'] = 'aircraftjson'; |
179 | 179 | //$last_exec['aircraftlistjson'] = 0; |
180 | 180 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
181 | - } else if (preg_match('/opensky/i',$host)) { |
|
181 | + } else if (preg_match('/opensky/i', $host)) { |
|
182 | 182 | //$formats[$id] = 'aircraftlistjson'; |
183 | 183 | $globalSources[$id]['format'] = 'opensky'; |
184 | 184 | //$last_exec['aircraftlistjson'] = 0; |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | exit(0); |
196 | 196 | } |
197 | 197 | */ |
198 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
198 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
199 | 199 | //$formats[$id] = 'planeupdatefaa'; |
200 | 200 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
201 | 201 | //$last_exec['planeupdatefaa'] = 0; |
@@ -204,37 +204,37 @@ discard block |
||
204 | 204 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
205 | 205 | exit(0); |
206 | 206 | } |
207 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
207 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
208 | 208 | //$formats[$id] = 'phpvmacars'; |
209 | 209 | $globalSources[$id]['format'] = 'phpvmacars'; |
210 | 210 | //$last_exec['phpvmacars'] = 0; |
211 | 211 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
212 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
212 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) { |
|
213 | 213 | //$formats[$id] = 'phpvmacars'; |
214 | 214 | $globalSources[$id]['format'] = 'vaos'; |
215 | 215 | //$last_exec['phpvmacars'] = 0; |
216 | 216 | if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
217 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
217 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
218 | 218 | //$formats[$id] = 'phpvmacars'; |
219 | 219 | $globalSources[$id]['format'] = 'vam'; |
220 | 220 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
221 | - } else if (preg_match('/whazzup/i',$host)) { |
|
221 | + } else if (preg_match('/whazzup/i', $host)) { |
|
222 | 222 | //$formats[$id] = 'whazzup'; |
223 | 223 | $globalSources[$id]['format'] = 'whazzup'; |
224 | 224 | //$last_exec['whazzup'] = 0; |
225 | 225 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
226 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
226 | + } else if (preg_match('/blitzortung/i', $host)) { |
|
227 | 227 | $globalSources[$id]['format'] = 'blitzortung'; |
228 | 228 | if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
229 | - } else if (preg_match('/airwhere/i',$host)) { |
|
229 | + } else if (preg_match('/airwhere/i', $host)) { |
|
230 | 230 | $globalSources[$id]['format'] = 'airwhere'; |
231 | 231 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
232 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
232 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
233 | 233 | //$formats[$id] = 'pirepsjson'; |
234 | 234 | $globalSources[$id]['format'] = 'pirepsjson'; |
235 | 235 | //$last_exec['pirepsjson'] = 0; |
236 | 236 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
237 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
237 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
238 | 238 | //$formats[$id] = 'fr24json'; |
239 | 239 | $globalSources[$id]['format'] = 'fr24json'; |
240 | 240 | //$last_exec['fr24json'] = 0; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
244 | 244 | exit(0); |
245 | 245 | } |
246 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
246 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
247 | 247 | //$formats[$id] = 'fr24json'; |
248 | 248 | $globalSources[$id]['format'] = 'myshiptracking'; |
249 | 249 | //$last_exec['fr24json'] = 0; |
@@ -253,21 +253,21 @@ discard block |
||
253 | 253 | exit(0); |
254 | 254 | } |
255 | 255 | //} else if (preg_match('/10001/',$host)) { |
256 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
256 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
257 | 257 | //$formats[$id] = 'tsv'; |
258 | 258 | $globalSources[$id]['format'] = 'tsv'; |
259 | 259 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
260 | 260 | } |
261 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
261 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
262 | 262 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
263 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
263 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
264 | 264 | if ($idf !== false) { |
265 | 265 | $httpfeeds[$id] = $idf; |
266 | 266 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
267 | 267 | } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
268 | 268 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
269 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
270 | - $hostport = explode(':',$host); |
|
269 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
270 | + $hostport = explode(':', $host); |
|
271 | 271 | if (isset($hostport[1])) { |
272 | 272 | $port = $hostport[1]; |
273 | 273 | $hostn = $hostport[0]; |
@@ -277,19 +277,19 @@ discard block |
||
277 | 277 | } |
278 | 278 | $Common = new Common(); |
279 | 279 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
280 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
280 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
281 | 281 | } else { |
282 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
282 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
283 | 283 | } |
284 | 284 | if ($s) { |
285 | 285 | $sockets[$id] = $s; |
286 | 286 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
287 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
287 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
288 | 288 | //$formats[$id] = 'aprs'; |
289 | 289 | $globalSources[$id]['format'] = 'aprs'; |
290 | 290 | //$aprs_connect = 0; |
291 | 291 | //$use_aprs = true; |
292 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
292 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
293 | 293 | $globalSources[$id]['format'] = 'vrstcp'; |
294 | 294 | } elseif ($port == '10001') { |
295 | 295 | //$formats[$id] = 'tsv'; |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
329 | 329 | else $timeout = 20; |
330 | 330 | $errno = ''; |
331 | -$errstr=''; |
|
331 | +$errstr = ''; |
|
332 | 332 | |
333 | 333 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
334 | 334 | /* Initiate connections to all the hosts simultaneously */ |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | //connect_all($globalSources); |
337 | 337 | |
338 | 338 | if (isset($globalProxy) && $globalProxy) { |
339 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
339 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
340 | 340 | } else { |
341 | 341 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
342 | 342 | } |
@@ -366,16 +366,16 @@ discard block |
||
366 | 366 | |
367 | 367 | if ($use_aprs) { |
368 | 368 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
369 | - $APRS=new APRS(); |
|
369 | + $APRS = new APRS(); |
|
370 | 370 | $aprs_connect = 0; |
371 | 371 | $aprs_keep = 120; |
372 | 372 | $aprs_last_tx = time(); |
373 | 373 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
374 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
374 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
375 | 375 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
376 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
376 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
377 | 377 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
378 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
378 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
379 | 379 | if ($aprs_full) $aprs_filter = ''; |
380 | 380 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
381 | 381 | else $aprs_pass = '-1'; |
@@ -389,12 +389,12 @@ discard block |
||
389 | 389 | sleep(1); |
390 | 390 | if ($globalDebug) echo "SCAN MODE \n\n"; |
391 | 391 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
392 | -$endtime = time()+$globalCronEnd; |
|
392 | +$endtime = time() + $globalCronEnd; |
|
393 | 393 | $i = 1; |
394 | 394 | $tt = array(); |
395 | 395 | // Delete all ATC |
396 | 396 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
397 | - $ATC=new ATC($Connection->db); |
|
397 | + $ATC = new ATC($Connection->db); |
|
398 | 398 | } |
399 | 399 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
400 | 400 | $ATC->deleteAll(); |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | while ($i > 0) { |
405 | 405 | if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
406 | 406 | |
407 | - if (!$globalDaemon) $i = $endtime-time(); |
|
407 | + if (!$globalDaemon) $i = $endtime - time(); |
|
408 | 408 | // Delete old ATC |
409 | 409 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
410 | 410 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | } |
419 | 419 | if ($max < $globalMinFetch) { |
420 | 420 | if ($globalDebug) echo 'Sleeping...'."\n"; |
421 | - sleep($globalMinFetch-$max+2); |
|
421 | + sleep($globalMinFetch - $max + 2); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | //$buffer = $Common->getData($hosts[$id]); |
438 | 438 | $buffer = $Common->getData($value['host']); |
439 | 439 | if ($buffer != '') $reset = 0; |
440 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
441 | - $buffer = explode('\n',$buffer); |
|
440 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
441 | + $buffer = explode('\n', $buffer); |
|
442 | 442 | foreach ($buffer as $line) { |
443 | 443 | if ($line != '' && count($line) > 7) { |
444 | 444 | $line = explode(',', $line); |
@@ -471,11 +471,11 @@ discard block |
||
471 | 471 | ) |
472 | 472 | ) { |
473 | 473 | date_default_timezone_set('CET'); |
474 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
474 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
475 | 475 | date_default_timezone_set('UTC'); |
476 | 476 | if ($buffer != '') $reset = 0; |
477 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
478 | - $buffer = explode('\n',$buffer); |
|
477 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
478 | + $buffer = explode('\n', $buffer); |
|
479 | 479 | foreach ($buffer as $line) { |
480 | 480 | if ($line != '') { |
481 | 481 | //echo "'".$line."'\n"; |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | $ais_data = $AIS->parse_line(trim($line)); |
484 | 484 | $data = array(); |
485 | 485 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
486 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
486 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
487 | 487 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
488 | 488 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
489 | 489 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
496 | 496 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
497 | 497 | if (isset($ais_data['timestamp'])) { |
498 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
498 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
499 | 499 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
500 | 500 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
501 | 501 | $add = true; |
@@ -518,21 +518,21 @@ discard block |
||
518 | 518 | $w = $e = null; |
519 | 519 | |
520 | 520 | if (isset($arr[$id])) { |
521 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
521 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
522 | 522 | if ($nn > 0) { |
523 | 523 | foreach ($httpfeeds as $feed) { |
524 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
524 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
525 | 525 | if ($buffer === FALSE) { |
526 | 526 | connect_all($globalSources); |
527 | 527 | } |
528 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
529 | - $buffer = explode('\n',$buffer); |
|
528 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
529 | + $buffer = explode('\n', $buffer); |
|
530 | 530 | foreach ($buffer as $line) { |
531 | 531 | if ($line != '') { |
532 | 532 | $ais_data = $AIS->parse_line(trim($line)); |
533 | 533 | $data = array(); |
534 | 534 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
535 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
535 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
536 | 536 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
537 | 537 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
538 | 538 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -544,9 +544,9 @@ discard block |
||
544 | 544 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
545 | 545 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
546 | 546 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
547 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
547 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
548 | 548 | if (isset($ais_data['timestamp'])) { |
549 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
549 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
550 | 550 | } else { |
551 | 551 | $data['datetime'] = date('Y-m-d H:i:s'); |
552 | 552 | } |
@@ -578,10 +578,10 @@ discard block |
||
578 | 578 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
579 | 579 | ) |
580 | 580 | ) { |
581 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
581 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
582 | 582 | if ($buffer != '') { |
583 | 583 | //echo $buffer; |
584 | - $all_data = json_decode($buffer,true); |
|
584 | + $all_data = json_decode($buffer, true); |
|
585 | 585 | //print_r($all_data); |
586 | 586 | if (isset($all_data[0]['DATA'])) { |
587 | 587 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | $data['ident'] = $line['NAME']; |
591 | 591 | $data['mmsi'] = $line['MMSI']; |
592 | 592 | if (strlen($data['mmsi']) > 9) { |
593 | - $data['mmsi'] = substr($data['mmsi'],-9); |
|
593 | + $data['mmsi'] = substr($data['mmsi'], -9); |
|
594 | 594 | } |
595 | 595 | $data['speed'] = $line['SOG']; |
596 | 596 | $data['heading'] = $line['COG']; |
@@ -600,8 +600,8 @@ discard block |
||
600 | 600 | //$data['type_id'] = $line['TYPE']; |
601 | 601 | $data['imo'] = $line['IMO']; |
602 | 602 | if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
603 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
604 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
603 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV'])); |
|
604 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
605 | 605 | $data['format_source'] = 'myshiptracking'; |
606 | 606 | $data['id_source'] = $id_source; |
607 | 607 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -618,16 +618,16 @@ discard block |
||
618 | 618 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
619 | 619 | ) |
620 | 620 | ) { |
621 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
621 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
622 | 622 | if ($buffer != '') { |
623 | - $all_data = json_decode($buffer,true); |
|
623 | + $all_data = json_decode($buffer, true); |
|
624 | 624 | if (isset($all_data[0]['mmsi'])) { |
625 | 625 | foreach ($all_data as $line) { |
626 | 626 | if ($line != '') { |
627 | 627 | $data = array(); |
628 | 628 | $data['ident'] = $line['shipname']; |
629 | 629 | $data['callsign'] = $line['callsign']; |
630 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
630 | + $data['mmsi'] = substr($line['mmsi'], -9); |
|
631 | 631 | $data['speed'] = $line['sog']; |
632 | 632 | if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
633 | 633 | $data['latitude'] = $line['latitude']; |
@@ -654,14 +654,14 @@ discard block |
||
654 | 654 | ) { |
655 | 655 | $buffer = $Common->getData($value['host']); |
656 | 656 | if ($buffer != '') { |
657 | - $all_data = json_decode($buffer,true); |
|
657 | + $all_data = json_decode($buffer, true); |
|
658 | 658 | if (isset($all_data['features'][0]['id'])) { |
659 | 659 | foreach ($all_data['features'] as $line) { |
660 | 660 | print_r($line); |
661 | 661 | $data = array(); |
662 | 662 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
663 | 663 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
664 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
664 | + if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9); |
|
665 | 665 | if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
666 | 666 | if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
667 | 667 | if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
@@ -688,31 +688,31 @@ discard block |
||
688 | 688 | ) |
689 | 689 | ) { |
690 | 690 | echo 'download...'; |
691 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
691 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
692 | 692 | echo 'done !'."\n"; |
693 | 693 | // FIXME: Need more work |
694 | 694 | if ($buffer != '') $reset = 0; |
695 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
696 | - $buffer = explode('\n',$buffer); |
|
695 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
696 | + $buffer = explode('\n', $buffer); |
|
697 | 697 | foreach ($buffer as $line) { |
698 | 698 | if ($line != '') { |
699 | 699 | $data = array(); |
700 | 700 | echo $line."\n"; |
701 | - $data['mmsi'] = (int)substr($line,0,9); |
|
702 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
703 | - $data['status_id'] = substr($line,21,2); |
|
704 | - $data['type_id'] = substr($line,24,3); |
|
705 | - $data['latitude'] = substr($line,29,9); |
|
706 | - $data['longitude'] = substr($line,41,9); |
|
707 | - $data['speed'] = round(substr($line,51,5)); |
|
701 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
702 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
703 | + $data['status_id'] = substr($line, 21, 2); |
|
704 | + $data['type_id'] = substr($line, 24, 3); |
|
705 | + $data['latitude'] = substr($line, 29, 9); |
|
706 | + $data['longitude'] = substr($line, 41, 9); |
|
707 | + $data['speed'] = round(substr($line, 51, 5)); |
|
708 | 708 | //$data['course'] = substr($line,57,5); |
709 | - $data['heading'] = round(substr($line,63,3)); |
|
709 | + $data['heading'] = round(substr($line, 63, 3)); |
|
710 | 710 | //$data['draft'] = substr($line,67,4); |
711 | 711 | //$data['length'] = substr($line,72,3); |
712 | 712 | //$data['beam'] = substr($line,76,2); |
713 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
713 | + $data['ident'] = trim(utf8_encode(substr($line, 78, 20))); |
|
714 | 714 | //$data['callsign'] = trim(substr($line,100,7); |
715 | - $data['arrival_code'] = substr($line,108,20); |
|
715 | + $data['arrival_code'] = substr($line, 108, 20); |
|
716 | 716 | //$data['etaDate'] = substr($line,129,5); |
717 | 717 | //$data['etaTime'] = substr($line,135,5); |
718 | 718 | $data['format_source'] = 'shipplotter'; |
@@ -743,8 +743,8 @@ discard block |
||
743 | 743 | ) { |
744 | 744 | //$buffer = $Common->getData($hosts[$id]); |
745 | 745 | $buffer = $Common->getData($value['host']); |
746 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
747 | - $buffer = explode('\n',$buffer); |
|
746 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
747 | + $buffer = explode('\n', $buffer); |
|
748 | 748 | $reset = 0; |
749 | 749 | foreach ($buffer as $line) { |
750 | 750 | if ($line != '') { |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
756 | 756 | $data['pilot_id'] = $line[1]; |
757 | 757 | $data['pilot_name'] = $line[2]; |
758 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
758 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
759 | 759 | $data['ident'] = $line[0]; // ident |
760 | 760 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
761 | 761 | $data['speed'] = $line[8]; // speed |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
772 | 772 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
773 | 773 | $data['departure_airport_icao'] = $line[11]; |
774 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
774 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
775 | 775 | $data['arrival_airport_icao'] = $line[13]; |
776 | 776 | $data['frequency'] = $line[4]; |
777 | 777 | $data['type'] = $line[18]; |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | $data['id_source'] = $id_source; |
781 | 781 | //$data['arrival_airport_time'] = ; |
782 | 782 | if ($line[9] != '') { |
783 | - $aircraft_data = explode('/',$line[9]); |
|
783 | + $aircraft_data = explode('/', $line[9]); |
|
784 | 784 | if (isset($aircraft_data[1])) { |
785 | 785 | $data['aircraft_icao'] = $aircraft_data[1]; |
786 | 786 | } |
@@ -795,9 +795,9 @@ discard block |
||
795 | 795 | if ($line[3] === 'PILOT') $SI->add($data); |
796 | 796 | elseif ($line[3] === 'ATC') { |
797 | 797 | //print_r($data); |
798 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
799 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
800 | - $typec = substr($data['ident'],-3); |
|
798 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
799 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
800 | + $typec = substr($data['ident'], -3); |
|
801 | 801 | if ($typec === 'APP') $data['type'] = 'Approach'; |
802 | 802 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
803 | 803 | elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
@@ -809,8 +809,8 @@ discard block |
||
809 | 809 | elseif ($data['type'] === '') $data['type'] = 'Observer'; |
810 | 810 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
811 | 811 | if (isset($ATC)) { |
812 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
813 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
812 | + if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
813 | + else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
814 | 814 | } |
815 | 815 | } |
816 | 816 | unset($data); |
@@ -826,24 +826,24 @@ discard block |
||
826 | 826 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
827 | 827 | ) |
828 | 828 | ) { |
829 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
829 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
830 | 830 | if ($buffer != '') { |
831 | 831 | $all_data = simplexml_load_string($buffer); |
832 | - foreach($all_data->children() as $childdata) { |
|
832 | + foreach ($all_data->children() as $childdata) { |
|
833 | 833 | $data = array(); |
834 | 834 | $line = $childdata; |
835 | 835 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
836 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
837 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
838 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
839 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
840 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
841 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
842 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
836 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
837 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
838 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
839 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
840 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
841 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
842 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
843 | 843 | $data['altitude_relative'] = 'AMSL'; |
844 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
844 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
845 | 845 | $data['aircraft_icao'] = 'PARAGLIDER'; |
846 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
846 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
847 | 847 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
848 | 848 | $data['format_source'] = $value['format']; |
849 | 849 | $SI->add($data); |
@@ -851,22 +851,22 @@ discard block |
||
851 | 851 | } |
852 | 852 | } |
853 | 853 | $Source->deleteOldLocationByType('gs'); |
854 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
854 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
855 | 855 | if ($buffer != '') { |
856 | 856 | $all_data = simplexml_load_string($buffer); |
857 | - foreach($all_data->children() as $childdata) { |
|
857 | + foreach ($all_data->children() as $childdata) { |
|
858 | 858 | $data = array(); |
859 | 859 | $line = $childdata; |
860 | - $data['id'] = (int)$line['gsID']; |
|
861 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
862 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
863 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
860 | + $data['id'] = (int) $line['gsID']; |
|
861 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
862 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
863 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
864 | 864 | $data['altitude_relative'] = 'AMSL'; |
865 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
865 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
866 | 866 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
867 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
867 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
868 | 868 | } else { |
869 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
869 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
870 | 870 | } |
871 | 871 | unset($data); |
872 | 872 | } |
@@ -884,9 +884,9 @@ discard block |
||
884 | 884 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
885 | 885 | ) |
886 | 886 | ) { |
887 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
887 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
888 | 888 | if ($buffer != '') { |
889 | - $all_data = json_decode($buffer,true); |
|
889 | + $all_data = json_decode($buffer, true); |
|
890 | 890 | if (isset($all_data['acList'])) { |
891 | 891 | $reset = 0; |
892 | 892 | foreach ($all_data['acList'] as $line) { |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
903 | 903 | $data['emergency'] = ''; // emergency |
904 | 904 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
905 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
905 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
906 | 906 | else $data['datetime'] = date('Y-m-d H:i:s'); |
907 | 907 | //$data['datetime'] = date('Y-m-d H:i:s'); |
908 | 908 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | $data['verticalrate'] = $line['vrt']; // verticale rate |
928 | 928 | $data['squawk'] = $line['squawk']; // squawk |
929 | 929 | $data['emergency'] = ''; // emergency |
930 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
930 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
931 | 931 | else $data['datetime'] = date('Y-m-d H:i:s'); |
932 | 932 | $data['format_source'] = 'aircraftlistjson'; |
933 | 933 | $data['id_source'] = $id_source; |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | ) |
949 | 949 | ) { |
950 | 950 | $buffer = $Common->getData($value['host']); |
951 | - $all_data = json_decode($buffer,true); |
|
951 | + $all_data = json_decode($buffer, true); |
|
952 | 952 | if (isset($all_data['planes'])) { |
953 | 953 | $reset = 0; |
954 | 954 | foreach ($all_data['planes'] as $key => $line) { |
@@ -965,12 +965,12 @@ discard block |
||
965 | 965 | $data['emergency'] = ''; // emergency |
966 | 966 | $data['registration'] = $line[2]; |
967 | 967 | $data['aircraft_icao'] = $line[0]; |
968 | - $deparr = explode('-',$line[1]); |
|
968 | + $deparr = explode('-', $line[1]); |
|
969 | 969 | if (count($deparr) === 2) { |
970 | 970 | $data['departure_airport_icao'] = $deparr[0]; |
971 | 971 | $data['arrival_airport_icao'] = $deparr[1]; |
972 | 972 | } |
973 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
973 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
974 | 974 | $data['format_source'] = 'planeupdatefaa'; |
975 | 975 | $data['id_source'] = $id_source; |
976 | 976 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | ) |
989 | 989 | ) { |
990 | 990 | $buffer = $Common->getData($value['host']); |
991 | - $all_data = json_decode($buffer,true); |
|
991 | + $all_data = json_decode($buffer, true); |
|
992 | 992 | if (isset($all_data['states'])) { |
993 | 993 | $reset = 0; |
994 | 994 | foreach ($all_data['states'] as $key => $line) { |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | //$data['emergency'] = ''; // emergency |
1006 | 1006 | //$data['registration'] = $line[2]; |
1007 | 1007 | //$data['aircraft_icao'] = $line[0]; |
1008 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1008 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
1009 | 1009 | $data['format_source'] = 'opensky'; |
1010 | 1010 | $data['id_source'] = $id_source; |
1011 | 1011 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | ) |
1023 | 1023 | ) { |
1024 | 1024 | $buffer = $Common->getData($value['host']); |
1025 | - $all_data = json_decode($buffer,true); |
|
1025 | + $all_data = json_decode($buffer, true); |
|
1026 | 1026 | if (isset($all_data['aircraft'])) { |
1027 | 1027 | $reset = 0; |
1028 | 1028 | foreach ($all_data['aircraft'] as $key => $line) { |
@@ -1058,7 +1058,7 @@ discard block |
||
1058 | 1058 | ) { |
1059 | 1059 | //$buffer = $Common->getData($hosts[$id]); |
1060 | 1060 | $buffer = $Common->getData($value['host']); |
1061 | - $all_data = json_decode($buffer,true); |
|
1061 | + $all_data = json_decode($buffer, true); |
|
1062 | 1062 | if (!empty($all_data)) $reset = 0; |
1063 | 1063 | foreach ($all_data as $key => $line) { |
1064 | 1064 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -1096,11 +1096,11 @@ discard block |
||
1096 | 1096 | ) |
1097 | 1097 | ) { |
1098 | 1098 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
1099 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1099 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
1100 | 1100 | //echo $buffer; |
1101 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1102 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1103 | - $all_data = json_decode($buffer,true); |
|
1101 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
1102 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
1103 | + $all_data = json_decode($buffer, true); |
|
1104 | 1104 | if (json_last_error() != JSON_ERROR_NONE) { |
1105 | 1105 | die(json_last_error_msg()); |
1106 | 1106 | } |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | //$data['departure_airport_iata'] = $line[11]; |
1124 | 1124 | //$data['arrival_airport_iata'] = $line[12]; |
1125 | 1125 | //$data['emergency'] = ''; // emergency |
1126 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
1126 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
1127 | 1127 | $data['format_source'] = 'radarvirtueljson'; |
1128 | 1128 | $data['id_source'] = $id_source; |
1129 | 1129 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1144,14 +1144,14 @@ discard block |
||
1144 | 1144 | ) { |
1145 | 1145 | //$buffer = $Common->getData($hosts[$id]); |
1146 | 1146 | $buffer = $Common->getData($value['host'].'?'.time()); |
1147 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1147 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
1148 | 1148 | |
1149 | 1149 | if (isset($all_data['pireps'])) { |
1150 | 1150 | $reset = 0; |
1151 | 1151 | foreach ($all_data['pireps'] as $line) { |
1152 | 1152 | $data = array(); |
1153 | 1153 | $data['id'] = $line['id']; |
1154 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1154 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1155 | 1155 | $data['ident'] = $line['callsign']; // ident |
1156 | 1156 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
1157 | 1157 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -1181,9 +1181,9 @@ discard block |
||
1181 | 1181 | $SI->add($data); |
1182 | 1182 | // print_r($data); |
1183 | 1183 | } elseif ($line['icon'] === 'ct') { |
1184 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
1185 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
1186 | - $typec = substr($data['ident'],-3); |
|
1184 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
1185 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
1186 | + $typec = substr($data['ident'], -3); |
|
1187 | 1187 | $data['type'] = ''; |
1188 | 1188 | if ($typec === 'APP') $data['type'] = 'Approach'; |
1189 | 1189 | elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
@@ -1194,7 +1194,7 @@ discard block |
||
1194 | 1194 | elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
1195 | 1195 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
1196 | 1196 | else $data['type'] = 'Observer'; |
1197 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
1197 | + if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']); |
|
1198 | 1198 | } |
1199 | 1199 | unset($data); |
1200 | 1200 | } |
@@ -1211,14 +1211,14 @@ discard block |
||
1211 | 1211 | //$buffer = $Common->getData($hosts[$id]); |
1212 | 1212 | if ($globalDebug) echo 'Get Data...'."\n"; |
1213 | 1213 | $buffer = $Common->getData($value['host']); |
1214 | - $all_data = json_decode($buffer,true); |
|
1214 | + $all_data = json_decode($buffer, true); |
|
1215 | 1215 | if ($buffer != '' && is_array($all_data)) { |
1216 | 1216 | $reset = 0; |
1217 | 1217 | foreach ($all_data as $line) { |
1218 | 1218 | $data = array(); |
1219 | 1219 | //$data['id'] = $line['id']; // id not usable |
1220 | 1220 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
1221 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1221 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1222 | 1222 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
1223 | 1223 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
1224 | 1224 | $data['ident'] = $line['flightnum']; // ident |
@@ -1233,7 +1233,7 @@ discard block |
||
1233 | 1233 | //$data['datetime'] = $line['lastupdate']; |
1234 | 1234 | //$data['last_update'] = $line['lastupdate']; |
1235 | 1235 | if (isset($value['timezone'])) { |
1236 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1236 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1237 | 1237 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1238 | 1238 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1239 | 1239 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1249,14 +1249,14 @@ discard block |
||
1249 | 1249 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1250 | 1250 | if (isset($line['aircraftname'])) { |
1251 | 1251 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1252 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1253 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1252 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1253 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1254 | 1254 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1255 | 1255 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1256 | 1256 | else { |
1257 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1258 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1259 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1257 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
1258 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
1259 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1260 | 1260 | } |
1261 | 1261 | } |
1262 | 1262 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1281,7 +1281,7 @@ discard block |
||
1281 | 1281 | //$buffer = $Common->getData($hosts[$id]); |
1282 | 1282 | if ($globalDebug) echo 'Get Data...'."\n"; |
1283 | 1283 | $buffer = $Common->getData($value['host']); |
1284 | - $all_data = json_decode($buffer,true); |
|
1284 | + $all_data = json_decode($buffer, true); |
|
1285 | 1285 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
1286 | 1286 | $reset = 0; |
1287 | 1287 | foreach ($all_data['ACARSData'] as $line) { |
@@ -1292,7 +1292,7 @@ discard block |
||
1292 | 1292 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1293 | 1293 | if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
1294 | 1294 | if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
1295 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1295 | + $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident |
|
1296 | 1296 | if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
1297 | 1297 | $data['altitude'] = $line['altitude']; // altitude |
1298 | 1298 | $data['speed'] = $line['groundspeed']; // speed |
@@ -1303,7 +1303,7 @@ discard block |
||
1303 | 1303 | //$data['squawk'] = ''; // squawk |
1304 | 1304 | //$data['emergency'] = ''; // emergency |
1305 | 1305 | if (isset($value['timezone'])) { |
1306 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1306 | + $datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone'])); |
|
1307 | 1307 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1308 | 1308 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1309 | 1309 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1339,14 +1339,14 @@ discard block |
||
1339 | 1339 | //$buffer = $Common->getData($hosts[$id]); |
1340 | 1340 | if ($globalDebug) echo 'Get Data...'."\n"; |
1341 | 1341 | $buffer = $Common->getData($value['host']); |
1342 | - $all_data = json_decode($buffer,true); |
|
1342 | + $all_data = json_decode($buffer, true); |
|
1343 | 1343 | if ($buffer != '' && is_array($all_data)) { |
1344 | 1344 | $reset = 0; |
1345 | 1345 | foreach ($all_data as $line) { |
1346 | 1346 | $data = array(); |
1347 | 1347 | //$data['id'] = $line['id']; // id not usable |
1348 | 1348 | $data['id'] = trim($line['flight_id']); |
1349 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1349 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1350 | 1350 | $data['pilot_name'] = $line['pilot_name']; |
1351 | 1351 | $data['pilot_id'] = $line['pilot_id']; |
1352 | 1352 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1390,24 +1390,24 @@ discard block |
||
1390 | 1390 | //$buffer = $Common->getData($hosts[$id]); |
1391 | 1391 | if ($globalDebug) echo 'Get Data...'."\n"; |
1392 | 1392 | $buffer = $Common->getData($value['host']); |
1393 | - $all_data = json_decode($buffer,true); |
|
1393 | + $all_data = json_decode($buffer, true); |
|
1394 | 1394 | if ($buffer != '') { |
1395 | 1395 | $Source->deleteLocationBySource('blitzortung'); |
1396 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1397 | - $buffer = explode('\n',$buffer); |
|
1396 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
1397 | + $buffer = explode('\n', $buffer); |
|
1398 | 1398 | foreach ($buffer as $buffer_line) { |
1399 | - $line = json_decode($buffer_line,true); |
|
1399 | + $line = json_decode($buffer_line, true); |
|
1400 | 1400 | if (isset($line['time'])) { |
1401 | 1401 | $data = array(); |
1402 | 1402 | $data['altitude'] = $line['alt']; // altitude |
1403 | 1403 | $data['latitude'] = $line['lat']; // lat |
1404 | 1404 | $data['longitude'] = $line['lon']; // long |
1405 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
1405 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
1406 | 1406 | $data['id_source'] = $id_source; |
1407 | 1407 | $data['format_source'] = 'blitzortung'; |
1408 | 1408 | $SI->add($data); |
1409 | 1409 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1410 | - $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
1410 | + $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
1411 | 1411 | unset($data); |
1412 | 1412 | } |
1413 | 1413 | } |
@@ -1430,11 +1430,11 @@ discard block |
||
1430 | 1430 | //$value = $formats[$nb]; |
1431 | 1431 | $format = $globalSources[$nb]['format']; |
1432 | 1432 | if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
1433 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1433 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1434 | 1434 | } elseif ($format === 'vrstcp') { |
1435 | 1435 | $buffer = @socket_read($r, 6000); |
1436 | 1436 | } else { |
1437 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1437 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1438 | 1438 | } |
1439 | 1439 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1440 | 1440 | //echo $buffer."\n"; |
@@ -1444,8 +1444,8 @@ discard block |
||
1444 | 1444 | //$SI::del(); |
1445 | 1445 | if ($buffer !== FALSE) { |
1446 | 1446 | if ($format === 'vrstcp') { |
1447 | - $buffer = explode('},{',$buffer); |
|
1448 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1447 | + $buffer = explode('},{', $buffer); |
|
1448 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1449 | 1449 | } |
1450 | 1450 | // SBS format is CSV format |
1451 | 1451 | if ($buffer !== FALSE && $buffer !== '') { |
@@ -1469,7 +1469,7 @@ discard block |
||
1469 | 1469 | $ais_data = $AIS->parse_line(trim($buffer)); |
1470 | 1470 | $data = array(); |
1471 | 1471 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
1472 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1472 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9); |
|
1473 | 1473 | if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
1474 | 1474 | if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
1475 | 1475 | if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
@@ -1480,13 +1480,13 @@ discard block |
||
1480 | 1480 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1481 | 1481 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1482 | 1482 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1483 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1483 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1484 | 1484 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1485 | 1485 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1486 | 1486 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1487 | 1487 | |
1488 | 1488 | if (isset($ais_data['timestamp'])) { |
1489 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1489 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1490 | 1490 | } else { |
1491 | 1491 | $data['datetime'] = date('Y-m-d H:i:s'); |
1492 | 1492 | } |
@@ -1497,10 +1497,10 @@ discard block |
||
1497 | 1497 | } elseif ($format === 'flightgearsp') { |
1498 | 1498 | //echo $buffer."\n"; |
1499 | 1499 | if (strlen($buffer) > 5) { |
1500 | - $line = explode(',',$buffer); |
|
1500 | + $line = explode(',', $buffer); |
|
1501 | 1501 | $data = array(); |
1502 | 1502 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1503 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1503 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1504 | 1504 | $data['ident'] = $line[6]; |
1505 | 1505 | $data['aircraft_name'] = $line[7]; |
1506 | 1506 | $data['longitude'] = $line[1]; |
@@ -1517,16 +1517,16 @@ discard block |
||
1517 | 1517 | } elseif ($format === 'acars') { |
1518 | 1518 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1519 | 1519 | $ACARS->add(trim($buffer)); |
1520 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1520 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1521 | 1521 | $ACARS->deleteLiveAcarsData(); |
1522 | 1522 | } elseif ($format === 'flightgearmp') { |
1523 | - if (substr($buffer,0,1) != '#') { |
|
1523 | + if (substr($buffer, 0, 1) != '#') { |
|
1524 | 1524 | $data = array(); |
1525 | 1525 | //echo $buffer."\n"; |
1526 | - $line = explode(' ',$buffer); |
|
1526 | + $line = explode(' ', $buffer); |
|
1527 | 1527 | if (count($line) === 11) { |
1528 | - $userserver = explode('@',$line[0]); |
|
1529 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1528 | + $userserver = explode('@', $line[0]); |
|
1529 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1530 | 1530 | $data['ident'] = $userserver[0]; |
1531 | 1531 | $data['registration'] = $userserver[0]; |
1532 | 1532 | $data['latitude'] = $line[4]; |
@@ -1534,8 +1534,8 @@ discard block |
||
1534 | 1534 | $data['altitude'] = $line[6]; |
1535 | 1535 | $data['datetime'] = date('Y-m-d H:i:s'); |
1536 | 1536 | $aircraft_type = $line[10]; |
1537 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1538 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1537 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1538 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1539 | 1539 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1540 | 1540 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1541 | 1541 | } |
@@ -1544,8 +1544,8 @@ discard block |
||
1544 | 1544 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1545 | 1545 | die; |
1546 | 1546 | } elseif ($format === 'vrstcp') { |
1547 | - foreach($buffer as $all_data) { |
|
1548 | - $line = json_decode('{'.$all_data.'}',true); |
|
1547 | + foreach ($buffer as $all_data) { |
|
1548 | + $line = json_decode('{'.$all_data.'}', true); |
|
1549 | 1549 | $data = array(); |
1550 | 1550 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1551 | 1551 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1571,16 +1571,16 @@ discard block |
||
1571 | 1571 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1572 | 1572 | unset($data); |
1573 | 1573 | } |
1574 | - } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
|
1574 | + } elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') { |
|
1575 | 1575 | $line = explode("\t", $buffer); |
1576 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1576 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1577 | 1577 | $key = $line[$k]; |
1578 | - $lined[$key] = $line[$k+1]; |
|
1578 | + $lined[$key] = $line[$k + 1]; |
|
1579 | 1579 | } |
1580 | 1580 | if (count($lined) > 3) { |
1581 | 1581 | $data['hex'] = $lined['hexid']; |
1582 | 1582 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1583 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1583 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1584 | 1584 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1585 | 1585 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1586 | 1586 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1599,23 +1599,23 @@ discard block |
||
1599 | 1599 | } else $error = true; |
1600 | 1600 | } elseif ($format === 'aprs' && $use_aprs) { |
1601 | 1601 | if ($aprs_connect === 0) { |
1602 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1602 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1603 | 1603 | $aprs_connect = 1; |
1604 | 1604 | } |
1605 | 1605 | |
1606 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1606 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1607 | 1607 | $aprs_last_tx = time(); |
1608 | 1608 | $data_aprs = "# Keep alive"; |
1609 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1609 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1610 | 1610 | } |
1611 | 1611 | |
1612 | 1612 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1613 | 1613 | //echo 'APRS data : '.$buffer."\n"; |
1614 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1615 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1614 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1615 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1616 | 1616 | //echo $buffer."\n"; |
1617 | 1617 | date_default_timezone_set('UTC'); |
1618 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1618 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1619 | 1619 | $line = $APRS->parse($buffer); |
1620 | 1620 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1621 | 1621 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1630,7 +1630,7 @@ discard block |
||
1630 | 1630 | if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
1631 | 1631 | if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
1632 | 1632 | if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
1633 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1633 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1634 | 1634 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1635 | 1635 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1636 | 1636 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1713,29 +1713,29 @@ discard block |
||
1713 | 1713 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1714 | 1714 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1715 | 1715 | $Source->deleteOldLocationByType('gs'); |
1716 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
1717 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1716 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
1717 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1718 | 1718 | } else { |
1719 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1719 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1720 | 1720 | } |
1721 | 1721 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
1722 | 1722 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1723 | 1723 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1724 | 1724 | $Source->deleteOldLocationByType('wx'); |
1725 | 1725 | $weather_data = json_encode($line); |
1726 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
1727 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1726 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
1727 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1728 | 1728 | } else { |
1729 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1729 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1730 | 1730 | } |
1731 | 1731 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
1732 | 1732 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1733 | 1733 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1734 | 1734 | $Source->deleteOldLocationByType('lightning'); |
1735 | - if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
1736 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1735 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
1736 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1737 | 1737 | } else { |
1738 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1738 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1739 | 1739 | } |
1740 | 1740 | } elseif ($globalDebug) { |
1741 | 1741 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -1744,7 +1744,7 @@ discard block |
||
1744 | 1744 | unset($data); |
1745 | 1745 | } |
1746 | 1746 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1747 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
1747 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
1748 | 1748 | } |
1749 | 1749 | /* |
1750 | 1750 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) { |
@@ -1753,7 +1753,7 @@ discard block |
||
1753 | 1753 | */ |
1754 | 1754 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1755 | 1755 | elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1756 | - if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1756 | + if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1757 | 1757 | $Source->deleteOldLocationByType('lightning'); |
1758 | 1758 | $Source->deleteOldLocationByType('wx'); |
1759 | 1759 | $globalSources[$nb]['last_weather_clean'] = time(); |
@@ -1838,7 +1838,7 @@ discard block |
||
1838 | 1838 | connect_all($sourceee); |
1839 | 1839 | $sourceee = array(); |
1840 | 1840 | //connect_all($globalSources); |
1841 | - $tt[$format]=0; |
|
1841 | + $tt[$format] = 0; |
|
1842 | 1842 | break; |
1843 | 1843 | } |
1844 | 1844 | //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
@@ -1848,14 +1848,14 @@ discard block |
||
1848 | 1848 | } else { |
1849 | 1849 | $error = socket_strerror(socket_last_error()); |
1850 | 1850 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1851 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1851 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1852 | 1852 | if (isset($globalDebug)) echo "Restarting...\n"; |
1853 | 1853 | // Restart the script if possible |
1854 | 1854 | if (is_array($sockets)) { |
1855 | 1855 | if ($globalDebug) echo "Shutdown all sockets..."; |
1856 | 1856 | |
1857 | 1857 | foreach ($sockets as $sock) { |
1858 | - @socket_shutdown($sock,2); |
|
1858 | + @socket_shutdown($sock, 2); |
|
1859 | 1859 | @socket_close($sock); |
1860 | 1860 | } |
1861 | 1861 |