@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | |
18 | 18 | $debug = true; |
19 | 19 | |
20 | -$ACARS=new ACARS(null,true); |
|
20 | +$ACARS = new ACARS(null, true); |
|
21 | 21 | date_default_timezone_set('UTC'); |
22 | 22 | // signal handler - playing nice with sockets and dump1090 |
23 | -pcntl_signal(SIGINT, function($signo) { |
|
23 | +pcntl_signal(SIGINT, function($signo) { |
|
24 | 24 | global $sock; |
25 | 25 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
26 | 26 | socket_shutdown($sock, 0); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $sock = socket_create(AF_INET, SOCK_DGRAM, 0) or die("Unable to create socket\n"); |
37 | 37 | |
38 | 38 | // Bind the source address |
39 | -if( !socket_bind($sock, $globalACARSHost , $globalACARSPort) ) |
|
39 | +if (!socket_bind($sock, $globalACARSHost, $globalACARSPort)) |
|
40 | 40 | { |
41 | 41 | $errorcode = socket_last_error(); |
42 | 42 | $errormsg = socket_strerror($errorcode); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | echo "LISTEN UDP MODE \n\n"; |
48 | -while(1) { |
|
48 | +while (1) { |
|
49 | 49 | $r = socket_recvfrom($sock, $buffer, 512, 0, $remote_ip, $remote_port); |
50 | 50 | |
51 | 51 | // lets play nice and handle signals such as ctrl-c/kill properly |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | // (null) 2 23/02/2015 14:46:06 0 -16 X .D-AIPW ! 1L 7 M82A LH077P 010952342854:VP-MIBI+W+0)-V+(),GB1 |
55 | 55 | echo $buffer."\n"; |
56 | 56 | $ACARS->add(trim($buffer)); |
57 | - socket_sendto($sock, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
57 | + socket_sendto($sock, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
58 | 58 | $ACARS->deleteLiveAcarsData(); |
59 | 59 | } |
60 | -pcntl_exec($_,$argv); |
|
60 | +pcntl_exec($_, $argv); |
|
61 | 61 | ?> |
@@ -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')); |
|
57 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver')); |
|
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'])) { |
@@ -80,28 +80,28 @@ discard block |
||
80 | 80 | else $id_source = 1; |
81 | 81 | if (isset($globalServer) && $globalServer) { |
82 | 82 | if ($globalDebug) echo "Using Server Mode\n"; |
83 | - $SI=new SpotterServer(); |
|
83 | + $SI = new SpotterServer(); |
|
84 | 84 | /* |
85 | 85 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
86 | 86 | $SI = new adsb2aprs(); |
87 | 87 | $SI->connect(); |
88 | 88 | */ |
89 | -} else $SI=new SpotterImport($Connection->db); |
|
89 | +} else $SI = new SpotterImport($Connection->db); |
|
90 | 90 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
91 | 91 | if (isset($globalMarine) && $globalMarine) { |
92 | 92 | $AIS = new AIS(); |
93 | 93 | $MI = new MarineImport($Connection->db); |
94 | 94 | } |
95 | 95 | //$APRS=new APRS($Connection->db); |
96 | -$SBS=new SBS(); |
|
97 | -$ACARS=new ACARS($Connection->db,true); |
|
98 | -$Source=new Source($Connection->db); |
|
99 | -$Common=new Common(); |
|
96 | +$SBS = new SBS(); |
|
97 | +$ACARS = new ACARS($Connection->db, true); |
|
98 | +$Source = new Source($Connection->db); |
|
99 | +$Common = new Common(); |
|
100 | 100 | date_default_timezone_set('UTC'); |
101 | 101 | //$servertz = system('date +%Z'); |
102 | 102 | // signal handler - playing nice with sockets and dump1090 |
103 | 103 | if (function_exists('pcntl_fork')) { |
104 | - pcntl_signal(SIGINT, function() { |
|
104 | + pcntl_signal(SIGINT, function() { |
|
105 | 105 | global $sockets; |
106 | 106 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
107 | 107 | die("Bye!\n"); |
@@ -117,30 +117,30 @@ discard block |
||
117 | 117 | |
118 | 118 | function connect_all($hosts) { |
119 | 119 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
120 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
120 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
121 | 121 | $reset++; |
122 | 122 | if ($globalDebug) echo 'Connect to all...'."\n"; |
123 | 123 | foreach ($hosts as $id => $value) { |
124 | 124 | $host = $value['host']; |
125 | 125 | $globalSources[$id]['last_exec'] = 0; |
126 | 126 | // Here we check type of source(s) |
127 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
128 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
127 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
128 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
129 | 129 | //$formats[$id] = 'deltadbtxt'; |
130 | 130 | $globalSources[$id]['format'] = 'deltadbtxt'; |
131 | 131 | //$last_exec['deltadbtxt'] = 0; |
132 | 132 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
133 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
133 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
134 | 134 | //$formats[$id] = 'vatsimtxt'; |
135 | 135 | $globalSources[$id]['format'] = 'vatsimtxt'; |
136 | 136 | //$last_exec['vatsimtxt'] = 0; |
137 | 137 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
138 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
138 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
139 | 139 | //$formats[$id] = 'aircraftlistjson'; |
140 | 140 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
141 | 141 | //$last_exec['aircraftlistjson'] = 0; |
142 | 142 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
143 | - } else if (preg_match('/opensky/i',$host)) { |
|
143 | + } else if (preg_match('/opensky/i', $host)) { |
|
144 | 144 | //$formats[$id] = 'aircraftlistjson'; |
145 | 145 | $globalSources[$id]['format'] = 'opensky'; |
146 | 146 | //$last_exec['aircraftlistjson'] = 0; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | exit(0); |
158 | 158 | } |
159 | 159 | */ |
160 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
160 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
161 | 161 | //$formats[$id] = 'planeupdatefaa'; |
162 | 162 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
163 | 163 | //$last_exec['planeupdatefaa'] = 0; |
@@ -166,32 +166,32 @@ discard block |
||
166 | 166 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
167 | 167 | exit(0); |
168 | 168 | } |
169 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
169 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
170 | 170 | //$formats[$id] = 'phpvmacars'; |
171 | 171 | $globalSources[$id]['format'] = 'phpvmacars'; |
172 | 172 | //$last_exec['phpvmacars'] = 0; |
173 | 173 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
174 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
174 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
175 | 175 | //$formats[$id] = 'phpvmacars'; |
176 | 176 | $globalSources[$id]['format'] = 'vam'; |
177 | 177 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
178 | - } else if (preg_match('/whazzup/i',$host)) { |
|
178 | + } else if (preg_match('/whazzup/i', $host)) { |
|
179 | 179 | //$formats[$id] = 'whazzup'; |
180 | 180 | $globalSources[$id]['format'] = 'whazzup'; |
181 | 181 | //$last_exec['whazzup'] = 0; |
182 | 182 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
183 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
183 | + } else if (preg_match('/blitzortung/i', $host)) { |
|
184 | 184 | $globalSources[$id]['format'] = 'blitzortung'; |
185 | 185 | if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
186 | - } else if (preg_match('/airwhere/i',$host)) { |
|
186 | + } else if (preg_match('/airwhere/i', $host)) { |
|
187 | 187 | $globalSources[$id]['format'] = 'airwhere'; |
188 | 188 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
189 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
189 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
190 | 190 | //$formats[$id] = 'pirepsjson'; |
191 | 191 | $globalSources[$id]['format'] = 'pirepsjson'; |
192 | 192 | //$last_exec['pirepsjson'] = 0; |
193 | 193 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
194 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
194 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
195 | 195 | //$formats[$id] = 'fr24json'; |
196 | 196 | $globalSources[$id]['format'] = 'fr24json'; |
197 | 197 | //$last_exec['fr24json'] = 0; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
201 | 201 | exit(0); |
202 | 202 | } |
203 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
203 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
204 | 204 | //$formats[$id] = 'fr24json'; |
205 | 205 | $globalSources[$id]['format'] = 'myshiptracking'; |
206 | 206 | //$last_exec['fr24json'] = 0; |
@@ -210,22 +210,22 @@ discard block |
||
210 | 210 | exit(0); |
211 | 211 | } |
212 | 212 | //} else if (preg_match('/10001/',$host)) { |
213 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
213 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
214 | 214 | //$formats[$id] = 'tsv'; |
215 | 215 | $globalSources[$id]['format'] = 'tsv'; |
216 | 216 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
217 | 217 | } |
218 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
218 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
219 | 219 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
220 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
220 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
221 | 221 | if ($idf !== false) { |
222 | 222 | $httpfeeds[$id] = $idf; |
223 | 223 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
224 | 224 | } |
225 | 225 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
226 | 226 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
227 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
228 | - $hostport = explode(':',$host); |
|
227 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
228 | + $hostport = explode(':', $host); |
|
229 | 229 | if (isset($hostport[1])) { |
230 | 230 | $port = $hostport[1]; |
231 | 231 | $hostn = $hostport[0]; |
@@ -235,19 +235,19 @@ discard block |
||
235 | 235 | } |
236 | 236 | $Common = new Common(); |
237 | 237 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
238 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
238 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
239 | 239 | } else { |
240 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
240 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
241 | 241 | } |
242 | 242 | if ($s) { |
243 | 243 | $sockets[$id] = $s; |
244 | 244 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
245 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
245 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
246 | 246 | //$formats[$id] = 'aprs'; |
247 | 247 | $globalSources[$id]['format'] = 'aprs'; |
248 | 248 | //$aprs_connect = 0; |
249 | 249 | //$use_aprs = true; |
250 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
250 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
251 | 251 | $globalSources[$id]['format'] = 'vrstcp'; |
252 | 252 | } elseif ($port == '10001') { |
253 | 253 | //$formats[$id] = 'tsv'; |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
287 | 287 | else $timeout = 20; |
288 | 288 | $errno = ''; |
289 | -$errstr=''; |
|
289 | +$errstr = ''; |
|
290 | 290 | |
291 | 291 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
292 | 292 | /* Initiate connections to all the hosts simultaneously */ |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | //connect_all($globalSources); |
295 | 295 | |
296 | 296 | if (isset($globalProxy) && $globalProxy) { |
297 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
297 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
298 | 298 | } else { |
299 | 299 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
300 | 300 | } |
@@ -324,16 +324,16 @@ discard block |
||
324 | 324 | |
325 | 325 | if ($use_aprs) { |
326 | 326 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
327 | - $APRS=new APRS(); |
|
327 | + $APRS = new APRS(); |
|
328 | 328 | $aprs_connect = 0; |
329 | 329 | $aprs_keep = 120; |
330 | 330 | $aprs_last_tx = time(); |
331 | 331 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
332 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
332 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
333 | 333 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
334 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
334 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
335 | 335 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
336 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
336 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
337 | 337 | if ($aprs_full) $aprs_filter = ''; |
338 | 338 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
339 | 339 | else $aprs_pass = '-1'; |
@@ -347,12 +347,12 @@ discard block |
||
347 | 347 | sleep(1); |
348 | 348 | if ($globalDebug) echo "SCAN MODE \n\n"; |
349 | 349 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
350 | -$endtime = time()+$globalCronEnd; |
|
350 | +$endtime = time() + $globalCronEnd; |
|
351 | 351 | $i = 1; |
352 | 352 | $tt = array(); |
353 | 353 | // Delete all ATC |
354 | 354 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
355 | - $ATC=new ATC($Connection->db); |
|
355 | + $ATC = new ATC($Connection->db); |
|
356 | 356 | } |
357 | 357 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
358 | 358 | $ATC->deleteAll(); |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | |
361 | 361 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
362 | 362 | while ($i > 0) { |
363 | - if (!$globalDaemon) $i = $endtime-time(); |
|
363 | + if (!$globalDaemon) $i = $endtime - time(); |
|
364 | 364 | // Delete old ATC |
365 | 365 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
366 | 366 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | } |
375 | 375 | if ($max != $globalMinFetch) { |
376 | 376 | if ($globalDebug) echo 'Sleeping...'."\n"; |
377 | - sleep($globalMinFetch-$max+2); |
|
377 | + sleep($globalMinFetch - $max + 2); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | //$buffer = $Common->getData($hosts[$id]); |
394 | 394 | $buffer = $Common->getData($value['host']); |
395 | 395 | if ($buffer != '') $reset = 0; |
396 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
397 | - $buffer = explode('\n',$buffer); |
|
396 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
397 | + $buffer = explode('\n', $buffer); |
|
398 | 398 | foreach ($buffer as $line) { |
399 | 399 | if ($line != '' && count($line) > 7) { |
400 | 400 | $line = explode(',', $line); |
@@ -427,11 +427,11 @@ discard block |
||
427 | 427 | ) |
428 | 428 | ) { |
429 | 429 | date_default_timezone_set('CET'); |
430 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
430 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
431 | 431 | date_default_timezone_set('UTC'); |
432 | 432 | if ($buffer != '') $reset = 0; |
433 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
434 | - $buffer = explode('\n',$buffer); |
|
433 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
434 | + $buffer = explode('\n', $buffer); |
|
435 | 435 | foreach ($buffer as $line) { |
436 | 436 | if ($line != '') { |
437 | 437 | //echo "'".$line."'\n"; |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
450 | 450 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
451 | 451 | if (isset($ais_data['timestamp'])) { |
452 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
452 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
453 | 453 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
454 | 454 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
455 | 455 | $add = true; |
@@ -472,12 +472,12 @@ discard block |
||
472 | 472 | $w = $e = null; |
473 | 473 | |
474 | 474 | if (isset($arr[$id])) { |
475 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
475 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
476 | 476 | if ($nn > 0) { |
477 | 477 | foreach ($httpfeeds as $feed) { |
478 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
479 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
480 | - $buffer = explode('\n',$buffer); |
|
478 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
479 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
480 | + $buffer = explode('\n', $buffer); |
|
481 | 481 | foreach ($buffer as $line) { |
482 | 482 | if ($line != '') { |
483 | 483 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -495,9 +495,9 @@ 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['destination'])) $data['arrival_code'] = $ais_data['destination']; |
498 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
498 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
499 | 499 | if (isset($ais_data['timestamp'])) { |
500 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
500 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
501 | 501 | } else { |
502 | 502 | $data['datetime'] = date('Y-m-d H:i:s'); |
503 | 503 | } |
@@ -528,10 +528,10 @@ discard block |
||
528 | 528 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
529 | 529 | ) |
530 | 530 | ) { |
531 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
531 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
532 | 532 | if ($buffer != '') { |
533 | 533 | //echo $buffer; |
534 | - $all_data = json_decode($buffer,true); |
|
534 | + $all_data = json_decode($buffer, true); |
|
535 | 535 | //print_r($all_data); |
536 | 536 | if (isset($all_data[0]['DATA'])) { |
537 | 537 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
547 | 547 | $data['imo'] = $line['IMO']; |
548 | 548 | //$data['arrival_code'] = $ais_data['destination']; |
549 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
549 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
550 | 550 | $data['format_source'] = 'myshiptracking'; |
551 | 551 | $data['id_source'] = $id_source; |
552 | 552 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -563,9 +563,9 @@ discard block |
||
563 | 563 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
564 | 564 | ) |
565 | 565 | ) { |
566 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
566 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
567 | 567 | if ($buffer != '') { |
568 | - $all_data = json_decode($buffer,true); |
|
568 | + $all_data = json_decode($buffer, true); |
|
569 | 569 | if (isset($all_data[0]['mmsi'])) { |
570 | 570 | foreach ($all_data as $line) { |
571 | 571 | if ($line != '') { |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | ) { |
600 | 600 | $buffer = $Common->getData($value['host']); |
601 | 601 | if ($buffer != '') { |
602 | - $all_data = json_decode($buffer,true); |
|
602 | + $all_data = json_decode($buffer, true); |
|
603 | 603 | if (isset($all_data['features'][0]['id'])) { |
604 | 604 | foreach ($all_data['features'] as $line) { |
605 | 605 | $data = array(); |
@@ -632,27 +632,27 @@ discard block |
||
632 | 632 | ) |
633 | 633 | ) { |
634 | 634 | echo 'download...'; |
635 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
635 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
636 | 636 | echo 'done !'."\n"; |
637 | 637 | if ($buffer != '') $reset = 0; |
638 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
639 | - $buffer = explode('\n',$buffer); |
|
638 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
639 | + $buffer = explode('\n', $buffer); |
|
640 | 640 | foreach ($buffer as $line) { |
641 | 641 | if ($line != '') { |
642 | 642 | $data = array(); |
643 | - $data['mmsi'] = (int)substr($line,0,9); |
|
644 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
643 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
644 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
645 | 645 | //$data['status'] = substr($line,21,2); |
646 | 646 | //$data['type'] = substr($line,24,3); |
647 | - $data['latitude'] = substr($line,29,9); |
|
648 | - $data['longitude'] = substr($line,41,9); |
|
649 | - $data['speed'] = round(substr($line,51,5)); |
|
647 | + $data['latitude'] = substr($line, 29, 9); |
|
648 | + $data['longitude'] = substr($line, 41, 9); |
|
649 | + $data['speed'] = round(substr($line, 51, 5)); |
|
650 | 650 | //$data['course'] = substr($line,57,5); |
651 | - $data['heading'] = round(substr($line,63,3)); |
|
651 | + $data['heading'] = round(substr($line, 63, 3)); |
|
652 | 652 | //$data['draft'] = substr($line,67,4); |
653 | 653 | //$data['length'] = substr($line,72,3); |
654 | 654 | //$data['beam'] = substr($line,76,2); |
655 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
655 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
656 | 656 | //$data['callsign'] = trim(substr($line,100,7); |
657 | 657 | //$data['dest'] = substr($line,108,20); |
658 | 658 | //$data['etaDate'] = substr($line,129,5); |
@@ -685,8 +685,8 @@ discard block |
||
685 | 685 | ) { |
686 | 686 | //$buffer = $Common->getData($hosts[$id]); |
687 | 687 | $buffer = $Common->getData($value['host']); |
688 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
689 | - $buffer = explode('\n',$buffer); |
|
688 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
689 | + $buffer = explode('\n', $buffer); |
|
690 | 690 | $reset = 0; |
691 | 691 | foreach ($buffer as $line) { |
692 | 692 | if ($line != '') { |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
698 | 698 | $data['pilot_id'] = $line[1]; |
699 | 699 | $data['pilot_name'] = $line[2]; |
700 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
700 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
701 | 701 | $data['ident'] = $line[0]; // ident |
702 | 702 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
703 | 703 | $data['speed'] = $line[8]; // speed |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
714 | 714 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
715 | 715 | $data['departure_airport_icao'] = $line[11]; |
716 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
716 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
717 | 717 | $data['arrival_airport_icao'] = $line[13]; |
718 | 718 | $data['frequency'] = $line[4]; |
719 | 719 | $data['type'] = $line[18]; |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | $data['id_source'] = $id_source; |
723 | 723 | //$data['arrival_airport_time'] = ; |
724 | 724 | if ($line[9] != '') { |
725 | - $aircraft_data = explode('/',$line[9]); |
|
725 | + $aircraft_data = explode('/', $line[9]); |
|
726 | 726 | if (isset($aircraft_data[1])) { |
727 | 727 | $data['aircraft_icao'] = $aircraft_data[1]; |
728 | 728 | } |
@@ -737,9 +737,9 @@ discard block |
||
737 | 737 | if ($line[3] == 'PILOT') $SI->add($data); |
738 | 738 | elseif ($line[3] == 'ATC') { |
739 | 739 | //print_r($data); |
740 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
741 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
742 | - $typec = substr($data['ident'],-3); |
|
740 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
741 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
742 | + $typec = substr($data['ident'], -3); |
|
743 | 743 | if ($typec == 'APP') $data['type'] = 'Approach'; |
744 | 744 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
745 | 745 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -751,8 +751,8 @@ discard block |
||
751 | 751 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
752 | 752 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
753 | 753 | if (isset($ATC)) { |
754 | - 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']); |
|
755 | - 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']); |
|
754 | + 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']); |
|
755 | + 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']); |
|
756 | 756 | } |
757 | 757 | } |
758 | 758 | unset($data); |
@@ -768,24 +768,24 @@ discard block |
||
768 | 768 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
769 | 769 | ) |
770 | 770 | ) { |
771 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
771 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
772 | 772 | if ($buffer != '') { |
773 | 773 | $all_data = simplexml_load_string($buffer); |
774 | - foreach($all_data->children() as $childdata) { |
|
774 | + foreach ($all_data->children() as $childdata) { |
|
775 | 775 | $data = array(); |
776 | 776 | $line = $childdata; |
777 | 777 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
778 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
779 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
780 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
781 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
782 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
783 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
784 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
778 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
779 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
780 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
781 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
782 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
783 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
784 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
785 | 785 | $data['altitude_relative'] = 'AMSL'; |
786 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
786 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
787 | 787 | $data['aircraft_icao'] = 'PARAGLIDER'; |
788 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
788 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
789 | 789 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
790 | 790 | $data['format_source'] = $value['format']; |
791 | 791 | $SI->add($data); |
@@ -793,22 +793,22 @@ discard block |
||
793 | 793 | } |
794 | 794 | } |
795 | 795 | $Source->deleteOldLocationByType('gs'); |
796 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
796 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
797 | 797 | if ($buffer != '') { |
798 | 798 | $all_data = simplexml_load_string($buffer); |
799 | - foreach($all_data->children() as $childdata) { |
|
799 | + foreach ($all_data->children() as $childdata) { |
|
800 | 800 | $data = array(); |
801 | 801 | $line = $childdata; |
802 | - $data['id'] = (int)$line['gsID']; |
|
803 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
804 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
805 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
802 | + $data['id'] = (int) $line['gsID']; |
|
803 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
804 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
805 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
806 | 806 | $data['altitude_relative'] = 'AMSL'; |
807 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
807 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
808 | 808 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
809 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
809 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
810 | 810 | } else { |
811 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
811 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
812 | 812 | } |
813 | 813 | unset($data); |
814 | 814 | } |
@@ -826,9 +826,9 @@ discard block |
||
826 | 826 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
827 | 827 | ) |
828 | 828 | ) { |
829 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
829 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
830 | 830 | if ($buffer != '') { |
831 | - $all_data = json_decode($buffer,true); |
|
831 | + $all_data = json_decode($buffer, true); |
|
832 | 832 | if (isset($all_data['acList'])) { |
833 | 833 | $reset = 0; |
834 | 834 | foreach ($all_data['acList'] as $line) { |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
845 | 845 | $data['emergency'] = ''; // emergency |
846 | 846 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
847 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
847 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
848 | 848 | else $data['datetime'] = date('Y-m-d H:i:s'); |
849 | 849 | //$data['datetime'] = date('Y-m-d H:i:s'); |
850 | 850 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | $data['verticalrate'] = $line['vrt']; // verticale rate |
870 | 870 | $data['squawk'] = $line['squawk']; // squawk |
871 | 871 | $data['emergency'] = ''; // emergency |
872 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
872 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
873 | 873 | else $data['datetime'] = date('Y-m-d H:i:s'); |
874 | 874 | $data['format_source'] = 'aircraftlistjson'; |
875 | 875 | $data['id_source'] = $id_source; |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | ) |
891 | 891 | ) { |
892 | 892 | $buffer = $Common->getData($value['host']); |
893 | - $all_data = json_decode($buffer,true); |
|
893 | + $all_data = json_decode($buffer, true); |
|
894 | 894 | if (isset($all_data['planes'])) { |
895 | 895 | $reset = 0; |
896 | 896 | foreach ($all_data['planes'] as $key => $line) { |
@@ -907,12 +907,12 @@ discard block |
||
907 | 907 | $data['emergency'] = ''; // emergency |
908 | 908 | $data['registration'] = $line[2]; |
909 | 909 | $data['aircraft_icao'] = $line[0]; |
910 | - $deparr = explode('-',$line[1]); |
|
910 | + $deparr = explode('-', $line[1]); |
|
911 | 911 | if (count($deparr) == 2) { |
912 | 912 | $data['departure_airport_icao'] = $deparr[0]; |
913 | 913 | $data['arrival_airport_icao'] = $deparr[1]; |
914 | 914 | } |
915 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
915 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
916 | 916 | $data['format_source'] = 'planeupdatefaa'; |
917 | 917 | $data['id_source'] = $id_source; |
918 | 918 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | ) |
931 | 931 | ) { |
932 | 932 | $buffer = $Common->getData($value['host']); |
933 | - $all_data = json_decode($buffer,true); |
|
933 | + $all_data = json_decode($buffer, true); |
|
934 | 934 | if (isset($all_data['states'])) { |
935 | 935 | $reset = 0; |
936 | 936 | foreach ($all_data['states'] as $key => $line) { |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | //$data['emergency'] = ''; // emergency |
948 | 948 | //$data['registration'] = $line[2]; |
949 | 949 | //$data['aircraft_icao'] = $line[0]; |
950 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
950 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
951 | 951 | $data['format_source'] = 'opensky'; |
952 | 952 | $data['id_source'] = $id_source; |
953 | 953 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | ) { |
967 | 967 | //$buffer = $Common->getData($hosts[$id]); |
968 | 968 | $buffer = $Common->getData($value['host']); |
969 | - $all_data = json_decode($buffer,true); |
|
969 | + $all_data = json_decode($buffer, true); |
|
970 | 970 | if (!empty($all_data)) $reset = 0; |
971 | 971 | foreach ($all_data as $key => $line) { |
972 | 972 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -1004,11 +1004,11 @@ discard block |
||
1004 | 1004 | ) |
1005 | 1005 | ) { |
1006 | 1006 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
1007 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1007 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
1008 | 1008 | //echo $buffer; |
1009 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1010 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1011 | - $all_data = json_decode($buffer,true); |
|
1009 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
1010 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
1011 | + $all_data = json_decode($buffer, true); |
|
1012 | 1012 | if (json_last_error() != JSON_ERROR_NONE) { |
1013 | 1013 | die(json_last_error_msg()); |
1014 | 1014 | } |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | //$data['departure_airport_iata'] = $line[11]; |
1032 | 1032 | //$data['arrival_airport_iata'] = $line[12]; |
1033 | 1033 | //$data['emergency'] = ''; // emergency |
1034 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
1034 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
1035 | 1035 | $data['format_source'] = 'radarvirtueljson'; |
1036 | 1036 | $data['id_source'] = $id_source; |
1037 | 1037 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1052,14 +1052,14 @@ discard block |
||
1052 | 1052 | ) { |
1053 | 1053 | //$buffer = $Common->getData($hosts[$id]); |
1054 | 1054 | $buffer = $Common->getData($value['host'].'?'.time()); |
1055 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1055 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
1056 | 1056 | |
1057 | 1057 | if (isset($all_data['pireps'])) { |
1058 | 1058 | $reset = 0; |
1059 | 1059 | foreach ($all_data['pireps'] as $line) { |
1060 | 1060 | $data = array(); |
1061 | 1061 | $data['id'] = $line['id']; |
1062 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1062 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1063 | 1063 | $data['ident'] = $line['callsign']; // ident |
1064 | 1064 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
1065 | 1065 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -1089,9 +1089,9 @@ discard block |
||
1089 | 1089 | $SI->add($data); |
1090 | 1090 | // print_r($data); |
1091 | 1091 | } elseif ($line['icon'] == 'ct') { |
1092 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
1093 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
1094 | - $typec = substr($data['ident'],-3); |
|
1092 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
1093 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
1094 | + $typec = substr($data['ident'], -3); |
|
1095 | 1095 | $data['type'] = ''; |
1096 | 1096 | if ($typec == 'APP') $data['type'] = 'Approach'; |
1097 | 1097 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
1103 | 1103 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1104 | 1104 | else $data['type'] = 'Observer'; |
1105 | - 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']); |
|
1105 | + 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']); |
|
1106 | 1106 | } |
1107 | 1107 | unset($data); |
1108 | 1108 | } |
@@ -1119,14 +1119,14 @@ discard block |
||
1119 | 1119 | //$buffer = $Common->getData($hosts[$id]); |
1120 | 1120 | if ($globalDebug) echo 'Get Data...'."\n"; |
1121 | 1121 | $buffer = $Common->getData($value['host']); |
1122 | - $all_data = json_decode($buffer,true); |
|
1122 | + $all_data = json_decode($buffer, true); |
|
1123 | 1123 | if ($buffer != '' && is_array($all_data)) { |
1124 | 1124 | $reset = 0; |
1125 | 1125 | foreach ($all_data as $line) { |
1126 | 1126 | $data = array(); |
1127 | 1127 | //$data['id'] = $line['id']; // id not usable |
1128 | 1128 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
1129 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1129 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1130 | 1130 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
1131 | 1131 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
1132 | 1132 | $data['ident'] = $line['flightnum']; // ident |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | //$data['datetime'] = $line['lastupdate']; |
1142 | 1142 | //$data['last_update'] = $line['lastupdate']; |
1143 | 1143 | if (isset($value['timezone'])) { |
1144 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1144 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1145 | 1145 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1146 | 1146 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1147 | 1147 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1154,14 +1154,14 @@ discard block |
||
1154 | 1154 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1155 | 1155 | if (isset($line['aircraftname'])) { |
1156 | 1156 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1157 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1158 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1157 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1158 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1159 | 1159 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1160 | 1160 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1161 | 1161 | else { |
1162 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1163 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1164 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1162 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
1163 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
1164 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1165 | 1165 | } |
1166 | 1166 | } |
1167 | 1167 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1186,14 +1186,14 @@ discard block |
||
1186 | 1186 | //$buffer = $Common->getData($hosts[$id]); |
1187 | 1187 | if ($globalDebug) echo 'Get Data...'."\n"; |
1188 | 1188 | $buffer = $Common->getData($value['host']); |
1189 | - $all_data = json_decode($buffer,true); |
|
1189 | + $all_data = json_decode($buffer, true); |
|
1190 | 1190 | if ($buffer != '' && is_array($all_data)) { |
1191 | 1191 | $reset = 0; |
1192 | 1192 | foreach ($all_data as $line) { |
1193 | 1193 | $data = array(); |
1194 | 1194 | //$data['id'] = $line['id']; // id not usable |
1195 | 1195 | $data['id'] = trim($line['flight_id']); |
1196 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1196 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1197 | 1197 | $data['pilot_name'] = $line['pilot_name']; |
1198 | 1198 | $data['pilot_id'] = $line['pilot_id']; |
1199 | 1199 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1237,24 +1237,24 @@ discard block |
||
1237 | 1237 | //$buffer = $Common->getData($hosts[$id]); |
1238 | 1238 | if ($globalDebug) echo 'Get Data...'."\n"; |
1239 | 1239 | $buffer = $Common->getData($value['host']); |
1240 | - $all_data = json_decode($buffer,true); |
|
1240 | + $all_data = json_decode($buffer, true); |
|
1241 | 1241 | if ($buffer != '') { |
1242 | 1242 | $Source->deleteLocationBySource('blitzortung'); |
1243 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1244 | - $buffer = explode('\n',$buffer); |
|
1243 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
1244 | + $buffer = explode('\n', $buffer); |
|
1245 | 1245 | foreach ($buffer as $buffer_line) { |
1246 | - $line = json_decode($buffer_line,true); |
|
1246 | + $line = json_decode($buffer_line, true); |
|
1247 | 1247 | if (isset($line['time'])) { |
1248 | 1248 | $data = array(); |
1249 | 1249 | $data['altitude'] = $line['alt']; // altitude |
1250 | 1250 | $data['latitude'] = $line['lat']; // lat |
1251 | 1251 | $data['longitude'] = $line['lon']; // long |
1252 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
1252 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
1253 | 1253 | $data['id_source'] = $id_source; |
1254 | 1254 | $data['format_source'] = 'blitzortung'; |
1255 | 1255 | $SI->add($data); |
1256 | 1256 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1257 | - $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
1257 | + $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
1258 | 1258 | unset($data); |
1259 | 1259 | } |
1260 | 1260 | } |
@@ -1279,11 +1279,11 @@ discard block |
||
1279 | 1279 | //$value = $formats[$nb]; |
1280 | 1280 | $format = $globalSources[$nb]['format']; |
1281 | 1281 | if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
1282 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1282 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1283 | 1283 | } elseif ($format == 'vrstcp') { |
1284 | 1284 | $buffer = @socket_read($r, 6000); |
1285 | 1285 | } else { |
1286 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1286 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1287 | 1287 | } |
1288 | 1288 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1289 | 1289 | //echo $buffer."\n"; |
@@ -1292,8 +1292,8 @@ discard block |
||
1292 | 1292 | $error = false; |
1293 | 1293 | //$SI::del(); |
1294 | 1294 | if ($format == 'vrstcp') { |
1295 | - $buffer = explode('},{',$buffer); |
|
1296 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1295 | + $buffer = explode('},{', $buffer); |
|
1296 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1297 | 1297 | // SBS format is CSV format |
1298 | 1298 | if ($buffer !== FALSE && $buffer != '') { |
1299 | 1299 | $tt[$format] = 0; |
@@ -1327,13 +1327,13 @@ discard block |
||
1327 | 1327 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1328 | 1328 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1329 | 1329 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1330 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1330 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1331 | 1331 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1332 | 1332 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1333 | 1333 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1334 | 1334 | |
1335 | 1335 | if (isset($ais_data['timestamp'])) { |
1336 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1336 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1337 | 1337 | } else { |
1338 | 1338 | $data['datetime'] = date('Y-m-d H:i:s'); |
1339 | 1339 | } |
@@ -1344,10 +1344,10 @@ discard block |
||
1344 | 1344 | } elseif ($format == 'flightgearsp') { |
1345 | 1345 | //echo $buffer."\n"; |
1346 | 1346 | if (strlen($buffer) > 5) { |
1347 | - $line = explode(',',$buffer); |
|
1347 | + $line = explode(',', $buffer); |
|
1348 | 1348 | $data = array(); |
1349 | 1349 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1350 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1350 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1351 | 1351 | $data['ident'] = $line[6]; |
1352 | 1352 | $data['aircraft_name'] = $line[7]; |
1353 | 1353 | $data['longitude'] = $line[1]; |
@@ -1364,16 +1364,16 @@ discard block |
||
1364 | 1364 | } elseif ($format == 'acars') { |
1365 | 1365 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1366 | 1366 | $ACARS->add(trim($buffer)); |
1367 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1367 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1368 | 1368 | $ACARS->deleteLiveAcarsData(); |
1369 | 1369 | } elseif ($format == 'flightgearmp') { |
1370 | - if (substr($buffer,0,1) != '#') { |
|
1370 | + if (substr($buffer, 0, 1) != '#') { |
|
1371 | 1371 | $data = array(); |
1372 | 1372 | //echo $buffer."\n"; |
1373 | - $line = explode(' ',$buffer); |
|
1373 | + $line = explode(' ', $buffer); |
|
1374 | 1374 | if (count($line) == 11) { |
1375 | - $userserver = explode('@',$line[0]); |
|
1376 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1375 | + $userserver = explode('@', $line[0]); |
|
1376 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1377 | 1377 | $data['ident'] = $userserver[0]; |
1378 | 1378 | $data['registration'] = $userserver[0]; |
1379 | 1379 | $data['latitude'] = $line[4]; |
@@ -1381,8 +1381,8 @@ discard block |
||
1381 | 1381 | $data['altitude'] = $line[6]; |
1382 | 1382 | $data['datetime'] = date('Y-m-d H:i:s'); |
1383 | 1383 | $aircraft_type = $line[10]; |
1384 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1385 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1384 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1385 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1386 | 1386 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1387 | 1387 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1388 | 1388 | } |
@@ -1391,8 +1391,8 @@ discard block |
||
1391 | 1391 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1392 | 1392 | die; |
1393 | 1393 | } elseif ($format == 'vrstcp') { |
1394 | - foreach($buffer as $all_data) { |
|
1395 | - $line = json_decode('{'.$all_data.'}',true); |
|
1394 | + foreach ($buffer as $all_data) { |
|
1395 | + $line = json_decode('{'.$all_data.'}', true); |
|
1396 | 1396 | $data = array(); |
1397 | 1397 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1398 | 1398 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1418,16 +1418,16 @@ discard block |
||
1418 | 1418 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1419 | 1419 | unset($data); |
1420 | 1420 | } |
1421 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1421 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1422 | 1422 | $line = explode("\t", $buffer); |
1423 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1423 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1424 | 1424 | $key = $line[$k]; |
1425 | - $lined[$key] = $line[$k+1]; |
|
1425 | + $lined[$key] = $line[$k + 1]; |
|
1426 | 1426 | } |
1427 | 1427 | if (count($lined) > 3) { |
1428 | 1428 | $data['hex'] = $lined['hexid']; |
1429 | 1429 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1430 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1430 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1431 | 1431 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1432 | 1432 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1433 | 1433 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1446,22 +1446,22 @@ discard block |
||
1446 | 1446 | } else $error = true; |
1447 | 1447 | } elseif ($format == 'aprs' && $use_aprs) { |
1448 | 1448 | if ($aprs_connect == 0) { |
1449 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1449 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1450 | 1450 | $aprs_connect = 1; |
1451 | 1451 | } |
1452 | 1452 | |
1453 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1453 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1454 | 1454 | $aprs_last_tx = time(); |
1455 | 1455 | $data_aprs = "# Keep alive"; |
1456 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1456 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1457 | 1457 | } |
1458 | 1458 | |
1459 | 1459 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1460 | 1460 | //echo 'APRS data : '.$buffer."\n"; |
1461 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1462 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1461 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1462 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1463 | 1463 | //echo $buffer."\n"; |
1464 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1464 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1465 | 1465 | $line = $APRS->parse($buffer); |
1466 | 1466 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1467 | 1467 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1476,7 +1476,7 @@ discard block |
||
1476 | 1476 | if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
1477 | 1477 | if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
1478 | 1478 | if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
1479 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1479 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1480 | 1480 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1481 | 1481 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1482 | 1482 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1555,29 +1555,29 @@ discard block |
||
1555 | 1555 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1556 | 1556 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1557 | 1557 | $Source->deleteOldLocationByType('gs'); |
1558 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
1559 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1558 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
1559 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1560 | 1560 | } else { |
1561 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1561 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1562 | 1562 | } |
1563 | 1563 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1564 | 1564 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1565 | 1565 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1566 | 1566 | $Source->deleteOldLocationByType('wx'); |
1567 | 1567 | $weather_data = json_encode($line); |
1568 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
1569 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1568 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
1569 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1570 | 1570 | } else { |
1571 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1571 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1572 | 1572 | } |
1573 | 1573 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') { |
1574 | 1574 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1575 | 1575 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1576 | 1576 | $Source->deleteOldLocationByType('lightning'); |
1577 | - if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
1578 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1577 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
1578 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1579 | 1579 | } else { |
1580 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1580 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1581 | 1581 | } |
1582 | 1582 | } elseif ($globalDebug) { |
1583 | 1583 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -1586,7 +1586,7 @@ discard block |
||
1586 | 1586 | unset($data); |
1587 | 1587 | } |
1588 | 1588 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1589 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
1589 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
1590 | 1590 | } |
1591 | 1591 | /* |
1592 | 1592 | 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')) { |
@@ -1595,7 +1595,7 @@ discard block |
||
1595 | 1595 | */ |
1596 | 1596 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1597 | 1597 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1598 | - if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1598 | + if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1599 | 1599 | $Source->deleteOldLocationByType('lightning'); |
1600 | 1600 | $Source->deleteOldLocationByType('wx'); |
1601 | 1601 | $globalSources[$nb]['last_weather_clean'] = time(); |
@@ -1680,7 +1680,7 @@ discard block |
||
1680 | 1680 | connect_all($sourceee); |
1681 | 1681 | $sourceee = array(); |
1682 | 1682 | //connect_all($globalSources); |
1683 | - $tt[$format]=0; |
|
1683 | + $tt[$format] = 0; |
|
1684 | 1684 | break; |
1685 | 1685 | } |
1686 | 1686 | } |
@@ -1689,14 +1689,14 @@ discard block |
||
1689 | 1689 | } else { |
1690 | 1690 | $error = socket_strerror(socket_last_error()); |
1691 | 1691 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1692 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1692 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1693 | 1693 | if (isset($globalDebug)) echo "Restarting...\n"; |
1694 | 1694 | // Restart the script if possible |
1695 | 1695 | if (is_array($sockets)) { |
1696 | 1696 | if ($globalDebug) echo "Shutdown all sockets..."; |
1697 | 1697 | |
1698 | 1698 | foreach ($sockets as $sock) { |
1699 | - @socket_shutdown($sock,2); |
|
1699 | + @socket_shutdown($sock, 2); |
|
1700 | 1700 | @socket_close($sock); |
1701 | 1701 | } |
1702 | 1702 |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | } |
20 | 20 | } |
21 | 21 | /** |
22 | - * Change IATA to ICAO value for ident |
|
23 | - * |
|
24 | - * @param String $ident ident |
|
25 | - * @return String the icao |
|
26 | - */ |
|
22 | + * Change IATA to ICAO value for ident |
|
23 | + * |
|
24 | + * @param String $ident ident |
|
25 | + * @return String the icao |
|
26 | + */ |
|
27 | 27 | public function ident2icao($ident) { |
28 | 28 | if (substr($ident,0,2) == 'AF') { |
29 | 29 | if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | - * Deletes all info in the live table |
|
43 | - * |
|
44 | - * @return String success or false |
|
45 | - * |
|
46 | - */ |
|
42 | + * Deletes all info in the live table |
|
43 | + * |
|
44 | + * @return String success or false |
|
45 | + * |
|
46 | + */ |
|
47 | 47 | public function deleteLiveAcarsData() |
48 | 48 | { |
49 | 49 | global $globalDBdriver; |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | - * Deletes all info in the archive table |
|
67 | - * |
|
68 | - * @return String success or false |
|
69 | - * |
|
70 | - */ |
|
66 | + * Deletes all info in the archive table |
|
67 | + * |
|
68 | + * @return String success or false |
|
69 | + * |
|
70 | + */ |
|
71 | 71 | public function deleteArchiveAcarsData() |
72 | 72 | { |
73 | 73 | global $globalACARSArchiveKeepMonths, $globalDBdriver; |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | |
89 | 89 | |
90 | 90 | /** |
91 | - * Parse ACARS data |
|
92 | - * |
|
93 | - * @param String ACARS data in acarsdec data |
|
94 | - * |
|
95 | - */ |
|
91 | + * Parse ACARS data |
|
92 | + * |
|
93 | + * @param String ACARS data in acarsdec data |
|
94 | + * |
|
95 | + */ |
|
96 | 96 | public function parse($data) { |
97 | 97 | global $globalDebug, $globalACARSArchive; |
98 | 98 | //$Image = new Image($this->db); |
@@ -722,11 +722,11 @@ discard block |
||
722 | 722 | } |
723 | 723 | |
724 | 724 | /** |
725 | - * Add ACARS data |
|
726 | - * |
|
727 | - * @param String ACARS data in acarsdec data |
|
728 | - * |
|
729 | - */ |
|
725 | + * Add ACARS data |
|
726 | + * |
|
727 | + * @param String ACARS data in acarsdec data |
|
728 | + * |
|
729 | + */ |
|
730 | 730 | function add($data) { |
731 | 731 | global $globalDebug, $globalACARSArchive; |
732 | 732 | $Image = new Image($this->db); |
@@ -773,15 +773,15 @@ discard block |
||
773 | 773 | } |
774 | 774 | |
775 | 775 | /** |
776 | - * Add Live ACARS data in DB |
|
777 | - * |
|
778 | - * @param String $ident ident |
|
779 | - * @param String $registration Registration of the aircraft |
|
780 | - * @param String $label Label of the ACARS message |
|
781 | - * @param String $block_id Block id of the ACARS message |
|
782 | - * @param String $msg_no Number of the ACARS message |
|
783 | - * @param String $message ACARS message |
|
784 | - */ |
|
776 | + * Add Live ACARS data in DB |
|
777 | + * |
|
778 | + * @param String $ident ident |
|
779 | + * @param String $registration Registration of the aircraft |
|
780 | + * @param String $label Label of the ACARS message |
|
781 | + * @param String $block_id Block id of the ACARS message |
|
782 | + * @param String $msg_no Number of the ACARS message |
|
783 | + * @param String $message ACARS message |
|
784 | + */ |
|
785 | 785 | public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
786 | 786 | global $globalDebug; |
787 | 787 | date_default_timezone_set('UTC'); |
@@ -817,15 +817,15 @@ discard block |
||
817 | 817 | } |
818 | 818 | |
819 | 819 | /** |
820 | - * Add Archive ACARS data in DB |
|
821 | - * |
|
822 | - * @param String $ident ident |
|
823 | - * @param String $registration Registration of the aircraft |
|
824 | - * @param String $label Label of the ACARS message |
|
825 | - * @param String $block_id Block id of the ACARS message |
|
826 | - * @param String $msg_no Number of the ACARS message |
|
827 | - * @param String $message ACARS message |
|
828 | - */ |
|
820 | + * Add Archive ACARS data in DB |
|
821 | + * |
|
822 | + * @param String $ident ident |
|
823 | + * @param String $registration Registration of the aircraft |
|
824 | + * @param String $label Label of the ACARS message |
|
825 | + * @param String $block_id Block id of the ACARS message |
|
826 | + * @param String $msg_no Number of the ACARS message |
|
827 | + * @param String $message ACARS message |
|
828 | + */ |
|
829 | 829 | public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
830 | 830 | global $globalDebug; |
831 | 831 | date_default_timezone_set('UTC'); |
@@ -856,11 +856,11 @@ discard block |
||
856 | 856 | } |
857 | 857 | |
858 | 858 | /** |
859 | - * Get Message title from label from DB |
|
860 | - * |
|
861 | - * @param String $label |
|
862 | - * @return String Return ACARS title |
|
863 | - */ |
|
859 | + * Get Message title from label from DB |
|
860 | + * |
|
861 | + * @param String $label |
|
862 | + * @return String Return ACARS title |
|
863 | + */ |
|
864 | 864 | public function getTitlefromLabel($label) { |
865 | 865 | $Connection = new Connection($this->db); |
866 | 866 | $this->db = $Connection->db; |
@@ -879,10 +879,10 @@ discard block |
||
879 | 879 | } |
880 | 880 | |
881 | 881 | /** |
882 | - * List all Message title & label from DB |
|
883 | - * |
|
884 | - * @return Array Return ACARS data in array |
|
885 | - */ |
|
882 | + * List all Message title & label from DB |
|
883 | + * |
|
884 | + * @return Array Return ACARS data in array |
|
885 | + */ |
|
886 | 886 | public function getAllTitleLabel() { |
887 | 887 | $query = "SELECT * FROM acars_label ORDER BY title"; |
888 | 888 | $query_values = array(); |
@@ -899,11 +899,11 @@ discard block |
||
899 | 899 | } |
900 | 900 | |
901 | 901 | /** |
902 | - * Get Live ACARS data from DB |
|
903 | - * |
|
904 | - * @param String $ident |
|
905 | - * @return Array Return ACARS data in array |
|
906 | - */ |
|
902 | + * Get Live ACARS data from DB |
|
903 | + * |
|
904 | + * @param String $ident |
|
905 | + * @return Array Return ACARS data in array |
|
906 | + */ |
|
907 | 907 | public function getLiveAcarsData($ident) { |
908 | 908 | $query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC"; |
909 | 909 | $query_values = array(':ident' => $ident); |
@@ -920,10 +920,10 @@ discard block |
||
920 | 920 | } |
921 | 921 | |
922 | 922 | /** |
923 | - * Get Latest ACARS data from DB |
|
924 | - * |
|
925 | - * @return Array Return ACARS data in array |
|
926 | - */ |
|
923 | + * Get Latest ACARS data from DB |
|
924 | + * |
|
925 | + * @return Array Return ACARS data in array |
|
926 | + */ |
|
927 | 927 | public function getLatestAcarsData($limit = '',$label = '') { |
928 | 928 | global $globalURL, $globalDBdriver; |
929 | 929 | $Image = new Image($this->db); |
@@ -1011,10 +1011,10 @@ discard block |
||
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | /** |
1014 | - * Get Archive ACARS data from DB |
|
1015 | - * |
|
1016 | - * @return Array Return ACARS data in array |
|
1017 | - */ |
|
1014 | + * Get Archive ACARS data from DB |
|
1015 | + * |
|
1016 | + * @return Array Return ACARS data in array |
|
1017 | + */ |
|
1018 | 1018 | public function getArchiveAcarsData($limit = '',$label = '') { |
1019 | 1019 | global $globalURL, $globalDBdriver; |
1020 | 1020 | $Image = new Image($this->db); |
@@ -1102,13 +1102,13 @@ discard block |
||
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | /** |
1105 | - * Add ModeS data to DB |
|
1106 | - * |
|
1107 | - * @param String $ident ident |
|
1108 | - * @param String $registration Registration of the aircraft |
|
1109 | - * @param String $icao |
|
1110 | - * @param String $ICAOTypeCode |
|
1111 | - */ |
|
1105 | + * Add ModeS data to DB |
|
1106 | + * |
|
1107 | + * @param String $ident ident |
|
1108 | + * @param String $registration Registration of the aircraft |
|
1109 | + * @param String $icao |
|
1110 | + * @param String $ICAOTypeCode |
|
1111 | + */ |
|
1112 | 1112 | public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
1113 | 1113 | global $globalDebug, $globalDBdriver; |
1114 | 1114 | $ident = trim($ident); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | public $db; |
11 | 11 | public $SI; |
12 | 12 | private $fromACARSscript = false; |
13 | - public function __construct($dbc = null,$fromACARSscript = false) { |
|
13 | + public function __construct($dbc = null, $fromACARSscript = false) { |
|
14 | 14 | $Connection = new Connection($dbc); |
15 | 15 | $this->db = $Connection->db(); |
16 | 16 | if ($fromACARSscript) { |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @return String the icao |
26 | 26 | */ |
27 | 27 | public function ident2icao($ident) { |
28 | - if (substr($ident,0,2) == 'AF') { |
|
29 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
30 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
28 | + if (substr($ident, 0, 2) == 'AF') { |
|
29 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
30 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
31 | 31 | } else { |
32 | 32 | $Spotter = new Spotter($this->db); |
33 | - $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
|
33 | + $identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2)); |
|
34 | 34 | if (isset($identicao[0])) { |
35 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
35 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
36 | 36 | } else $icao = $ident; |
37 | 37 | } |
38 | 38 | return $icao; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $sth = $this->db->prepare($query); |
58 | 58 | $sth->execute(); |
59 | - } catch(PDOException $e) { |
|
59 | + } catch (PDOException $e) { |
|
60 | 60 | return "error"; |
61 | 61 | } |
62 | 62 | return "success"; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | $sth = $this->db->prepare($query); |
82 | 82 | $sth->execute(); |
83 | - } catch(PDOException $e) { |
|
83 | + } catch (PDOException $e) { |
|
84 | 84 | return "error"; |
85 | 85 | } |
86 | 86 | return "success"; |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | $ident = ''; |
106 | 106 | $message = ''; |
107 | 107 | $result = array(); |
108 | - $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); |
|
109 | - 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); |
|
110 | - 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); |
|
111 | - 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); |
|
108 | + $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); |
|
109 | + 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); |
|
110 | + 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); |
|
111 | + 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); |
|
112 | 112 | if ($n != 0) { |
113 | - $registration = str_replace('.','',$registration); |
|
114 | - $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
|
113 | + $registration = str_replace('.', '', $registration); |
|
114 | + $result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message); |
|
115 | 115 | if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
116 | 116 | } else $message = $data; |
117 | 117 | $decode = array(); |
@@ -131,14 +131,14 @@ discard block |
||
131 | 131 | $temp = ''; |
132 | 132 | $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); |
133 | 133 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
134 | - $latitude = $la / 10000.0; |
|
135 | - $longitude = $ln / 10000.0; |
|
134 | + $latitude = $la/10000.0; |
|
135 | + $longitude = $ln/10000.0; |
|
136 | 136 | if ($lac == 'S') $latitude = '-'.$latitude; |
137 | 137 | if ($lnc == 'W') $longitude = '-'.$longitude; |
138 | 138 | // Temp not always available |
139 | 139 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
140 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
141 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
140 | + if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt); |
|
141 | + else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C'); |
|
142 | 142 | |
143 | 143 | //$icao = $Translation->checkTranslation($ident); |
144 | 144 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -150,19 +150,19 @@ discard block |
||
150 | 150 | $dhour = ''; |
151 | 151 | $darr = ''; |
152 | 152 | $ahour = ''; |
153 | - $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
|
153 | + $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour); |
|
154 | 154 | if ($n == 4 && strlen($darr) == 4) { |
155 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
156 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
157 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
155 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
156 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
157 | + if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n"; |
|
158 | 158 | //$icao = ACARS->ident2icao($ident); |
159 | 159 | //$icao = $Translation->checkTranslation($ident); |
160 | 160 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
161 | 161 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
162 | 162 | $found = true; |
163 | 163 | } |
164 | - elseif ($n == 2 || $n == 4) { |
|
165 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
164 | + elseif ($n == 2 || $n == 4) { |
|
165 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
166 | 166 | if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
167 | 167 | //$icao = ACARS->ident2icao($ident); |
168 | 168 | //$icao = $Translation->checkTranslation($ident); |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | $ahour = ''; |
221 | 221 | $aair = ''; |
222 | 222 | $apiste = ''; |
223 | - $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); |
|
223 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste); |
|
224 | 224 | if ($n > 8) { |
225 | - 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"; |
|
226 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
227 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
225 | + 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"; |
|
226 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
227 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
228 | 228 | $icao = trim($aident); |
229 | 229 | |
230 | 230 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
250 | 250 | $las = $las.'.'.$lass; |
251 | 251 | $lns = $lns.'.'.$lns; |
252 | - $latitude = $las / 1000.0; |
|
253 | - $longitude = $lns / 1000.0; |
|
252 | + $latitude = $las/1000.0; |
|
253 | + $longitude = $lns/1000.0; |
|
254 | 254 | if ($lac == 'S') $latitude = '-'.$latitude; |
255 | 255 | if ($lnc == 'W') $longitude = '-'.$longitude; |
256 | 256 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
@@ -345,17 +345,17 @@ discard block |
||
345 | 345 | $alt = ''; |
346 | 346 | $fuel = ''; |
347 | 347 | $speed = ''; |
348 | - $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); |
|
348 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
349 | 349 | if ($n == 9) { |
350 | 350 | //if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
351 | 351 | $icao = trim($aident); |
352 | 352 | $decode['icao'] = $icao; |
353 | - $latitude = $las / 100.0; |
|
354 | - $longitude = $lns / 100.0; |
|
353 | + $latitude = $las/100.0; |
|
354 | + $longitude = $lns/100.0; |
|
355 | 355 | if ($lac == 'S') $latitude = '-'.$latitude; |
356 | 356 | if ($lnc == 'W') $longitude = '-'.$longitude; |
357 | 357 | |
358 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
|
358 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed); |
|
359 | 359 | $found = true; |
360 | 360 | } |
361 | 361 | } |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | if ($lac == 'S') $latitude = '-'.$latitude; |
375 | 375 | if ($lnc == 'W') $longitude = '-'.$longitude; |
376 | 376 | |
377 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
|
377 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
|
378 | 378 | $found = true; |
379 | 379 | } |
380 | 380 | } |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | $dair = ''; |
408 | 408 | $darr = ''; |
409 | 409 | $aident = ''; |
410 | - $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); |
|
410 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
411 | 411 | if ($n == 8) { |
412 | 412 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
413 | 413 | $icao = trim($aident); |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | */ |
440 | 440 | $dair = ''; |
441 | 441 | $darr = ''; |
442 | - $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
|
442 | + $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr); |
|
443 | 443 | if ($n == 3) { |
444 | 444 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
445 | 445 | //$icao = $Translation->checkTranslation($ident); |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | */ |
455 | 455 | $dair = ''; |
456 | 456 | $darr = ''; |
457 | - $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
|
457 | + $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr); |
|
458 | 458 | if ($n == 3) { |
459 | 459 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
460 | 460 | //$icao = $Translation->checkTranslation($ident); |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | } |
465 | 465 | } |
466 | 466 | if (!$found) { |
467 | - $n = sscanf($message,'MET01%4c',$airport); |
|
467 | + $n = sscanf($message, 'MET01%4c', $airport); |
|
468 | 468 | if ($n == 1) { |
469 | 469 | if ($globalDebug) echo 'airport name : '.$airport; |
470 | 470 | $decode = array('Airport/Waypoint name' => $airport); |
@@ -472,241 +472,241 @@ discard block |
||
472 | 472 | } |
473 | 473 | } |
474 | 474 | if ($label == 'H1') { |
475 | - if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
|
476 | - $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
|
475 | + if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) { |
|
476 | + $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode); |
|
477 | 477 | } |
478 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
479 | - $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
|
478 | + elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) { |
|
479 | + $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode); |
|
480 | 480 | } |
481 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
482 | - $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
|
481 | + elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) { |
|
482 | + $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode); |
|
483 | 483 | } |
484 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
485 | - $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
|
484 | + elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) { |
|
485 | + $decode = array_merge(array('Message nature' => 'Weather observation'), $decode); |
|
486 | 486 | } |
487 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
488 | - $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
|
487 | + elseif (preg_match(':^#DFB/PIREP:', $message)) { |
|
488 | + $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode); |
|
489 | 489 | } |
490 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
491 | - $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
|
490 | + elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) { |
|
491 | + $decode = array_merge(array('Message nature' => 'Engine Data'), $decode); |
|
492 | 492 | } |
493 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
494 | - $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
|
493 | + elseif (preg_match(':^#M1AAEP:', $message)) { |
|
494 | + $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode); |
|
495 | 495 | } |
496 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
497 | - $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
|
496 | + elseif (preg_match(':^#M2APWD:', $message)) { |
|
497 | + $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode); |
|
498 | 498 | } |
499 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
500 | - $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
|
499 | + elseif (preg_match(':^#M1BREQPWI:', $message)) { |
|
500 | + $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode); |
|
501 | 501 | } |
502 | - elseif (preg_match(':^#CF:',$message)) { |
|
503 | - $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
|
502 | + elseif (preg_match(':^#CF:', $message)) { |
|
503 | + $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode); |
|
504 | 504 | } |
505 | - elseif (preg_match(':^#DF:',$message)) { |
|
506 | - $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
|
505 | + elseif (preg_match(':^#DF:', $message)) { |
|
506 | + $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode); |
|
507 | 507 | } |
508 | - elseif (preg_match(':^#EC:',$message)) { |
|
509 | - $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
|
508 | + elseif (preg_match(':^#EC:', $message)) { |
|
509 | + $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode); |
|
510 | 510 | } |
511 | - elseif (preg_match(':^#EI:',$message)) { |
|
512 | - $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
|
511 | + elseif (preg_match(':^#EI:', $message)) { |
|
512 | + $decode = array_merge(array('Message nature' => 'Engine Report'), $decode); |
|
513 | 513 | } |
514 | - elseif (preg_match(':^#H1:',$message)) { |
|
515 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
|
514 | + elseif (preg_match(':^#H1:', $message)) { |
|
515 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode); |
|
516 | 516 | } |
517 | - elseif (preg_match(':^#H2:',$message)) { |
|
518 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
|
517 | + elseif (preg_match(':^#H2:', $message)) { |
|
518 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode); |
|
519 | 519 | } |
520 | - elseif (preg_match(':^#HD:',$message)) { |
|
521 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
|
520 | + elseif (preg_match(':^#HD:', $message)) { |
|
521 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode); |
|
522 | 522 | } |
523 | - elseif (preg_match(':^#M1:',$message)) { |
|
524 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
|
523 | + elseif (preg_match(':^#M1:', $message)) { |
|
524 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode); |
|
525 | 525 | } |
526 | - elseif (preg_match(':^#M2:',$message)) { |
|
527 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
|
526 | + elseif (preg_match(':^#M2:', $message)) { |
|
527 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode); |
|
528 | 528 | } |
529 | - elseif (preg_match(':^#M3:',$message)) { |
|
530 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
|
529 | + elseif (preg_match(':^#M3:', $message)) { |
|
530 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode); |
|
531 | 531 | } |
532 | - elseif (preg_match(':^#MD:',$message)) { |
|
533 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
|
532 | + elseif (preg_match(':^#MD:', $message)) { |
|
533 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode); |
|
534 | 534 | } |
535 | - elseif (preg_match(':^#PS:',$message)) { |
|
536 | - $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
|
535 | + elseif (preg_match(':^#PS:', $message)) { |
|
536 | + $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode); |
|
537 | 537 | } |
538 | - elseif (preg_match(':^#S1:',$message)) { |
|
539 | - $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
|
538 | + elseif (preg_match(':^#S1:', $message)) { |
|
539 | + $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode); |
|
540 | 540 | } |
541 | - elseif (preg_match(':^#S2:',$message)) { |
|
542 | - $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
|
541 | + elseif (preg_match(':^#S2:', $message)) { |
|
542 | + $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode); |
|
543 | 543 | } |
544 | - elseif (preg_match(':^#SD:',$message)) { |
|
545 | - $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
|
544 | + elseif (preg_match(':^#SD:', $message)) { |
|
545 | + $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode); |
|
546 | 546 | } |
547 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
548 | - $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
|
547 | + elseif (preg_match(':^#T[0-8]:', $message)) { |
|
548 | + $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode); |
|
549 | 549 | } |
550 | - elseif (preg_match(':^#WO:',$message)) { |
|
551 | - $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
|
550 | + elseif (preg_match(':^#WO:', $message)) { |
|
551 | + $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode); |
|
552 | 552 | } |
553 | - elseif (preg_match(':^#A1:',$message)) { |
|
554 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
|
553 | + elseif (preg_match(':^#A1:', $message)) { |
|
554 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode); |
|
555 | 555 | } |
556 | - elseif (preg_match(':^#A3:',$message)) { |
|
557 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
|
556 | + elseif (preg_match(':^#A3:', $message)) { |
|
557 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode); |
|
558 | 558 | } |
559 | - elseif (preg_match(':^#A4:',$message)) { |
|
560 | - $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
|
559 | + elseif (preg_match(':^#A4:', $message)) { |
|
560 | + $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode); |
|
561 | 561 | } |
562 | - elseif (preg_match(':^#A6:',$message)) { |
|
563 | - $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
|
562 | + elseif (preg_match(':^#A6:', $message)) { |
|
563 | + $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode); |
|
564 | 564 | } |
565 | - elseif (preg_match(':^#A8:',$message)) { |
|
566 | - $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
|
565 | + elseif (preg_match(':^#A8:', $message)) { |
|
566 | + $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode); |
|
567 | 567 | } |
568 | - elseif (preg_match(':^#A9:',$message)) { |
|
569 | - $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
|
568 | + elseif (preg_match(':^#A9:', $message)) { |
|
569 | + $decode = array_merge(array('Message nature' => 'ATIS report'), $decode); |
|
570 | 570 | } |
571 | - elseif (preg_match(':^#A0:',$message)) { |
|
572 | - $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
|
571 | + elseif (preg_match(':^#A0:', $message)) { |
|
572 | + $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode); |
|
573 | 573 | } |
574 | - elseif (preg_match(':^#AA:',$message)) { |
|
575 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
574 | + elseif (preg_match(':^#AA:', $message)) { |
|
575 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
576 | 576 | } |
577 | - elseif (preg_match(':^#AB:',$message)) { |
|
578 | - $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
|
577 | + elseif (preg_match(':^#AB:', $message)) { |
|
578 | + $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode); |
|
579 | 579 | } |
580 | - elseif (preg_match(':^#AC:',$message)) { |
|
581 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
|
580 | + elseif (preg_match(':^#AC:', $message)) { |
|
581 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode); |
|
582 | 582 | } |
583 | - elseif (preg_match(':^#AD:',$message)) { |
|
584 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
|
583 | + elseif (preg_match(':^#AD:', $message)) { |
|
584 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode); |
|
585 | 585 | } |
586 | - elseif (preg_match(':^#AF:',$message)) { |
|
587 | - $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
|
586 | + elseif (preg_match(':^#AF:', $message)) { |
|
587 | + $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode); |
|
588 | 588 | } |
589 | - elseif (preg_match(':^#B1:',$message)) { |
|
590 | - $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
|
589 | + elseif (preg_match(':^#B1:', $message)) { |
|
590 | + $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode); |
|
591 | 591 | } |
592 | - elseif (preg_match(':^#B2:',$message)) { |
|
593 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
|
592 | + elseif (preg_match(':^#B2:', $message)) { |
|
593 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode); |
|
594 | 594 | } |
595 | - elseif (preg_match(':^#B3:',$message)) { |
|
596 | - $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
|
595 | + elseif (preg_match(':^#B3:', $message)) { |
|
596 | + $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode); |
|
597 | 597 | } |
598 | - elseif (preg_match(':^#B4:',$message)) { |
|
599 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
|
598 | + elseif (preg_match(':^#B4:', $message)) { |
|
599 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode); |
|
600 | 600 | } |
601 | - elseif (preg_match(':^#B6:',$message)) { |
|
602 | - $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
|
601 | + elseif (preg_match(':^#B6:', $message)) { |
|
602 | + $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode); |
|
603 | 603 | } |
604 | - elseif (preg_match(':^#B8:',$message)) { |
|
605 | - $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
|
604 | + elseif (preg_match(':^#B8:', $message)) { |
|
605 | + $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode); |
|
606 | 606 | } |
607 | - elseif (preg_match(':^#B9:',$message)) { |
|
608 | - $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
|
607 | + elseif (preg_match(':^#B9:', $message)) { |
|
608 | + $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode); |
|
609 | 609 | } |
610 | - elseif (preg_match(':^#B0:',$message)) { |
|
611 | - $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
|
610 | + elseif (preg_match(':^#B0:', $message)) { |
|
611 | + $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode); |
|
612 | 612 | } |
613 | - elseif (preg_match(':^#BA:',$message)) { |
|
614 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
613 | + elseif (preg_match(':^#BA:', $message)) { |
|
614 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
615 | 615 | } |
616 | - elseif (preg_match(':^#BB:',$message)) { |
|
617 | - $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
|
616 | + elseif (preg_match(':^#BB:', $message)) { |
|
617 | + $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode); |
|
618 | 618 | } |
619 | - elseif (preg_match(':^#BC:',$message)) { |
|
620 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
|
619 | + elseif (preg_match(':^#BC:', $message)) { |
|
620 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode); |
|
621 | 621 | } |
622 | - elseif (preg_match(':^#BD:',$message)) { |
|
623 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
|
622 | + elseif (preg_match(':^#BD:', $message)) { |
|
623 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode); |
|
624 | 624 | } |
625 | - elseif (preg_match(':^#BE:',$message)) { |
|
626 | - $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
|
625 | + elseif (preg_match(':^#BE:', $message)) { |
|
626 | + $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode); |
|
627 | 627 | } |
628 | - elseif (preg_match(':^#BF:',$message)) { |
|
629 | - $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
|
628 | + elseif (preg_match(':^#BF:', $message)) { |
|
629 | + $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode); |
|
630 | 630 | } |
631 | - elseif (preg_match(':^#H3:',$message)) { |
|
632 | - $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
|
631 | + elseif (preg_match(':^#H3:', $message)) { |
|
632 | + $decode = array_merge(array('Message nature' => 'Icing Report'), $decode); |
|
633 | 633 | } |
634 | 634 | } |
635 | 635 | if ($label == '10') { |
636 | - if (preg_match(':^DTO01:',$message)) { |
|
637 | - $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
|
636 | + if (preg_match(':^DTO01:', $message)) { |
|
637 | + $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode); |
|
638 | 638 | } |
639 | - elseif (preg_match(':^AIS01:',$message)) { |
|
640 | - $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
|
639 | + elseif (preg_match(':^AIS01:', $message)) { |
|
640 | + $decode = array_merge(array('Message nature' => 'AIS Request'), $decode); |
|
641 | 641 | } |
642 | - elseif (preg_match(':^FTX01:',$message)) { |
|
643 | - $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
|
642 | + elseif (preg_match(':^FTX01:', $message)) { |
|
643 | + $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode); |
|
644 | 644 | } |
645 | - elseif (preg_match(':^FPL01:',$message)) { |
|
646 | - $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
|
645 | + elseif (preg_match(':^FPL01:', $message)) { |
|
646 | + $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode); |
|
647 | 647 | } |
648 | - elseif (preg_match(':^WAB01:',$message)) { |
|
649 | - $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
|
648 | + elseif (preg_match(':^WAB01:', $message)) { |
|
649 | + $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode); |
|
650 | 650 | } |
651 | - elseif (preg_match(':^MET01:',$message)) { |
|
652 | - $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
|
651 | + elseif (preg_match(':^MET01:', $message)) { |
|
652 | + $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode); |
|
653 | 653 | } |
654 | - elseif (preg_match(':^WAB02:',$message)) { |
|
655 | - $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
|
654 | + elseif (preg_match(':^WAB02:', $message)) { |
|
655 | + $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode); |
|
656 | 656 | } |
657 | 657 | } |
658 | 658 | if ($label == '15') { |
659 | - if (preg_match(':^FST01:',$message)) { |
|
660 | - $decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode); |
|
659 | + if (preg_match(':^FST01:', $message)) { |
|
660 | + $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode); |
|
661 | 661 | } |
662 | 662 | } |
663 | 663 | if (!$found && $label == 'SA') { |
664 | - $n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at); |
|
664 | + $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at); |
|
665 | 665 | if ($n == 4) { |
666 | 666 | $vsta = array('Version' => $version); |
667 | 667 | if ($state == 'E') { |
668 | - $vsta = array_merge($vsta,array('Link state' => 'Established')); |
|
668 | + $vsta = array_merge($vsta, array('Link state' => 'Established')); |
|
669 | 669 | } |
670 | 670 | elseif ($state == 'L') { |
671 | - $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
|
671 | + $vsta = array_merge($vsta, array('Link state' => 'Lost')); |
|
672 | 672 | } |
673 | 673 | else { |
674 | - $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
|
674 | + $vsta = array_merge($vsta, array('Link state' => 'Unknown')); |
|
675 | 675 | } |
676 | 676 | if ($type == 'V') { |
677 | - $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
|
677 | + $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS')); |
|
678 | 678 | } |
679 | 679 | elseif ($type == 'S') { |
680 | - $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
|
680 | + $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM')); |
|
681 | 681 | } |
682 | 682 | elseif ($type == 'H') { |
683 | - $vsta = array_merge($vsta,array('Link type' => 'HF')); |
|
683 | + $vsta = array_merge($vsta, array('Link type' => 'HF')); |
|
684 | 684 | } |
685 | 685 | elseif ($type == 'G') { |
686 | - $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
|
686 | + $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM')); |
|
687 | 687 | } |
688 | 688 | elseif ($type == 'C') { |
689 | - $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
|
689 | + $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM')); |
|
690 | 690 | } |
691 | 691 | elseif ($type == '2') { |
692 | - $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
|
692 | + $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2')); |
|
693 | 693 | } |
694 | 694 | elseif ($type == 'X') { |
695 | - $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
|
695 | + $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero')); |
|
696 | 696 | } |
697 | 697 | elseif ($type == 'I') { |
698 | - $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
|
698 | + $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM')); |
|
699 | 699 | } |
700 | 700 | else { |
701 | - $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
|
701 | + $vsta = array_merge($vsta, array('Link type' => 'Unknown')); |
|
702 | 702 | } |
703 | - $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
|
704 | - $decode = array_merge($vsta,$decode); |
|
703 | + $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2)))); |
|
704 | + $decode = array_merge($vsta, $decode); |
|
705 | 705 | } |
706 | 706 | } |
707 | 707 | |
708 | 708 | $title = $this->getTitlefromLabel($label); |
709 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
709 | + if ($title != '') $decode = array_merge(array('Message title' => $title), $decode); |
|
710 | 710 | /* |
711 | 711 | // Business jets always use GS0001 |
712 | 712 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -734,13 +734,13 @@ discard block |
||
734 | 734 | $Translation = new Translation($this->db); |
735 | 735 | $message = $this->parse($data); |
736 | 736 | if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') { |
737 | - $ident = (string)$message['ident']; |
|
737 | + $ident = (string) $message['ident']; |
|
738 | 738 | $label = $message['label']; |
739 | 739 | $block_id = $message['block_id']; |
740 | 740 | $msg_no = $message['msg_no']; |
741 | 741 | $msg = $message['message']; |
742 | 742 | $decode = $message['decode']; |
743 | - $registration = (string)$message['registration']; |
|
743 | + $registration = (string) $message['registration']; |
|
744 | 744 | if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
745 | 745 | else $latitude = ''; |
746 | 746 | if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
@@ -754,20 +754,20 @@ discard block |
||
754 | 754 | $Image->addSpotterImage($registration); |
755 | 755 | } |
756 | 756 | // Business jets always use GS0001 |
757 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
757 | + if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude); |
|
758 | 758 | if ($globalDebug && isset($info) && $info != '') echo $info; |
759 | 759 | if (count($decode) > 0) $decode_json = json_encode($decode); |
760 | 760 | else $decode_json = ''; |
761 | 761 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
762 | - $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
|
762 | + $Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS'); |
|
763 | 763 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
764 | - $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
|
764 | + $Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS'); |
|
765 | 765 | } |
766 | - $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
767 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
768 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
766 | + $result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
767 | + if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F'); |
|
768 | + if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
769 | 769 | if ($globalDebug && count($decode) > 0) { |
770 | - echo "Human readable data : ".implode(' - ',$decode)."\n"; |
|
770 | + echo "Human readable data : ".implode(' - ', $decode)."\n"; |
|
771 | 771 | } |
772 | 772 | } |
773 | 773 | } |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | * @param String $msg_no Number of the ACARS message |
783 | 783 | * @param String $message ACARS message |
784 | 784 | */ |
785 | - public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
785 | + public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
786 | 786 | global $globalDebug; |
787 | 787 | date_default_timezone_set('UTC'); |
788 | 788 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
@@ -790,21 +790,21 @@ discard block |
||
790 | 790 | $this->db = $Connection->db; |
791 | 791 | if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
792 | 792 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
793 | - $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
|
793 | + $query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message); |
|
794 | 794 | try { |
795 | 795 | $stht = $this->db->prepare($query_test); |
796 | 796 | $stht->execute($query_test_values); |
797 | - } catch(PDOException $e) { |
|
797 | + } catch (PDOException $e) { |
|
798 | 798 | return "error : ".$e->getMessage(); |
799 | 799 | } |
800 | 800 | if ($stht->fetchColumn() == 0) { |
801 | 801 | if ($globalDebug) echo "Add Live ACARS data..."; |
802 | 802 | $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)"; |
803 | - $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")); |
|
803 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s")); |
|
804 | 804 | try { |
805 | 805 | $sth = $this->db->prepare($query); |
806 | 806 | $sth->execute($query_values); |
807 | - } catch(PDOException $e) { |
|
807 | + } catch (PDOException $e) { |
|
808 | 808 | return "error : ".$e->getMessage(); |
809 | 809 | } |
810 | 810 | } else { |
@@ -826,10 +826,10 @@ discard block |
||
826 | 826 | * @param String $msg_no Number of the ACARS message |
827 | 827 | * @param String $message ACARS message |
828 | 828 | */ |
829 | - public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
829 | + public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
830 | 830 | global $globalDebug; |
831 | 831 | date_default_timezone_set('UTC'); |
832 | - 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) { |
|
832 | + if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) { |
|
833 | 833 | /* |
834 | 834 | if ($globalDebug) echo "Test if not already in Archive ACARS table..."; |
835 | 835 | $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message"; |
@@ -844,11 +844,11 @@ discard block |
||
844 | 844 | */ |
845 | 845 | if ($globalDebug) echo "Add Live ACARS data..."; |
846 | 846 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
847 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
847 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
848 | 848 | try { |
849 | 849 | $sth = $this->db->prepare($query); |
850 | 850 | $sth->execute($query_values); |
851 | - } catch(PDOException $e) { |
|
851 | + } catch (PDOException $e) { |
|
852 | 852 | return "error : ".$e->getMessage(); |
853 | 853 | } |
854 | 854 | if ($globalDebug) echo "Done\n"; |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | try { |
870 | 870 | $sth = $this->db->prepare($query); |
871 | 871 | $sth->execute($query_values); |
872 | - } catch(PDOException $e) { |
|
872 | + } catch (PDOException $e) { |
|
873 | 873 | echo "error : ".$e->getMessage(); |
874 | 874 | return ''; |
875 | 875 | } |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | try { |
890 | 890 | $sth = $this->db->prepare($query); |
891 | 891 | $sth->execute($query_values); |
892 | - } catch(PDOException $e) { |
|
892 | + } catch (PDOException $e) { |
|
893 | 893 | echo "error : ".$e->getMessage(); |
894 | 894 | return array(); |
895 | 895 | } |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | try { |
911 | 911 | $sth = $this->db->prepare($query); |
912 | 912 | $sth->execute($query_values); |
913 | - } catch(PDOException $e) { |
|
913 | + } catch (PDOException $e) { |
|
914 | 914 | echo "error : ".$e->getMessage(); |
915 | 915 | return array(); |
916 | 916 | } |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | * |
925 | 925 | * @return Array Return ACARS data in array |
926 | 926 | */ |
927 | - public function getLatestAcarsData($limit = '',$label = '') { |
|
927 | + public function getLatestAcarsData($limit = '', $label = '') { |
|
928 | 928 | global $globalURL, $globalDBdriver; |
929 | 929 | $Image = new Image($this->db); |
930 | 930 | $Spotter = new Spotter($this->db); |
@@ -935,8 +935,8 @@ discard block |
||
935 | 935 | if ($limit != "") |
936 | 936 | { |
937 | 937 | $limit_array = explode(",", $limit); |
938 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
939 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
938 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
939 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
940 | 940 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
941 | 941 | { |
942 | 942 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -952,46 +952,46 @@ discard block |
||
952 | 952 | try { |
953 | 953 | $sth = $this->db->prepare($query); |
954 | 954 | $sth->execute($query_values); |
955 | - } catch(PDOException $e) { |
|
955 | + } catch (PDOException $e) { |
|
956 | 956 | return "error : ".$e->getMessage(); |
957 | 957 | } |
958 | 958 | $i = 0; |
959 | 959 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
960 | 960 | $data = array(); |
961 | 961 | if ($row['registration'] != '') { |
962 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
962 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
963 | 963 | $image_array = $Image->getSpotterImage($row['registration']); |
964 | - 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'])); |
|
965 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
966 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
964 | + 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'])); |
|
965 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
966 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
967 | 967 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
968 | 968 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
969 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
969 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
970 | 970 | if (isset($identicao[0])) { |
971 | - if (substr($row['ident'],0,2) == 'AF') { |
|
972 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
973 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
974 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
975 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
971 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
972 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
973 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
974 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
975 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
976 | 976 | } else $icao = $row['ident']; |
977 | - $icao = $Translation->checkTranslation($icao,false); |
|
978 | - $decode = json_decode($row['decode'],true); |
|
977 | + $icao = $Translation->checkTranslation($icao, false); |
|
978 | + $decode = json_decode($row['decode'], true); |
|
979 | 979 | $found = false; |
980 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
980 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
981 | 981 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
982 | 982 | if (isset($airport_info[0]['icao'])) { |
983 | 983 | $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
984 | 984 | $found = true; |
985 | 985 | } |
986 | 986 | } |
987 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
987 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
988 | 988 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
989 | 989 | if (isset($airport_info[0]['icao'])) { |
990 | 990 | $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
991 | 991 | $found = true; |
992 | 992 | } |
993 | 993 | } |
994 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
994 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
995 | 995 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
996 | 996 | if (isset($airport_info[0]['icao'])) { |
997 | 997 | $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>'; |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | } |
1000 | 1000 | } |
1001 | 1001 | if ($found) $row['decode'] = json_encode($decode); |
1002 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1002 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1003 | 1003 | $result[] = $data; |
1004 | 1004 | $i++; |
1005 | 1005 | } |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | * |
1016 | 1016 | * @return Array Return ACARS data in array |
1017 | 1017 | */ |
1018 | - public function getArchiveAcarsData($limit = '',$label = '') { |
|
1018 | + public function getArchiveAcarsData($limit = '', $label = '') { |
|
1019 | 1019 | global $globalURL, $globalDBdriver; |
1020 | 1020 | $Image = new Image($this->db); |
1021 | 1021 | $Spotter = new Spotter($this->db); |
@@ -1025,8 +1025,8 @@ discard block |
||
1025 | 1025 | if ($limit != "") |
1026 | 1026 | { |
1027 | 1027 | $limit_array = explode(",", $limit); |
1028 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1029 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1028 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1029 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1030 | 1030 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1031 | 1031 | { |
1032 | 1032 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1047,43 +1047,43 @@ discard block |
||
1047 | 1047 | try { |
1048 | 1048 | $sth = $this->db->prepare($query); |
1049 | 1049 | $sth->execute($query_values); |
1050 | - } catch(PDOException $e) { |
|
1050 | + } catch (PDOException $e) { |
|
1051 | 1051 | return "error : ".$e->getMessage(); |
1052 | 1052 | } |
1053 | - $i=0; |
|
1053 | + $i = 0; |
|
1054 | 1054 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
1055 | 1055 | $data = array(); |
1056 | 1056 | if ($row['registration'] != '') { |
1057 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
1057 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
1058 | 1058 | $image_array = $Image->getSpotterImage($row['registration']); |
1059 | - 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'])); |
|
1060 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1061 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1059 | + 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'])); |
|
1060 | + else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1061 | + } else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1062 | 1062 | $icao = ''; |
1063 | 1063 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
1064 | 1064 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
1065 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
1065 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
1066 | 1066 | if (isset($identicao[0])) { |
1067 | - if (substr($row['ident'],0,2) == 'AF') { |
|
1068 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1069 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1070 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1071 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
1067 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
1068 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1069 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
1070 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
1071 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
1072 | 1072 | } else $icao = $row['ident']; |
1073 | 1073 | $icao = $Translation->checkTranslation($icao); |
1074 | - $decode = json_decode($row['decode'],true); |
|
1074 | + $decode = json_decode($row['decode'], true); |
|
1075 | 1075 | $found = false; |
1076 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
1076 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
1077 | 1077 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1078 | 1078 | 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>'; |
1079 | 1079 | $found = true; |
1080 | 1080 | } |
1081 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1081 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1082 | 1082 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1083 | 1083 | 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>'; |
1084 | 1084 | $found = true; |
1085 | 1085 | } |
1086 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1086 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1087 | 1087 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1088 | 1088 | if (isset($airport_info[0]['icao'])) { |
1089 | 1089 | $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>'; |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | } |
1092 | 1092 | } |
1093 | 1093 | if ($found) $row['decode'] = json_encode($decode); |
1094 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1094 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1095 | 1095 | $result[] = $data; |
1096 | 1096 | $i++; |
1097 | 1097 | } |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | * @param String $icao |
1110 | 1110 | * @param String $ICAOTypeCode |
1111 | 1111 | */ |
1112 | - public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
|
1112 | + public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') { |
|
1113 | 1113 | global $globalDebug, $globalDBdriver; |
1114 | 1114 | $ident = trim($ident); |
1115 | 1115 | $Translation = new Translation($this->db); |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | if ($globalDebug) echo "Ident or registration null, exit\n"; |
1123 | 1123 | return ''; |
1124 | 1124 | } |
1125 | - $registration = str_replace('.','',$registration); |
|
1125 | + $registration = str_replace('.', '', $registration); |
|
1126 | 1126 | $ident = $Translation->ident2icao($ident); |
1127 | 1127 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1128 | 1128 | if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | try { |
1132 | 1132 | $sthsi = $this->db->prepare($querysi); |
1133 | 1133 | $sthsi->execute($querysi_values); |
1134 | - } catch(PDOException $e) { |
|
1134 | + } catch (PDOException $e) { |
|
1135 | 1135 | if ($globalDebug) echo $e->getMessage(); |
1136 | 1136 | return "error : ".$e->getMessage(); |
1137 | 1137 | } |
@@ -1141,8 +1141,8 @@ discard block |
||
1141 | 1141 | $Translation = new Translation($this->db); |
1142 | 1142 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1143 | 1143 | if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
1144 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1145 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1144 | + if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1145 | + elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1146 | 1146 | } else { |
1147 | 1147 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1148 | 1148 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | try { |
1151 | 1151 | $sth = $this->db->prepare($query); |
1152 | 1152 | $sth->execute($query_values); |
1153 | - } catch(PDOException $e) { |
|
1153 | + } catch (PDOException $e) { |
|
1154 | 1154 | if ($globalDebug) echo $e->getMessage(); |
1155 | 1155 | return "error : ".$e->getMessage(); |
1156 | 1156 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | $sth->closeCursor(); |
1159 | 1159 | if (isset($result['modes'])) $hex = $result['modes']; |
1160 | 1160 | else $hex = ''; |
1161 | - $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
|
1161 | + $SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS'); |
|
1162 | 1162 | if ($this->fromACARSscript) $this->SI->add($SI_data); |
1163 | 1163 | } |
1164 | 1164 | } |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | try { |
1169 | 1169 | $sth = $this->db->prepare($query); |
1170 | 1170 | $sth->execute($query_values); |
1171 | - } catch(PDOException $e) { |
|
1171 | + } catch (PDOException $e) { |
|
1172 | 1172 | if ($globalDebug) echo $e->getMessage(); |
1173 | 1173 | return "error : ".$e->getMessage(); |
1174 | 1174 | } |
@@ -1178,7 +1178,7 @@ discard block |
||
1178 | 1178 | if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
1179 | 1179 | else $ModeS = ''; |
1180 | 1180 | if ($ModeS == '') { |
1181 | - $id = explode('-',$result['flightaware_id']); |
|
1181 | + $id = explode('-', $result['flightaware_id']); |
|
1182 | 1182 | $ModeS = $id[0]; |
1183 | 1183 | } |
1184 | 1184 | if ($ModeS != '') { |
@@ -1188,20 +1188,20 @@ discard block |
||
1188 | 1188 | try { |
1189 | 1189 | $sthc = $this->db->prepare($queryc); |
1190 | 1190 | $sthc->execute($queryc_values); |
1191 | - } catch(PDOException $e) { |
|
1191 | + } catch (PDOException $e) { |
|
1192 | 1192 | if ($globalDebug) echo $e->getMessage(); |
1193 | 1193 | return "error : ".$e->getMessage(); |
1194 | 1194 | } |
1195 | 1195 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1196 | 1196 | $sthc->closeCursor(); |
1197 | - if (count($row) == 0) { |
|
1197 | + if (count($row) == 0) { |
|
1198 | 1198 | if ($globalDebug) echo " Add to ModeS table - "; |
1199 | 1199 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1200 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1200 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1201 | 1201 | try { |
1202 | 1202 | $sthi = $this->db->prepare($queryi); |
1203 | 1203 | $sthi->execute($queryi_values); |
1204 | - } catch(PDOException $e) { |
|
1204 | + } catch (PDOException $e) { |
|
1205 | 1205 | if ($globalDebug) echo $e->getMessage(); |
1206 | 1206 | return "error : ".$e->getMessage(); |
1207 | 1207 | } |
@@ -1209,15 +1209,15 @@ discard block |
||
1209 | 1209 | if ($globalDebug) echo " Update ModeS table - "; |
1210 | 1210 | if ($ICAOTypeCode != '') { |
1211 | 1211 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1212 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1212 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1213 | 1213 | } else { |
1214 | 1214 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1215 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration); |
|
1215 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration); |
|
1216 | 1216 | } |
1217 | 1217 | try { |
1218 | 1218 | $sthi = $this->db->prepare($queryi); |
1219 | 1219 | $sthi->execute($queryi_values); |
1220 | - } catch(PDOException $e) { |
|
1220 | + } catch (PDOException $e) { |
|
1221 | 1221 | if ($globalDebug) echo $e->getMessage(); |
1222 | 1222 | return "error : ".$e->getMessage(); |
1223 | 1223 | } |
@@ -1254,12 +1254,12 @@ discard block |
||
1254 | 1254 | elseif ($globalDBdriver == 'pgsql') { |
1255 | 1255 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1256 | 1256 | } |
1257 | - $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
|
1257 | + $queryi_values = array(':Registration' => $registration, ':ident' => $icao); |
|
1258 | 1258 | } |
1259 | 1259 | try { |
1260 | 1260 | $sthi = $this->db->prepare($queryi); |
1261 | 1261 | $sthi->execute($queryi_values); |
1262 | - } catch(PDOException $e) { |
|
1262 | + } catch (PDOException $e) { |
|
1263 | 1263 | if ($globalDebug) echo $e->getMessage(); |
1264 | 1264 | return "error : ".$e->getMessage(); |
1265 | 1265 | } |
@@ -26,14 +26,19 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function ident2icao($ident) { |
28 | 28 | if (substr($ident,0,2) == 'AF') { |
29 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
30 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
29 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
30 | + $icao = $ident; |
|
31 | + } else { |
|
32 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
33 | + } |
|
31 | 34 | } else { |
32 | 35 | $Spotter = new Spotter($this->db); |
33 | 36 | $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
34 | 37 | if (isset($identicao[0])) { |
35 | 38 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
36 | - } else $icao = $ident; |
|
39 | + } else { |
|
40 | + $icao = $ident; |
|
41 | + } |
|
37 | 42 | } |
38 | 43 | return $icao; |
39 | 44 | } |
@@ -106,14 +111,24 @@ discard block |
||
106 | 111 | $message = ''; |
107 | 112 | $result = array(); |
108 | 113 | $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); |
109 | - 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); |
|
110 | - 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); |
|
111 | - 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); |
|
114 | + if ($n == 0) { |
|
115 | + $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); |
|
116 | + } |
|
117 | + if ($n == 0) { |
|
118 | + $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); |
|
119 | + } |
|
120 | + if ($n == 0) { |
|
121 | + $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); |
|
122 | + } |
|
112 | 123 | if ($n != 0) { |
113 | 124 | $registration = str_replace('.','',$registration); |
114 | 125 | $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
115 | - if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
116 | - } else $message = $data; |
|
126 | + if ($globalDebug) { |
|
127 | + echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
128 | + } |
|
129 | + } else { |
|
130 | + $message = $data; |
|
131 | + } |
|
117 | 132 | $decode = array(); |
118 | 133 | $found = false; |
119 | 134 | // if ($registration != '' && $ident != '' && $registration != '!') { |
@@ -133,12 +148,21 @@ discard block |
||
133 | 148 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
134 | 149 | $latitude = $la / 10000.0; |
135 | 150 | $longitude = $ln / 10000.0; |
136 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
137 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
151 | + if ($lac == 'S') { |
|
152 | + $latitude = '-'.$latitude; |
|
153 | + } |
|
154 | + if ($lnc == 'W') { |
|
155 | + $longitude = '-'.$longitude; |
|
156 | + } |
|
138 | 157 | // Temp not always available |
139 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
140 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
141 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
158 | + if ($globalDebug) { |
|
159 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
160 | + } |
|
161 | + if ($temp == '') { |
|
162 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
163 | + } else { |
|
164 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
165 | + } |
|
142 | 166 | |
143 | 167 | //$icao = $Translation->checkTranslation($ident); |
144 | 168 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -152,25 +176,35 @@ discard block |
||
152 | 176 | $ahour = ''; |
153 | 177 | $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
154 | 178 | if ($n == 4 && strlen($darr) == 4) { |
155 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
156 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
157 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
179 | + if ($dhour != '') { |
|
180 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
181 | + } |
|
182 | + if ($ahour != '') { |
|
183 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
184 | + } |
|
185 | + if ($globalDebug) { |
|
186 | + echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
187 | + } |
|
158 | 188 | //$icao = ACARS->ident2icao($ident); |
159 | 189 | //$icao = $Translation->checkTranslation($ident); |
160 | 190 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
161 | 191 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
162 | 192 | $found = true; |
163 | - } |
|
164 | - elseif ($n == 2 || $n == 4) { |
|
165 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
166 | - if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
193 | + } elseif ($n == 2 || $n == 4) { |
|
194 | + if ($dhour != '') { |
|
195 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
196 | + } |
|
197 | + if ($globalDebug) { |
|
198 | + echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
199 | + } |
|
167 | 200 | //$icao = ACARS->ident2icao($ident); |
168 | 201 | //$icao = $Translation->checkTranslation($ident); |
169 | 202 | $decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour); |
170 | 203 | $found = true; |
171 | - } |
|
172 | - elseif ($n == 1) { |
|
173 | - if ($globalDebug) echo 'airport arrival : '.$darr."\n"; |
|
204 | + } elseif ($n == 1) { |
|
205 | + if ($globalDebug) { |
|
206 | + echo 'airport arrival : '.$darr."\n"; |
|
207 | + } |
|
174 | 208 | //$icao = ACARS->ident2icao($ident); |
175 | 209 | //$icao = $Translation->checkTranslation($ident); |
176 | 210 | $decode = array('Arrival airport' => $darr); |
@@ -188,7 +222,9 @@ discard block |
||
188 | 222 | $darr = ''; |
189 | 223 | $n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr); |
190 | 224 | if ($n == 4) { |
191 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
225 | + if ($globalDebug) { |
|
226 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
227 | + } |
|
192 | 228 | //$icao = ACARS->ident2icao($ident); |
193 | 229 | //$icao = $Translation->checkTranslation($ident); |
194 | 230 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -222,14 +258,23 @@ discard block |
||
222 | 258 | $apiste = ''; |
223 | 259 | $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
224 | 260 | if ($n > 8) { |
225 | - 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"; |
|
226 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
227 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
261 | + if ($globalDebug) { |
|
262 | + 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"; |
|
263 | + } |
|
264 | + if ($dhour != '') { |
|
265 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
266 | + } |
|
267 | + if ($ahour != '') { |
|
268 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
269 | + } |
|
228 | 270 | $icao = trim($aident); |
229 | 271 | |
230 | 272 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
231 | - if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
232 | - else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
273 | + if ($ahour == '') { |
|
274 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
275 | + } else { |
|
276 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
277 | + } |
|
233 | 278 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
234 | 279 | $decode['icao'] = $icao; |
235 | 280 | $found = true; |
@@ -251,9 +296,15 @@ discard block |
||
251 | 296 | $lns = $lns.'.'.$lns; |
252 | 297 | $latitude = $las / 1000.0; |
253 | 298 | $longitude = $lns / 1000.0; |
254 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
255 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
256 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
299 | + if ($lac == 'S') { |
|
300 | + $latitude = '-'.$latitude; |
|
301 | + } |
|
302 | + if ($lnc == 'W') { |
|
303 | + $longitude = '-'.$longitude; |
|
304 | + } |
|
305 | + if ($globalDebug) { |
|
306 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
307 | + } |
|
257 | 308 | $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
258 | 309 | $found = true; |
259 | 310 | } |
@@ -271,7 +322,9 @@ discard block |
||
271 | 322 | $darr = ''; |
272 | 323 | $n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr); |
273 | 324 | if ($n == 4) { |
274 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
325 | + if ($globalDebug) { |
|
326 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
327 | + } |
|
275 | 328 | //$icao = $Translation->checkTranslation($ident); |
276 | 329 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
277 | 330 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -284,7 +337,9 @@ discard block |
||
284 | 337 | $darr = ''; |
285 | 338 | $n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr); |
286 | 339 | if ($n == 4) { |
287 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
340 | + if ($globalDebug) { |
|
341 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
342 | + } |
|
288 | 343 | //$icao = $Translation->checkTranslation($ident); |
289 | 344 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
290 | 345 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -297,7 +352,9 @@ discard block |
||
297 | 352 | $darr = ''; |
298 | 353 | $n = sscanf($message, "002AF %4c %4c ", $dair, $darr); |
299 | 354 | if ($n == 2) { |
300 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
355 | + if ($globalDebug) { |
|
356 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
357 | + } |
|
301 | 358 | //$icao = $Translation->checkTranslation($ident); |
302 | 359 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
303 | 360 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -311,7 +368,9 @@ discard block |
||
311 | 368 | $darr = ''; |
312 | 369 | $n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
313 | 370 | if ($n == 6) { |
314 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
371 | + if ($globalDebug) { |
|
372 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
373 | + } |
|
315 | 374 | //$icao = $Translation->checkTranslation($ident); |
316 | 375 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
317 | 376 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -324,7 +383,9 @@ discard block |
||
324 | 383 | $darr = ''; |
325 | 384 | $n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
326 | 385 | if ($n == 7) { |
327 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
386 | + if ($globalDebug) { |
|
387 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
388 | + } |
|
328 | 389 | //$icao = $Translation->checkTranslation($ident); |
329 | 390 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
330 | 391 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -352,8 +413,12 @@ discard block |
||
352 | 413 | $decode['icao'] = $icao; |
353 | 414 | $latitude = $las / 100.0; |
354 | 415 | $longitude = $lns / 100.0; |
355 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
356 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
416 | + if ($lac == 'S') { |
|
417 | + $latitude = '-'.$latitude; |
|
418 | + } |
|
419 | + if ($lnc == 'W') { |
|
420 | + $longitude = '-'.$longitude; |
|
421 | + } |
|
357 | 422 | |
358 | 423 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
359 | 424 | $found = true; |
@@ -371,8 +436,12 @@ discard block |
||
371 | 436 | if ($n == 4) { |
372 | 437 | $latitude = $las; |
373 | 438 | $longitude = $lns; |
374 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
375 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
439 | + if ($lac == 'S') { |
|
440 | + $latitude = '-'.$latitude; |
|
441 | + } |
|
442 | + if ($lnc == 'W') { |
|
443 | + $longitude = '-'.$longitude; |
|
444 | + } |
|
376 | 445 | |
377 | 446 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
378 | 447 | $found = true; |
@@ -388,7 +457,9 @@ discard block |
||
388 | 457 | $darr = ''; |
389 | 458 | $n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr); |
390 | 459 | if ($n == 5) { |
391 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
460 | + if ($globalDebug) { |
|
461 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
462 | + } |
|
392 | 463 | //$icao = $Translation->checkTranslation($ident); |
393 | 464 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
394 | 465 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -409,7 +480,9 @@ discard block |
||
409 | 480 | $aident = ''; |
410 | 481 | $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
411 | 482 | if ($n == 8) { |
412 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
483 | + if ($globalDebug) { |
|
484 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
485 | + } |
|
413 | 486 | $icao = trim($aident); |
414 | 487 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
415 | 488 | $decode['icao'] = $icao; |
@@ -426,7 +499,9 @@ discard block |
||
426 | 499 | $darr = ''; |
427 | 500 | $n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr); |
428 | 501 | if ($n == 5) { |
429 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
502 | + if ($globalDebug) { |
|
503 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
504 | + } |
|
430 | 505 | //$icao = $Translation->checkTranslation($ident); |
431 | 506 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
432 | 507 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -441,7 +516,9 @@ discard block |
||
441 | 516 | $darr = ''; |
442 | 517 | $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
443 | 518 | if ($n == 3) { |
444 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
519 | + if ($globalDebug) { |
|
520 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
521 | + } |
|
445 | 522 | //$icao = $Translation->checkTranslation($ident); |
446 | 523 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
447 | 524 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -456,7 +533,9 @@ discard block |
||
456 | 533 | $darr = ''; |
457 | 534 | $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
458 | 535 | if ($n == 3) { |
459 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
536 | + if ($globalDebug) { |
|
537 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
538 | + } |
|
460 | 539 | //$icao = $Translation->checkTranslation($ident); |
461 | 540 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
462 | 541 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -466,7 +545,9 @@ discard block |
||
466 | 545 | if (!$found) { |
467 | 546 | $n = sscanf($message,'MET01%4c',$airport); |
468 | 547 | if ($n == 1) { |
469 | - if ($globalDebug) echo 'airport name : '.$airport; |
|
548 | + if ($globalDebug) { |
|
549 | + echo 'airport name : '.$airport; |
|
550 | + } |
|
470 | 551 | $decode = array('Airport/Waypoint name' => $airport); |
471 | 552 | $found = true; |
472 | 553 | } |
@@ -474,184 +555,126 @@ discard block |
||
474 | 555 | if ($label == 'H1') { |
475 | 556 | if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
476 | 557 | $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
477 | - } |
|
478 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
558 | + } elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
479 | 559 | $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
480 | - } |
|
481 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
560 | + } elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
482 | 561 | $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
483 | - } |
|
484 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
562 | + } elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
485 | 563 | $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
486 | - } |
|
487 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
564 | + } elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
488 | 565 | $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
489 | - } |
|
490 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
566 | + } elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
491 | 567 | $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
492 | - } |
|
493 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
568 | + } elseif (preg_match(':^#M1AAEP:',$message)) { |
|
494 | 569 | $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
495 | - } |
|
496 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
570 | + } elseif (preg_match(':^#M2APWD:',$message)) { |
|
497 | 571 | $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
498 | - } |
|
499 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
572 | + } elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
500 | 573 | $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
501 | - } |
|
502 | - elseif (preg_match(':^#CF:',$message)) { |
|
574 | + } elseif (preg_match(':^#CF:',$message)) { |
|
503 | 575 | $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
504 | - } |
|
505 | - elseif (preg_match(':^#DF:',$message)) { |
|
576 | + } elseif (preg_match(':^#DF:',$message)) { |
|
506 | 577 | $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
507 | - } |
|
508 | - elseif (preg_match(':^#EC:',$message)) { |
|
578 | + } elseif (preg_match(':^#EC:',$message)) { |
|
509 | 579 | $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
510 | - } |
|
511 | - elseif (preg_match(':^#EI:',$message)) { |
|
580 | + } elseif (preg_match(':^#EI:',$message)) { |
|
512 | 581 | $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
513 | - } |
|
514 | - elseif (preg_match(':^#H1:',$message)) { |
|
582 | + } elseif (preg_match(':^#H1:',$message)) { |
|
515 | 583 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
516 | - } |
|
517 | - elseif (preg_match(':^#H2:',$message)) { |
|
584 | + } elseif (preg_match(':^#H2:',$message)) { |
|
518 | 585 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
519 | - } |
|
520 | - elseif (preg_match(':^#HD:',$message)) { |
|
586 | + } elseif (preg_match(':^#HD:',$message)) { |
|
521 | 587 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
522 | - } |
|
523 | - elseif (preg_match(':^#M1:',$message)) { |
|
588 | + } elseif (preg_match(':^#M1:',$message)) { |
|
524 | 589 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
525 | - } |
|
526 | - elseif (preg_match(':^#M2:',$message)) { |
|
590 | + } elseif (preg_match(':^#M2:',$message)) { |
|
527 | 591 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
528 | - } |
|
529 | - elseif (preg_match(':^#M3:',$message)) { |
|
592 | + } elseif (preg_match(':^#M3:',$message)) { |
|
530 | 593 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
531 | - } |
|
532 | - elseif (preg_match(':^#MD:',$message)) { |
|
594 | + } elseif (preg_match(':^#MD:',$message)) { |
|
533 | 595 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
534 | - } |
|
535 | - elseif (preg_match(':^#PS:',$message)) { |
|
596 | + } elseif (preg_match(':^#PS:',$message)) { |
|
536 | 597 | $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
537 | - } |
|
538 | - elseif (preg_match(':^#S1:',$message)) { |
|
598 | + } elseif (preg_match(':^#S1:',$message)) { |
|
539 | 599 | $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
540 | - } |
|
541 | - elseif (preg_match(':^#S2:',$message)) { |
|
600 | + } elseif (preg_match(':^#S2:',$message)) { |
|
542 | 601 | $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
543 | - } |
|
544 | - elseif (preg_match(':^#SD:',$message)) { |
|
602 | + } elseif (preg_match(':^#SD:',$message)) { |
|
545 | 603 | $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
546 | - } |
|
547 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
604 | + } elseif (preg_match(':^#T[0-8]:',$message)) { |
|
548 | 605 | $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
549 | - } |
|
550 | - elseif (preg_match(':^#WO:',$message)) { |
|
606 | + } elseif (preg_match(':^#WO:',$message)) { |
|
551 | 607 | $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
552 | - } |
|
553 | - elseif (preg_match(':^#A1:',$message)) { |
|
608 | + } elseif (preg_match(':^#A1:',$message)) { |
|
554 | 609 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
555 | - } |
|
556 | - elseif (preg_match(':^#A3:',$message)) { |
|
610 | + } elseif (preg_match(':^#A3:',$message)) { |
|
557 | 611 | $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
558 | - } |
|
559 | - elseif (preg_match(':^#A4:',$message)) { |
|
612 | + } elseif (preg_match(':^#A4:',$message)) { |
|
560 | 613 | $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
561 | - } |
|
562 | - elseif (preg_match(':^#A6:',$message)) { |
|
614 | + } elseif (preg_match(':^#A6:',$message)) { |
|
563 | 615 | $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
564 | - } |
|
565 | - elseif (preg_match(':^#A8:',$message)) { |
|
616 | + } elseif (preg_match(':^#A8:',$message)) { |
|
566 | 617 | $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
567 | - } |
|
568 | - elseif (preg_match(':^#A9:',$message)) { |
|
618 | + } elseif (preg_match(':^#A9:',$message)) { |
|
569 | 619 | $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
570 | - } |
|
571 | - elseif (preg_match(':^#A0:',$message)) { |
|
620 | + } elseif (preg_match(':^#A0:',$message)) { |
|
572 | 621 | $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
573 | - } |
|
574 | - elseif (preg_match(':^#AA:',$message)) { |
|
622 | + } elseif (preg_match(':^#AA:',$message)) { |
|
575 | 623 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
576 | - } |
|
577 | - elseif (preg_match(':^#AB:',$message)) { |
|
624 | + } elseif (preg_match(':^#AB:',$message)) { |
|
578 | 625 | $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
579 | - } |
|
580 | - elseif (preg_match(':^#AC:',$message)) { |
|
626 | + } elseif (preg_match(':^#AC:',$message)) { |
|
581 | 627 | $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
582 | - } |
|
583 | - elseif (preg_match(':^#AD:',$message)) { |
|
628 | + } elseif (preg_match(':^#AD:',$message)) { |
|
584 | 629 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
585 | - } |
|
586 | - elseif (preg_match(':^#AF:',$message)) { |
|
630 | + } elseif (preg_match(':^#AF:',$message)) { |
|
587 | 631 | $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
588 | - } |
|
589 | - elseif (preg_match(':^#B1:',$message)) { |
|
632 | + } elseif (preg_match(':^#B1:',$message)) { |
|
590 | 633 | $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
591 | - } |
|
592 | - elseif (preg_match(':^#B2:',$message)) { |
|
634 | + } elseif (preg_match(':^#B2:',$message)) { |
|
593 | 635 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
594 | - } |
|
595 | - elseif (preg_match(':^#B3:',$message)) { |
|
636 | + } elseif (preg_match(':^#B3:',$message)) { |
|
596 | 637 | $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
597 | - } |
|
598 | - elseif (preg_match(':^#B4:',$message)) { |
|
638 | + } elseif (preg_match(':^#B4:',$message)) { |
|
599 | 639 | $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
600 | - } |
|
601 | - elseif (preg_match(':^#B6:',$message)) { |
|
640 | + } elseif (preg_match(':^#B6:',$message)) { |
|
602 | 641 | $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
603 | - } |
|
604 | - elseif (preg_match(':^#B8:',$message)) { |
|
642 | + } elseif (preg_match(':^#B8:',$message)) { |
|
605 | 643 | $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
606 | - } |
|
607 | - elseif (preg_match(':^#B9:',$message)) { |
|
644 | + } elseif (preg_match(':^#B9:',$message)) { |
|
608 | 645 | $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
609 | - } |
|
610 | - elseif (preg_match(':^#B0:',$message)) { |
|
646 | + } elseif (preg_match(':^#B0:',$message)) { |
|
611 | 647 | $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
612 | - } |
|
613 | - elseif (preg_match(':^#BA:',$message)) { |
|
648 | + } elseif (preg_match(':^#BA:',$message)) { |
|
614 | 649 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
615 | - } |
|
616 | - elseif (preg_match(':^#BB:',$message)) { |
|
650 | + } elseif (preg_match(':^#BB:',$message)) { |
|
617 | 651 | $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
618 | - } |
|
619 | - elseif (preg_match(':^#BC:',$message)) { |
|
652 | + } elseif (preg_match(':^#BC:',$message)) { |
|
620 | 653 | $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
621 | - } |
|
622 | - elseif (preg_match(':^#BD:',$message)) { |
|
654 | + } elseif (preg_match(':^#BD:',$message)) { |
|
623 | 655 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
624 | - } |
|
625 | - elseif (preg_match(':^#BE:',$message)) { |
|
656 | + } elseif (preg_match(':^#BE:',$message)) { |
|
626 | 657 | $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
627 | - } |
|
628 | - elseif (preg_match(':^#BF:',$message)) { |
|
658 | + } elseif (preg_match(':^#BF:',$message)) { |
|
629 | 659 | $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
630 | - } |
|
631 | - elseif (preg_match(':^#H3:',$message)) { |
|
660 | + } elseif (preg_match(':^#H3:',$message)) { |
|
632 | 661 | $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
633 | 662 | } |
634 | 663 | } |
635 | 664 | if ($label == '10') { |
636 | 665 | if (preg_match(':^DTO01:',$message)) { |
637 | 666 | $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
638 | - } |
|
639 | - elseif (preg_match(':^AIS01:',$message)) { |
|
667 | + } elseif (preg_match(':^AIS01:',$message)) { |
|
640 | 668 | $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
641 | - } |
|
642 | - elseif (preg_match(':^FTX01:',$message)) { |
|
669 | + } elseif (preg_match(':^FTX01:',$message)) { |
|
643 | 670 | $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
644 | - } |
|
645 | - elseif (preg_match(':^FPL01:',$message)) { |
|
671 | + } elseif (preg_match(':^FPL01:',$message)) { |
|
646 | 672 | $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
647 | - } |
|
648 | - elseif (preg_match(':^WAB01:',$message)) { |
|
673 | + } elseif (preg_match(':^WAB01:',$message)) { |
|
649 | 674 | $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
650 | - } |
|
651 | - elseif (preg_match(':^MET01:',$message)) { |
|
675 | + } elseif (preg_match(':^MET01:',$message)) { |
|
652 | 676 | $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
653 | - } |
|
654 | - elseif (preg_match(':^WAB02:',$message)) { |
|
677 | + } elseif (preg_match(':^WAB02:',$message)) { |
|
655 | 678 | $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
656 | 679 | } |
657 | 680 | } |
@@ -666,38 +689,28 @@ discard block |
||
666 | 689 | $vsta = array('Version' => $version); |
667 | 690 | if ($state == 'E') { |
668 | 691 | $vsta = array_merge($vsta,array('Link state' => 'Established')); |
669 | - } |
|
670 | - elseif ($state == 'L') { |
|
692 | + } elseif ($state == 'L') { |
|
671 | 693 | $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
672 | - } |
|
673 | - else { |
|
694 | + } else { |
|
674 | 695 | $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
675 | 696 | } |
676 | 697 | if ($type == 'V') { |
677 | 698 | $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
678 | - } |
|
679 | - elseif ($type == 'S') { |
|
699 | + } elseif ($type == 'S') { |
|
680 | 700 | $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
681 | - } |
|
682 | - elseif ($type == 'H') { |
|
701 | + } elseif ($type == 'H') { |
|
683 | 702 | $vsta = array_merge($vsta,array('Link type' => 'HF')); |
684 | - } |
|
685 | - elseif ($type == 'G') { |
|
703 | + } elseif ($type == 'G') { |
|
686 | 704 | $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
687 | - } |
|
688 | - elseif ($type == 'C') { |
|
705 | + } elseif ($type == 'C') { |
|
689 | 706 | $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
690 | - } |
|
691 | - elseif ($type == '2') { |
|
707 | + } elseif ($type == '2') { |
|
692 | 708 | $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
693 | - } |
|
694 | - elseif ($type == 'X') { |
|
709 | + } elseif ($type == 'X') { |
|
695 | 710 | $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
696 | - } |
|
697 | - elseif ($type == 'I') { |
|
711 | + } elseif ($type == 'I') { |
|
698 | 712 | $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
699 | - } |
|
700 | - else { |
|
713 | + } else { |
|
701 | 714 | $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
702 | 715 | } |
703 | 716 | $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
@@ -706,7 +719,9 @@ discard block |
||
706 | 719 | } |
707 | 720 | |
708 | 721 | $title = $this->getTitlefromLabel($label); |
709 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
722 | + if ($title != '') { |
|
723 | + $decode = array_merge(array('Message title' => $title),$decode); |
|
724 | + } |
|
710 | 725 | /* |
711 | 726 | // Business jets always use GS0001 |
712 | 727 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -741,31 +756,54 @@ discard block |
||
741 | 756 | $msg = $message['message']; |
742 | 757 | $decode = $message['decode']; |
743 | 758 | $registration = (string)$message['registration']; |
744 | - if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
|
745 | - else $latitude = ''; |
|
746 | - if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
|
747 | - else $longitude = ''; |
|
748 | - if (isset($decode['airicao'])) $airicao = $decode['airicao']; |
|
749 | - else $airicao = ''; |
|
750 | - if (isset($decode['icao'])) $icao = $decode['icao']; |
|
751 | - else $icao = $Translation->checkTranslation($ident); |
|
759 | + if (isset($decode['latitude'])) { |
|
760 | + $latitude = $decode['latitude']; |
|
761 | + } else { |
|
762 | + $latitude = ''; |
|
763 | + } |
|
764 | + if (isset($decode['longitude'])) { |
|
765 | + $longitude = $decode['longitude']; |
|
766 | + } else { |
|
767 | + $longitude = ''; |
|
768 | + } |
|
769 | + if (isset($decode['airicao'])) { |
|
770 | + $airicao = $decode['airicao']; |
|
771 | + } else { |
|
772 | + $airicao = ''; |
|
773 | + } |
|
774 | + if (isset($decode['icao'])) { |
|
775 | + $icao = $decode['icao']; |
|
776 | + } else { |
|
777 | + $icao = $Translation->checkTranslation($ident); |
|
778 | + } |
|
752 | 779 | $image_array = $Image->getSpotterImage($registration); |
753 | 780 | if (!isset($image_array[0]['registration'])) { |
754 | 781 | $Image->addSpotterImage($registration); |
755 | 782 | } |
756 | 783 | // Business jets always use GS0001 |
757 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
758 | - if ($globalDebug && isset($info) && $info != '') echo $info; |
|
759 | - if (count($decode) > 0) $decode_json = json_encode($decode); |
|
760 | - else $decode_json = ''; |
|
784 | + if ($ident != 'GS0001') { |
|
785 | + $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
786 | + } |
|
787 | + if ($globalDebug && isset($info) && $info != '') { |
|
788 | + echo $info; |
|
789 | + } |
|
790 | + if (count($decode) > 0) { |
|
791 | + $decode_json = json_encode($decode); |
|
792 | + } else { |
|
793 | + $decode_json = ''; |
|
794 | + } |
|
761 | 795 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
762 | 796 | $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
763 | 797 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
764 | 798 | $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
765 | 799 | } |
766 | 800 | $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
767 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
768 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
801 | + if (!isset($globalACARSArchive)) { |
|
802 | + $globalACARSArchive = array('10','80','81','82','3F'); |
|
803 | + } |
|
804 | + if ($result && in_array($label,$globalACARSArchive)) { |
|
805 | + $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
806 | + } |
|
769 | 807 | if ($globalDebug && count($decode) > 0) { |
770 | 808 | echo "Human readable data : ".implode(' - ',$decode)."\n"; |
771 | 809 | } |
@@ -788,7 +826,9 @@ discard block |
||
788 | 826 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
789 | 827 | $Connection = new Connection($this->db); |
790 | 828 | $this->db = $Connection->db; |
791 | - if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
|
829 | + if ($globalDebug) { |
|
830 | + echo "Test if not already in Live ACARS table..."; |
|
831 | + } |
|
792 | 832 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
793 | 833 | $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
794 | 834 | try { |
@@ -798,7 +838,9 @@ discard block |
||
798 | 838 | return "error : ".$e->getMessage(); |
799 | 839 | } |
800 | 840 | if ($stht->fetchColumn() == 0) { |
801 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
841 | + if ($globalDebug) { |
|
842 | + echo "Add Live ACARS data..."; |
|
843 | + } |
|
802 | 844 | $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)"; |
803 | 845 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
804 | 846 | try { |
@@ -808,10 +850,14 @@ discard block |
||
808 | 850 | return "error : ".$e->getMessage(); |
809 | 851 | } |
810 | 852 | } else { |
811 | - if ($globalDebug) echo "Data already in DB...\n"; |
|
853 | + if ($globalDebug) { |
|
854 | + echo "Data already in DB...\n"; |
|
855 | + } |
|
812 | 856 | return false; |
813 | 857 | } |
814 | - if ($globalDebug) echo "Done\n"; |
|
858 | + if ($globalDebug) { |
|
859 | + echo "Done\n"; |
|
860 | + } |
|
815 | 861 | return true; |
816 | 862 | } |
817 | 863 | } |
@@ -842,7 +888,9 @@ discard block |
||
842 | 888 | } |
843 | 889 | if ($stht->fetchColumn() == 0) { |
844 | 890 | */ |
845 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
891 | + if ($globalDebug) { |
|
892 | + echo "Add Live ACARS data..."; |
|
893 | + } |
|
846 | 894 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
847 | 895 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
848 | 896 | try { |
@@ -851,7 +899,9 @@ discard block |
||
851 | 899 | } catch(PDOException $e) { |
852 | 900 | return "error : ".$e->getMessage(); |
853 | 901 | } |
854 | - if ($globalDebug) echo "Done\n"; |
|
902 | + if ($globalDebug) { |
|
903 | + echo "Done\n"; |
|
904 | + } |
|
855 | 905 | } |
856 | 906 | } |
857 | 907 | |
@@ -874,8 +924,11 @@ discard block |
||
874 | 924 | return ''; |
875 | 925 | } |
876 | 926 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
877 | - if (count($row) > 0) return $row[0]['title']; |
|
878 | - else return ''; |
|
927 | + if (count($row) > 0) { |
|
928 | + return $row[0]['title']; |
|
929 | + } else { |
|
930 | + return ''; |
|
931 | + } |
|
879 | 932 | } |
880 | 933 | |
881 | 934 | /** |
@@ -894,8 +947,11 @@ discard block |
||
894 | 947 | return array(); |
895 | 948 | } |
896 | 949 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
897 | - if (count($row) > 0) return $row; |
|
898 | - else return array(); |
|
950 | + if (count($row) > 0) { |
|
951 | + return $row; |
|
952 | + } else { |
|
953 | + return array(); |
|
954 | + } |
|
899 | 955 | } |
900 | 956 | |
901 | 957 | /** |
@@ -915,8 +971,11 @@ discard block |
||
915 | 971 | return array(); |
916 | 972 | } |
917 | 973 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
918 | - if (count($row) > 0) return $row[0]; |
|
919 | - else return array(); |
|
974 | + if (count($row) > 0) { |
|
975 | + return $row[0]; |
|
976 | + } else { |
|
977 | + return array(); |
|
978 | + } |
|
920 | 979 | } |
921 | 980 | |
922 | 981 | /** |
@@ -961,19 +1020,35 @@ discard block |
||
961 | 1020 | if ($row['registration'] != '') { |
962 | 1021 | $row['registration'] = str_replace('.','',$row['registration']); |
963 | 1022 | $image_array = $Image->getSpotterImage($row['registration']); |
964 | - 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'])); |
|
965 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
966 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
967 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
968 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
1023 | + if (count($image_array) > 0) { |
|
1024 | + $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'])); |
|
1025 | + } else { |
|
1026 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1027 | + } |
|
1028 | + } else { |
|
1029 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1030 | + } |
|
1031 | + if ($row['registration'] == '') { |
|
1032 | + $row['registration'] = 'NA'; |
|
1033 | + } |
|
1034 | + if ($row['ident'] == '') { |
|
1035 | + $row['ident'] = 'NA'; |
|
1036 | + } |
|
969 | 1037 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
970 | 1038 | if (isset($identicao[0])) { |
971 | 1039 | if (substr($row['ident'],0,2) == 'AF') { |
972 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
973 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
974 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1040 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
1041 | + $icao = $row['ident']; |
|
1042 | + } else { |
|
1043 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1044 | + } |
|
1045 | + } else { |
|
1046 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1047 | + } |
|
975 | 1048 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
976 | - } else $icao = $row['ident']; |
|
1049 | + } else { |
|
1050 | + $icao = $row['ident']; |
|
1051 | + } |
|
977 | 1052 | $icao = $Translation->checkTranslation($icao,false); |
978 | 1053 | $decode = json_decode($row['decode'],true); |
979 | 1054 | $found = false; |
@@ -998,7 +1073,9 @@ discard block |
||
998 | 1073 | $found = true; |
999 | 1074 | } |
1000 | 1075 | } |
1001 | - if ($found) $row['decode'] = json_encode($decode); |
|
1076 | + if ($found) { |
|
1077 | + $row['decode'] = json_encode($decode); |
|
1078 | + } |
|
1002 | 1079 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
1003 | 1080 | $result[] = $data; |
1004 | 1081 | $i++; |
@@ -1006,8 +1083,9 @@ discard block |
||
1006 | 1083 | if (isset($result)) { |
1007 | 1084 | $result[0]['query_number_rows'] = $i; |
1008 | 1085 | return $result; |
1086 | + } else { |
|
1087 | + return array(); |
|
1009 | 1088 | } |
1010 | - else return array(); |
|
1011 | 1089 | } |
1012 | 1090 | |
1013 | 1091 | /** |
@@ -1056,31 +1134,51 @@ discard block |
||
1056 | 1134 | if ($row['registration'] != '') { |
1057 | 1135 | $row['registration'] = str_replace('.','',$row['registration']); |
1058 | 1136 | $image_array = $Image->getSpotterImage($row['registration']); |
1059 | - 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'])); |
|
1060 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1061 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1137 | + if (count($image_array) > 0) { |
|
1138 | + $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'])); |
|
1139 | + } else { |
|
1140 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1141 | + } |
|
1142 | + } else { |
|
1143 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1144 | + } |
|
1062 | 1145 | $icao = ''; |
1063 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
1064 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
1146 | + if ($row['registration'] == '') { |
|
1147 | + $row['registration'] = 'NA'; |
|
1148 | + } |
|
1149 | + if ($row['ident'] == '') { |
|
1150 | + $row['ident'] = 'NA'; |
|
1151 | + } |
|
1065 | 1152 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
1066 | 1153 | if (isset($identicao[0])) { |
1067 | 1154 | if (substr($row['ident'],0,2) == 'AF') { |
1068 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1069 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1070 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1155 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
1156 | + $icao = $row['ident']; |
|
1157 | + } else { |
|
1158 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1159 | + } |
|
1160 | + } else { |
|
1161 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1162 | + } |
|
1071 | 1163 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
1072 | - } else $icao = $row['ident']; |
|
1164 | + } else { |
|
1165 | + $icao = $row['ident']; |
|
1166 | + } |
|
1073 | 1167 | $icao = $Translation->checkTranslation($icao); |
1074 | 1168 | $decode = json_decode($row['decode'],true); |
1075 | 1169 | $found = false; |
1076 | 1170 | if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
1077 | 1171 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1078 | - 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>'; |
|
1172 | + if (isset($airport_info[0]['icao'])) { |
|
1173 | + $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1174 | + } |
|
1079 | 1175 | $found = true; |
1080 | 1176 | } |
1081 | 1177 | if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
1082 | 1178 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1083 | - 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>'; |
|
1179 | + if (isset($airport_info[0]['icao'])) { |
|
1180 | + $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1181 | + } |
|
1084 | 1182 | $found = true; |
1085 | 1183 | } |
1086 | 1184 | if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
@@ -1090,7 +1188,9 @@ discard block |
||
1090 | 1188 | $found = true; |
1091 | 1189 | } |
1092 | 1190 | } |
1093 | - if ($found) $row['decode'] = json_encode($decode); |
|
1191 | + if ($found) { |
|
1192 | + $row['decode'] = json_encode($decode); |
|
1193 | + } |
|
1094 | 1194 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
1095 | 1195 | $result[] = $data; |
1096 | 1196 | $i++; |
@@ -1098,7 +1198,9 @@ discard block |
||
1098 | 1198 | if (isset($result)) { |
1099 | 1199 | $result[0]['query_number_rows'] = $i; |
1100 | 1200 | return $result; |
1101 | - } else return array(); |
|
1201 | + } else { |
|
1202 | + return array(); |
|
1203 | + } |
|
1102 | 1204 | } |
1103 | 1205 | |
1104 | 1206 | /** |
@@ -1114,25 +1216,37 @@ discard block |
||
1114 | 1216 | $ident = trim($ident); |
1115 | 1217 | $Translation = new Translation($this->db); |
1116 | 1218 | $Spotter = new Spotter($this->db); |
1117 | - if ($globalDebug) echo "Test if we add ModeS data..."; |
|
1219 | + if ($globalDebug) { |
|
1220 | + echo "Test if we add ModeS data..."; |
|
1221 | + } |
|
1118 | 1222 | //if ($icao == '') $icao = ACARS->ident2icao($ident); |
1119 | - if ($icao == '') $icao = $Translation->checkTranslation($ident); |
|
1120 | - if ($globalDebug) echo '- Ident : '.$icao.' - '; |
|
1223 | + if ($icao == '') { |
|
1224 | + $icao = $Translation->checkTranslation($ident); |
|
1225 | + } |
|
1226 | + if ($globalDebug) { |
|
1227 | + echo '- Ident : '.$icao.' - '; |
|
1228 | + } |
|
1121 | 1229 | if ($ident == '' || $registration == '') { |
1122 | - if ($globalDebug) echo "Ident or registration null, exit\n"; |
|
1230 | + if ($globalDebug) { |
|
1231 | + echo "Ident or registration null, exit\n"; |
|
1232 | + } |
|
1123 | 1233 | return ''; |
1124 | 1234 | } |
1125 | 1235 | $registration = str_replace('.','',$registration); |
1126 | 1236 | $ident = $Translation->ident2icao($ident); |
1127 | 1237 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1128 | - if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
|
1238 | + if ($globalDebug) { |
|
1239 | + echo "Check if needed to add translation ".$ident.'... '; |
|
1240 | + } |
|
1129 | 1241 | $querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1"; |
1130 | 1242 | $querysi_values = array(':registration' => $registration); |
1131 | 1243 | try { |
1132 | 1244 | $sthsi = $this->db->prepare($querysi); |
1133 | 1245 | $sthsi->execute($querysi_values); |
1134 | 1246 | } catch(PDOException $e) { |
1135 | - if ($globalDebug) echo $e->getMessage(); |
|
1247 | + if ($globalDebug) { |
|
1248 | + echo $e->getMessage(); |
|
1249 | + } |
|
1136 | 1250 | return "error : ".$e->getMessage(); |
1137 | 1251 | } |
1138 | 1252 | $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC); |
@@ -1140,9 +1254,14 @@ discard block |
||
1140 | 1254 | if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') { |
1141 | 1255 | $Translation = new Translation($this->db); |
1142 | 1256 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1143 | - if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
1144 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1145 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1257 | + if ($globalDebug) { |
|
1258 | + echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
1259 | + } |
|
1260 | + if ($ident != $trans_ident) { |
|
1261 | + $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1262 | + } elseif ($trans_ident == $ident) { |
|
1263 | + $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1264 | + } |
|
1146 | 1265 | } else { |
1147 | 1266 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1148 | 1267 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1151,32 +1270,46 @@ discard block |
||
1151 | 1270 | $sth = $this->db->prepare($query); |
1152 | 1271 | $sth->execute($query_values); |
1153 | 1272 | } catch(PDOException $e) { |
1154 | - if ($globalDebug) echo $e->getMessage(); |
|
1273 | + if ($globalDebug) { |
|
1274 | + echo $e->getMessage(); |
|
1275 | + } |
|
1155 | 1276 | return "error : ".$e->getMessage(); |
1156 | 1277 | } |
1157 | 1278 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1158 | 1279 | $sth->closeCursor(); |
1159 | - if (isset($result['modes'])) $hex = $result['modes']; |
|
1160 | - else $hex = ''; |
|
1280 | + if (isset($result['modes'])) { |
|
1281 | + $hex = $result['modes']; |
|
1282 | + } else { |
|
1283 | + $hex = ''; |
|
1284 | + } |
|
1161 | 1285 | $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
1162 | - if ($this->fromACARSscript) $this->SI->add($SI_data); |
|
1286 | + if ($this->fromACARSscript) { |
|
1287 | + $this->SI->add($SI_data); |
|
1288 | + } |
|
1163 | 1289 | } |
1164 | 1290 | } |
1165 | - if ($globalDebug) echo 'Done'."\n"; |
|
1291 | + if ($globalDebug) { |
|
1292 | + echo 'Done'."\n"; |
|
1293 | + } |
|
1166 | 1294 | $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1"; |
1167 | 1295 | $query_values = array(':ident' => $icao); |
1168 | 1296 | try { |
1169 | 1297 | $sth = $this->db->prepare($query); |
1170 | 1298 | $sth->execute($query_values); |
1171 | 1299 | } catch(PDOException $e) { |
1172 | - if ($globalDebug) echo $e->getMessage(); |
|
1300 | + if ($globalDebug) { |
|
1301 | + echo $e->getMessage(); |
|
1302 | + } |
|
1173 | 1303 | return "error : ".$e->getMessage(); |
1174 | 1304 | } |
1175 | 1305 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1176 | 1306 | $sth->closeCursor(); |
1177 | 1307 | if (isset($result['flightaware_id'])) { |
1178 | - if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
|
1179 | - else $ModeS = ''; |
|
1308 | + if (isset($result['ModeS'])) { |
|
1309 | + $ModeS = $result['ModeS']; |
|
1310 | + } else { |
|
1311 | + $ModeS = ''; |
|
1312 | + } |
|
1180 | 1313 | if ($ModeS == '') { |
1181 | 1314 | $id = explode('-',$result['flightaware_id']); |
1182 | 1315 | $ModeS = $id[0]; |
@@ -1189,24 +1322,32 @@ discard block |
||
1189 | 1322 | $sthc = $this->db->prepare($queryc); |
1190 | 1323 | $sthc->execute($queryc_values); |
1191 | 1324 | } catch(PDOException $e) { |
1192 | - if ($globalDebug) echo $e->getMessage(); |
|
1325 | + if ($globalDebug) { |
|
1326 | + echo $e->getMessage(); |
|
1327 | + } |
|
1193 | 1328 | return "error : ".$e->getMessage(); |
1194 | 1329 | } |
1195 | 1330 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1196 | 1331 | $sthc->closeCursor(); |
1197 | 1332 | if (count($row) == 0) { |
1198 | - if ($globalDebug) echo " Add to ModeS table - "; |
|
1333 | + if ($globalDebug) { |
|
1334 | + echo " Add to ModeS table - "; |
|
1335 | + } |
|
1199 | 1336 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1200 | 1337 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
1201 | 1338 | try { |
1202 | 1339 | $sthi = $this->db->prepare($queryi); |
1203 | 1340 | $sthi->execute($queryi_values); |
1204 | 1341 | } catch(PDOException $e) { |
1205 | - if ($globalDebug) echo $e->getMessage(); |
|
1342 | + if ($globalDebug) { |
|
1343 | + echo $e->getMessage(); |
|
1344 | + } |
|
1206 | 1345 | return "error : ".$e->getMessage(); |
1207 | 1346 | } |
1208 | 1347 | } else { |
1209 | - if ($globalDebug) echo " Update ModeS table - "; |
|
1348 | + if ($globalDebug) { |
|
1349 | + echo " Update ModeS table - "; |
|
1350 | + } |
|
1210 | 1351 | if ($ICAOTypeCode != '') { |
1211 | 1352 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1212 | 1353 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
@@ -1218,7 +1359,9 @@ discard block |
||
1218 | 1359 | $sthi = $this->db->prepare($queryi); |
1219 | 1360 | $sthi->execute($queryi_values); |
1220 | 1361 | } catch(PDOException $e) { |
1221 | - if ($globalDebug) echo $e->getMessage(); |
|
1362 | + if ($globalDebug) { |
|
1363 | + echo $e->getMessage(); |
|
1364 | + } |
|
1222 | 1365 | return "error : ".$e->getMessage(); |
1223 | 1366 | } |
1224 | 1367 | } |
@@ -1239,7 +1382,9 @@ discard block |
||
1239 | 1382 | return "error : ".$e->getMessage(); |
1240 | 1383 | } |
1241 | 1384 | */ |
1242 | - if ($globalDebug) echo " Update Spotter_output table - "; |
|
1385 | + if ($globalDebug) { |
|
1386 | + echo " Update Spotter_output table - "; |
|
1387 | + } |
|
1243 | 1388 | if ($ICAOTypeCode != '') { |
1244 | 1389 | if ($globalDBdriver == 'mysql') { |
1245 | 1390 | $queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
@@ -1250,8 +1395,7 @@ discard block |
||
1250 | 1395 | } else { |
1251 | 1396 | if ($globalDBdriver == 'mysql') { |
1252 | 1397 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
1253 | - } |
|
1254 | - elseif ($globalDBdriver == 'pgsql') { |
|
1398 | + } elseif ($globalDBdriver == 'pgsql') { |
|
1255 | 1399 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1256 | 1400 | } |
1257 | 1401 | $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
@@ -1260,14 +1404,20 @@ discard block |
||
1260 | 1404 | $sthi = $this->db->prepare($queryi); |
1261 | 1405 | $sthi->execute($queryi_values); |
1262 | 1406 | } catch(PDOException $e) { |
1263 | - if ($globalDebug) echo $e->getMessage(); |
|
1407 | + if ($globalDebug) { |
|
1408 | + echo $e->getMessage(); |
|
1409 | + } |
|
1264 | 1410 | return "error : ".$e->getMessage(); |
1265 | 1411 | } |
1266 | 1412 | } |
1267 | 1413 | } else { |
1268 | - if ($globalDebug) echo " Can't find ModeS in spotter_output - "; |
|
1414 | + if ($globalDebug) { |
|
1415 | + echo " Can't find ModeS in spotter_output - "; |
|
1416 | + } |
|
1417 | + } |
|
1418 | + if ($globalDebug) { |
|
1419 | + echo "Done\n"; |
|
1269 | 1420 | } |
1270 | - if ($globalDebug) echo "Done\n"; |
|
1271 | 1421 | } |
1272 | 1422 | } |
1273 | 1423 | ?> |