@@ -15,7 +15,7 @@ |
||
15 | 15 | */ |
16 | 16 | public function parse_xml($url) { |
17 | 17 | $Common = new Common(); |
18 | - $filedata = $Common->getData($url,'get','','','','','','',true); |
|
18 | + $filedata = $Common->getData($url, 'get', '', '', '', '', '', '', true); |
|
19 | 19 | if ($filedata != '' && $filedata !== false) { |
20 | 20 | $xml = simplexml_load_string($filedata); |
21 | 21 | if ($xml !== false) { |
@@ -175,8 +175,7 @@ discard block |
||
175 | 175 | '\~' => 'TNC Stream SW'); |
176 | 176 | |
177 | 177 | private function urshift($n, $s) { |
178 | - return ($n >= 0) ? ($n >> $s) : |
|
179 | - (($n & 0x7fffffff) >> $s) | |
|
178 | + return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| |
|
180 | 179 | (0x40000000 >> ($s - 1)); |
181 | 180 | } |
182 | 181 | |
@@ -192,7 +191,7 @@ discard block |
||
192 | 191 | $input_len = strlen($input); |
193 | 192 | |
194 | 193 | /* Find the end of header checking for NULL bytes while doing it. */ |
195 | - $splitpos = strpos($input,':'); |
|
194 | + $splitpos = strpos($input, ':'); |
|
196 | 195 | |
197 | 196 | /* Check that end was found and body has at least one byte. */ |
198 | 197 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
@@ -202,14 +201,14 @@ discard block |
||
202 | 201 | |
203 | 202 | if ($debug) echo 'input : '.$input."\n"; |
204 | 203 | /* Save header and body. */ |
205 | - $body = substr($input,$splitpos+1,$input_len); |
|
204 | + $body = substr($input, $splitpos + 1, $input_len); |
|
206 | 205 | $body_len = strlen($body); |
207 | - $header = substr($input,0,$splitpos); |
|
206 | + $header = substr($input, 0, $splitpos); |
|
208 | 207 | if ($debug) echo 'header : '.$header."\n"; |
209 | 208 | |
210 | 209 | /* Parse source, target and path. */ |
211 | 210 | //FLRDF0A52>APRS,qAS,LSTB |
212 | - if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
|
211 | + if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) { |
|
213 | 212 | $ident = $matches[1]; |
214 | 213 | $all_elements = $matches[2]; |
215 | 214 | if ($ident == 'AIRCRAFT') { |
@@ -226,13 +225,13 @@ discard block |
||
226 | 225 | if ($debug) 'No ident'."\n"; |
227 | 226 | return false; |
228 | 227 | } |
229 | - $elements = explode(',',$all_elements); |
|
228 | + $elements = explode(',', $all_elements); |
|
230 | 229 | $source = end($elements); |
231 | 230 | $result['source'] = $source; |
232 | 231 | foreach ($elements as $element) { |
233 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
232 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) { |
|
234 | 233 | //if ($element == 'TCPIP*') return false; |
235 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
234 | + } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) { |
|
236 | 235 | if ($debug) echo 'element : '.$element."\n"; |
237 | 236 | return false; |
238 | 237 | } |
@@ -245,14 +244,14 @@ discard block |
||
245 | 244 | */ |
246 | 245 | } |
247 | 246 | |
248 | - $type = substr($body,0,1); |
|
247 | + $type = substr($body, 0, 1); |
|
249 | 248 | if ($debug) echo 'type : '.$type."\n"; |
250 | 249 | if ($type == ';') { |
251 | 250 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
252 | - $result['address'] = trim(substr($body,1,9)); |
|
251 | + $result['address'] = trim(substr($body, 1, 9)); |
|
253 | 252 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
254 | - $result['mmsi'] = trim(substr($body,1,9)); |
|
255 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
253 | + $result['mmsi'] = trim(substr($body, 1, 9)); |
|
254 | + } else $result['ident'] = trim(substr($body, 1, 9)); |
|
256 | 255 | } elseif ($type == ',') { |
257 | 256 | // Invalid data or test data |
258 | 257 | return false; |
@@ -260,20 +259,20 @@ discard block |
||
260 | 259 | |
261 | 260 | // Check for Timestamp |
262 | 261 | $find = false; |
263 | - $body_parse = substr($body,1); |
|
264 | - if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
|
265 | - $body_parse = substr($body_parse,10); |
|
262 | + $body_parse = substr($body, 1); |
|
263 | + if (preg_match('/^;(.){9}\*/', $body, $matches)) { |
|
264 | + $body_parse = substr($body_parse, 10); |
|
266 | 265 | $find = true; |
267 | 266 | } |
268 | - if (preg_match('/^`(.*)\//',$body,$matches)) { |
|
269 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
267 | + if (preg_match('/^`(.*)\//', $body, $matches)) { |
|
268 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
270 | 269 | $find = true; |
271 | 270 | } |
272 | - if (preg_match("/^'(.*)\//",$body,$matches)) { |
|
273 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
271 | + if (preg_match("/^'(.*)\//", $body, $matches)) { |
|
272 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
274 | 273 | $find = true; |
275 | 274 | } |
276 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
|
275 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) { |
|
277 | 276 | $find = true; |
278 | 277 | $timestamp = $matches[0]; |
279 | 278 | if ($matches[4] == 'h') { |
@@ -286,17 +285,17 @@ discard block |
||
286 | 285 | // This work or not ? |
287 | 286 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
288 | 287 | } |
289 | - $body_parse = substr($body_parse,7); |
|
288 | + $body_parse = substr($body_parse, 7); |
|
290 | 289 | $result['timestamp'] = $timestamp; |
291 | 290 | } |
292 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
|
291 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) { |
|
293 | 292 | $find = true; |
294 | 293 | $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
295 | - $body_parse = substr($body_parse,8); |
|
294 | + $body_parse = substr($body_parse, 8); |
|
296 | 295 | $result['timestamp'] = $timestamp; |
297 | 296 | } |
298 | 297 | //if (strlen($body_parse) > 19) { |
299 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
298 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) { |
|
300 | 299 | $find = true; |
301 | 300 | // 4658.70N/00707.78Ez |
302 | 301 | $sind = strtoupper($matches[3]); |
@@ -318,11 +317,11 @@ discard block |
||
318 | 317 | */ |
319 | 318 | $latitude = $lat + floatval($lat_min)/60; |
320 | 319 | $longitude = $lon + floatval($lon_min)/60; |
321 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
322 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
320 | + if ($sind == 'S') $latitude = 0 - $latitude; |
|
321 | + if ($wind == 'W') $longitude = 0 - $longitude; |
|
323 | 322 | $result['latitude'] = $latitude; |
324 | 323 | $result['longitude'] = $longitude; |
325 | - $body_parse = substr($body_parse,18); |
|
324 | + $body_parse = substr($body_parse, 18); |
|
326 | 325 | $body_parse_len = strlen($body_parse); |
327 | 326 | } |
328 | 327 | $body_parse_len = strlen($body_parse); |
@@ -349,22 +348,22 @@ discard block |
||
349 | 348 | //' |
350 | 349 | //if ($type != ';' && $type != '>') { |
351 | 350 | if ($type != '') { |
352 | - $body_parse = substr($body_parse,1); |
|
351 | + $body_parse = substr($body_parse, 1); |
|
353 | 352 | $body_parse_len = strlen($body_parse); |
354 | 353 | $result['symbol_code'] = $symbol_code; |
355 | 354 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
356 | 355 | if ($symbol_code != '_') { |
357 | 356 | } |
358 | 357 | if ($body_parse_len >= 7) { |
359 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
360 | - $course = substr($body_parse,0,3); |
|
358 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) { |
|
359 | + $course = substr($body_parse, 0, 3); |
|
361 | 360 | $tmp_s = intval($course); |
362 | 361 | if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
363 | - $speed = substr($body_parse,4,3); |
|
362 | + $speed = substr($body_parse, 4, 3); |
|
364 | 363 | if ($speed != '...') { |
365 | 364 | $result['speed'] = intval($speed); |
366 | 365 | } |
367 | - $body_parse = substr($body_parse,7); |
|
366 | + $body_parse = substr($body_parse, 7); |
|
368 | 367 | } |
369 | 368 | // Check PHGR, PHG, RNG |
370 | 369 | } |
@@ -374,11 +373,11 @@ discard block |
||
374 | 373 | } |
375 | 374 | */ |
376 | 375 | if (strlen($body_parse) > 0) { |
377 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
376 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) { |
|
378 | 377 | $altitude = intval($matches[1]); |
379 | 378 | $result['altitude'] = $altitude; |
380 | 379 | //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
381 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
380 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse)); |
|
382 | 381 | } |
383 | 382 | } |
384 | 383 | // Telemetry |
@@ -388,58 +387,58 @@ discard block |
||
388 | 387 | } |
389 | 388 | */ |
390 | 389 | // DAO |
391 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
390 | + if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) { |
|
392 | 391 | $dao = $matches[1]; |
393 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
392 | + if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) { |
|
394 | 393 | $dao_split = str_split($dao); |
395 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
396 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
394 | + $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0; |
|
395 | + $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0; |
|
397 | 396 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
398 | 397 | else $result['latitude'] += $lat_off; |
399 | 398 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
400 | 399 | else $result['longitude'] += $lon_off; |
401 | 400 | } |
402 | - $body_parse = substr($body_parse,6); |
|
401 | + $body_parse = substr($body_parse, 6); |
|
403 | 402 | } |
404 | - if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
405 | - $result['ident'] = str_replace('_',' ',$matches[1]); |
|
403 | + if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) { |
|
404 | + $result['ident'] = str_replace('_', ' ', $matches[1]); |
|
406 | 405 | } |
407 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
406 | + if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) { |
|
408 | 407 | $result['squawk'] = $matches[1]; |
409 | 408 | } |
410 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
409 | + if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) { |
|
411 | 410 | $result['aircraft_icao'] = $matches[1]; |
412 | 411 | } |
413 | - if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { |
|
412 | + if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) { |
|
414 | 413 | $result['verticalrate'] = $matches[1]; |
415 | 414 | } |
416 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
415 | + if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) { |
|
417 | 416 | $result['typeid'] = $matches[1]; |
418 | 417 | } |
419 | - if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { |
|
418 | + if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) { |
|
420 | 419 | $result['statusid'] = $matches[1]; |
421 | 420 | } |
422 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
421 | + if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) { |
|
423 | 422 | $result['imo'] = $matches[1]; |
424 | 423 | } |
425 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
424 | + if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) { |
|
426 | 425 | $result['arrival_date'] = $matches[1]; |
427 | 426 | } |
428 | - if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { |
|
429 | - $result['arrival_code'] = str_replace('_',' ',$matches[1]); |
|
427 | + if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) { |
|
428 | + $result['arrival_code'] = str_replace('_', ' ', $matches[1]); |
|
430 | 429 | } |
431 | 430 | // OGN comment |
432 | 431 | //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
433 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
432 | + if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) { |
|
434 | 433 | $id = $matches[1]; |
435 | 434 | //$mode = substr($id,0,2); |
436 | - $address = substr($id,2); |
|
437 | - $addressType = (intval(substr($id,0,2),16))&3; |
|
435 | + $address = substr($id, 2); |
|
436 | + $addressType = (intval(substr($id, 0, 2), 16))&3; |
|
438 | 437 | if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
439 | 438 | elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
440 | 439 | elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
441 | 440 | elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
442 | - $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
|
441 | + $aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2); |
|
443 | 442 | $result['aircrafttype_code'] = $aircraftType; |
444 | 443 | if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
445 | 444 | elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
@@ -456,110 +455,110 @@ discard block |
||
456 | 455 | elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
457 | 456 | elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
458 | 457 | elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
459 | - $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
|
458 | + $stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0; |
|
460 | 459 | $result['stealth'] = $stealth; |
461 | 460 | $result['address'] = $address; |
462 | 461 | } |
463 | 462 | //Comment |
464 | 463 | $result['comment'] = trim($body_parse); |
465 | 464 | // parse weather |
466 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
465 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
467 | 466 | $result['wind_dir'] = intval($matches[1]); |
468 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
469 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
470 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
471 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
472 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
467 | + $result['wind_speed'] = round(intval($matches[2])*1.60934, 1); |
|
468 | + $result['wind_gust'] = round(intval($matches[3])*1.60934, 1); |
|
469 | + $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1); |
|
470 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
471 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
473 | 472 | $result['wind_dir'] = intval($matches[1]); |
474 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
475 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
476 | - $result['temp'] = round(5/9*(($matches[4])-32),1); |
|
477 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
478 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
473 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
474 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
475 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); |
|
476 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
477 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
479 | 478 | $result['wind_dir'] = intval($matches[1]); |
480 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
481 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
482 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
483 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
479 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
480 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
481 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
482 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) { |
|
484 | 483 | $result['wind_dir'] = intval($matches[1]); |
485 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
486 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
487 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
484 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
485 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
486 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
488 | 487 | } |
489 | 488 | // temperature |
490 | 489 | //g012t088r000p000P000h38b10110 |
491 | 490 | //g011t086r000p000P000h29b10198 |
492 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
493 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
494 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
495 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
496 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
497 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
491 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
492 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
493 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
494 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
495 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
496 | + if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1); |
|
498 | 497 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
499 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
500 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
501 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
502 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
503 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
504 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
505 | - if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1); |
|
506 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
498 | + if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1); |
|
499 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
500 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
501 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
502 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
503 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
504 | + if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1); |
|
505 | + if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1); |
|
507 | 506 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
508 | - if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1); |
|
509 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
510 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
511 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
512 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
513 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
514 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
515 | - if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1); |
|
507 | + if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1); |
|
508 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
509 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { |
|
510 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
511 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
512 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
513 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
514 | + if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1); |
|
516 | 515 | if ($matches[7] != '...') $result['humidity'] = intval($matches[7]); |
517 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
518 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
519 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
520 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
521 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
522 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
523 | - if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1); |
|
516 | + if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1); |
|
517 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
518 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { |
|
519 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
520 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
521 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
522 | + if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1); |
|
524 | 523 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
525 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
526 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
527 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) { |
|
528 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
529 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
530 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
531 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
524 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
525 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
526 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) { |
|
527 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
528 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
529 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
530 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
532 | 531 | if ($matches[6] != '...') $result['humidity'] = intval($matches[6]); |
533 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
534 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
535 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
536 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
537 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
538 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
539 | - if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1); |
|
532 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
533 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
534 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
535 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
536 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
537 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
538 | + if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1); |
|
540 | 539 | if ($matches[5] != '...') $result['humidity'] = intval($matches[5]); |
541 | - if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1); |
|
542 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
543 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
544 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
545 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
540 | + if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1); |
|
541 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
542 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
543 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
544 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
546 | 545 | if ($matches[2] != '...') $result['humidity'] = intval($matches[3]); |
547 | - if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1); |
|
548 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
549 | - } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) { |
|
550 | - if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1); |
|
551 | - if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1); |
|
552 | - if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1); |
|
546 | + if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1); |
|
547 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
548 | + } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) { |
|
549 | + if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1); |
|
550 | + if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1); |
|
551 | + if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1); |
|
553 | 552 | if ($matches[4] != '...') $result['humidity'] = intval($matches[4]); |
554 | - if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1); |
|
555 | - $body_parse = substr($body_parse,strlen($matches[0])); |
|
553 | + if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1); |
|
554 | + $body_parse = substr($body_parse, strlen($matches[0])); |
|
556 | 555 | } |
557 | 556 | $result['comment'] = trim($body_parse); |
558 | 557 | } |
559 | 558 | } else $result['comment'] = trim($body_parse); |
560 | 559 | } |
561 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
562 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
560 | + if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4); |
|
561 | + if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4); |
|
563 | 562 | if ($debug) print_r($result); |
564 | 563 | return $result; |
565 | 564 | } |
@@ -568,34 +567,34 @@ discard block |
||
568 | 567 | * Connect to APRS server |
569 | 568 | */ |
570 | 569 | public function connect() { |
571 | - global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
570 | + global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
572 | 571 | $aprs_connect = 0; |
573 | 572 | $aprs_keep = 120; |
574 | 573 | $aprs_last_tx = time(); |
575 | 574 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
576 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
575 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
577 | 576 | if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
578 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
577 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
579 | 578 | if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
580 | 579 | else $aprs_pass = '-1'; |
581 | - $aprs_filter = ''; |
|
580 | + $aprs_filter = ''; |
|
582 | 581 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
583 | 582 | $Common = new Common(); |
584 | - $s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr); |
|
583 | + $s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr); |
|
585 | 584 | if ($s !== false) { |
586 | 585 | echo 'Connected to APRS server! '."\n"; |
587 | 586 | $authstart = time(); |
588 | 587 | $this->socket = $s; |
589 | - $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
|
590 | - socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); |
|
591 | - while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
|
588 | + $send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0); |
|
589 | + socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1); |
|
590 | + while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) { |
|
592 | 591 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
593 | 592 | echo 'APRS user verified !'."\n"; |
594 | 593 | $this->connected = true; |
595 | 594 | return true; |
596 | 595 | break; |
597 | 596 | } |
598 | - if (time()-$authstart > 5) { |
|
597 | + if (time() - $authstart > 5) { |
|
599 | 598 | echo 'APRS timeout'."\n"; |
600 | 599 | break; |
601 | 600 | } |
@@ -617,7 +616,7 @@ discard block |
||
617 | 616 | public function send($data) { |
618 | 617 | global $globalDebug; |
619 | 618 | if ($this->connected === false) $this->connect(); |
620 | - $send = socket_send( $this->socket , $data , strlen($data),0); |
|
619 | + $send = socket_send($this->socket, $data, strlen($data), 0); |
|
621 | 620 | if ($send === FALSE) { |
622 | 621 | if ($globalDebug) echo 'Reconnect...'; |
623 | 622 | socket_close($this->socket); |
@@ -627,17 +626,17 @@ discard block |
||
627 | 626 | } |
628 | 627 | |
629 | 628 | class APRSSpotter extends APRS { |
630 | - public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) { |
|
629 | + public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) { |
|
631 | 630 | $Common = new Common(); |
632 | 631 | date_default_timezone_set('UTC'); |
633 | 632 | if ($latitude != '' && $longitude != '') { |
634 | 633 | $lat = $latitude; |
635 | 634 | $long = $longitude; |
636 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
637 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
638 | - $coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
639 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
640 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
635 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
636 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
637 | + $coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
638 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
639 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
641 | 640 | $w = $w1.$w2; |
642 | 641 | //$w = '00'; |
643 | 642 | $custom = ''; |
@@ -664,26 +663,26 @@ discard block |
||
664 | 663 | $geoid= round($GeoidClass->get($lat,$long)*3.28084,2); |
665 | 664 | $altitude_real = round($altitude_real + $geoid); |
666 | 665 | */ |
667 | - $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
666 | + $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
668 | 667 | } |
669 | 668 | } |
670 | 669 | } |
671 | 670 | class APRSMarine extends APRS { |
672 | - public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) { |
|
671 | + public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) { |
|
673 | 672 | $Common = new Common(); |
674 | 673 | date_default_timezone_set('UTC'); |
675 | 674 | if ($latitude != '' && $longitude != '') { |
676 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
677 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
678 | - $coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
679 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
680 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
675 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
676 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
677 | + $coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
678 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
679 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
681 | 680 | $w = $w1.$w2; |
682 | 681 | //$w = '00'; |
683 | 682 | $custom = ''; |
684 | 683 | if ($ident != '') { |
685 | 684 | if ($custom != '') $custom .= '/'; |
686 | - $custom .= 'CS='.str_replace(' ','_',$ident); |
|
685 | + $custom .= 'CS='.str_replace(' ', '_', $ident); |
|
687 | 686 | } |
688 | 687 | if ($typeid != '') { |
689 | 688 | if ($custom != '') $custom .= '/'; |
@@ -703,11 +702,11 @@ discard block |
||
703 | 702 | } |
704 | 703 | if ($arrival_code != '') { |
705 | 704 | if ($custom != '') $custom .= '/'; |
706 | - $custom .= 'AC='.str_replace(' ','_',$arrival_code); |
|
705 | + $custom .= 'AC='.str_replace(' ', '_', $arrival_code); |
|
707 | 706 | } |
708 | 707 | if ($custom != '') $custom = ' '.$custom; |
709 | 708 | $altitude = 0; |
710 | - $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
709 | + $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
711 | 710 | } |
712 | 711 | } |
713 | 712 | } |
@@ -26,22 +26,22 @@ discard block |
||
26 | 26 | * @param Array $filter the filter |
27 | 27 | * @return Array the SQL part |
28 | 28 | */ |
29 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
29 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
30 | 30 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
31 | 31 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
32 | 32 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
33 | - foreach($globalStatsFilters[$globalFilterName] as $source) { |
|
33 | + foreach ($globalStatsFilters[$globalFilterName] as $source) { |
|
34 | 34 | if (isset($source['source'])) $filter['source'][] = $source['source']; |
35 | 35 | } |
36 | 36 | } else { |
37 | 37 | $filter = $globalStatsFilters[$globalFilterName]; |
38 | 38 | } |
39 | 39 | } |
40 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
40 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
41 | 41 | $filter_query_join = ''; |
42 | 42 | $filter_query_where = ''; |
43 | 43 | if (isset($filter['source']) && !empty($filter['source'])) { |
44 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
44 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
45 | 45 | } |
46 | 46 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
47 | 47 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | try { |
61 | 61 | $sth = $this->db->prepare($query); |
62 | 62 | $sth->execute($query_values); |
63 | - } catch(PDOException $e) { |
|
63 | + } catch (PDOException $e) { |
|
64 | 64 | return "error : ".$e->getMessage(); |
65 | 65 | } |
66 | 66 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | * @return Array Return ATC |
74 | 74 | */ |
75 | 75 | public function getById($id) { |
76 | - $filter_query = $this->getFilter(array(),true,true); |
|
76 | + $filter_query = $this->getFilter(array(), true, true); |
|
77 | 77 | $query = "SELECT * FROM atc".$filter_query." atc_id = :id"; |
78 | 78 | $query_values = array(':id' => $id); |
79 | 79 | try { |
80 | 80 | $sth = $this->db->prepare($query); |
81 | 81 | $sth->execute($query_values); |
82 | - } catch(PDOException $e) { |
|
82 | + } catch (PDOException $e) { |
|
83 | 83 | return "error : ".$e->getMessage(); |
84 | 84 | } |
85 | 85 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -92,19 +92,19 @@ discard block |
||
92 | 92 | * @param String $format_source Format source |
93 | 93 | * @return Array Return ATC |
94 | 94 | */ |
95 | - public function getByIdent($ident,$format_source = '') { |
|
96 | - $filter_query = $this->getFilter(array(),true,true); |
|
95 | + public function getByIdent($ident, $format_source = '') { |
|
96 | + $filter_query = $this->getFilter(array(), true, true); |
|
97 | 97 | if ($format_source == '') { |
98 | 98 | $query = "SELECT * FROM atc".$filter_query." ident = :ident"; |
99 | 99 | $query_values = array(':ident' => $ident); |
100 | 100 | } else { |
101 | 101 | $query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source"; |
102 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
102 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
103 | 103 | } |
104 | 104 | try { |
105 | 105 | $sth = $this->db->prepare($query); |
106 | 106 | $sth->execute($query_values); |
107 | - } catch(PDOException $e) { |
|
107 | + } catch (PDOException $e) { |
|
108 | 108 | return "error : ".$e->getMessage(); |
109 | 109 | } |
110 | 110 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -126,18 +126,18 @@ discard block |
||
126 | 126 | * @param String $format_source Format source |
127 | 127 | * @param String $source_name Source name |
128 | 128 | */ |
129 | - public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
130 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
131 | - $info = str_replace('^','<br />',$info); |
|
132 | - $info = str_replace('&sect;','',$info); |
|
133 | - $info = str_replace('"','',$info); |
|
129 | + public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
130 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
131 | + $info = str_replace('^', '<br />', $info); |
|
132 | + $info = str_replace('&sect;', '', $info); |
|
133 | + $info = str_replace('"', '', $info); |
|
134 | 134 | if ($type == '') $type = NULL; |
135 | 135 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
136 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
136 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
137 | 137 | try { |
138 | 138 | $sth = $this->db->prepare($query); |
139 | 139 | $sth->execute($query_values); |
140 | - } catch(PDOException $e) { |
|
140 | + } catch (PDOException $e) { |
|
141 | 141 | return "error : ".$e->getMessage(); |
142 | 142 | } |
143 | 143 | } |
@@ -157,18 +157,18 @@ discard block |
||
157 | 157 | * @param String $format_source Format source |
158 | 158 | * @param String $source_name Source name |
159 | 159 | */ |
160 | - public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
161 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
162 | - $info = str_replace('^','<br />',$info); |
|
163 | - $info = str_replace('&sect;','',$info); |
|
164 | - $info = str_replace('"','',$info); |
|
160 | + public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
161 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
162 | + $info = str_replace('^', '<br />', $info); |
|
163 | + $info = str_replace('&sect;', '', $info); |
|
164 | + $info = str_replace('"', '', $info); |
|
165 | 165 | if ($type == '') $type = NULL; |
166 | 166 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
167 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
167 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
168 | 168 | try { |
169 | 169 | $sth = $this->db->prepare($query); |
170 | 170 | $sth->execute($query_values); |
171 | - } catch(PDOException $e) { |
|
171 | + } catch (PDOException $e) { |
|
172 | 172 | return "error : ".$e->getMessage(); |
173 | 173 | } |
174 | 174 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | try { |
184 | 184 | $sth = $this->db->prepare($query); |
185 | 185 | $sth->execute($query_values); |
186 | - } catch(PDOException $e) { |
|
186 | + } catch (PDOException $e) { |
|
187 | 187 | return "error : ".$e->getMessage(); |
188 | 188 | } |
189 | 189 | } |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | * @param String $ident Flight ident |
194 | 194 | * @param String $format_source Format source |
195 | 195 | */ |
196 | - public function deleteByIdent($ident,$format_source) { |
|
196 | + public function deleteByIdent($ident, $format_source) { |
|
197 | 197 | $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source"; |
198 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
198 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
199 | 199 | try { |
200 | 200 | $sth = $this->db->prepare($query); |
201 | 201 | $sth->execute($query_values); |
202 | - } catch(PDOException $e) { |
|
202 | + } catch (PDOException $e) { |
|
203 | 203 | return "error : ".$e->getMessage(); |
204 | 204 | } |
205 | 205 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | try { |
214 | 214 | $sth = $this->db->prepare($query); |
215 | 215 | $sth->execute($query_values); |
216 | - } catch(PDOException $e) { |
|
216 | + } catch (PDOException $e) { |
|
217 | 217 | return "error : ".$e->getMessage(); |
218 | 218 | } |
219 | 219 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | try { |
232 | 232 | $sth = $this->db->prepare($query); |
233 | 233 | $sth->execute(); |
234 | - } catch(PDOException $e) { |
|
234 | + } catch (PDOException $e) { |
|
235 | 235 | return "error"; |
236 | 236 | } |
237 | 237 | return "success"; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /* |
22 | 22 | * Initialize DB connection |
23 | 23 | */ |
24 | - public function __construct($dbc = null,$fromACARSscript = false) { |
|
24 | + public function __construct($dbc = null, $fromACARSscript = false) { |
|
25 | 25 | $Connection = new Connection($dbc); |
26 | 26 | $this->db = $Connection->db(); |
27 | 27 | if ($this->db === null) die('Error: No DB connection. (ACARS)'); |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | * @return String the icao |
39 | 39 | */ |
40 | 40 | public function ident2icao($ident) { |
41 | - if (substr($ident,0,2) == 'AF') { |
|
42 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
43 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
41 | + if (substr($ident, 0, 2) == 'AF') { |
|
42 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
43 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
44 | 44 | } else { |
45 | 45 | $Spotter = new Spotter($this->db); |
46 | - $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
|
46 | + $identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2)); |
|
47 | 47 | if (isset($identicao[0])) { |
48 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
48 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
49 | 49 | } else $icao = $ident; |
50 | 50 | } |
51 | 51 | return $icao; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | $sth = $this->db->prepare($query); |
71 | 71 | $sth->execute(); |
72 | - } catch(PDOException $e) { |
|
72 | + } catch (PDOException $e) { |
|
73 | 73 | return "error"; |
74 | 74 | } |
75 | 75 | return "success"; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | $sth = $this->db->prepare($query); |
95 | 95 | $sth->execute(); |
96 | - } catch(PDOException $e) { |
|
96 | + } catch (PDOException $e) { |
|
97 | 97 | return "error"; |
98 | 98 | } |
99 | 99 | return "success"; |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | $ident = ''; |
119 | 119 | $message = ''; |
120 | 120 | $result = array(); |
121 | - $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
122 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
123 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
124 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
121 | + $n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
122 | + if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
123 | + if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
124 | + if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
125 | 125 | if ($n != 0) { |
126 | - $registration = str_replace('.','',$registration); |
|
127 | - $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
|
126 | + $registration = str_replace('.', '', $registration); |
|
127 | + $result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message); |
|
128 | 128 | if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
129 | 129 | } else $message = $data; |
130 | 130 | $decode = array(); |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | $temp = ''; |
145 | 145 | $n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp); |
146 | 146 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
147 | - $latitude = $la / 10000.0; |
|
148 | - $longitude = $ln / 10000.0; |
|
147 | + $latitude = $la/10000.0; |
|
148 | + $longitude = $ln/10000.0; |
|
149 | 149 | if ($lac == 'S') $latitude = '-'.$latitude; |
150 | 150 | if ($lnc == 'W') $longitude = '-'.$longitude; |
151 | 151 | // Temp not always available |
152 | 152 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
153 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
154 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
153 | + if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt); |
|
154 | + else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C'); |
|
155 | 155 | |
156 | 156 | //$icao = $Translation->checkTranslation($ident); |
157 | 157 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -163,19 +163,19 @@ discard block |
||
163 | 163 | $dhour = ''; |
164 | 164 | $darr = ''; |
165 | 165 | $ahour = ''; |
166 | - $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
|
166 | + $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour); |
|
167 | 167 | if ($n == 4 && strlen($darr) == 4) { |
168 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
169 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
170 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
168 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
169 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
170 | + if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n"; |
|
171 | 171 | //$icao = ACARS->ident2icao($ident); |
172 | 172 | //$icao = $Translation->checkTranslation($ident); |
173 | 173 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
174 | 174 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
175 | 175 | $found = true; |
176 | 176 | } |
177 | - elseif ($n == 2 || $n == 4) { |
|
178 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
177 | + elseif ($n == 2 || $n == 4) { |
|
178 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
179 | 179 | if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
180 | 180 | //$icao = ACARS->ident2icao($ident); |
181 | 181 | //$icao = $Translation->checkTranslation($ident); |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | $ahour = ''; |
234 | 234 | $aair = ''; |
235 | 235 | $apiste = ''; |
236 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
|
236 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste); |
|
237 | 237 | if ($n > 8) { |
238 | - if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
239 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
240 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
238 | + if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
239 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
240 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
241 | 241 | $icao = trim($aident); |
242 | 242 | |
243 | 243 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
263 | 263 | $las = $las.'.'.$lass; |
264 | 264 | $lns = $lns.'.'.$lns; |
265 | - $latitude = $las / 1000.0; |
|
266 | - $longitude = $lns / 1000.0; |
|
265 | + $latitude = $las/1000.0; |
|
266 | + $longitude = $lns/1000.0; |
|
267 | 267 | if ($lac == 'S') $latitude = '-'.$latitude; |
268 | 268 | if ($lnc == 'W') $longitude = '-'.$longitude; |
269 | 269 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
@@ -358,17 +358,17 @@ discard block |
||
358 | 358 | $alt = ''; |
359 | 359 | $fuel = ''; |
360 | 360 | $speed = ''; |
361 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
361 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
362 | 362 | if ($n == 9) { |
363 | 363 | //if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
364 | 364 | $icao = trim($aident); |
365 | 365 | $decode['icao'] = $icao; |
366 | - $latitude = $las / 100.0; |
|
367 | - $longitude = $lns / 100.0; |
|
366 | + $latitude = $las/100.0; |
|
367 | + $longitude = $lns/100.0; |
|
368 | 368 | if ($lac == 'S') $latitude = '-'.$latitude; |
369 | 369 | if ($lnc == 'W') $longitude = '-'.$longitude; |
370 | 370 | |
371 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
|
371 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed); |
|
372 | 372 | $found = true; |
373 | 373 | } |
374 | 374 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | if ($lac == 'S') $latitude = '-'.$latitude; |
388 | 388 | if ($lnc == 'W') $longitude = '-'.$longitude; |
389 | 389 | |
390 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
|
390 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
|
391 | 391 | $found = true; |
392 | 392 | } |
393 | 393 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | $dair = ''; |
421 | 421 | $darr = ''; |
422 | 422 | $aident = ''; |
423 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
423 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
424 | 424 | if ($n == 8) { |
425 | 425 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
426 | 426 | $icao = trim($aident); |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | */ |
453 | 453 | $dair = ''; |
454 | 454 | $darr = ''; |
455 | - $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
|
455 | + $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr); |
|
456 | 456 | if ($n == 3) { |
457 | 457 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
458 | 458 | //$icao = $Translation->checkTranslation($ident); |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | */ |
468 | 468 | $dair = ''; |
469 | 469 | $darr = ''; |
470 | - $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
|
470 | + $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr); |
|
471 | 471 | if ($n == 3) { |
472 | 472 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
473 | 473 | //$icao = $Translation->checkTranslation($ident); |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | } |
478 | 478 | } |
479 | 479 | if (!$found) { |
480 | - $n = sscanf($message,'MET01%4c',$airport); |
|
480 | + $n = sscanf($message, 'MET01%4c', $airport); |
|
481 | 481 | if ($n == 1) { |
482 | 482 | if ($globalDebug) echo 'airport name : '.$airport; |
483 | 483 | $decode = array('Airport/Waypoint name' => $airport); |
@@ -485,241 +485,241 @@ discard block |
||
485 | 485 | } |
486 | 486 | } |
487 | 487 | if ($label == 'H1') { |
488 | - if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
|
489 | - $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
|
488 | + if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) { |
|
489 | + $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode); |
|
490 | 490 | } |
491 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
492 | - $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
|
491 | + elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) { |
|
492 | + $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode); |
|
493 | 493 | } |
494 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
495 | - $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
|
494 | + elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) { |
|
495 | + $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode); |
|
496 | 496 | } |
497 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
498 | - $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
|
497 | + elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) { |
|
498 | + $decode = array_merge(array('Message nature' => 'Weather observation'), $decode); |
|
499 | 499 | } |
500 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
501 | - $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
|
500 | + elseif (preg_match(':^#DFB/PIREP:', $message)) { |
|
501 | + $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode); |
|
502 | 502 | } |
503 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
504 | - $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
|
503 | + elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) { |
|
504 | + $decode = array_merge(array('Message nature' => 'Engine Data'), $decode); |
|
505 | 505 | } |
506 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
507 | - $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
|
506 | + elseif (preg_match(':^#M1AAEP:', $message)) { |
|
507 | + $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode); |
|
508 | 508 | } |
509 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
510 | - $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
|
509 | + elseif (preg_match(':^#M2APWD:', $message)) { |
|
510 | + $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode); |
|
511 | 511 | } |
512 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
513 | - $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
|
512 | + elseif (preg_match(':^#M1BREQPWI:', $message)) { |
|
513 | + $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode); |
|
514 | 514 | } |
515 | - elseif (preg_match(':^#CF:',$message)) { |
|
516 | - $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
|
515 | + elseif (preg_match(':^#CF:', $message)) { |
|
516 | + $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode); |
|
517 | 517 | } |
518 | - elseif (preg_match(':^#DF:',$message)) { |
|
519 | - $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
|
518 | + elseif (preg_match(':^#DF:', $message)) { |
|
519 | + $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode); |
|
520 | 520 | } |
521 | - elseif (preg_match(':^#EC:',$message)) { |
|
522 | - $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
|
521 | + elseif (preg_match(':^#EC:', $message)) { |
|
522 | + $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode); |
|
523 | 523 | } |
524 | - elseif (preg_match(':^#EI:',$message)) { |
|
525 | - $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
|
524 | + elseif (preg_match(':^#EI:', $message)) { |
|
525 | + $decode = array_merge(array('Message nature' => 'Engine Report'), $decode); |
|
526 | 526 | } |
527 | - elseif (preg_match(':^#H1:',$message)) { |
|
528 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
|
527 | + elseif (preg_match(':^#H1:', $message)) { |
|
528 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode); |
|
529 | 529 | } |
530 | - elseif (preg_match(':^#H2:',$message)) { |
|
531 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
|
530 | + elseif (preg_match(':^#H2:', $message)) { |
|
531 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode); |
|
532 | 532 | } |
533 | - elseif (preg_match(':^#HD:',$message)) { |
|
534 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
|
533 | + elseif (preg_match(':^#HD:', $message)) { |
|
534 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode); |
|
535 | 535 | } |
536 | - elseif (preg_match(':^#M1:',$message)) { |
|
537 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
|
536 | + elseif (preg_match(':^#M1:', $message)) { |
|
537 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode); |
|
538 | 538 | } |
539 | - elseif (preg_match(':^#M2:',$message)) { |
|
540 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
|
539 | + elseif (preg_match(':^#M2:', $message)) { |
|
540 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode); |
|
541 | 541 | } |
542 | - elseif (preg_match(':^#M3:',$message)) { |
|
543 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
|
542 | + elseif (preg_match(':^#M3:', $message)) { |
|
543 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode); |
|
544 | 544 | } |
545 | - elseif (preg_match(':^#MD:',$message)) { |
|
546 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
|
545 | + elseif (preg_match(':^#MD:', $message)) { |
|
546 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode); |
|
547 | 547 | } |
548 | - elseif (preg_match(':^#PS:',$message)) { |
|
549 | - $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
|
548 | + elseif (preg_match(':^#PS:', $message)) { |
|
549 | + $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode); |
|
550 | 550 | } |
551 | - elseif (preg_match(':^#S1:',$message)) { |
|
552 | - $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
|
551 | + elseif (preg_match(':^#S1:', $message)) { |
|
552 | + $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode); |
|
553 | 553 | } |
554 | - elseif (preg_match(':^#S2:',$message)) { |
|
555 | - $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
|
554 | + elseif (preg_match(':^#S2:', $message)) { |
|
555 | + $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode); |
|
556 | 556 | } |
557 | - elseif (preg_match(':^#SD:',$message)) { |
|
558 | - $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
|
557 | + elseif (preg_match(':^#SD:', $message)) { |
|
558 | + $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode); |
|
559 | 559 | } |
560 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
561 | - $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
|
560 | + elseif (preg_match(':^#T[0-8]:', $message)) { |
|
561 | + $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode); |
|
562 | 562 | } |
563 | - elseif (preg_match(':^#WO:',$message)) { |
|
564 | - $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
|
563 | + elseif (preg_match(':^#WO:', $message)) { |
|
564 | + $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode); |
|
565 | 565 | } |
566 | - elseif (preg_match(':^#A1:',$message)) { |
|
567 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
|
566 | + elseif (preg_match(':^#A1:', $message)) { |
|
567 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode); |
|
568 | 568 | } |
569 | - elseif (preg_match(':^#A3:',$message)) { |
|
570 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
|
569 | + elseif (preg_match(':^#A3:', $message)) { |
|
570 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode); |
|
571 | 571 | } |
572 | - elseif (preg_match(':^#A4:',$message)) { |
|
573 | - $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
|
572 | + elseif (preg_match(':^#A4:', $message)) { |
|
573 | + $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode); |
|
574 | 574 | } |
575 | - elseif (preg_match(':^#A6:',$message)) { |
|
576 | - $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
|
575 | + elseif (preg_match(':^#A6:', $message)) { |
|
576 | + $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode); |
|
577 | 577 | } |
578 | - elseif (preg_match(':^#A8:',$message)) { |
|
579 | - $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
|
578 | + elseif (preg_match(':^#A8:', $message)) { |
|
579 | + $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode); |
|
580 | 580 | } |
581 | - elseif (preg_match(':^#A9:',$message)) { |
|
582 | - $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
|
581 | + elseif (preg_match(':^#A9:', $message)) { |
|
582 | + $decode = array_merge(array('Message nature' => 'ATIS report'), $decode); |
|
583 | 583 | } |
584 | - elseif (preg_match(':^#A0:',$message)) { |
|
585 | - $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
|
584 | + elseif (preg_match(':^#A0:', $message)) { |
|
585 | + $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode); |
|
586 | 586 | } |
587 | - elseif (preg_match(':^#AA:',$message)) { |
|
588 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
587 | + elseif (preg_match(':^#AA:', $message)) { |
|
588 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
589 | 589 | } |
590 | - elseif (preg_match(':^#AB:',$message)) { |
|
591 | - $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
|
590 | + elseif (preg_match(':^#AB:', $message)) { |
|
591 | + $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode); |
|
592 | 592 | } |
593 | - elseif (preg_match(':^#AC:',$message)) { |
|
594 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
|
593 | + elseif (preg_match(':^#AC:', $message)) { |
|
594 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode); |
|
595 | 595 | } |
596 | - elseif (preg_match(':^#AD:',$message)) { |
|
597 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
|
596 | + elseif (preg_match(':^#AD:', $message)) { |
|
597 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode); |
|
598 | 598 | } |
599 | - elseif (preg_match(':^#AF:',$message)) { |
|
600 | - $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
|
599 | + elseif (preg_match(':^#AF:', $message)) { |
|
600 | + $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode); |
|
601 | 601 | } |
602 | - elseif (preg_match(':^#B1:',$message)) { |
|
603 | - $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
|
602 | + elseif (preg_match(':^#B1:', $message)) { |
|
603 | + $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode); |
|
604 | 604 | } |
605 | - elseif (preg_match(':^#B2:',$message)) { |
|
606 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
|
605 | + elseif (preg_match(':^#B2:', $message)) { |
|
606 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode); |
|
607 | 607 | } |
608 | - elseif (preg_match(':^#B3:',$message)) { |
|
609 | - $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
|
608 | + elseif (preg_match(':^#B3:', $message)) { |
|
609 | + $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode); |
|
610 | 610 | } |
611 | - elseif (preg_match(':^#B4:',$message)) { |
|
612 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
|
611 | + elseif (preg_match(':^#B4:', $message)) { |
|
612 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode); |
|
613 | 613 | } |
614 | - elseif (preg_match(':^#B6:',$message)) { |
|
615 | - $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
|
614 | + elseif (preg_match(':^#B6:', $message)) { |
|
615 | + $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode); |
|
616 | 616 | } |
617 | - elseif (preg_match(':^#B8:',$message)) { |
|
618 | - $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
|
617 | + elseif (preg_match(':^#B8:', $message)) { |
|
618 | + $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode); |
|
619 | 619 | } |
620 | - elseif (preg_match(':^#B9:',$message)) { |
|
621 | - $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
|
620 | + elseif (preg_match(':^#B9:', $message)) { |
|
621 | + $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode); |
|
622 | 622 | } |
623 | - elseif (preg_match(':^#B0:',$message)) { |
|
624 | - $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
|
623 | + elseif (preg_match(':^#B0:', $message)) { |
|
624 | + $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode); |
|
625 | 625 | } |
626 | - elseif (preg_match(':^#BA:',$message)) { |
|
627 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
626 | + elseif (preg_match(':^#BA:', $message)) { |
|
627 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
628 | 628 | } |
629 | - elseif (preg_match(':^#BB:',$message)) { |
|
630 | - $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
|
629 | + elseif (preg_match(':^#BB:', $message)) { |
|
630 | + $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode); |
|
631 | 631 | } |
632 | - elseif (preg_match(':^#BC:',$message)) { |
|
633 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
|
632 | + elseif (preg_match(':^#BC:', $message)) { |
|
633 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode); |
|
634 | 634 | } |
635 | - elseif (preg_match(':^#BD:',$message)) { |
|
636 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
|
635 | + elseif (preg_match(':^#BD:', $message)) { |
|
636 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode); |
|
637 | 637 | } |
638 | - elseif (preg_match(':^#BE:',$message)) { |
|
639 | - $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
|
638 | + elseif (preg_match(':^#BE:', $message)) { |
|
639 | + $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode); |
|
640 | 640 | } |
641 | - elseif (preg_match(':^#BF:',$message)) { |
|
642 | - $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
|
641 | + elseif (preg_match(':^#BF:', $message)) { |
|
642 | + $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode); |
|
643 | 643 | } |
644 | - elseif (preg_match(':^#H3:',$message)) { |
|
645 | - $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
|
644 | + elseif (preg_match(':^#H3:', $message)) { |
|
645 | + $decode = array_merge(array('Message nature' => 'Icing Report'), $decode); |
|
646 | 646 | } |
647 | 647 | } |
648 | 648 | if ($label == '10') { |
649 | - if (preg_match(':^DTO01:',$message)) { |
|
650 | - $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
|
649 | + if (preg_match(':^DTO01:', $message)) { |
|
650 | + $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode); |
|
651 | 651 | } |
652 | - elseif (preg_match(':^AIS01:',$message)) { |
|
653 | - $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
|
652 | + elseif (preg_match(':^AIS01:', $message)) { |
|
653 | + $decode = array_merge(array('Message nature' => 'AIS Request'), $decode); |
|
654 | 654 | } |
655 | - elseif (preg_match(':^FTX01:',$message)) { |
|
656 | - $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
|
655 | + elseif (preg_match(':^FTX01:', $message)) { |
|
656 | + $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode); |
|
657 | 657 | } |
658 | - elseif (preg_match(':^FPL01:',$message)) { |
|
659 | - $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
|
658 | + elseif (preg_match(':^FPL01:', $message)) { |
|
659 | + $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode); |
|
660 | 660 | } |
661 | - elseif (preg_match(':^WAB01:',$message)) { |
|
662 | - $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
|
661 | + elseif (preg_match(':^WAB01:', $message)) { |
|
662 | + $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode); |
|
663 | 663 | } |
664 | - elseif (preg_match(':^MET01:',$message)) { |
|
665 | - $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
|
664 | + elseif (preg_match(':^MET01:', $message)) { |
|
665 | + $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode); |
|
666 | 666 | } |
667 | - elseif (preg_match(':^WAB02:',$message)) { |
|
668 | - $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
|
667 | + elseif (preg_match(':^WAB02:', $message)) { |
|
668 | + $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode); |
|
669 | 669 | } |
670 | 670 | } |
671 | 671 | if ($label == '15') { |
672 | - if (preg_match(':^FST01:',$message)) { |
|
673 | - $decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode); |
|
672 | + if (preg_match(':^FST01:', $message)) { |
|
673 | + $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode); |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | if (!$found && $label == 'SA') { |
677 | - $n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at); |
|
677 | + $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at); |
|
678 | 678 | if ($n == 4) { |
679 | 679 | $vsta = array('Version' => $version); |
680 | 680 | if ($state == 'E') { |
681 | - $vsta = array_merge($vsta,array('Link state' => 'Established')); |
|
681 | + $vsta = array_merge($vsta, array('Link state' => 'Established')); |
|
682 | 682 | } |
683 | 683 | elseif ($state == 'L') { |
684 | - $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
|
684 | + $vsta = array_merge($vsta, array('Link state' => 'Lost')); |
|
685 | 685 | } |
686 | 686 | else { |
687 | - $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
|
687 | + $vsta = array_merge($vsta, array('Link state' => 'Unknown')); |
|
688 | 688 | } |
689 | 689 | if ($type == 'V') { |
690 | - $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
|
690 | + $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS')); |
|
691 | 691 | } |
692 | 692 | elseif ($type == 'S') { |
693 | - $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
|
693 | + $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM')); |
|
694 | 694 | } |
695 | 695 | elseif ($type == 'H') { |
696 | - $vsta = array_merge($vsta,array('Link type' => 'HF')); |
|
696 | + $vsta = array_merge($vsta, array('Link type' => 'HF')); |
|
697 | 697 | } |
698 | 698 | elseif ($type == 'G') { |
699 | - $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
|
699 | + $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM')); |
|
700 | 700 | } |
701 | 701 | elseif ($type == 'C') { |
702 | - $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
|
702 | + $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM')); |
|
703 | 703 | } |
704 | 704 | elseif ($type == '2') { |
705 | - $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
|
705 | + $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2')); |
|
706 | 706 | } |
707 | 707 | elseif ($type == 'X') { |
708 | - $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
|
708 | + $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero')); |
|
709 | 709 | } |
710 | 710 | elseif ($type == 'I') { |
711 | - $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
|
711 | + $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM')); |
|
712 | 712 | } |
713 | 713 | else { |
714 | - $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
|
714 | + $vsta = array_merge($vsta, array('Link type' => 'Unknown')); |
|
715 | 715 | } |
716 | - $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
|
717 | - $decode = array_merge($vsta,$decode); |
|
716 | + $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2)))); |
|
717 | + $decode = array_merge($vsta, $decode); |
|
718 | 718 | } |
719 | 719 | } |
720 | 720 | |
721 | 721 | $title = $this->getTitlefromLabel($label); |
722 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
722 | + if ($title != '') $decode = array_merge(array('Message title' => $title), $decode); |
|
723 | 723 | /* |
724 | 724 | // Business jets always use GS0001 |
725 | 725 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -747,13 +747,13 @@ discard block |
||
747 | 747 | $Translation = new Translation($this->db); |
748 | 748 | $message = $this->parse($data); |
749 | 749 | if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') { |
750 | - $ident = (string)$message['ident']; |
|
750 | + $ident = (string) $message['ident']; |
|
751 | 751 | $label = $message['label']; |
752 | 752 | $block_id = $message['block_id']; |
753 | 753 | $msg_no = $message['msg_no']; |
754 | 754 | $msg = $message['message']; |
755 | 755 | $decode = $message['decode']; |
756 | - $registration = (string)$message['registration']; |
|
756 | + $registration = (string) $message['registration']; |
|
757 | 757 | if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
758 | 758 | else $latitude = ''; |
759 | 759 | if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
@@ -767,20 +767,20 @@ discard block |
||
767 | 767 | $Image->addSpotterImage($registration); |
768 | 768 | } |
769 | 769 | // Business jets always use GS0001 |
770 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
770 | + if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude); |
|
771 | 771 | if ($globalDebug && isset($info) && $info != '') echo $info; |
772 | 772 | if (count($decode) > 0) $decode_json = json_encode($decode); |
773 | 773 | else $decode_json = ''; |
774 | 774 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
775 | - $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
|
775 | + $Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS'); |
|
776 | 776 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
777 | - $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
|
777 | + $Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS'); |
|
778 | 778 | } |
779 | - $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
780 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
781 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
779 | + $result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
780 | + if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F'); |
|
781 | + if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
782 | 782 | if ($globalDebug && count($decode) > 0) { |
783 | - echo "Human readable data : ".implode(' - ',$decode)."\n"; |
|
783 | + echo "Human readable data : ".implode(' - ', $decode)."\n"; |
|
784 | 784 | } |
785 | 785 | } |
786 | 786 | } |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | * @param String $msg_no Number of the ACARS message |
796 | 796 | * @param String $message ACARS message |
797 | 797 | */ |
798 | - public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
798 | + public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
799 | 799 | global $globalDebug; |
800 | 800 | date_default_timezone_set('UTC'); |
801 | 801 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
@@ -803,21 +803,21 @@ discard block |
||
803 | 803 | $this->db = $Connection->db; |
804 | 804 | if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
805 | 805 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
806 | - $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
|
806 | + $query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message); |
|
807 | 807 | try { |
808 | 808 | $stht = $this->db->prepare($query_test); |
809 | 809 | $stht->execute($query_test_values); |
810 | - } catch(PDOException $e) { |
|
810 | + } catch (PDOException $e) { |
|
811 | 811 | return "error : ".$e->getMessage(); |
812 | 812 | } |
813 | 813 | if ($stht->fetchColumn() == 0) { |
814 | 814 | if ($globalDebug) echo "Add Live ACARS data..."; |
815 | 815 | $query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)"; |
816 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
|
816 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s")); |
|
817 | 817 | try { |
818 | 818 | $sth = $this->db->prepare($query); |
819 | 819 | $sth->execute($query_values); |
820 | - } catch(PDOException $e) { |
|
820 | + } catch (PDOException $e) { |
|
821 | 821 | return "error : ".$e->getMessage(); |
822 | 822 | } |
823 | 823 | } else { |
@@ -839,10 +839,10 @@ discard block |
||
839 | 839 | * @param String $msg_no Number of the ACARS message |
840 | 840 | * @param String $message ACARS message |
841 | 841 | */ |
842 | - public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
842 | + public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
843 | 843 | global $globalDebug; |
844 | 844 | date_default_timezone_set('UTC'); |
845 | - if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) { |
|
845 | + if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) { |
|
846 | 846 | /* |
847 | 847 | if ($globalDebug) echo "Test if not already in Archive ACARS table..."; |
848 | 848 | $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message"; |
@@ -857,11 +857,11 @@ discard block |
||
857 | 857 | */ |
858 | 858 | if ($globalDebug) echo "Add Live ACARS data..."; |
859 | 859 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
860 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
860 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
861 | 861 | try { |
862 | 862 | $sth = $this->db->prepare($query); |
863 | 863 | $sth->execute($query_values); |
864 | - } catch(PDOException $e) { |
|
864 | + } catch (PDOException $e) { |
|
865 | 865 | return "error : ".$e->getMessage(); |
866 | 866 | } |
867 | 867 | if ($globalDebug) echo "Done\n"; |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | try { |
883 | 883 | $sth = $this->db->prepare($query); |
884 | 884 | $sth->execute($query_values); |
885 | - } catch(PDOException $e) { |
|
885 | + } catch (PDOException $e) { |
|
886 | 886 | echo "error : ".$e->getMessage(); |
887 | 887 | return ''; |
888 | 888 | } |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | try { |
903 | 903 | $sth = $this->db->prepare($query); |
904 | 904 | $sth->execute($query_values); |
905 | - } catch(PDOException $e) { |
|
905 | + } catch (PDOException $e) { |
|
906 | 906 | echo "error : ".$e->getMessage(); |
907 | 907 | return array(); |
908 | 908 | } |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | try { |
924 | 924 | $sth = $this->db->prepare($query); |
925 | 925 | $sth->execute($query_values); |
926 | - } catch(PDOException $e) { |
|
926 | + } catch (PDOException $e) { |
|
927 | 927 | echo "error : ".$e->getMessage(); |
928 | 928 | return array(); |
929 | 929 | } |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | * |
938 | 938 | * @return Array Return ACARS data in array |
939 | 939 | */ |
940 | - public function getLatestAcarsData($limit = '',$label = '') { |
|
940 | + public function getLatestAcarsData($limit = '', $label = '') { |
|
941 | 941 | global $globalURL, $globalDBdriver; |
942 | 942 | $Image = new Image($this->db); |
943 | 943 | $Spotter = new Spotter($this->db); |
@@ -948,8 +948,8 @@ discard block |
||
948 | 948 | if ($limit != "") |
949 | 949 | { |
950 | 950 | $limit_array = explode(",", $limit); |
951 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
952 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
951 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
952 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
953 | 953 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
954 | 954 | { |
955 | 955 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -965,46 +965,46 @@ discard block |
||
965 | 965 | try { |
966 | 966 | $sth = $this->db->prepare($query); |
967 | 967 | $sth->execute($query_values); |
968 | - } catch(PDOException $e) { |
|
968 | + } catch (PDOException $e) { |
|
969 | 969 | return "error : ".$e->getMessage(); |
970 | 970 | } |
971 | 971 | $i = 0; |
972 | 972 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
973 | 973 | $data = array(); |
974 | 974 | if ($row['registration'] != '') { |
975 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
975 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
976 | 976 | $image_array = $Image->getSpotterImage($row['registration']); |
977 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
978 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
979 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
977 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
978 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
979 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
980 | 980 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
981 | 981 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
982 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
982 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
983 | 983 | if (isset($identicao[0])) { |
984 | - if (substr($row['ident'],0,2) == 'AF') { |
|
985 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
986 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
987 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
988 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
984 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
985 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
986 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
987 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
988 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
989 | 989 | } else $icao = $row['ident']; |
990 | - $icao = $Translation->checkTranslation($icao,false); |
|
991 | - $decode = json_decode($row['decode'],true); |
|
990 | + $icao = $Translation->checkTranslation($icao, false); |
|
991 | + $decode = json_decode($row['decode'], true); |
|
992 | 992 | $found = false; |
993 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
993 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
994 | 994 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
995 | 995 | if (isset($airport_info[0]['icao'])) { |
996 | 996 | $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
997 | 997 | $found = true; |
998 | 998 | } |
999 | 999 | } |
1000 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1000 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1001 | 1001 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1002 | 1002 | if (isset($airport_info[0]['icao'])) { |
1003 | 1003 | $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1004 | 1004 | $found = true; |
1005 | 1005 | } |
1006 | 1006 | } |
1007 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1007 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1008 | 1008 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1009 | 1009 | if (isset($airport_info[0]['icao'])) { |
1010 | 1010 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | } |
1013 | 1013 | } |
1014 | 1014 | if ($found) $row['decode'] = json_encode($decode); |
1015 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1015 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1016 | 1016 | $result[] = $data; |
1017 | 1017 | $i++; |
1018 | 1018 | } |
@@ -1028,7 +1028,7 @@ discard block |
||
1028 | 1028 | * |
1029 | 1029 | * @return Array Return ACARS data in array |
1030 | 1030 | */ |
1031 | - public function getArchiveAcarsData($limit = '',$label = '') { |
|
1031 | + public function getArchiveAcarsData($limit = '', $label = '') { |
|
1032 | 1032 | global $globalURL, $globalDBdriver; |
1033 | 1033 | $Image = new Image($this->db); |
1034 | 1034 | $Spotter = new Spotter($this->db); |
@@ -1038,8 +1038,8 @@ discard block |
||
1038 | 1038 | if ($limit != "") |
1039 | 1039 | { |
1040 | 1040 | $limit_array = explode(",", $limit); |
1041 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1042 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1042 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1043 | 1043 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1044 | 1044 | { |
1045 | 1045 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1060,43 +1060,43 @@ discard block |
||
1060 | 1060 | try { |
1061 | 1061 | $sth = $this->db->prepare($query); |
1062 | 1062 | $sth->execute($query_values); |
1063 | - } catch(PDOException $e) { |
|
1063 | + } catch (PDOException $e) { |
|
1064 | 1064 | return "error : ".$e->getMessage(); |
1065 | 1065 | } |
1066 | - $i=0; |
|
1066 | + $i = 0; |
|
1067 | 1067 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
1068 | 1068 | $data = array(); |
1069 | 1069 | if ($row['registration'] != '') { |
1070 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
1070 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
1071 | 1071 | $image_array = $Image->getSpotterImage($row['registration']); |
1072 | - if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
1073 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1074 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1072 | + if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
1073 | + else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1074 | + } else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1075 | 1075 | $icao = ''; |
1076 | 1076 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
1077 | 1077 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
1078 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
1078 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
1079 | 1079 | if (isset($identicao[0])) { |
1080 | - if (substr($row['ident'],0,2) == 'AF') { |
|
1081 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1082 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1083 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1084 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
1080 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
1081 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1082 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
1083 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
1084 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
1085 | 1085 | } else $icao = $row['ident']; |
1086 | 1086 | $icao = $Translation->checkTranslation($icao); |
1087 | - $decode = json_decode($row['decode'],true); |
|
1087 | + $decode = json_decode($row['decode'], true); |
|
1088 | 1088 | $found = false; |
1089 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
1089 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
1090 | 1090 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1091 | 1091 | if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1092 | 1092 | $found = true; |
1093 | 1093 | } |
1094 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1094 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1095 | 1095 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1096 | 1096 | if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1097 | 1097 | $found = true; |
1098 | 1098 | } |
1099 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1099 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1100 | 1100 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1101 | 1101 | if (isset($airport_info[0]['icao'])) { |
1102 | 1102 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1104,7 +1104,7 @@ discard block |
||
1104 | 1104 | } |
1105 | 1105 | } |
1106 | 1106 | if ($found) $row['decode'] = json_encode($decode); |
1107 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1107 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1108 | 1108 | $result[] = $data; |
1109 | 1109 | $i++; |
1110 | 1110 | } |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | * @param String $icao |
1123 | 1123 | * @param String $ICAOTypeCode |
1124 | 1124 | */ |
1125 | - public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
|
1125 | + public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') { |
|
1126 | 1126 | global $globalDebug, $globalDBdriver; |
1127 | 1127 | $ident = trim($ident); |
1128 | 1128 | $Translation = new Translation($this->db); |
@@ -1135,7 +1135,7 @@ discard block |
||
1135 | 1135 | if ($globalDebug) echo "Ident or registration null, exit\n"; |
1136 | 1136 | return ''; |
1137 | 1137 | } |
1138 | - $registration = str_replace('.','',$registration); |
|
1138 | + $registration = str_replace('.', '', $registration); |
|
1139 | 1139 | $ident = $Translation->ident2icao($ident); |
1140 | 1140 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1141 | 1141 | if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | try { |
1145 | 1145 | $sthsi = $this->db->prepare($querysi); |
1146 | 1146 | $sthsi->execute($querysi_values); |
1147 | - } catch(PDOException $e) { |
|
1147 | + } catch (PDOException $e) { |
|
1148 | 1148 | if ($globalDebug) echo $e->getMessage(); |
1149 | 1149 | return "error : ".$e->getMessage(); |
1150 | 1150 | } |
@@ -1154,8 +1154,8 @@ discard block |
||
1154 | 1154 | $Translation = new Translation($this->db); |
1155 | 1155 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1156 | 1156 | if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
1157 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1158 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1157 | + if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1158 | + elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1159 | 1159 | } else { |
1160 | 1160 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1161 | 1161 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | try { |
1164 | 1164 | $sth = $this->db->prepare($query); |
1165 | 1165 | $sth->execute($query_values); |
1166 | - } catch(PDOException $e) { |
|
1166 | + } catch (PDOException $e) { |
|
1167 | 1167 | if ($globalDebug) echo $e->getMessage(); |
1168 | 1168 | return "error : ".$e->getMessage(); |
1169 | 1169 | } |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | $sth->closeCursor(); |
1172 | 1172 | if (isset($result['modes'])) $hex = $result['modes']; |
1173 | 1173 | else $hex = ''; |
1174 | - $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
|
1174 | + $SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS'); |
|
1175 | 1175 | if ($this->fromACARSscript) $this->SI->add($SI_data); |
1176 | 1176 | } |
1177 | 1177 | } |
@@ -1181,7 +1181,7 @@ discard block |
||
1181 | 1181 | try { |
1182 | 1182 | $sth = $this->db->prepare($query); |
1183 | 1183 | $sth->execute($query_values); |
1184 | - } catch(PDOException $e) { |
|
1184 | + } catch (PDOException $e) { |
|
1185 | 1185 | if ($globalDebug) echo $e->getMessage(); |
1186 | 1186 | return "error : ".$e->getMessage(); |
1187 | 1187 | } |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
1192 | 1192 | else $ModeS = ''; |
1193 | 1193 | if ($ModeS == '') { |
1194 | - $id = explode('-',$result['flightaware_id']); |
|
1194 | + $id = explode('-', $result['flightaware_id']); |
|
1195 | 1195 | $ModeS = $id[0]; |
1196 | 1196 | } |
1197 | 1197 | if ($ModeS != '') { |
@@ -1201,20 +1201,20 @@ discard block |
||
1201 | 1201 | try { |
1202 | 1202 | $sthc = $this->db->prepare($queryc); |
1203 | 1203 | $sthc->execute($queryc_values); |
1204 | - } catch(PDOException $e) { |
|
1204 | + } catch (PDOException $e) { |
|
1205 | 1205 | if ($globalDebug) echo $e->getMessage(); |
1206 | 1206 | return "error : ".$e->getMessage(); |
1207 | 1207 | } |
1208 | 1208 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1209 | 1209 | $sthc->closeCursor(); |
1210 | - if (count($row) == 0) { |
|
1210 | + if (count($row) == 0) { |
|
1211 | 1211 | if ($globalDebug) echo " Add to ModeS table - "; |
1212 | 1212 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1213 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1213 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1214 | 1214 | try { |
1215 | 1215 | $sthi = $this->db->prepare($queryi); |
1216 | 1216 | $sthi->execute($queryi_values); |
1217 | - } catch(PDOException $e) { |
|
1217 | + } catch (PDOException $e) { |
|
1218 | 1218 | if ($globalDebug) echo $e->getMessage(); |
1219 | 1219 | return "error : ".$e->getMessage(); |
1220 | 1220 | } |
@@ -1222,15 +1222,15 @@ discard block |
||
1222 | 1222 | if ($globalDebug) echo " Update ModeS table - "; |
1223 | 1223 | if ($ICAOTypeCode != '') { |
1224 | 1224 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1225 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1225 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1226 | 1226 | } else { |
1227 | 1227 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1228 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration); |
|
1228 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration); |
|
1229 | 1229 | } |
1230 | 1230 | try { |
1231 | 1231 | $sthi = $this->db->prepare($queryi); |
1232 | 1232 | $sthi->execute($queryi_values); |
1233 | - } catch(PDOException $e) { |
|
1233 | + } catch (PDOException $e) { |
|
1234 | 1234 | if ($globalDebug) echo $e->getMessage(); |
1235 | 1235 | return "error : ".$e->getMessage(); |
1236 | 1236 | } |
@@ -1267,12 +1267,12 @@ discard block |
||
1267 | 1267 | elseif ($globalDBdriver == 'pgsql') { |
1268 | 1268 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1269 | 1269 | } |
1270 | - $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
|
1270 | + $queryi_values = array(':Registration' => $registration, ':ident' => $icao); |
|
1271 | 1271 | } |
1272 | 1272 | try { |
1273 | 1273 | $sthi = $this->db->prepare($queryi); |
1274 | 1274 | $sthi->execute($queryi_values); |
1275 | - } catch(PDOException $e) { |
|
1275 | + } catch (PDOException $e) { |
|
1276 | 1276 | if ($globalDebug) echo $e->getMessage(); |
1277 | 1277 | return "error : ".$e->getMessage(); |
1278 | 1278 | } |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | |
4 | -class Connection{ |
|
4 | +class Connection { |
|
5 | 5 | public $db = null; |
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 50; |
8 | 8 | |
9 | - public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
|
9 | + public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) { |
|
10 | 10 | global $globalNoDB; |
11 | 11 | if (isset($globalNoDB) && $globalNoDB === TRUE) { |
12 | 12 | $this->db = null; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | if ($user === null && $pass === null) { |
17 | 17 | $this->createDBConnection(); |
18 | 18 | } else { |
19 | - $this->createDBConnection(null,$user,$pass); |
|
19 | + $this->createDBConnection(null, $user, $pass); |
|
20 | 20 | } |
21 | 21 | } else { |
22 | 22 | $this->createDBConnection($dbname); |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | while (true) { |
101 | 101 | try { |
102 | 102 | if ($globalDBSdriver == 'mysql') { |
103 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
103 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
104 | 104 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
105 | 105 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
106 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
107 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
108 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
109 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
110 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
106 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
107 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500); |
|
108 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
109 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
110 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
111 | 111 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
112 | 112 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
113 | 113 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -117,19 +117,19 @@ discard block |
||
117 | 117 | $this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"'); |
118 | 118 | //$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"'); |
119 | 119 | } else { |
120 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
120 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
121 | 121 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
122 | 122 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
123 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
124 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
125 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
126 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
127 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
123 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
124 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
125 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
126 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
127 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
128 | 128 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
129 | 129 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
130 | 130 | } |
131 | 131 | break; |
132 | - } catch(PDOException $e) { |
|
132 | + } catch (PDOException $e) { |
|
133 | 133 | $i++; |
134 | 134 | if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
135 | 135 | //exit; |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | try { |
155 | 155 | //$Connection = new Connection(); |
156 | 156 | $results = $this->db->query($query); |
157 | - } catch(PDOException $e) { |
|
157 | + } catch (PDOException $e) { |
|
158 | 158 | return false; |
159 | 159 | } |
160 | - if($results->rowCount()>0) { |
|
160 | + if ($results->rowCount() > 0) { |
|
161 | 161 | return true; |
162 | 162 | } |
163 | 163 | else return false; |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | |
182 | - } catch(PDOException $e) { |
|
183 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
182 | + } catch (PDOException $e) { |
|
183 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
184 | 184 | throw $e; |
185 | 185 | } |
186 | 186 | //echo 'error ! '.$e->getMessage(); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | /* |
193 | 193 | * Check if index exist |
194 | 194 | */ |
195 | - public function indexExists($table,$index) |
|
195 | + public function indexExists($table, $index) |
|
196 | 196 | { |
197 | 197 | global $globalDBdriver, $globalDBname; |
198 | 198 | if ($globalDBdriver == 'mysql') { |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | try { |
204 | 204 | //$Connection = new Connection(); |
205 | 205 | $results = $this->db->query($query); |
206 | - } catch(PDOException $e) { |
|
206 | + } catch (PDOException $e) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
210 | - if($nb[0]['nb'] > 0) { |
|
210 | + if ($nb[0]['nb'] > 0) { |
|
211 | 211 | return true; |
212 | 212 | } |
213 | 213 | else return false; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
223 | 223 | try { |
224 | 224 | $results = $this->db->query($query); |
225 | - } catch(PDOException $e) { |
|
225 | + } catch (PDOException $e) { |
|
226 | 226 | return "error : ".$e->getMessage()."\n"; |
227 | 227 | } |
228 | 228 | $columns = array(); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | return $columns; |
235 | 235 | } |
236 | 236 | |
237 | - public function getColumnType($table,$column) { |
|
237 | + public function getColumnType($table, $column) { |
|
238 | 238 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
239 | 239 | $tomet = $select->getColumnMeta(0); |
240 | 240 | return $tomet['native_type']; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * Check if a column name exist in a table |
245 | 245 | * @return Boolean column exist or not |
246 | 246 | */ |
247 | - public function checkColumnName($table,$name) |
|
247 | + public function checkColumnName($table, $name) |
|
248 | 248 | { |
249 | 249 | global $globalDBdriver, $globalDBname; |
250 | 250 | if ($globalDBdriver == 'mysql') { |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | } |
255 | 255 | try { |
256 | 256 | $sth = $this->db()->prepare($query); |
257 | - $sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name)); |
|
258 | - } catch(PDOException $e) { |
|
257 | + $sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name)); |
|
258 | + } catch (PDOException $e) { |
|
259 | 259 | echo "error : ".$e->getMessage()."\n"; |
260 | 260 | } |
261 | 261 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | try { |
295 | 295 | $sth = $this->db->prepare($query); |
296 | 296 | $sth->execute(); |
297 | - } catch(PDOException $e) { |
|
297 | + } catch (PDOException $e) { |
|
298 | 298 | return "error : ".$e->getMessage()."\n"; |
299 | 299 | } |
300 | 300 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -18,82 +18,82 @@ discard block |
||
18 | 18 | public function parse($buffer) { |
19 | 19 | // Not yet finished, no CRC checks |
20 | 20 | $data = array(); |
21 | - $typehex = substr($buffer,0,1); |
|
22 | - if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1); |
|
23 | - elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13); |
|
24 | - else $hex = substr($buffer,1,-1); |
|
25 | - $bin = gmp_strval( gmp_init($hex,16), 2); |
|
21 | + $typehex = substr($buffer, 0, 1); |
|
22 | + if ($typehex == '*' || $typehex == ':') $hex = substr($buffer, 1, -1); |
|
23 | + elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer, 13, -13); |
|
24 | + else $hex = substr($buffer, 1, -1); |
|
25 | + $bin = gmp_strval(gmp_init($hex, 16), 2); |
|
26 | 26 | //if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) { |
27 | 27 | if (strlen($hex) == 28) { |
28 | - $df = intval(substr($bin,0,5),2); |
|
28 | + $df = intval(substr($bin, 0, 5), 2); |
|
29 | 29 | //$ca = intval(substr($bin,5,3),2); |
30 | 30 | // Only support DF17 for now |
31 | 31 | //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) { |
32 | - if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) { |
|
33 | - $icao = substr($hex,2,6); |
|
32 | + if (($df == 17 || $df == 18) && ($this->parityCheck($hex, $bin) || $typehex == '@')) { |
|
33 | + $icao = substr($hex, 2, 6); |
|
34 | 34 | $data['hex'] = $icao; |
35 | - $tc = intval(substr($bin,32,5),2); |
|
35 | + $tc = intval(substr($bin, 32, 5), 2); |
|
36 | 36 | if ($tc >= 1 && $tc <= 4) { |
37 | 37 | //callsign |
38 | - $csbin = substr($bin,40,56); |
|
38 | + $csbin = substr($bin, 40, 56); |
|
39 | 39 | $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######'); |
40 | 40 | $cs = ''; |
41 | - $cs .= $charset[intval(substr($csbin,0,6),2)]; |
|
42 | - $cs .= $charset[intval(substr($csbin,6,6),2)]; |
|
43 | - $cs .= $charset[intval(substr($csbin,12,6),2)]; |
|
44 | - $cs .= $charset[intval(substr($csbin,18,6),2)]; |
|
45 | - $cs .= $charset[intval(substr($csbin,24,6),2)]; |
|
46 | - $cs .= $charset[intval(substr($csbin,30,6),2)]; |
|
47 | - $cs .= $charset[intval(substr($csbin,36,6),2)]; |
|
48 | - $cs .= $charset[intval(substr($csbin,42,6),2)]; |
|
49 | - $cs = str_replace('_','',$cs); |
|
50 | - $cs = str_replace('#','',$cs); |
|
41 | + $cs .= $charset[intval(substr($csbin, 0, 6), 2)]; |
|
42 | + $cs .= $charset[intval(substr($csbin, 6, 6), 2)]; |
|
43 | + $cs .= $charset[intval(substr($csbin, 12, 6), 2)]; |
|
44 | + $cs .= $charset[intval(substr($csbin, 18, 6), 2)]; |
|
45 | + $cs .= $charset[intval(substr($csbin, 24, 6), 2)]; |
|
46 | + $cs .= $charset[intval(substr($csbin, 30, 6), 2)]; |
|
47 | + $cs .= $charset[intval(substr($csbin, 36, 6), 2)]; |
|
48 | + $cs .= $charset[intval(substr($csbin, 42, 6), 2)]; |
|
49 | + $cs = str_replace('_', '', $cs); |
|
50 | + $cs = str_replace('#', '', $cs); |
|
51 | 51 | $callsign = $cs; |
52 | 52 | $data['ident'] = $callsign; |
53 | 53 | } elseif ($tc >= 9 && $tc <= 18) { |
54 | 54 | // Check Q-bit |
55 | - $q = substr($bin,47,1); |
|
55 | + $q = substr($bin, 47, 1); |
|
56 | 56 | if ($q) { |
57 | - $n = intval(substr($bin,40,7).substr($bin,48,4),2); |
|
58 | - $alt = $n*25-1000; |
|
57 | + $n = intval(substr($bin, 40, 7).substr($bin, 48, 4), 2); |
|
58 | + $alt = $n*25 - 1000; |
|
59 | 59 | $data['altitude'] = $alt; |
60 | 60 | } |
61 | 61 | // Check odd/even flag |
62 | - $oe = substr($bin,53,1); |
|
62 | + $oe = substr($bin, 53, 1); |
|
63 | 63 | //if ($oe) => odd else even |
64 | 64 | // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
65 | - $cprlat = intval(substr($bin,54,17),2)/131072.0; |
|
66 | - $cprlon = intval(substr($bin,71,17),2)/131072.0; |
|
67 | - if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
65 | + $cprlat = intval(substr($bin, 54, 17), 2)/131072.0; |
|
66 | + $cprlon = intval(substr($bin, 71, 17), 2)/131072.0; |
|
67 | + if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat, 'longitude' => $cprlon, 'created' => time()); |
|
68 | 68 | elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
69 | 69 | $cprlat_odd = $cprlat; |
70 | 70 | $cprlon_odd = $cprlon; |
71 | 71 | $cprlat_even = $this::$latlon[$icao]['latitude']; |
72 | 72 | $cprlon_even = $this::$latlon[$icao]['longitude']; |
73 | - $j = 59*$cprlat_even-60*$cprlat_odd+0.5; |
|
74 | - $lat_even = (360.0/60)*($j%60+$cprlat_even); |
|
75 | - $lat_odd = (360.0/59)*($j%59+$cprlat_odd); |
|
73 | + $j = 59*$cprlat_even - 60*$cprlat_odd + 0.5; |
|
74 | + $lat_even = (360.0/60)*($j%60 + $cprlat_even); |
|
75 | + $lat_odd = (360.0/59)*($j%59 + $cprlat_odd); |
|
76 | 76 | if ($lat_even >= 270) $lat_even = $lat_even - 360; |
77 | 77 | if ($lat_odd >= 270) $lat_odd = $lat_odd - 360; |
78 | 78 | // check latitude zone |
79 | 79 | if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) { |
80 | 80 | if ($this::$latlon[$icao]['created'] > time()) { |
81 | - $ni = $this->cprN($lat_even,0); |
|
82 | - $m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5); |
|
83 | - $lon = (360.0/$ni)*($m%$ni+$cprlon_even); |
|
81 | + $ni = $this->cprN($lat_even, 0); |
|
82 | + $m = floor($cprlon_even*($this->cprNL($lat_even) - 1) - $cprlon_odd*$this->cprNL($lat_even) + 0.5); |
|
83 | + $lon = (360.0/$ni)*($m%$ni + $cprlon_even); |
|
84 | 84 | $lat = $lat_even; |
85 | - if ($lon > 180) $lon = $lon -360; |
|
85 | + if ($lon > 180) $lon = $lon - 360; |
|
86 | 86 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
87 | 87 | //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
88 | 88 | $data['latitude'] = $lat; |
89 | 89 | $data['longitude'] = $lon; |
90 | 90 | } |
91 | 91 | } else { |
92 | - $ni = $this->cprN($lat_odd,1); |
|
93 | - $m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5); |
|
94 | - $lon = (360.0/$ni)*($m%$ni+$cprlon_odd); |
|
92 | + $ni = $this->cprN($lat_odd, 1); |
|
93 | + $m = floor($cprlon_even*($this->cprNL($lat_odd) - 1) - $cprlon_odd*$this->cprNL($lat_odd) + 0.5); |
|
94 | + $lon = (360.0/$ni)*($m%$ni + $cprlon_odd); |
|
95 | 95 | $lat = $lat_odd; |
96 | - if ($lon > 180) $lon = $lon -360; |
|
96 | + if ($lon > 180) $lon = $lon - 360; |
|
97 | 97 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
98 | 98 | //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
99 | 99 | $data['latitude'] = $lat; |
@@ -105,15 +105,15 @@ discard block |
||
105 | 105 | } |
106 | 106 | } elseif ($tc == 19) { |
107 | 107 | // speed & heading |
108 | - $v_ew_dir = intval(substr($bin,45,1)); |
|
109 | - $v_ew = intval(substr($bin,46,10),2); |
|
110 | - $v_ns_dir = intval(substr($bin,56,1)); |
|
111 | - $v_ns = intval(substr($bin,57,10),2); |
|
108 | + $v_ew_dir = intval(substr($bin, 45, 1)); |
|
109 | + $v_ew = intval(substr($bin, 46, 10), 2); |
|
110 | + $v_ns_dir = intval(substr($bin, 56, 1)); |
|
111 | + $v_ns = intval(substr($bin, 57, 10), 2); |
|
112 | 112 | if ($v_ew_dir) $v_ew = -1*$v_ew; |
113 | 113 | if ($v_ns_dir) $v_ns = -1*$v_ns; |
114 | - $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
|
115 | - $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
|
116 | - if ($heading <0) $heading = $heading+360; |
|
114 | + $speed = sqrt($v_ns*$v_ns + $v_ew*$v_ew); |
|
115 | + $heading = atan2($v_ew, $v_ns)*360.0/(2*pi()); |
|
116 | + if ($heading < 0) $heading = $heading + 360; |
|
117 | 117 | $data['speed'] = $speed; |
118 | 118 | $data['heading'] = $heading; |
119 | 119 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * Lookup table to convert the latitude to index. |
129 | 129 | */ |
130 | 130 | private function cprNL($lat) { |
131 | - if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
131 | + if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
132 | 132 | if ($lat < 10.47047130) return 59; |
133 | 133 | if ($lat < 14.82817437) return 58; |
134 | 134 | if ($lat < 18.18626357) return 57; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | return 1; |
191 | 191 | } |
192 | 192 | |
193 | - private function cprN($lat,$isodd) { |
|
193 | + private function cprN($lat, $isodd) { |
|
194 | 194 | $nl = $this->cprNL($lat) - $isodd; |
195 | 195 | if ($nl > 1) return $nl; |
196 | 196 | else return 1; |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000 |
215 | 215 | ); |
216 | 216 | $crc = 0; |
217 | - $checksum = intval(substr($msg,22,6),16); |
|
217 | + $checksum = intval(substr($msg, 22, 6), 16); |
|
218 | 218 | for ($j = 0; $j < strlen($bin); $j++) { |
219 | - if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
219 | + if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j], 0); |
|
220 | 220 | } |
221 | 221 | if ($crc == $checksum) return true; |
222 | 222 | else { |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | $msg['aircraftid'] = hexdec($data['address']); |
239 | 239 | $msg['hex'] = $data['address']; |
240 | 240 | $msg['flightid'] = hexdec($data['address']); |
241 | - $msg['date_gen'] = date('Y/m/d',$data['timestamp']); |
|
242 | - $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180'; |
|
243 | - $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
|
244 | - $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
|
241 | + $msg['date_gen'] = date('Y/m/d', $data['timestamp']); |
|
242 | + $msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180'; |
|
243 | + $msg['date_log'] = date('Y/m/d', $data['timestamp']); |
|
244 | + $msg['time_log'] = date('H:i:s', $data['timestamp']).'.180'; |
|
245 | 245 | $msg['callsign'] = $data['ident']; |
246 | 246 | $msg['altitude'] = ''; |
247 | 247 | $msg['speed'] = ''; |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $msg['emergency'] = ''; |
255 | 255 | $msg['SPI'] = ''; |
256 | 256 | $msg['ground'] = ''; |
257 | - $result[] = implode(',',$msg); |
|
257 | + $result[] = implode(',', $msg); |
|
258 | 258 | } |
259 | 259 | if (isset($data['latitude']) && $data['latitude'] != 0) { |
260 | 260 | $msg = array(); |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | $msg['aircraftid'] = hexdec($data['address']); |
265 | 265 | $msg['hex'] = $data['address']; |
266 | 266 | $msg['flightid'] = hexdec($data['address']); |
267 | - $msg['date_gen'] = date('Y/m/d',$data['timestamp']); |
|
268 | - $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180'; |
|
269 | - $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
|
270 | - $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
|
267 | + $msg['date_gen'] = date('Y/m/d', $data['timestamp']); |
|
268 | + $msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180'; |
|
269 | + $msg['date_log'] = date('Y/m/d', $data['timestamp']); |
|
270 | + $msg['time_log'] = date('H:i:s', $data['timestamp']).'.180'; |
|
271 | 271 | $msg['callsign'] = ''; |
272 | 272 | if (isset($data['altitude'])) $msg['altitude'] = $data['altitude']; |
273 | 273 | else $msg['altitude'] = ''; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $msg['SPI'] = 0; |
286 | 286 | if (isset($data['ground'])) $msg['ground'] = 1; |
287 | 287 | else $msg['ground'] = 0; |
288 | - $result[] = implode(',',$msg); |
|
288 | + $result[] = implode(',', $msg); |
|
289 | 289 | } |
290 | 290 | return $result; |
291 | 291 | } |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | $globalDebug = FALSE; |
71 | 71 | $dbroot = $_SESSION['database_root']; |
72 | 72 | $dbrootpass = $_SESSION['database_rootpass']; |
73 | - $error .= create_db::create_database($dbroot,$dbrootpass,$globalDBuser,$globalDBpass,$globalDBname,$globalDBdriver,$globalDBhost); |
|
73 | + $error .= create_db::create_database($dbroot, $dbrootpass, $globalDBuser, $globalDBpass, $globalDBname, $globalDBdriver, $globalDBhost); |
|
74 | 74 | sleep(5); |
75 | 75 | if ($error != '') { |
76 | 76 | $_SESSION['error'] = $error; |
77 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create database')); |
|
78 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database')); |
|
77 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Create database')); |
|
78 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Create database')); |
|
79 | 79 | $_SESSION['install'] = 'database_import'; |
80 | 80 | $_SESSION['next'] = 'Create and import tables'; |
81 | - $result = array('error' => $error,'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
81 | + $result = array('error' => $error, 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
82 | 82 | print json_encode($result); |
83 | 83 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'database_import') { |
84 | 84 | $globalDebug = FALSE; |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | } |
93 | 93 | if ($error != '') { |
94 | 94 | $_SESSION['error'] = $error; |
95 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
|
96 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables')); |
|
95 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Create and import tables')); |
|
96 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Create and import tables')); |
|
97 | 97 | if ($globalSBS1 && !$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
98 | 98 | $_SESSION['install'] = 'populate'; |
99 | 99 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B'; |
@@ -101,24 +101,24 @@ discard block |
||
101 | 101 | $_SESSION['install'] = 'sources'; |
102 | 102 | $_SESSION['next'] = 'Insert data in source table'; |
103 | 103 | } |
104 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
104 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
105 | 105 | print json_encode($result); |
106 | 106 | } elseif (!is_numeric($check_version)) { |
107 | 107 | $error .= $check_version; |
108 | 108 | $_SESSION['error'] = $error; |
109 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
|
109 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Create and import tables')); |
|
110 | 110 | if (!isset($_SESSION['next'])) $_SESSION['next'] = ''; |
111 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
111 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
112 | 112 | print json_encode($result); |
113 | 113 | } else { |
114 | 114 | $error .= update_schema::check_version(true); |
115 | 115 | if ($error != '') { |
116 | 116 | $_SESSION['error'] = $error; |
117 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Update schema if needed')); |
|
118 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed')); |
|
117 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Update schema if needed')); |
|
118 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Update schema if needed')); |
|
119 | 119 | $_SESSION['install'] = 'sources'; |
120 | 120 | $_SESSION['next'] = 'Insert data in source table'; |
121 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
121 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
122 | 122 | print json_encode($result); |
123 | 123 | } |
124 | 124 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'waypoints') { |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | $error .= update_db::update_waypoints(); |
128 | 128 | if ($error != '') { |
129 | 129 | $_SESSION['error'] = $error; |
130 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate waypoints database')); |
|
131 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database')); |
|
130 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate waypoints database')); |
|
131 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate waypoints database')); |
|
132 | 132 | /* |
133 | 133 | $_SESSION['install'] = 'airspace'; |
134 | 134 | $_SESSION['next'] = 'Populate airspace table'; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | $_SESSION['install'] = 'countries'; |
147 | 147 | $_SESSION['next'] = 'Populate countries table'; |
148 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
148 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
149 | 149 | print json_encode($result); |
150 | 150 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'countries') { |
151 | 151 | include_once('class.update_db.php'); |
@@ -153,12 +153,12 @@ discard block |
||
153 | 153 | $error .= update_db::update_countries(); |
154 | 154 | if ($error != '') { |
155 | 155 | $_SESSION['error'] = $error; |
156 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database')); |
|
157 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database')); |
|
156 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate countries database')); |
|
157 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate countries database')); |
|
158 | 158 | if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
159 | 159 | $_SESSION['install'] = 'notam'; |
160 | 160 | $_SESSION['next'] = 'Populate NOTAM table with externals data'; |
161 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
161 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
162 | 162 | print json_encode($result); |
163 | 163 | /* |
164 | 164 | } elseif (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) { |
@@ -171,15 +171,15 @@ discard block |
||
171 | 171 | } else { |
172 | 172 | $_SESSION['install'] = 'sources'; |
173 | 173 | $_SESSION['next'] = 'Insert data in source table'; |
174 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
174 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
175 | 175 | print json_encode($result); |
176 | 176 | } |
177 | 177 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'populate') { |
178 | 178 | if (!is_writable('tmp')) { |
179 | 179 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
180 | 180 | $_SESSION['error'] = $error; |
181 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
182 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
181 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for ADS-B')); |
|
182 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
183 | 183 | print json_encode($result); |
184 | 184 | } else { |
185 | 185 | include_once('class.update_db.php'); |
@@ -187,19 +187,19 @@ discard block |
||
187 | 187 | $error .= update_db::update_ModeS_fam(); |
188 | 188 | if ($error != '') { |
189 | 189 | $_SESSION['error'] = $error; |
190 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
191 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
190 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for ADS-B')); |
|
191 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate aircraft_modes table with externals data for ADS-B')); |
|
192 | 192 | $_SESSION['install'] = 'populate_flarm'; |
193 | 193 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for FLARM'; |
194 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
194 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
195 | 195 | print json_encode($result); |
196 | 196 | } |
197 | 197 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'populate_flarm') { |
198 | 198 | if (!is_writable('tmp')) { |
199 | 199 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
200 | 200 | $_SESSION['error'] = $error; |
201 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
202 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
201 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for FLARM')); |
|
202 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
203 | 203 | print json_encode($result); |
204 | 204 | } else { |
205 | 205 | include_once('class.update_db.php'); |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | $error .= update_db::update_ModeS_ogn(); |
209 | 209 | if ($error != '') { |
210 | 210 | $_SESSION['error'] = $error; |
211 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
212 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
211 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for FLARM')); |
|
212 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate aircraft_modes table with externals data for FLARM')); |
|
213 | 213 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
214 | 214 | $_SESSION['install'] = 'vatsim'; |
215 | 215 | if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
@@ -228,15 +228,15 @@ discard block |
||
228 | 228 | $_SESSION['install'] = 'routes'; |
229 | 229 | $_SESSION['next'] = 'Populate routes table with externals data'; |
230 | 230 | } |
231 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
231 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
232 | 232 | print json_encode($result); |
233 | 233 | } |
234 | 234 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'routes') { |
235 | 235 | if (!is_writable('tmp')) { |
236 | 236 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
237 | 237 | $_SESSION['error'] = $error; |
238 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
239 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
238 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate aircraft_modes table with externals data for ADS-B')); |
|
239 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
240 | 240 | print json_encode($result); |
241 | 241 | } else { |
242 | 242 | include_once('class.update_db.php'); |
@@ -244,19 +244,19 @@ discard block |
||
244 | 244 | $error .= update_db::update_routes_fam(); |
245 | 245 | if ($error != '') { |
246 | 246 | $_SESSION['error'] = $error; |
247 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate routes table with externals data')); |
|
248 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data')); |
|
247 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate routes table with externals data')); |
|
248 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate routes table with externals data')); |
|
249 | 249 | $_SESSION['install'] = 'translation'; |
250 | 250 | $_SESSION['next'] = 'Populate translation table with externals data'; |
251 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
251 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
252 | 252 | print json_encode($result); |
253 | 253 | } |
254 | 254 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'translation') { |
255 | 255 | if (!is_writable('tmp')) { |
256 | 256 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
257 | 257 | $_SESSION['error'] = $error; |
258 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data')); |
|
259 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
258 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate translation table with externals data')); |
|
259 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
260 | 260 | print json_encode($result); |
261 | 261 | } else { |
262 | 262 | include_once('class.update_db.php'); |
@@ -264,8 +264,8 @@ discard block |
||
264 | 264 | $error .= update_db::update_translation_fam(); |
265 | 265 | if ($error != '') { |
266 | 266 | $_SESSION['error'] = $error; |
267 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data')); |
|
268 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data')); |
|
267 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate translation table with externals data')); |
|
268 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate translation table with externals data')); |
|
269 | 269 | if ($_SESSION['waypoints'] == 1) { |
270 | 270 | $_SESSION['install'] = 'waypoints'; |
271 | 271 | $_SESSION['next'] = 'Populate waypoints table'; |
@@ -283,15 +283,15 @@ discard block |
||
283 | 283 | $_SESSION['install'] = 'sources'; |
284 | 284 | $_SESSION['next'] = 'Insert data in source table'; |
285 | 285 | } |
286 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
286 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
287 | 287 | print json_encode($result); |
288 | 288 | } |
289 | 289 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'owner') { |
290 | 290 | if (!is_writable('tmp')) { |
291 | 291 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
292 | 292 | $_SESSION['error'] = $error; |
293 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data')); |
|
294 | - $result = array('error' => $error,'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
293 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate owner table with externals data')); |
|
294 | + $result = array('error' => $error, 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
295 | 295 | print json_encode($result); |
296 | 296 | } else { |
297 | 297 | include_once('class.update_db.php'); |
@@ -299,19 +299,19 @@ discard block |
||
299 | 299 | $error = update_db::update_owner_fam(); |
300 | 300 | if ($error != '') { |
301 | 301 | $_SESSION['error'] = $error; |
302 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data')); |
|
303 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data')); |
|
302 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate owner table with externals data')); |
|
303 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate owner table with externals data')); |
|
304 | 304 | $_SESSION['install'] = 'sources'; |
305 | 305 | $_SESSION['next'] = 'Insert data in source table'; |
306 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
306 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
307 | 307 | print json_encode($result); |
308 | 308 | } |
309 | 309 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'notam') { |
310 | 310 | if (!is_writable('tmp')) { |
311 | 311 | $error = 'The directory <i>install/tmp</i> must be writable.'; |
312 | 312 | $_SESSION['error'] = $error; |
313 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data')); |
|
314 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
313 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate notam table with externals data')); |
|
314 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
315 | 315 | print json_encode($result); |
316 | 316 | } else { |
317 | 317 | include_once('class.update_db.php'); |
@@ -320,13 +320,13 @@ discard block |
||
320 | 320 | $error .= update_db::update_notam(); |
321 | 321 | if ($error != '') { |
322 | 322 | $_SESSION['error'] = $error; |
323 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data')); |
|
324 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data')); |
|
323 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate notam table with externals data')); |
|
324 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate notam table with externals data')); |
|
325 | 325 | } else { |
326 | 326 | if ($error != '') { |
327 | 327 | $_SESSION['error'] = $error; |
328 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data (no source defined)')); |
|
329 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)')); |
|
328 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Populate notam table with externals data (no source defined)')); |
|
329 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Populate notam table with externals data (no source defined)')); |
|
330 | 330 | } |
331 | 331 | /* |
332 | 332 | if (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) { |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | $_SESSION['install'] = 'sources'; |
341 | 341 | $_SESSION['next'] = 'Insert data in source table'; |
342 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
342 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
343 | 343 | print json_encode($result); |
344 | 344 | //} |
345 | 345 | } |
@@ -376,9 +376,9 @@ discard block |
||
376 | 376 | $Source = new Source(); |
377 | 377 | $Source->deleteAllLocation(); |
378 | 378 | foreach ($sources as $src) { |
379 | - if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png'); |
|
379 | + if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'], $src['latitude'], $src['longitude'], $src['altitude'], $src['city'], $src['country'], $src['source'], 'antenna.png'); |
|
380 | 380 | } |
381 | - $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert data in source table')); |
|
381 | + $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert data in source table')); |
|
382 | 382 | unset($_SESSION['sources']); |
383 | 383 | } |
384 | 384 | /* |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | $_SESSION['install'] = 'finish'; |
404 | 404 | $_SESSION['next'] = 'finish'; |
405 | 405 | } |
406 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
406 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
407 | 407 | print json_encode($result); |
408 | 408 | } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'vatsim') { |
409 | 409 | include_once('../install/class.create_db.php'); |
@@ -415,48 +415,48 @@ discard block |
||
415 | 415 | $error .= update_db::update_IVAO(); |
416 | 416 | if ($error != '') { |
417 | 417 | $_SESSION['error'] = $error; |
418 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
|
419 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
418 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert IVAO data')); |
|
419 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert IVAO data')); |
|
420 | 420 | } else { |
421 | 421 | $error .= update_db::update_vatsim(); |
422 | 422 | if ($error != '') { |
423 | 423 | $_SESSION['error'] = $error; |
424 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
|
425 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
424 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert VATSIM data')); |
|
425 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert VATSIM data')); |
|
426 | 426 | } |
427 | 427 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
428 | 428 | $error .= update_db::update_vatsim(); |
429 | 429 | if ($error != '') { |
430 | 430 | $_SESSION['error'] = $error; |
431 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
|
432 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
431 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert VATSIM data')); |
|
432 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert VATSIM data')); |
|
433 | 433 | } elseif (isset($globalIVAO) && $globalIVAO) { |
434 | 434 | if (file_exists('tmp/ivae_feb2013.zip')) { |
435 | 435 | $error .= update_db::update_IVAO(); |
436 | 436 | if ($error != '') { |
437 | 437 | $_SESSION['error'] = $error; |
438 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
|
439 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
438 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert IVAO data')); |
|
439 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert IVAO data')); |
|
440 | 440 | } else { |
441 | 441 | $error .= update_db::update_vatsim(); |
442 | 442 | if ($error != '') { |
443 | 443 | $_SESSION['error'] = $error; |
444 | - $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data (IVAO not found)')); |
|
445 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)')); |
|
444 | + $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'], array('Insert VATSIM data (IVAO not found)')); |
|
445 | + } else $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert VATSIM data (IVAO not found)')); |
|
446 | 446 | } |
447 | 447 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
448 | - $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert phpVMS data')); |
|
448 | + $_SESSION['done'] = array_merge($_SESSION['done'], array('Insert phpVMS data')); |
|
449 | 449 | } |
450 | 450 | //$_SESSION['install'] = 'routes'; |
451 | 451 | //$_SESSION['next'] = 'Populate routes table with externals data'; |
452 | 452 | $_SESSION['install'] = 'finish'; |
453 | 453 | $_SESSION['next'] = 'finish'; |
454 | - $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
|
454 | + $result = array('error' => $error, 'errorlst' => $_SESSION['errorlst'], 'done' => $_SESSION['done'], 'next' => $_SESSION['next'], 'install' => $_SESSION['install']); |
|
455 | 455 | print json_encode($result); |
456 | 456 | } else { |
457 | 457 | //unset($_SESSION['install']); |
458 | 458 | $_SESSION['error'] = 'Unknwon task : '.$_SESSION['install']; |
459 | - $result = array('error' => 'Unknwon task : '.$_SESSION['install'],'done' => $_SESSION['done'],'next' => 'finish','install' => 'finish'); |
|
459 | + $result = array('error' => 'Unknwon task : '.$_SESSION['install'], 'done' => $_SESSION['done'], 'next' => 'finish', 'install' => 'finish'); |
|
460 | 460 | print json_encode($result); |
461 | 461 | } |
462 | 462 | ?> |
463 | 463 | \ No newline at end of file |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | try { |
15 | 15 | $sth = $Connection->db->prepare($query); |
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch (PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | 19 | } |
20 | 20 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
21 | + $Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | try { |
51 | 51 | $sth = $Connection->db->prepare($query); |
52 | 52 | $sth->execute(); |
53 | - } catch(PDOException $e) { |
|
53 | + } catch (PDOException $e) { |
|
54 | 54 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
55 | 55 | } |
56 | 56 | // Copy schedules data to routes table |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | try { |
61 | 61 | $sth = $Connection->db->prepare($query); |
62 | 62 | $sth->execute(); |
63 | - } catch(PDOException $e) { |
|
63 | + } catch (PDOException $e) { |
|
64 | 64 | return "error (delete schedule table) : ".$e->getMessage()."\n"; |
65 | 65 | } |
66 | 66 | // Add source column |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | try { |
69 | 69 | $sth = $Connection->db->prepare($query); |
70 | 70 | $sth->execute(); |
71 | - } catch(PDOException $e) { |
|
71 | + } catch (PDOException $e) { |
|
72 | 72 | return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
73 | 73 | } |
74 | 74 | // Delete unused column |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | try { |
77 | 77 | $sth = $Connection->db->prepare($query); |
78 | 78 | $sth->execute(); |
79 | - } catch(PDOException $e) { |
|
79 | + } catch (PDOException $e) { |
|
80 | 80 | return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
81 | 81 | } |
82 | 82 | // Add ModeS column |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | try { |
85 | 85 | $sth = $Connection->db->prepare($query); |
86 | 86 | $sth->execute(); |
87 | - } catch(PDOException $e) { |
|
87 | + } catch (PDOException $e) { |
|
88 | 88 | return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
89 | 89 | } |
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | 91 | try { |
92 | 92 | $sth = $Connection->db->prepare($query); |
93 | 93 | $sth->execute(); |
94 | - } catch(PDOException $e) { |
|
94 | + } catch (PDOException $e) { |
|
95 | 95 | return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
96 | 96 | } |
97 | 97 | // Add auto_increment for aircraft_modes |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | try { |
100 | 100 | $sth = $Connection->db->prepare($query); |
101 | 101 | $sth->execute(); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
104 | 104 | } |
105 | 105 | $error = ''; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | try { |
111 | 111 | $sth = $Connection->db->prepare($query); |
112 | 112 | $sth->execute(); |
113 | - } catch(PDOException $e) { |
|
113 | + } catch (PDOException $e) { |
|
114 | 114 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
115 | 115 | } |
116 | 116 | return $error; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | try { |
124 | 124 | $sth = $Connection->db->prepare($query); |
125 | 125 | $sth->execute(); |
126 | - } catch(PDOException $e) { |
|
126 | + } catch (PDOException $e) { |
|
127 | 127 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
128 | 128 | } |
129 | 129 | $error = ''; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | try { |
135 | 135 | $sth = $Connection->db->prepare($query); |
136 | 136 | $sth->execute(); |
137 | - } catch(PDOException $e) { |
|
137 | + } catch (PDOException $e) { |
|
138 | 138 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
139 | 139 | } |
140 | 140 | return $error; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | try { |
148 | 148 | $sth = $Connection->db->prepare($query); |
149 | 149 | $sth->execute(); |
150 | - } catch(PDOException $e) { |
|
150 | + } catch (PDOException $e) { |
|
151 | 151 | return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
152 | 152 | } |
153 | 153 | // Add image_source_website column to spotter_image |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | try { |
156 | 156 | $sth = $Connection->db->prepare($query); |
157 | 157 | $sth->execute(); |
158 | - } catch(PDOException $e) { |
|
158 | + } catch (PDOException $e) { |
|
159 | 159 | return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
160 | 160 | } |
161 | 161 | $error = ''; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | try { |
165 | 165 | $sth = $Connection->db->prepare($query); |
166 | 166 | $sth->execute(); |
167 | - } catch(PDOException $e) { |
|
167 | + } catch (PDOException $e) { |
|
168 | 168 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
169 | 169 | } |
170 | 170 | return $error; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | try { |
183 | 183 | $sth = $Connection->db->prepare($query); |
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch (PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | 187 | } |
188 | 188 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $Connection->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
201 | 201 | } |
202 | 202 | // Add aircraft_shadow column to aircraft |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | try { |
205 | 205 | $sth = $Connection->db->prepare($query); |
206 | 206 | $sth->execute(); |
207 | - } catch(PDOException $e) { |
|
207 | + } catch (PDOException $e) { |
|
208 | 208 | return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
209 | 209 | } |
210 | 210 | // Add aircraft_shadow column to spotter_live |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | $sth = $Connection->db->prepare($query); |
214 | 214 | $sth->execute(); |
215 | - } catch(PDOException $e) { |
|
215 | + } catch (PDOException $e) { |
|
216 | 216 | return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
217 | 217 | } |
218 | 218 | $error = ''; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | try { |
226 | 226 | $sth = $Connection->db->prepare($query); |
227 | 227 | $sth->execute(); |
228 | - } catch(PDOException $e) { |
|
228 | + } catch (PDOException $e) { |
|
229 | 229 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
230 | 230 | } |
231 | 231 | return $error; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | 235 | $Connection = new Connection(); |
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
236 | + if (!$Connection->indexExists('spotter_output', 'flightaware_id')) { |
|
237 | 237 | $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | try { |
251 | 251 | $sth = $Connection->db->prepare($query); |
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch (PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | 255 | } |
256 | 256 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | try { |
266 | 266 | $sth = $Connection->db->prepare($query); |
267 | 267 | $sth->execute(); |
268 | - } catch(PDOException $e) { |
|
268 | + } catch (PDOException $e) { |
|
269 | 269 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
270 | 270 | } |
271 | 271 | return $error; |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | 276 | $Connection = new Connection(); |
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
277 | + $query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | 279 | try { |
280 | 280 | $sth = $Connection->db->prepare($query); |
281 | 281 | $sth->execute(); |
282 | - } catch(PDOException $e) { |
|
282 | + } catch (PDOException $e) { |
|
283 | 283 | return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
284 | 284 | } |
285 | 285 | if ($globalDBdriver == 'mysql') { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | try { |
288 | 288 | $sth = $Connection->db->prepare($query); |
289 | 289 | $sth->execute(); |
290 | - } catch(PDOException $e) { |
|
290 | + } catch (PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | 292 | } |
293 | 293 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | 301 | } else { |
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
302 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | 303 | } |
304 | 304 | } else { |
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
305 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | 306 | } |
307 | 307 | try { |
308 | 308 | $sth = $Connection->db->prepare($query); |
309 | 309 | $sth->execute(); |
310 | - } catch(PDOException $e) { |
|
310 | + } catch (PDOException $e) { |
|
311 | 311 | return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
312 | 312 | } |
313 | 313 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | try { |
321 | 321 | $sth = $Connection->db->prepare($query); |
322 | 322 | $sth->execute(); |
323 | - } catch(PDOException $e) { |
|
323 | + } catch (PDOException $e) { |
|
324 | 324 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
325 | 325 | } |
326 | 326 | return $error; |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | try { |
340 | 340 | $sth = $Connection->db->prepare($query); |
341 | 341 | $sth->execute(); |
342 | - } catch(PDOException $e) { |
|
342 | + } catch (PDOException $e) { |
|
343 | 343 | return "error (insert last_update values) : ".$e->getMessage()."\n"; |
344 | 344 | } |
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | 346 | try { |
347 | 347 | $sth = $Connection->db->prepare($query); |
348 | 348 | $sth->execute(); |
349 | - } catch(PDOException $e) { |
|
349 | + } catch (PDOException $e) { |
|
350 | 350 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
351 | 351 | } |
352 | 352 | return $error; |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | 356 | $Connection = new Connection(); |
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
357 | + $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | 359 | try { |
360 | 360 | $sth = $Connection->db->prepare($query); |
361 | 361 | $sth->execute(); |
362 | - } catch(PDOException $e) { |
|
362 | + } catch (PDOException $e) { |
|
363 | 363 | return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
364 | 364 | } |
365 | 365 | $error = ''; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | try { |
372 | 372 | $sth = $Connection->db->prepare($query); |
373 | 373 | $sth->execute(); |
374 | - } catch(PDOException $e) { |
|
374 | + } catch (PDOException $e) { |
|
375 | 375 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
376 | 376 | } |
377 | 377 | return $error; |
@@ -379,11 +379,11 @@ discard block |
||
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | 381 | $Connection = new Connection(); |
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
382 | + $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | 383 | try { |
384 | 384 | $sth = $Connection->db->prepare($query); |
385 | 385 | $sth->execute(); |
386 | - } catch(PDOException $e) { |
|
386 | + } catch (PDOException $e) { |
|
387 | 387 | return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
388 | 388 | } |
389 | 389 | $error = ''; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | try { |
402 | 402 | $sth = $Connection->db->prepare($query); |
403 | 403 | $sth->execute(); |
404 | - } catch(PDOException $e) { |
|
404 | + } catch (PDOException $e) { |
|
405 | 405 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
406 | 406 | } |
407 | 407 | return $error; |
@@ -410,18 +410,18 @@ discard block |
||
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | 412 | $Connection = new Connection(); |
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
413 | + $query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | 414 | try { |
415 | 415 | $sth = $Connection->db->prepare($query); |
416 | 416 | $sth->execute(); |
417 | - } catch(PDOException $e) { |
|
417 | + } catch (PDOException $e) { |
|
418 | 418 | return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
419 | 419 | } |
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
420 | + $query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | 421 | try { |
422 | 422 | $sth = $Connection->db->prepare($query); |
423 | 423 | $sth->execute(); |
424 | - } catch(PDOException $e) { |
|
424 | + } catch (PDOException $e) { |
|
425 | 425 | return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
426 | 426 | } |
427 | 427 | if ($globalDBdriver == 'mysql') { |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | try { |
430 | 430 | $sth = $Connection->db->prepare($query); |
431 | 431 | $sth->execute(); |
432 | - } catch(PDOException $e) { |
|
432 | + } catch (PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | 434 | } |
435 | 435 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -441,15 +441,15 @@ discard block |
||
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | 443 | } else { |
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
444 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | 445 | } |
446 | 446 | } else { |
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
447 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | 448 | } |
449 | 449 | try { |
450 | 450 | $sth = $Connection->db->prepare($query); |
451 | 451 | $sth->execute(); |
452 | - } catch(PDOException $e) { |
|
452 | + } catch (PDOException $e) { |
|
453 | 453 | return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
454 | 454 | } |
455 | 455 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | try { |
460 | 460 | $sth = $Connection->db->prepare($query); |
461 | 461 | $sth->execute(); |
462 | - } catch(PDOException $e) { |
|
462 | + } catch (PDOException $e) { |
|
463 | 463 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
464 | 464 | } |
465 | 465 | return $error; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | try { |
488 | 488 | $sth = $Connection->db->prepare($query); |
489 | 489 | $sth->execute(); |
490 | - } catch(PDOException $e) { |
|
490 | + } catch (PDOException $e) { |
|
491 | 491 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
492 | 492 | } |
493 | 493 | return $error; |
@@ -495,12 +495,12 @@ discard block |
||
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | 497 | $Connection = new Connection(); |
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) { |
|
499 | + $query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch (PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | 505 | } |
506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | try { |
510 | 510 | $sth = $Connection->db->prepare($query); |
511 | 511 | $sth->execute(); |
512 | - } catch(PDOException $e) { |
|
512 | + } catch (PDOException $e) { |
|
513 | 513 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
514 | 514 | } |
515 | 515 | return $error; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $Connection->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
532 | 532 | } |
533 | 533 | return $error; |
@@ -538,11 +538,11 @@ discard block |
||
538 | 538 | $Connection = new Connection(); |
539 | 539 | $error = ''; |
540 | 540 | // Add tables |
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
541 | + $query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | 542 | try { |
543 | 543 | $sth = $Connection->db->prepare($query); |
544 | 544 | $sth->execute(); |
545 | - } catch(PDOException $e) { |
|
545 | + } catch (PDOException $e) { |
|
546 | 546 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 547 | } |
548 | 548 | if ($error != '') return $error; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | try { |
551 | 551 | $sth = $Connection->db->prepare($query); |
552 | 552 | $sth->execute(); |
553 | - } catch(PDOException $e) { |
|
553 | + } catch (PDOException $e) { |
|
554 | 554 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
555 | 555 | } |
556 | 556 | return $error; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | try { |
572 | 572 | $sth = $Connection->db->prepare($query); |
573 | 573 | $sth->execute(); |
574 | - } catch(PDOException $e) { |
|
574 | + } catch (PDOException $e) { |
|
575 | 575 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
576 | 576 | } |
577 | 577 | return $error; |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | try { |
590 | 590 | $sth = $Connection->db->prepare($query); |
591 | 591 | $sth->execute(); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
594 | 594 | } |
595 | 595 | return $error; |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | $Connection = new Connection(); |
599 | 599 | $error = ''; |
600 | 600 | // Modify stats_airport table |
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
601 | + if (!$Connection->checkColumnName('stats_airport', 'airport_name')) { |
|
602 | 602 | $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
603 | 603 | try { |
604 | 604 | $sth = $Connection->db->prepare($query); |
605 | 605 | $sth->execute(); |
606 | - } catch(PDOException $e) { |
|
606 | + } catch (PDOException $e) { |
|
607 | 607 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 608 | } |
609 | 609 | } |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | try { |
613 | 613 | $sth = $Connection->db->prepare($query); |
614 | 614 | $sth->execute(); |
615 | - } catch(PDOException $e) { |
|
615 | + } catch (PDOException $e) { |
|
616 | 616 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
617 | 617 | } |
618 | 618 | return $error; |
@@ -629,73 +629,73 @@ discard block |
||
629 | 629 | try { |
630 | 630 | $sth = $Connection->db->prepare($query); |
631 | 631 | $sth->execute(); |
632 | - } catch(PDOException $e) { |
|
632 | + } catch (PDOException $e) { |
|
633 | 633 | return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
634 | 634 | } |
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | 636 | try { |
637 | 637 | $sth = $Connection->db->prepare($query); |
638 | 638 | $sth->execute(); |
639 | - } catch(PDOException $e) { |
|
639 | + } catch (PDOException $e) { |
|
640 | 640 | return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
641 | 641 | } |
642 | - if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
|
642 | + if (!$Connection->checkColumnName('spotter_archive', 'over_country')) { |
|
643 | 643 | // Add column over_country |
644 | 644 | $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
645 | 645 | try { |
646 | 646 | $sth = $Connection->db->prepare($query); |
647 | 647 | $sth->execute(); |
648 | - } catch(PDOException $e) { |
|
648 | + } catch (PDOException $e) { |
|
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
650 | 650 | } |
651 | 651 | } |
652 | - if (!$Connection->checkColumnName('spotter_live','over_country')) { |
|
652 | + if (!$Connection->checkColumnName('spotter_live', 'over_country')) { |
|
653 | 653 | // Add column over_country |
654 | 654 | $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
655 | 655 | try { |
656 | 656 | $sth = $Connection->db->prepare($query); |
657 | 657 | $sth->execute(); |
658 | - } catch(PDOException $e) { |
|
658 | + } catch (PDOException $e) { |
|
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
660 | 660 | } |
661 | 661 | } |
662 | - if (!$Connection->checkColumnName('spotter_output','source_name')) { |
|
662 | + if (!$Connection->checkColumnName('spotter_output', 'source_name')) { |
|
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | 664 | $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | - } catch(PDOException $e) { |
|
668 | + } catch (PDOException $e) { |
|
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | 670 | } |
671 | 671 | } |
672 | - if (!$Connection->checkColumnName('spotter_live','source_name')) { |
|
672 | + if (!$Connection->checkColumnName('spotter_live', 'source_name')) { |
|
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | 674 | $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | - } catch(PDOException $e) { |
|
678 | + } catch (PDOException $e) { |
|
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | 680 | } |
681 | 681 | } |
682 | - if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
|
682 | + if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) { |
|
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | 684 | $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | - } catch(PDOException $e) { |
|
688 | + } catch (PDOException $e) { |
|
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | 690 | } |
691 | 691 | } |
692 | - if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
|
692 | + if (!$Connection->checkColumnName('spotter_archive', 'source_name')) { |
|
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | 694 | $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | - } catch(PDOException $e) { |
|
698 | + } catch (PDOException $e) { |
|
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 700 | } |
701 | 701 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | try { |
705 | 705 | $sth = $Connection->db->prepare($query); |
706 | 706 | $sth->execute(); |
707 | - } catch(PDOException $e) { |
|
707 | + } catch (PDOException $e) { |
|
708 | 708 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
709 | 709 | } |
710 | 710 | return $error; |
@@ -719,13 +719,13 @@ discard block |
||
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | - if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
|
722 | + if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) { |
|
723 | 723 | // Add column over_country |
724 | 724 | $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
725 | 725 | try { |
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | - } catch(PDOException $e) { |
|
728 | + } catch (PDOException $e) { |
|
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 730 | } |
731 | 731 | } |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | try { |
742 | 742 | $sth = $Connection->db->prepare($query); |
743 | 743 | $sth->execute(); |
744 | - } catch(PDOException $e) { |
|
744 | + } catch (PDOException $e) { |
|
745 | 745 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
746 | 746 | } |
747 | 747 | return $error; |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | private static function update_from_21() { |
751 | 751 | $Connection = new Connection(); |
752 | 752 | $error = ''; |
753 | - if (!$Connection->checkColumnName('stats_airport','stats_type')) { |
|
753 | + if (!$Connection->checkColumnName('stats_airport', 'stats_type')) { |
|
754 | 754 | // Rename type to stats_type |
755 | 755 | $query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; |
756 | 756 | try { |
757 | 757 | $sth = $Connection->db->prepare($query); |
758 | 758 | $sth->execute(); |
759 | - } catch(PDOException $e) { |
|
759 | + } catch (PDOException $e) { |
|
760 | 760 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 761 | } |
762 | 762 | if ($error != '') return $error; |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | try { |
766 | 766 | $sth = $Connection->db->prepare($query); |
767 | 767 | $sth->execute(); |
768 | - } catch(PDOException $e) { |
|
768 | + } catch (PDOException $e) { |
|
769 | 769 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
770 | 770 | } |
771 | 771 | return $error; |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | try { |
789 | 789 | $sth = $Connection->db->prepare($query); |
790 | 790 | $sth->execute(); |
791 | - } catch(PDOException $e) { |
|
791 | + } catch (PDOException $e) { |
|
792 | 792 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
793 | 793 | } |
794 | 794 | return $error; |
@@ -814,17 +814,17 @@ discard block |
||
814 | 814 | try { |
815 | 815 | $sth = $Connection->db->prepare($query); |
816 | 816 | $sth->execute(); |
817 | - } catch(PDOException $e) { |
|
817 | + } catch (PDOException $e) { |
|
818 | 818 | return "error (create index on spotter_archive) : ".$e->getMessage()."\n"; |
819 | 819 | } |
820 | 820 | } |
821 | - if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
|
821 | + if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) { |
|
822 | 822 | // Add aircraft_manufacturer to stats_aircraft |
823 | 823 | $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
824 | 824 | try { |
825 | 825 | $sth = $Connection->db->prepare($query); |
826 | 826 | $sth->execute(); |
827 | - } catch(PDOException $e) { |
|
827 | + } catch (PDOException $e) { |
|
828 | 828 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
829 | 829 | } |
830 | 830 | } |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | try { |
834 | 834 | $sth = $Connection->db->prepare($query); |
835 | 835 | $sth->execute(); |
836 | - } catch(PDOException $e) { |
|
836 | + } catch (PDOException $e) { |
|
837 | 837 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
838 | 838 | } |
839 | 839 | return $error; |
@@ -849,23 +849,23 @@ discard block |
||
849 | 849 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
850 | 850 | } |
851 | 851 | if ($error != '') return 'Import airlines.sql : '.$error; |
852 | - if (!$Connection->checkColumnName('airlines','forsource')) { |
|
852 | + if (!$Connection->checkColumnName('airlines', 'forsource')) { |
|
853 | 853 | // Add forsource to airlines |
854 | 854 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
855 | 855 | try { |
856 | 856 | $sth = $Connection->db->prepare($query); |
857 | 857 | $sth->execute(); |
858 | - } catch(PDOException $e) { |
|
858 | + } catch (PDOException $e) { |
|
859 | 859 | return "error (add forsource column) : ".$e->getMessage()."\n"; |
860 | 860 | } |
861 | 861 | } |
862 | - if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) { |
|
862 | + if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) { |
|
863 | 863 | // Add forsource to airlines |
864 | 864 | $query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
865 | 865 | try { |
866 | 866 | $sth = $Connection->db->prepare($query); |
867 | 867 | $sth->execute(); |
868 | - } catch(PDOException $e) { |
|
868 | + } catch (PDOException $e) { |
|
869 | 869 | return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n"; |
870 | 870 | } |
871 | 871 | // Add unique key |
@@ -877,17 +877,17 @@ discard block |
||
877 | 877 | try { |
878 | 878 | $sth = $Connection->db->prepare($query); |
879 | 879 | $sth->execute(); |
880 | - } catch(PDOException $e) { |
|
880 | + } catch (PDOException $e) { |
|
881 | 881 | return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n"; |
882 | 882 | } |
883 | 883 | } |
884 | - if (!$Connection->checkColumnName('stats_airport','stats_airline')) { |
|
884 | + if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) { |
|
885 | 885 | // Add forsource to airlines |
886 | 886 | $query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
887 | 887 | try { |
888 | 888 | $sth = $Connection->db->prepare($query); |
889 | 889 | $sth->execute(); |
890 | - } catch(PDOException $e) { |
|
890 | + } catch (PDOException $e) { |
|
891 | 891 | return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n"; |
892 | 892 | } |
893 | 893 | // Add unique key |
@@ -899,17 +899,17 @@ discard block |
||
899 | 899 | try { |
900 | 900 | $sth = $Connection->db->prepare($query); |
901 | 901 | $sth->execute(); |
902 | - } catch(PDOException $e) { |
|
902 | + } catch (PDOException $e) { |
|
903 | 903 | return "error (add unique key in stats_airport) : ".$e->getMessage()."\n"; |
904 | 904 | } |
905 | 905 | } |
906 | - if (!$Connection->checkColumnName('stats_country','stats_airline')) { |
|
906 | + if (!$Connection->checkColumnName('stats_country', 'stats_airline')) { |
|
907 | 907 | // Add forsource to airlines |
908 | 908 | $query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
909 | 909 | try { |
910 | 910 | $sth = $Connection->db->prepare($query); |
911 | 911 | $sth->execute(); |
912 | - } catch(PDOException $e) { |
|
912 | + } catch (PDOException $e) { |
|
913 | 913 | return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n"; |
914 | 914 | } |
915 | 915 | // Add unique key |
@@ -921,36 +921,36 @@ discard block |
||
921 | 921 | try { |
922 | 922 | $sth = $Connection->db->prepare($query); |
923 | 923 | $sth->execute(); |
924 | - } catch(PDOException $e) { |
|
924 | + } catch (PDOException $e) { |
|
925 | 925 | return "error (add unique key in stats_airline) : ".$e->getMessage()."\n"; |
926 | 926 | } |
927 | 927 | } |
928 | - if (!$Connection->checkColumnName('stats_flight','stats_airline')) { |
|
928 | + if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) { |
|
929 | 929 | // Add forsource to airlines |
930 | 930 | $query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
931 | 931 | try { |
932 | 932 | $sth = $Connection->db->prepare($query); |
933 | 933 | $sth->execute(); |
934 | - } catch(PDOException $e) { |
|
934 | + } catch (PDOException $e) { |
|
935 | 935 | return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n"; |
936 | 936 | } |
937 | 937 | } |
938 | - if (!$Connection->checkColumnName('stats','stats_airline')) { |
|
938 | + if (!$Connection->checkColumnName('stats', 'stats_airline')) { |
|
939 | 939 | // Add forsource to airlines |
940 | 940 | $query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
941 | 941 | try { |
942 | 942 | $sth = $Connection->db->prepare($query); |
943 | 943 | $sth->execute(); |
944 | - } catch(PDOException $e) { |
|
944 | + } catch (PDOException $e) { |
|
945 | 945 | return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n"; |
946 | 946 | } |
947 | - if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) { |
|
947 | + if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) { |
|
948 | 948 | // Add unique key |
949 | 949 | $query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);"; |
950 | 950 | try { |
951 | 951 | $sth = $Connection->db->prepare($query); |
952 | 952 | $sth->execute(); |
953 | - } catch(PDOException $e) { |
|
953 | + } catch (PDOException $e) { |
|
954 | 954 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
955 | 955 | } |
956 | 956 | } else { |
@@ -963,18 +963,18 @@ discard block |
||
963 | 963 | try { |
964 | 964 | $sth = $Connection->db->prepare($query); |
965 | 965 | $sth->execute(); |
966 | - } catch(PDOException $e) { |
|
966 | + } catch (PDOException $e) { |
|
967 | 967 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; |
968 | 968 | } |
969 | 969 | } |
970 | 970 | } |
971 | - if (!$Connection->checkColumnName('stats_registration','stats_airline')) { |
|
971 | + if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) { |
|
972 | 972 | // Add forsource to airlines |
973 | 973 | $query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
974 | 974 | try { |
975 | 975 | $sth = $Connection->db->prepare($query); |
976 | 976 | $sth->execute(); |
977 | - } catch(PDOException $e) { |
|
977 | + } catch (PDOException $e) { |
|
978 | 978 | return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n"; |
979 | 979 | } |
980 | 980 | // Add unique key |
@@ -986,17 +986,17 @@ discard block |
||
986 | 986 | try { |
987 | 987 | $sth = $Connection->db->prepare($query); |
988 | 988 | $sth->execute(); |
989 | - } catch(PDOException $e) { |
|
989 | + } catch (PDOException $e) { |
|
990 | 990 | return "error (add unique key in stats_registration) : ".$e->getMessage()."\n"; |
991 | 991 | } |
992 | 992 | } |
993 | - if (!$Connection->checkColumnName('stats_callsign','filter_name')) { |
|
993 | + if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) { |
|
994 | 994 | // Add forsource to airlines |
995 | 995 | $query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
996 | 996 | try { |
997 | 997 | $sth = $Connection->db->prepare($query); |
998 | 998 | $sth->execute(); |
999 | - } catch(PDOException $e) { |
|
999 | + } catch (PDOException $e) { |
|
1000 | 1000 | return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n"; |
1001 | 1001 | } |
1002 | 1002 | // Add unique key |
@@ -1008,17 +1008,17 @@ discard block |
||
1008 | 1008 | try { |
1009 | 1009 | $sth = $Connection->db->prepare($query); |
1010 | 1010 | $sth->execute(); |
1011 | - } catch(PDOException $e) { |
|
1011 | + } catch (PDOException $e) { |
|
1012 | 1012 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1013 | 1013 | } |
1014 | 1014 | } |
1015 | - if (!$Connection->checkColumnName('stats_airline','filter_name')) { |
|
1015 | + if (!$Connection->checkColumnName('stats_airline', 'filter_name')) { |
|
1016 | 1016 | // Add forsource to airlines |
1017 | 1017 | $query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1018 | 1018 | try { |
1019 | 1019 | $sth = $Connection->db->prepare($query); |
1020 | 1020 | $sth->execute(); |
1021 | - } catch(PDOException $e) { |
|
1021 | + } catch (PDOException $e) { |
|
1022 | 1022 | return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n"; |
1023 | 1023 | } |
1024 | 1024 | // Add unique key |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | try { |
1031 | 1031 | $sth = $Connection->db->prepare($query); |
1032 | 1032 | $sth->execute(); |
1033 | - } catch(PDOException $e) { |
|
1033 | + } catch (PDOException $e) { |
|
1034 | 1034 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; |
1035 | 1035 | } |
1036 | 1036 | } |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | try { |
1040 | 1040 | $sth = $Connection->db->prepare($query); |
1041 | 1041 | $sth->execute(); |
1042 | - } catch(PDOException $e) { |
|
1042 | + } catch (PDOException $e) { |
|
1043 | 1043 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1044 | 1044 | } |
1045 | 1045 | return $error; |
@@ -1049,13 +1049,13 @@ discard block |
||
1049 | 1049 | global $globalDBdriver; |
1050 | 1050 | $Connection = new Connection(); |
1051 | 1051 | $error = ''; |
1052 | - if (!$Connection->checkColumnName('stats_owner','stats_airline')) { |
|
1052 | + if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) { |
|
1053 | 1053 | // Add forsource to airlines |
1054 | 1054 | $query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1055 | 1055 | try { |
1056 | 1056 | $sth = $Connection->db->prepare($query); |
1057 | 1057 | $sth->execute(); |
1058 | - } catch(PDOException $e) { |
|
1058 | + } catch (PDOException $e) { |
|
1059 | 1059 | return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n"; |
1060 | 1060 | } |
1061 | 1061 | // Add unique key |
@@ -1067,17 +1067,17 @@ discard block |
||
1067 | 1067 | try { |
1068 | 1068 | $sth = $Connection->db->prepare($query); |
1069 | 1069 | $sth->execute(); |
1070 | - } catch(PDOException $e) { |
|
1070 | + } catch (PDOException $e) { |
|
1071 | 1071 | return "error (add unique key in stats_owner) : ".$e->getMessage()."\n"; |
1072 | 1072 | } |
1073 | 1073 | } |
1074 | - if (!$Connection->checkColumnName('stats_pilot','stats_airline')) { |
|
1074 | + if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) { |
|
1075 | 1075 | // Add forsource to airlines |
1076 | 1076 | $query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; |
1077 | 1077 | try { |
1078 | 1078 | $sth = $Connection->db->prepare($query); |
1079 | 1079 | $sth->execute(); |
1080 | - } catch(PDOException $e) { |
|
1080 | + } catch (PDOException $e) { |
|
1081 | 1081 | return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n"; |
1082 | 1082 | } |
1083 | 1083 | // Add unique key |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | try { |
1090 | 1090 | $sth = $Connection->db->prepare($query); |
1091 | 1091 | $sth->execute(); |
1092 | - } catch(PDOException $e) { |
|
1092 | + } catch (PDOException $e) { |
|
1093 | 1093 | return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1094 | 1094 | } |
1095 | 1095 | } |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | try { |
1098 | 1098 | $sth = $Connection->db->prepare($query); |
1099 | 1099 | $sth->execute(); |
1100 | - } catch(PDOException $e) { |
|
1100 | + } catch (PDOException $e) { |
|
1101 | 1101 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1102 | 1102 | } |
1103 | 1103 | return $error; |
@@ -1107,12 +1107,12 @@ discard block |
||
1107 | 1107 | global $globalDBdriver; |
1108 | 1108 | $Connection = new Connection(); |
1109 | 1109 | $error = ''; |
1110 | - if (!$Connection->checkColumnName('atc','format_source')) { |
|
1110 | + if (!$Connection->checkColumnName('atc', 'format_source')) { |
|
1111 | 1111 | $query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL"; |
1112 | 1112 | try { |
1113 | 1113 | $sth = $Connection->db->prepare($query); |
1114 | 1114 | $sth->execute(); |
1115 | - } catch(PDOException $e) { |
|
1115 | + } catch (PDOException $e) { |
|
1116 | 1116 | return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n"; |
1117 | 1117 | } |
1118 | 1118 | } |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | try { |
1121 | 1121 | $sth = $Connection->db->prepare($query); |
1122 | 1122 | $sth->execute(); |
1123 | - } catch(PDOException $e) { |
|
1123 | + } catch (PDOException $e) { |
|
1124 | 1124 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1125 | 1125 | } |
1126 | 1126 | return $error; |
@@ -1130,13 +1130,13 @@ discard block |
||
1130 | 1130 | global $globalDBdriver; |
1131 | 1131 | $Connection = new Connection(); |
1132 | 1132 | $error = ''; |
1133 | - if (!$Connection->checkColumnName('stats_pilot','format_source')) { |
|
1133 | + if (!$Connection->checkColumnName('stats_pilot', 'format_source')) { |
|
1134 | 1134 | // Add forsource to airlines |
1135 | 1135 | $query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''"; |
1136 | 1136 | try { |
1137 | 1137 | $sth = $Connection->db->prepare($query); |
1138 | 1138 | $sth->execute(); |
1139 | - } catch(PDOException $e) { |
|
1139 | + } catch (PDOException $e) { |
|
1140 | 1140 | return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n"; |
1141 | 1141 | } |
1142 | 1142 | // Add unique key |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | try { |
1149 | 1149 | $sth = $Connection->db->prepare($query); |
1150 | 1150 | $sth->execute(); |
1151 | - } catch(PDOException $e) { |
|
1151 | + } catch (PDOException $e) { |
|
1152 | 1152 | return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n"; |
1153 | 1153 | } |
1154 | 1154 | } |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | try { |
1157 | 1157 | $sth = $Connection->db->prepare($query); |
1158 | 1158 | $sth->execute(); |
1159 | - } catch(PDOException $e) { |
|
1159 | + } catch (PDOException $e) { |
|
1160 | 1160 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1161 | 1161 | } |
1162 | 1162 | return $error; |
@@ -1166,23 +1166,23 @@ discard block |
||
1166 | 1166 | global $globalDBdriver; |
1167 | 1167 | $Connection = new Connection(); |
1168 | 1168 | $error = ''; |
1169 | - if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) { |
|
1169 | + if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) { |
|
1170 | 1170 | // Add unique key |
1171 | 1171 | $query = "alter table spotter_live add index(latitude,longitude)"; |
1172 | 1172 | try { |
1173 | 1173 | $sth = $Connection->db->prepare($query); |
1174 | 1174 | $sth->execute(); |
1175 | - } catch(PDOException $e) { |
|
1175 | + } catch (PDOException $e) { |
|
1176 | 1176 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; |
1177 | 1177 | } |
1178 | 1178 | } |
1179 | - if (!$Connection->checkColumnName('aircraft','mfr')) { |
|
1179 | + if (!$Connection->checkColumnName('aircraft', 'mfr')) { |
|
1180 | 1180 | // Add mfr to aircraft |
1181 | 1181 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; |
1182 | 1182 | try { |
1183 | 1183 | $sth = $Connection->db->prepare($query); |
1184 | 1184 | $sth->execute(); |
1185 | - } catch(PDOException $e) { |
|
1185 | + } catch (PDOException $e) { |
|
1186 | 1186 | return "error (add mfr column in aircraft) : ".$e->getMessage()."\n"; |
1187 | 1187 | } |
1188 | 1188 | } |
@@ -1198,7 +1198,7 @@ discard block |
||
1198 | 1198 | try { |
1199 | 1199 | $sth = $Connection->db->prepare($query); |
1200 | 1200 | $sth->execute(); |
1201 | - } catch(PDOException $e) { |
|
1201 | + } catch (PDOException $e) { |
|
1202 | 1202 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1203 | 1203 | } |
1204 | 1204 | return $error; |
@@ -1208,13 +1208,13 @@ discard block |
||
1208 | 1208 | global $globalDBdriver; |
1209 | 1209 | $Connection = new Connection(); |
1210 | 1210 | $error = ''; |
1211 | - if ($Connection->checkColumnName('aircraft','mfr')) { |
|
1211 | + if ($Connection->checkColumnName('aircraft', 'mfr')) { |
|
1212 | 1212 | // drop mfr to aircraft |
1213 | 1213 | $query = "ALTER TABLE aircraft DROP COLUMN mfr"; |
1214 | 1214 | try { |
1215 | 1215 | $sth = $Connection->db->prepare($query); |
1216 | 1216 | $sth->execute(); |
1217 | - } catch(PDOException $e) { |
|
1217 | + } catch (PDOException $e) { |
|
1218 | 1218 | return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n"; |
1219 | 1219 | } |
1220 | 1220 | } |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | try { |
1231 | 1231 | $sth = $Connection->db->prepare($query); |
1232 | 1232 | $sth->execute(); |
1233 | - } catch(PDOException $e) { |
|
1233 | + } catch (PDOException $e) { |
|
1234 | 1234 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1235 | 1235 | } |
1236 | 1236 | return $error; |
@@ -1240,33 +1240,33 @@ discard block |
||
1240 | 1240 | global $globalDBdriver; |
1241 | 1241 | $Connection = new Connection(); |
1242 | 1242 | $error = ''; |
1243 | - if (!$Connection->indexExists('notam','ref_idx')) { |
|
1243 | + if (!$Connection->indexExists('notam', 'ref_idx')) { |
|
1244 | 1244 | // Add index key |
1245 | 1245 | $query = "create index ref_idx on notam (ref)"; |
1246 | 1246 | try { |
1247 | 1247 | $sth = $Connection->db->prepare($query); |
1248 | 1248 | $sth->execute(); |
1249 | - } catch(PDOException $e) { |
|
1249 | + } catch (PDOException $e) { |
|
1250 | 1250 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; |
1251 | 1251 | } |
1252 | 1252 | } |
1253 | - if (!$Connection->indexExists('accidents','registration_idx')) { |
|
1253 | + if (!$Connection->indexExists('accidents', 'registration_idx')) { |
|
1254 | 1254 | // Add index key |
1255 | 1255 | $query = "create index registration_idx on accidents (registration)"; |
1256 | 1256 | try { |
1257 | 1257 | $sth = $Connection->db->prepare($query); |
1258 | 1258 | $sth->execute(); |
1259 | - } catch(PDOException $e) { |
|
1259 | + } catch (PDOException $e) { |
|
1260 | 1260 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; |
1261 | 1261 | } |
1262 | 1262 | } |
1263 | - if (!$Connection->indexExists('accidents','rdts')) { |
|
1263 | + if (!$Connection->indexExists('accidents', 'rdts')) { |
|
1264 | 1264 | // Add index key |
1265 | 1265 | $query = "create index rdts on accidents (registration,date,type,source)"; |
1266 | 1266 | try { |
1267 | 1267 | $sth = $Connection->db->prepare($query); |
1268 | 1268 | $sth->execute(); |
1269 | - } catch(PDOException $e) { |
|
1269 | + } catch (PDOException $e) { |
|
1270 | 1270 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; |
1271 | 1271 | } |
1272 | 1272 | } |
@@ -1275,7 +1275,7 @@ discard block |
||
1275 | 1275 | try { |
1276 | 1276 | $sth = $Connection->db->prepare($query); |
1277 | 1277 | $sth->execute(); |
1278 | - } catch(PDOException $e) { |
|
1278 | + } catch (PDOException $e) { |
|
1279 | 1279 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1280 | 1280 | } |
1281 | 1281 | return $error; |
@@ -1285,23 +1285,23 @@ discard block |
||
1285 | 1285 | global $globalDBdriver; |
1286 | 1286 | $Connection = new Connection(); |
1287 | 1287 | $error = ''; |
1288 | - if (!$Connection->checkColumnName('accidents','airline_name')) { |
|
1288 | + if (!$Connection->checkColumnName('accidents', 'airline_name')) { |
|
1289 | 1289 | // Add airline_name to accidents |
1290 | 1290 | $query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL"; |
1291 | 1291 | try { |
1292 | 1292 | $sth = $Connection->db->prepare($query); |
1293 | 1293 | $sth->execute(); |
1294 | - } catch(PDOException $e) { |
|
1294 | + } catch (PDOException $e) { |
|
1295 | 1295 | return "error (add airline_name column in accidents) : ".$e->getMessage()."\n"; |
1296 | 1296 | } |
1297 | 1297 | } |
1298 | - if (!$Connection->checkColumnName('accidents','airline_icao')) { |
|
1298 | + if (!$Connection->checkColumnName('accidents', 'airline_icao')) { |
|
1299 | 1299 | // Add airline_icao to accidents |
1300 | 1300 | $query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL"; |
1301 | 1301 | try { |
1302 | 1302 | $sth = $Connection->db->prepare($query); |
1303 | 1303 | $sth->execute(); |
1304 | - } catch(PDOException $e) { |
|
1304 | + } catch (PDOException $e) { |
|
1305 | 1305 | return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n"; |
1306 | 1306 | } |
1307 | 1307 | } |
@@ -1309,7 +1309,7 @@ discard block |
||
1309 | 1309 | try { |
1310 | 1310 | $sth = $Connection->db->prepare($query); |
1311 | 1311 | $sth->execute(); |
1312 | - } catch(PDOException $e) { |
|
1312 | + } catch (PDOException $e) { |
|
1313 | 1313 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1314 | 1314 | } |
1315 | 1315 | return $error; |
@@ -1319,13 +1319,13 @@ discard block |
||
1319 | 1319 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
1320 | 1320 | $Connection = new Connection(); |
1321 | 1321 | $error = ''; |
1322 | - if (!$Connection->checkColumnName('airlines','alliance')) { |
|
1322 | + if (!$Connection->checkColumnName('airlines', 'alliance')) { |
|
1323 | 1323 | // Add alliance to airlines |
1324 | 1324 | $query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL"; |
1325 | 1325 | try { |
1326 | 1326 | $sth = $Connection->db->prepare($query); |
1327 | 1327 | $sth->execute(); |
1328 | - } catch(PDOException $e) { |
|
1328 | + } catch (PDOException $e) { |
|
1329 | 1329 | return "error (add alliance column in airlines) : ".$e->getMessage()."\n"; |
1330 | 1330 | } |
1331 | 1331 | } |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | try { |
1353 | 1353 | $sth = $Connection->db->prepare($query); |
1354 | 1354 | $sth->execute(); |
1355 | - } catch(PDOException $e) { |
|
1355 | + } catch (PDOException $e) { |
|
1356 | 1356 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1357 | 1357 | } |
1358 | 1358 | return $error; |
@@ -1362,13 +1362,13 @@ discard block |
||
1362 | 1362 | global $globalDBdriver, $globalVATSIM, $globalIVAO; |
1363 | 1363 | $Connection = new Connection(); |
1364 | 1364 | $error = ''; |
1365 | - if (!$Connection->checkColumnName('airlines','ban_eu')) { |
|
1365 | + if (!$Connection->checkColumnName('airlines', 'ban_eu')) { |
|
1366 | 1366 | // Add ban_eu to airlines |
1367 | 1367 | $query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'"; |
1368 | 1368 | try { |
1369 | 1369 | $sth = $Connection->db->prepare($query); |
1370 | 1370 | $sth->execute(); |
1371 | - } catch(PDOException $e) { |
|
1371 | + } catch (PDOException $e) { |
|
1372 | 1372 | return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n"; |
1373 | 1373 | } |
1374 | 1374 | } |
@@ -1376,7 +1376,7 @@ discard block |
||
1376 | 1376 | try { |
1377 | 1377 | $sth = $Connection->db->prepare($query); |
1378 | 1378 | $sth->execute(); |
1379 | - } catch(PDOException $e) { |
|
1379 | + } catch (PDOException $e) { |
|
1380 | 1380 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1381 | 1381 | } |
1382 | 1382 | return $error; |
@@ -1387,19 +1387,19 @@ discard block |
||
1387 | 1387 | $Connection = new Connection(); |
1388 | 1388 | $error = ''; |
1389 | 1389 | if ($globalDBdriver == 'mysql') { |
1390 | - if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') { |
|
1390 | + if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') { |
|
1391 | 1391 | $query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL"; |
1392 | 1392 | try { |
1393 | 1393 | $sth = $Connection->db->prepare($query); |
1394 | 1394 | $sth->execute(); |
1395 | - } catch(PDOException $e) { |
|
1395 | + } catch (PDOException $e) { |
|
1396 | 1396 | return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n"; |
1397 | 1397 | } |
1398 | 1398 | $query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()"; |
1399 | 1399 | try { |
1400 | 1400 | $sth = $Connection->db->prepare($query); |
1401 | 1401 | $sth->execute(); |
1402 | - } catch(PDOException $e) { |
|
1402 | + } catch (PDOException $e) { |
|
1403 | 1403 | return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n"; |
1404 | 1404 | } |
1405 | 1405 | |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | try { |
1408 | 1408 | $sth = $Connection->db->prepare($query); |
1409 | 1409 | $sth->execute(); |
1410 | - } catch(PDOException $e) { |
|
1410 | + } catch (PDOException $e) { |
|
1411 | 1411 | return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n"; |
1412 | 1412 | } |
1413 | 1413 | /*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150"; |
@@ -1458,7 +1458,7 @@ discard block |
||
1458 | 1458 | try { |
1459 | 1459 | $sth = $Connection->db->prepare($query); |
1460 | 1460 | $sth->execute(); |
1461 | - } catch(PDOException $e) { |
|
1461 | + } catch (PDOException $e) { |
|
1462 | 1462 | return "error (fix date) : ".$e->getMessage()."\n"; |
1463 | 1463 | } |
1464 | 1464 | } |
@@ -1543,7 +1543,7 @@ discard block |
||
1543 | 1543 | try { |
1544 | 1544 | $sth = $Connection->db->prepare($query); |
1545 | 1545 | $sth->execute(); |
1546 | - } catch(PDOException $e) { |
|
1546 | + } catch (PDOException $e) { |
|
1547 | 1547 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1548 | 1548 | } |
1549 | 1549 | return $error; |
@@ -1552,13 +1552,13 @@ discard block |
||
1552 | 1552 | global $globalDBdriver; |
1553 | 1553 | $Connection = new Connection(); |
1554 | 1554 | $error = ''; |
1555 | - if (!$Connection->indexExists('accidents','type')) { |
|
1555 | + if (!$Connection->indexExists('accidents', 'type')) { |
|
1556 | 1556 | // Add index key |
1557 | 1557 | $query = "create index type on accidents (type,date)"; |
1558 | 1558 | try { |
1559 | 1559 | $sth = $Connection->db->prepare($query); |
1560 | 1560 | $sth->execute(); |
1561 | - } catch(PDOException $e) { |
|
1561 | + } catch (PDOException $e) { |
|
1562 | 1562 | return "error (add index type on accidents) : ".$e->getMessage()."\n"; |
1563 | 1563 | } |
1564 | 1564 | } |
@@ -1566,7 +1566,7 @@ discard block |
||
1566 | 1566 | try { |
1567 | 1567 | $sth = $Connection->db->prepare($query); |
1568 | 1568 | $sth->execute(); |
1569 | - } catch(PDOException $e) { |
|
1569 | + } catch (PDOException $e) { |
|
1570 | 1570 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1571 | 1571 | } |
1572 | 1572 | return $error; |
@@ -1576,12 +1576,12 @@ discard block |
||
1576 | 1576 | global $globalDBdriver; |
1577 | 1577 | $Connection = new Connection(); |
1578 | 1578 | $error = ''; |
1579 | - if (!$Connection->checkColumnName('aircraft_modes','source_type')) { |
|
1579 | + if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) { |
|
1580 | 1580 | $query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'"; |
1581 | 1581 | try { |
1582 | 1582 | $sth = $Connection->db->prepare($query); |
1583 | 1583 | $sth->execute(); |
1584 | - } catch(PDOException $e) { |
|
1584 | + } catch (PDOException $e) { |
|
1585 | 1585 | return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n"; |
1586 | 1586 | } |
1587 | 1587 | } |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | try { |
1648 | 1648 | $sth = $Connection->db->prepare($query); |
1649 | 1649 | $sth->execute(); |
1650 | - } catch(PDOException $e) { |
|
1650 | + } catch (PDOException $e) { |
|
1651 | 1651 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1652 | 1652 | } |
1653 | 1653 | return $error; |
@@ -1699,7 +1699,7 @@ discard block |
||
1699 | 1699 | try { |
1700 | 1700 | $sth = $Connection->db->prepare($query); |
1701 | 1701 | $sth->execute(); |
1702 | - } catch(PDOException $e) { |
|
1702 | + } catch (PDOException $e) { |
|
1703 | 1703 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
1704 | 1704 | } |
1705 | 1705 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1708,18 +1708,18 @@ discard block |
||
1708 | 1708 | try { |
1709 | 1709 | $sth = $Connection->db->prepare($query); |
1710 | 1710 | $sth->execute(); |
1711 | - } catch(PDOException $e) { |
|
1711 | + } catch (PDOException $e) { |
|
1712 | 1712 | return "error (Change table format from archive to InnoDB for spotter_archive) : ".$e->getMessage()."\n"; |
1713 | 1713 | } |
1714 | 1714 | } |
1715 | 1715 | } |
1716 | - if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) { |
|
1716 | + if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) { |
|
1717 | 1717 | // Add index key |
1718 | 1718 | $query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)"; |
1719 | 1719 | try { |
1720 | 1720 | $sth = $Connection->db->prepare($query); |
1721 | 1721 | $sth->execute(); |
1722 | - } catch(PDOException $e) { |
|
1722 | + } catch (PDOException $e) { |
|
1723 | 1723 | return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n"; |
1724 | 1724 | } |
1725 | 1725 | } |
@@ -1727,7 +1727,7 @@ discard block |
||
1727 | 1727 | try { |
1728 | 1728 | $sth = $Connection->db->prepare($query); |
1729 | 1729 | $sth->execute(); |
1730 | - } catch(PDOException $e) { |
|
1730 | + } catch (PDOException $e) { |
|
1731 | 1731 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1732 | 1732 | } |
1733 | 1733 | return $error; |
@@ -1738,148 +1738,148 @@ discard block |
||
1738 | 1738 | $Connection = new Connection(); |
1739 | 1739 | $error = ''; |
1740 | 1740 | if ($globalDBdriver == 'mysql') { |
1741 | - if (!$Connection->checkColumnName('marine_output','type_id')) { |
|
1741 | + if (!$Connection->checkColumnName('marine_output', 'type_id')) { |
|
1742 | 1742 | $query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL"; |
1743 | 1743 | try { |
1744 | 1744 | $sth = $Connection->db->prepare($query); |
1745 | 1745 | $sth->execute(); |
1746 | - } catch(PDOException $e) { |
|
1746 | + } catch (PDOException $e) { |
|
1747 | 1747 | return "error (add column type_id in marine_output) : ".$e->getMessage()."\n"; |
1748 | 1748 | } |
1749 | 1749 | } |
1750 | - if (!$Connection->checkColumnName('marine_live','type_id')) { |
|
1750 | + if (!$Connection->checkColumnName('marine_live', 'type_id')) { |
|
1751 | 1751 | $query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL"; |
1752 | 1752 | try { |
1753 | 1753 | $sth = $Connection->db->prepare($query); |
1754 | 1754 | $sth->execute(); |
1755 | - } catch(PDOException $e) { |
|
1755 | + } catch (PDOException $e) { |
|
1756 | 1756 | return "error (add column type_id in marine_live) : ".$e->getMessage()."\n"; |
1757 | 1757 | } |
1758 | 1758 | } |
1759 | - if (!$Connection->checkColumnName('marine_archive','type_id')) { |
|
1759 | + if (!$Connection->checkColumnName('marine_archive', 'type_id')) { |
|
1760 | 1760 | $query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL"; |
1761 | 1761 | try { |
1762 | 1762 | $sth = $Connection->db->prepare($query); |
1763 | 1763 | $sth->execute(); |
1764 | - } catch(PDOException $e) { |
|
1764 | + } catch (PDOException $e) { |
|
1765 | 1765 | return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n"; |
1766 | 1766 | } |
1767 | 1767 | } |
1768 | - if (!$Connection->checkColumnName('marine_archive_output','type_id')) { |
|
1768 | + if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) { |
|
1769 | 1769 | $query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL"; |
1770 | 1770 | try { |
1771 | 1771 | $sth = $Connection->db->prepare($query); |
1772 | 1772 | $sth->execute(); |
1773 | - } catch(PDOException $e) { |
|
1773 | + } catch (PDOException $e) { |
|
1774 | 1774 | return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1775 | 1775 | } |
1776 | 1776 | } |
1777 | - if (!$Connection->checkColumnName('marine_output','status_id')) { |
|
1777 | + if (!$Connection->checkColumnName('marine_output', 'status_id')) { |
|
1778 | 1778 | $query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL"; |
1779 | 1779 | try { |
1780 | 1780 | $sth = $Connection->db->prepare($query); |
1781 | 1781 | $sth->execute(); |
1782 | - } catch(PDOException $e) { |
|
1782 | + } catch (PDOException $e) { |
|
1783 | 1783 | return "error (add column status_id in marine_output) : ".$e->getMessage()."\n"; |
1784 | 1784 | } |
1785 | 1785 | } |
1786 | - if (!$Connection->checkColumnName('marine_live','status_id')) { |
|
1786 | + if (!$Connection->checkColumnName('marine_live', 'status_id')) { |
|
1787 | 1787 | $query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL"; |
1788 | 1788 | try { |
1789 | 1789 | $sth = $Connection->db->prepare($query); |
1790 | 1790 | $sth->execute(); |
1791 | - } catch(PDOException $e) { |
|
1791 | + } catch (PDOException $e) { |
|
1792 | 1792 | return "error (add column status_id in marine_live) : ".$e->getMessage()."\n"; |
1793 | 1793 | } |
1794 | 1794 | } |
1795 | - if (!$Connection->checkColumnName('marine_archive','status_id')) { |
|
1795 | + if (!$Connection->checkColumnName('marine_archive', 'status_id')) { |
|
1796 | 1796 | $query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL"; |
1797 | 1797 | try { |
1798 | 1798 | $sth = $Connection->db->prepare($query); |
1799 | 1799 | $sth->execute(); |
1800 | - } catch(PDOException $e) { |
|
1800 | + } catch (PDOException $e) { |
|
1801 | 1801 | return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n"; |
1802 | 1802 | } |
1803 | 1803 | } |
1804 | - if (!$Connection->checkColumnName('marine_archive_output','status_id')) { |
|
1804 | + if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) { |
|
1805 | 1805 | $query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL"; |
1806 | 1806 | try { |
1807 | 1807 | $sth = $Connection->db->prepare($query); |
1808 | 1808 | $sth->execute(); |
1809 | - } catch(PDOException $e) { |
|
1809 | + } catch (PDOException $e) { |
|
1810 | 1810 | return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1811 | 1811 | } |
1812 | 1812 | } |
1813 | 1813 | } else { |
1814 | - if (!$Connection->checkColumnName('marine_output','type_id')) { |
|
1814 | + if (!$Connection->checkColumnName('marine_output', 'type_id')) { |
|
1815 | 1815 | $query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL"; |
1816 | 1816 | try { |
1817 | 1817 | $sth = $Connection->db->prepare($query); |
1818 | 1818 | $sth->execute(); |
1819 | - } catch(PDOException $e) { |
|
1819 | + } catch (PDOException $e) { |
|
1820 | 1820 | return "error (add column type_id in marine_output) : ".$e->getMessage()."\n"; |
1821 | 1821 | } |
1822 | 1822 | } |
1823 | - if (!$Connection->checkColumnName('marine_live','type_id')) { |
|
1823 | + if (!$Connection->checkColumnName('marine_live', 'type_id')) { |
|
1824 | 1824 | $query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL"; |
1825 | 1825 | try { |
1826 | 1826 | $sth = $Connection->db->prepare($query); |
1827 | 1827 | $sth->execute(); |
1828 | - } catch(PDOException $e) { |
|
1828 | + } catch (PDOException $e) { |
|
1829 | 1829 | return "error (add column type_id in marine_live) : ".$e->getMessage()."\n"; |
1830 | 1830 | } |
1831 | 1831 | } |
1832 | - if (!$Connection->checkColumnName('marine_archive','type_id')) { |
|
1832 | + if (!$Connection->checkColumnName('marine_archive', 'type_id')) { |
|
1833 | 1833 | $query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL"; |
1834 | 1834 | try { |
1835 | 1835 | $sth = $Connection->db->prepare($query); |
1836 | 1836 | $sth->execute(); |
1837 | - } catch(PDOException $e) { |
|
1837 | + } catch (PDOException $e) { |
|
1838 | 1838 | return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n"; |
1839 | 1839 | } |
1840 | 1840 | } |
1841 | - if (!$Connection->checkColumnName('marine_archive_output','type_id')) { |
|
1841 | + if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) { |
|
1842 | 1842 | $query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL"; |
1843 | 1843 | try { |
1844 | 1844 | $sth = $Connection->db->prepare($query); |
1845 | 1845 | $sth->execute(); |
1846 | - } catch(PDOException $e) { |
|
1846 | + } catch (PDOException $e) { |
|
1847 | 1847 | return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1848 | 1848 | } |
1849 | 1849 | } |
1850 | - if (!$Connection->checkColumnName('marine_output','status_id')) { |
|
1850 | + if (!$Connection->checkColumnName('marine_output', 'status_id')) { |
|
1851 | 1851 | $query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL"; |
1852 | 1852 | try { |
1853 | 1853 | $sth = $Connection->db->prepare($query); |
1854 | 1854 | $sth->execute(); |
1855 | - } catch(PDOException $e) { |
|
1855 | + } catch (PDOException $e) { |
|
1856 | 1856 | return "error (add column status_id in marine_output) : ".$e->getMessage()."\n"; |
1857 | 1857 | } |
1858 | 1858 | } |
1859 | - if (!$Connection->checkColumnName('marine_live','status_id')) { |
|
1859 | + if (!$Connection->checkColumnName('marine_live', 'status_id')) { |
|
1860 | 1860 | $query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL"; |
1861 | 1861 | try { |
1862 | 1862 | $sth = $Connection->db->prepare($query); |
1863 | 1863 | $sth->execute(); |
1864 | - } catch(PDOException $e) { |
|
1864 | + } catch (PDOException $e) { |
|
1865 | 1865 | return "error (add column status_id in marine_live) : ".$e->getMessage()."\n"; |
1866 | 1866 | } |
1867 | 1867 | } |
1868 | - if (!$Connection->checkColumnName('marine_archive','status_id')) { |
|
1868 | + if (!$Connection->checkColumnName('marine_archive', 'status_id')) { |
|
1869 | 1869 | $query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL"; |
1870 | 1870 | try { |
1871 | 1871 | $sth = $Connection->db->prepare($query); |
1872 | 1872 | $sth->execute(); |
1873 | - } catch(PDOException $e) { |
|
1873 | + } catch (PDOException $e) { |
|
1874 | 1874 | return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n"; |
1875 | 1875 | } |
1876 | 1876 | } |
1877 | - if (!$Connection->checkColumnName('marine_archive_output','status_id')) { |
|
1877 | + if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) { |
|
1878 | 1878 | $query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL"; |
1879 | 1879 | try { |
1880 | 1880 | $sth = $Connection->db->prepare($query); |
1881 | 1881 | $sth->execute(); |
1882 | - } catch(PDOException $e) { |
|
1882 | + } catch (PDOException $e) { |
|
1883 | 1883 | return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n"; |
1884 | 1884 | } |
1885 | 1885 | } |
@@ -1888,7 +1888,7 @@ discard block |
||
1888 | 1888 | try { |
1889 | 1889 | $sth = $Connection->db->prepare($query); |
1890 | 1890 | $sth->execute(); |
1891 | - } catch(PDOException $e) { |
|
1891 | + } catch (PDOException $e) { |
|
1892 | 1892 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1893 | 1893 | } |
1894 | 1894 | return $error; |
@@ -1903,14 +1903,14 @@ discard block |
||
1903 | 1903 | try { |
1904 | 1904 | $sth = $Connection->db->prepare($query); |
1905 | 1905 | $sth->execute(); |
1906 | - } catch(PDOException $e) { |
|
1906 | + } catch (PDOException $e) { |
|
1907 | 1907 | return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n"; |
1908 | 1908 | } |
1909 | 1909 | $query = "ALTER TABLE marine_identity MODIFY COLUMN mmsi varchar(255) DEFAULT NULL"; |
1910 | 1910 | try { |
1911 | 1911 | $sth = $Connection->db->prepare($query); |
1912 | 1912 | $sth->execute(); |
1913 | - } catch(PDOException $e) { |
|
1913 | + } catch (PDOException $e) { |
|
1914 | 1914 | return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n"; |
1915 | 1915 | } |
1916 | 1916 | } else { |
@@ -1918,14 +1918,14 @@ discard block |
||
1918 | 1918 | try { |
1919 | 1919 | $sth = $Connection->db->prepare($query); |
1920 | 1920 | $sth->execute(); |
1921 | - } catch(PDOException $e) { |
|
1921 | + } catch (PDOException $e) { |
|
1922 | 1922 | return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n"; |
1923 | 1923 | } |
1924 | 1924 | $query = "alter table marine_identity alter column mmsi type varchar(255)"; |
1925 | 1925 | try { |
1926 | 1926 | $sth = $Connection->db->prepare($query); |
1927 | 1927 | $sth->execute(); |
1928 | - } catch(PDOException $e) { |
|
1928 | + } catch (PDOException $e) { |
|
1929 | 1929 | return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n"; |
1930 | 1930 | } |
1931 | 1931 | } |
@@ -1933,7 +1933,7 @@ discard block |
||
1933 | 1933 | try { |
1934 | 1934 | $sth = $Connection->db->prepare($query); |
1935 | 1935 | $sth->execute(); |
1936 | - } catch(PDOException $e) { |
|
1936 | + } catch (PDOException $e) { |
|
1937 | 1937 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1938 | 1938 | } |
1939 | 1939 | return $error; |
@@ -1943,32 +1943,32 @@ discard block |
||
1943 | 1943 | global $globalDBdriver; |
1944 | 1944 | $Connection = new Connection(); |
1945 | 1945 | $error = ''; |
1946 | - if (!$Connection->checkColumnName('source_location','last_seen')) { |
|
1946 | + if (!$Connection->checkColumnName('source_location', 'last_seen')) { |
|
1947 | 1947 | $query = "ALTER TABLE source_location ADD COLUMN last_seen timestamp NULL DEFAULT NULL"; |
1948 | 1948 | try { |
1949 | 1949 | $sth = $Connection->db->prepare($query); |
1950 | 1950 | $sth->execute(); |
1951 | - } catch(PDOException $e) { |
|
1951 | + } catch (PDOException $e) { |
|
1952 | 1952 | return "error (add column last_seen in source_location) : ".$e->getMessage()."\n"; |
1953 | 1953 | } |
1954 | 1954 | } |
1955 | 1955 | if ($globalDBdriver == 'mysql') { |
1956 | - if (!$Connection->checkColumnName('source_location','location_id')) { |
|
1956 | + if (!$Connection->checkColumnName('source_location', 'location_id')) { |
|
1957 | 1957 | $query = "ALTER TABLE source_location ADD COLUMN location_id int(11) DEFAULT NULL"; |
1958 | 1958 | try { |
1959 | 1959 | $sth = $Connection->db->prepare($query); |
1960 | 1960 | $sth->execute(); |
1961 | - } catch(PDOException $e) { |
|
1961 | + } catch (PDOException $e) { |
|
1962 | 1962 | return "error (add column location_id in source_location) : ".$e->getMessage()."\n"; |
1963 | 1963 | } |
1964 | 1964 | } |
1965 | 1965 | } else { |
1966 | - if (!$Connection->checkColumnName('source_location','location_id')) { |
|
1966 | + if (!$Connection->checkColumnName('source_location', 'location_id')) { |
|
1967 | 1967 | $query = "ALTER TABLE source_location ADD COLUMN location_id integer DEFAULT NULL"; |
1968 | 1968 | try { |
1969 | 1969 | $sth = $Connection->db->prepare($query); |
1970 | 1970 | $sth->execute(); |
1971 | - } catch(PDOException $e) { |
|
1971 | + } catch (PDOException $e) { |
|
1972 | 1972 | return "error (add column location_id in source_location) : ".$e->getMessage()."\n"; |
1973 | 1973 | } |
1974 | 1974 | } |
@@ -1977,7 +1977,7 @@ discard block |
||
1977 | 1977 | try { |
1978 | 1978 | $sth = $Connection->db->prepare($query); |
1979 | 1979 | $sth->execute(); |
1980 | - } catch(PDOException $e) { |
|
1980 | + } catch (PDOException $e) { |
|
1981 | 1981 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
1982 | 1982 | } |
1983 | 1983 | return $error; |
@@ -1987,12 +1987,12 @@ discard block |
||
1987 | 1987 | global $globalDBdriver; |
1988 | 1988 | $Connection = new Connection(); |
1989 | 1989 | $error = ''; |
1990 | - if (!$Connection->checkColumnName('source_location','description')) { |
|
1990 | + if (!$Connection->checkColumnName('source_location', 'description')) { |
|
1991 | 1991 | $query = "ALTER TABLE source_location ADD COLUMN description text DEFAULT NULL"; |
1992 | 1992 | try { |
1993 | 1993 | $sth = $Connection->db->prepare($query); |
1994 | 1994 | $sth->execute(); |
1995 | - } catch(PDOException $e) { |
|
1995 | + } catch (PDOException $e) { |
|
1996 | 1996 | return "error (add column description in source_location) : ".$e->getMessage()."\n"; |
1997 | 1997 | } |
1998 | 1998 | } |
@@ -2000,7 +2000,7 @@ discard block |
||
2000 | 2000 | try { |
2001 | 2001 | $sth = $Connection->db->prepare($query); |
2002 | 2002 | $sth->execute(); |
2003 | - } catch(PDOException $e) { |
|
2003 | + } catch (PDOException $e) { |
|
2004 | 2004 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2005 | 2005 | } |
2006 | 2006 | return $error; |
@@ -2010,39 +2010,39 @@ discard block |
||
2010 | 2010 | global $globalDBdriver; |
2011 | 2011 | $Connection = new Connection(); |
2012 | 2012 | $error = ''; |
2013 | - if (!$Connection->checkColumnName('spotter_live','real_altitude')) { |
|
2013 | + if (!$Connection->checkColumnName('spotter_live', 'real_altitude')) { |
|
2014 | 2014 | $query = "ALTER TABLE spotter_live ADD COLUMN real_altitude float DEFAULT NULL"; |
2015 | 2015 | try { |
2016 | 2016 | $sth = $Connection->db->prepare($query); |
2017 | 2017 | $sth->execute(); |
2018 | - } catch(PDOException $e) { |
|
2018 | + } catch (PDOException $e) { |
|
2019 | 2019 | return "error (add column real_altitude in spotter_live) : ".$e->getMessage()."\n"; |
2020 | 2020 | } |
2021 | 2021 | } |
2022 | - if (!$Connection->checkColumnName('spotter_output','real_altitude')) { |
|
2022 | + if (!$Connection->checkColumnName('spotter_output', 'real_altitude')) { |
|
2023 | 2023 | $query = "ALTER TABLE spotter_output ADD COLUMN real_altitude float DEFAULT NULL"; |
2024 | 2024 | try { |
2025 | 2025 | $sth = $Connection->db->prepare($query); |
2026 | 2026 | $sth->execute(); |
2027 | - } catch(PDOException $e) { |
|
2027 | + } catch (PDOException $e) { |
|
2028 | 2028 | return "error (add column real_altitude in spotter_output) : ".$e->getMessage()."\n"; |
2029 | 2029 | } |
2030 | 2030 | } |
2031 | - if (!$Connection->checkColumnName('spotter_archive_output','real_altitude')) { |
|
2031 | + if (!$Connection->checkColumnName('spotter_archive_output', 'real_altitude')) { |
|
2032 | 2032 | $query = "ALTER TABLE spotter_archive_output ADD COLUMN real_altitude float DEFAULT NULL"; |
2033 | 2033 | try { |
2034 | 2034 | $sth = $Connection->db->prepare($query); |
2035 | 2035 | $sth->execute(); |
2036 | - } catch(PDOException $e) { |
|
2036 | + } catch (PDOException $e) { |
|
2037 | 2037 | return "error (add column real_altitude in spotter_archive_output) : ".$e->getMessage()."\n"; |
2038 | 2038 | } |
2039 | 2039 | } |
2040 | - if (!$Connection->checkColumnName('spotter_archive','real_altitude')) { |
|
2040 | + if (!$Connection->checkColumnName('spotter_archive', 'real_altitude')) { |
|
2041 | 2041 | $query = "ALTER TABLE spotter_archive ADD COLUMN real_altitude float DEFAULT NULL"; |
2042 | 2042 | try { |
2043 | 2043 | $sth = $Connection->db->prepare($query); |
2044 | 2044 | $sth->execute(); |
2045 | - } catch(PDOException $e) { |
|
2045 | + } catch (PDOException $e) { |
|
2046 | 2046 | return "error (add column real_altitude in spotter_archive) : ".$e->getMessage()."\n"; |
2047 | 2047 | } |
2048 | 2048 | } |
@@ -2050,7 +2050,7 @@ discard block |
||
2050 | 2050 | try { |
2051 | 2051 | $sth = $Connection->db->prepare($query); |
2052 | 2052 | $sth->execute(); |
2053 | - } catch(PDOException $e) { |
|
2053 | + } catch (PDOException $e) { |
|
2054 | 2054 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2055 | 2055 | } |
2056 | 2056 | return $error; |
@@ -2072,14 +2072,14 @@ discard block |
||
2072 | 2072 | try { |
2073 | 2073 | $sth = $Connection->db->prepare($query); |
2074 | 2074 | $sth->execute(); |
2075 | - } catch(PDOException $e) { |
|
2075 | + } catch (PDOException $e) { |
|
2076 | 2076 | return "error (modify column altitude in tracker_*) : ".$e->getMessage()."\n"; |
2077 | 2077 | } |
2078 | 2078 | $query = "UPDATE config SET value = '44' WHERE name = 'schema_version'"; |
2079 | 2079 | try { |
2080 | 2080 | $sth = $Connection->db->prepare($query); |
2081 | 2081 | $sth->execute(); |
2082 | - } catch(PDOException $e) { |
|
2082 | + } catch (PDOException $e) { |
|
2083 | 2083 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2084 | 2084 | } |
2085 | 2085 | return $error; |
@@ -2120,7 +2120,7 @@ discard block |
||
2120 | 2120 | try { |
2121 | 2121 | $sth = $Connection->db->prepare($query); |
2122 | 2122 | $sth->execute(); |
2123 | - } catch(PDOException $e) { |
|
2123 | + } catch (PDOException $e) { |
|
2124 | 2124 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2125 | 2125 | } |
2126 | 2126 | return $error; |
@@ -2143,7 +2143,7 @@ discard block |
||
2143 | 2143 | try { |
2144 | 2144 | $sth = $Connection->db->prepare($query); |
2145 | 2145 | $sth->execute(); |
2146 | - } catch(PDOException $e) { |
|
2146 | + } catch (PDOException $e) { |
|
2147 | 2147 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2148 | 2148 | } |
2149 | 2149 | return $error; |
@@ -2193,7 +2193,7 @@ discard block |
||
2193 | 2193 | try { |
2194 | 2194 | $sth = $Connection->db->prepare($query); |
2195 | 2195 | $sth->execute(); |
2196 | - } catch(PDOException $e) { |
|
2196 | + } catch (PDOException $e) { |
|
2197 | 2197 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2198 | 2198 | } |
2199 | 2199 | return $error; |
@@ -2216,7 +2216,7 @@ discard block |
||
2216 | 2216 | try { |
2217 | 2217 | $sth = $Connection->db->prepare($query); |
2218 | 2218 | $sth->execute(); |
2219 | - } catch(PDOException $e) { |
|
2219 | + } catch (PDOException $e) { |
|
2220 | 2220 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2221 | 2221 | } |
2222 | 2222 | return $error; |
@@ -2239,7 +2239,7 @@ discard block |
||
2239 | 2239 | try { |
2240 | 2240 | $sth = $Connection->db->prepare($query); |
2241 | 2241 | $sth->execute(); |
2242 | - } catch(PDOException $e) { |
|
2242 | + } catch (PDOException $e) { |
|
2243 | 2243 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2244 | 2244 | } |
2245 | 2245 | return $error; |
@@ -2260,7 +2260,7 @@ discard block |
||
2260 | 2260 | try { |
2261 | 2261 | $sth = $Connection->db->prepare($query); |
2262 | 2262 | $sth->execute(); |
2263 | - } catch(PDOException $e) { |
|
2263 | + } catch (PDOException $e) { |
|
2264 | 2264 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
2265 | 2265 | } |
2266 | 2266 | return $error; |
@@ -2283,7 +2283,7 @@ discard block |
||
2283 | 2283 | try { |
2284 | 2284 | $sth = $Connection->db->prepare($query); |
2285 | 2285 | $sth->execute(); |
2286 | - } catch(PDOException $e) { |
|
2286 | + } catch (PDOException $e) { |
|
2287 | 2287 | return "error (check_version): ".$e->getMessage()."\n"; |
2288 | 2288 | } |
2289 | 2289 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | header('Content-Type: text/javascript'); |
18 | 18 | |
19 | 19 | |
20 | -$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d')); |
|
20 | +$polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d')); |
|
21 | 21 | $output = '{"type": "FeatureCollection","features": ['; |
22 | 22 | if (!empty($polar)) { |
23 | - foreach($polar as $eachpolar) { |
|
23 | + foreach ($polar as $eachpolar) { |
|
24 | 24 | $data = json_decode($eachpolar['source_data']); |
25 | 25 | $name = $eachpolar['source_name']; |
26 | 26 | $coord = $Location->getLocationInfobySourceName($name); |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | $initial_longitude = $globalCenterLongitude; |
34 | 34 | } |
35 | 35 | $first = ''; |
36 | - foreach($data as $value => $key) { |
|
37 | - $final_coord = $Common->getCoordfromDistanceBearing($initial_latitude,$initial_longitude,$value*22.5,$key); |
|
38 | - if ($first == '') $first = '['.round($final_coord['longitude'],5).','.round($final_coord['latitude'],5).']'; |
|
36 | + foreach ($data as $value => $key) { |
|
37 | + $final_coord = $Common->getCoordfromDistanceBearing($initial_latitude, $initial_longitude, $value*22.5, $key); |
|
38 | + if ($first == '') $first = '['.round($final_coord['longitude'], 5).','.round($final_coord['latitude'], 5).']'; |
|
39 | 39 | $output .= '['.$final_coord['longitude'].','.$final_coord['latitude'].'],'; |
40 | 40 | } |
41 | 41 | $output .= $first; |
42 | 42 | $output .= ']]}},'; |
43 | 43 | } |
44 | - $output = substr($output, 0, -1); |
|
44 | + $output = substr($output, 0, -1); |
|
45 | 45 | } |
46 | 46 | $output .= ']}'; |
47 | 47 | print $output; |