@@ -19,8 +19,12 @@ discard block |
||
19 | 19 | } |
20 | 20 | $tracker = false; |
21 | 21 | $marine = false; |
22 | -if (isset($_GET['tracker'])) $tracker = true; |
|
23 | -if (isset($_GET['marine'])) $marine = true; |
|
22 | +if (isset($_GET['tracker'])) { |
|
23 | + $tracker = true; |
|
24 | +} |
|
25 | +if (isset($_GET['marine'])) { |
|
26 | + $marine = true; |
|
27 | +} |
|
24 | 28 | if ($tracker) { |
25 | 29 | require_once('require/class.Tracker.php'); |
26 | 30 | require_once('require/class.TrackerLive.php'); |
@@ -77,24 +81,49 @@ discard block |
||
77 | 81 | } |
78 | 82 | header('Content-Type: text/javascript'); |
79 | 83 | |
80 | -if (!isset($globalJsonCompress)) $compress = true; |
|
81 | -else $compress = $globalJsonCompress; |
|
84 | +if (!isset($globalJsonCompress)) { |
|
85 | + $compress = true; |
|
86 | +} else { |
|
87 | + $compress = $globalJsonCompress; |
|
88 | +} |
|
82 | 89 | |
83 | 90 | $from_archive = false; |
84 | 91 | $min = false; |
85 | 92 | $allhistory = false; |
86 | 93 | $filter['source'] = array(); |
87 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
88 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
89 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
90 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
91 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
92 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
93 | -if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
94 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
95 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
96 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
97 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
94 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
95 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
96 | +} |
|
97 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
98 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
99 | +} |
|
100 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
101 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
102 | +} |
|
103 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
104 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
105 | +} |
|
106 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
107 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
108 | +} |
|
109 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
110 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
111 | +} |
|
112 | +if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') { |
|
113 | + $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING); |
|
114 | +} |
|
115 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
116 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
117 | +} |
|
118 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
119 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
120 | +} |
|
121 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
122 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
123 | +} |
|
124 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
125 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
126 | +} |
|
98 | 127 | /* |
99 | 128 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
100 | 129 | $min = true; |
@@ -268,8 +297,12 @@ discard block |
||
268 | 297 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
269 | 298 | } |
270 | 299 | } |
271 | - if ($flightcnt == '') $flightcnt = 0; |
|
272 | -} else $flightcnt = 0; |
|
300 | + if ($flightcnt == '') { |
|
301 | + $flightcnt = 0; |
|
302 | + } |
|
303 | + } else { |
|
304 | + $flightcnt = 0; |
|
305 | +} |
|
273 | 306 | |
274 | 307 | $sqltime = round(microtime(true)-$begintime,2); |
275 | 308 | $minitime = time(); |
@@ -315,7 +348,9 @@ discard block |
||
315 | 348 | $gltf2 = false; |
316 | 349 | $scale = 1.0; |
317 | 350 | $minimumpixelsize = 20; |
318 | -if (isset($archivespeed)) $speed = $archivespeed; |
|
351 | +if (isset($archivespeed)) { |
|
352 | + $speed = $archivespeed; |
|
353 | +} |
|
319 | 354 | $output = '['; |
320 | 355 | if ($tracker) { |
321 | 356 | $output .= '{"id" : "document", "name" : "tracker","version" : "1.0"'; |
@@ -351,9 +386,13 @@ discard block |
||
351 | 386 | $image = "images/placeholder_thumb.png"; |
352 | 387 | } |
353 | 388 | |
354 | - if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id']; |
|
355 | - elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid']; |
|
356 | - elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id']; |
|
389 | + if (isset($spotter_item['flightaware_id'])) { |
|
390 | + $id = $spotter_item['flightaware_id']; |
|
391 | + } elseif (isset($spotter_item['famtrackid'])) { |
|
392 | + $id = $spotter_item['famtrackid']; |
|
393 | + } elseif (isset($spotter_item['fammarine_id'])) { |
|
394 | + $id = $spotter_item['fammarine_id']; |
|
395 | + } |
|
357 | 396 | if ($prev_flightaware_id != $id) { |
358 | 397 | if ($prev_flightaware_id != '') { |
359 | 398 | /* |
@@ -391,14 +430,24 @@ discard block |
||
391 | 430 | if (isset($spotter_item['squawk'])) { |
392 | 431 | $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
393 | 432 | } |
394 | - if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
395 | - if (isset($spotter_item['format_source'])) $output .= '"format": "'.$spotter_item['format_source'].'",'; |
|
396 | - if (isset($spotter_item['ident'])) $output.= '"ident": "'.$spotter_item['ident'].'",'; |
|
433 | + if (isset($spotter_item['registration'])) { |
|
434 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
435 | + } |
|
436 | + if (isset($spotter_item['format_source'])) { |
|
437 | + $output .= '"format": "'.$spotter_item['format_source'].'",'; |
|
438 | + } |
|
439 | + if (isset($spotter_item['ident'])) { |
|
440 | + $output.= '"ident": "'.$spotter_item['ident'].'",'; |
|
441 | + } |
|
397 | 442 | if ($tracker) { |
398 | - if (isset($spotter_item['type'])) $output .= '"tracker_type": "'.$spotter_item['type'].'",'; |
|
443 | + if (isset($spotter_item['type'])) { |
|
444 | + $output .= '"tracker_type": "'.$spotter_item['type'].'",'; |
|
445 | + } |
|
399 | 446 | $output.= '"type": "tracker"'; |
400 | 447 | } elseif ($marine) { |
401 | - if (isset($spotter_item['type'])) $output .= '"marine_type": "'.$spotter_item['type'].'",'; |
|
448 | + if (isset($spotter_item['type'])) { |
|
449 | + $output .= '"marine_type": "'.$spotter_item['type'].'",'; |
|
450 | + } |
|
402 | 451 | $output.= '"type": "marine"'; |
403 | 452 | } else { |
404 | 453 | if ($one3dmodel === false && isset($globalMap3DLiveries) && $globalMap3DLiveries) { |
@@ -449,7 +498,9 @@ discard block |
||
449 | 498 | $spotter_item['engine_type'] = $aircraft_info[0]['engine_type']; |
450 | 499 | $spotter_item['wake_category'] = $aircraft_info[0]['wake_category']; |
451 | 500 | $spotter_item['engine_count'] = $aircraft_info[0]['engine_count']; |
452 | - } else $aircraft_shadow = ''; |
|
501 | + } else { |
|
502 | + $aircraft_shadow = ''; |
|
503 | + } |
|
453 | 504 | $output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5'; |
454 | 505 | if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true' && isset($_COOKIE['IconColor'])) { |
455 | 506 | $rgb = $Common->hex2rgb($_COOKIE['IconColor']); |
@@ -457,7 +508,9 @@ discard block |
||
457 | 508 | } |
458 | 509 | $output .= '},'; |
459 | 510 | } |
460 | - } else $output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},'; |
|
511 | + } else { |
|
512 | + $output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},'; |
|
513 | + } |
|
461 | 514 | } elseif ($one3dmodel) { |
462 | 515 | if (isset($globalMap3DForceModel) && $globalMap3DForceModel != '') { |
463 | 516 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$globalMap3DForceModel.'","scale" : '.$scale.',"minimumPixelSize": '.$minimumpixelsize.''; |
@@ -497,7 +550,9 @@ discard block |
||
497 | 550 | $spotter_item['engine_type'] = $aircraft_info[0]['engine_type']; |
498 | 551 | $spotter_item['wake_category'] = $aircraft_info[0]['wake_category']; |
499 | 552 | $spotter_item['engine_count'] = $aircraft_info[0]['engine_count']; |
500 | - } else $aircraft_shadow = ''; |
|
553 | + } else { |
|
554 | + $aircraft_shadow = ''; |
|
555 | + } |
|
501 | 556 | if ($aircraft_shadow != '') { |
502 | 557 | if (isset($modelsdb2[$aircraft_shadow])) { |
503 | 558 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/gltf2/'.$modelsdb2[$aircraft_shadow]['glb'].'","scale" : '.$scale.',"minimumPixelSize": '.$modelsdb2[$aircraft_shadow]['size']; |
@@ -652,7 +707,9 @@ discard block |
||
652 | 707 | } |
653 | 708 | $output .= '},'; |
654 | 709 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
655 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
710 | + if ($spotter_item['aircraft_icao'] != '') { |
|
711 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
712 | + } |
|
656 | 713 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
657 | 714 | } |
658 | 715 | } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
@@ -674,7 +731,9 @@ discard block |
||
674 | 731 | } |
675 | 732 | $output .= '},'; |
676 | 733 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
677 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
734 | + if ($spotter_item['aircraft_icao'] != '') { |
|
735 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
736 | + } |
|
678 | 737 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
679 | 738 | } |
680 | 739 | } else { |
@@ -687,7 +746,9 @@ discard block |
||
687 | 746 | } |
688 | 747 | $output .= '},'; |
689 | 748 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
690 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
749 | + if ($spotter_item['aircraft_icao'] != '') { |
|
750 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
751 | + } |
|
691 | 752 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
692 | 753 | } |
693 | 754 | } elseif ($tracker && isset($spotter_item['type'])) { |
@@ -791,8 +852,11 @@ discard block |
||
791 | 852 | $output .= '},'; |
792 | 853 | } |
793 | 854 | } |
794 | - if (isset($onground) && $onground) $output = str_replace('%onground%','true',$output); |
|
795 | - else $output = str_replace('%onground%','false',$output); |
|
855 | + if (isset($onground) && $onground) { |
|
856 | + $output = str_replace('%onground%','true',$output); |
|
857 | + } else { |
|
858 | + $output = str_replace('%onground%','false',$output); |
|
859 | + } |
|
796 | 860 | |
797 | 861 | // $output .= '"heightReference": "CLAMP_TO_GROUND",'; |
798 | 862 | //$output .= '"heightReference": "'.$heightrelative.'",'; |
@@ -805,9 +869,15 @@ discard block |
||
805 | 869 | // $output .= '"interpolationDegree" : 5,'; |
806 | 870 | // $output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", '; |
807 | 871 | $output .= '"cartographicDegrees": ['; |
808 | - if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
|
809 | - if (isset($_COOKIE['MapTrack']) && $id == $_COOKIE['MapTrack'] && $minitracktime > strtotime($spotter_item['date'])) $minitracktime = strtotime($spotter_item['date']); |
|
810 | - if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
|
872 | + if ($minitime > strtotime($spotter_item['date'])) { |
|
873 | + $minitime = strtotime($spotter_item['date']); |
|
874 | + } |
|
875 | + if (isset($_COOKIE['MapTrack']) && $id == $_COOKIE['MapTrack'] && $minitracktime > strtotime($spotter_item['date'])) { |
|
876 | + $minitracktime = strtotime($spotter_item['date']); |
|
877 | + } |
|
878 | + if ($maxitime < strtotime($spotter_item['date'])) { |
|
879 | + $maxitime = strtotime($spotter_item['date']); |
|
880 | + } |
|
811 | 881 | $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
812 | 882 | $output .= $spotter_item['longitude'].', '; |
813 | 883 | $output .= $spotter_item['latitude']; |
@@ -830,7 +900,9 @@ discard block |
||
830 | 900 | $output .= ', '.round($spotter_item['altitude']*30.48); |
831 | 901 | $prevalt = round($spotter_item['altitude']*30.48); |
832 | 902 | } |
833 | - } else $output .= ', 0'; |
|
903 | + } else { |
|
904 | + $output .= ', 0'; |
|
905 | + } |
|
834 | 906 | //$orientation = '"orientation" : { '; |
835 | 907 | //$orientation .= '"unitQuaternion": ['; |
836 | 908 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
@@ -838,13 +910,18 @@ discard block |
||
838 | 910 | } else { |
839 | 911 | $nblatlong = $nblatlong+1; |
840 | 912 | $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
841 | - if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
|
913 | + if ($maxitime < strtotime($spotter_item['date'])) { |
|
914 | + $maxitime = strtotime($spotter_item['date']); |
|
915 | + } |
|
842 | 916 | if ($spotter_item['ground_speed'] == 0) { |
843 | 917 | $output .= $prevlong.', '; |
844 | 918 | $output .= $prevlat; |
845 | 919 | //if (!$marine && (!isset($onground) || !$onground)) $output .= ', '.$prevalt; |
846 | - if (!$marine) $output .= ', '.$prevalt; |
|
847 | - else $output .= ', 0'; |
|
920 | + if (!$marine) { |
|
921 | + $output .= ', '.$prevalt; |
|
922 | + } else { |
|
923 | + $output .= ', 0'; |
|
924 | + } |
|
848 | 925 | } else { |
849 | 926 | $output .= $spotter_item['longitude'].', '; |
850 | 927 | $output .= $spotter_item['latitude']; |
@@ -857,14 +934,17 @@ discard block |
||
857 | 934 | $output .= ', 0'; |
858 | 935 | } |
859 | 936 | } else { |
860 | - if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') $output .= ', '.round($spotter_item['real_altitude']*0.3048); |
|
861 | - elseif ($tracker) { |
|
937 | + if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') { |
|
938 | + $output .= ', '.round($spotter_item['real_altitude']*0.3048); |
|
939 | + } elseif ($tracker) { |
|
862 | 940 | $output .= ', '.round($spotter_item['altitude']*0.3048); |
863 | 941 | } else { |
864 | 942 | $output .= ', '.round($spotter_item['altitude']*30.48); |
865 | 943 | } |
866 | 944 | } |
867 | - } else $output .= ', 0'; |
|
945 | + } else { |
|
946 | + $output .= ', 0'; |
|
947 | + } |
|
868 | 948 | } |
869 | 949 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
870 | 950 | //$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
@@ -885,9 +965,10 @@ discard block |
||
885 | 965 | } else { |
886 | 966 | $output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output); |
887 | 967 | } |
968 | + } else { |
|
969 | + $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
888 | 970 | } |
889 | - else $output = str_replace('%minitime%',date("c",$minitime),$output); |
|
890 | -} elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '' && $minitracktime != $minitracktime_begin) { |
|
971 | + } elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '' && $minitracktime != $minitracktime_begin) { |
|
891 | 972 | $output = str_replace('%minitime%',date("c",$minitracktime),$output); |
892 | 973 | } else { |
893 | 974 | $output = str_replace('%minitime%',date("c",$minitime),$output); |
@@ -897,7 +978,10 @@ discard block |
||
897 | 978 | } else { |
898 | 979 | $output = str_replace('%maxitime%',date("c",$maxitime),$output); |
899 | 980 | } |
900 | -if ($gltf2) $output = str_replace('%gltf2%','true',$output); |
|
901 | -else $output = str_replace('%gltf2%','false',$output); |
|
981 | +if ($gltf2) { |
|
982 | + $output = str_replace('%gltf2%','true',$output); |
|
983 | +} else { |
|
984 | + $output = str_replace('%gltf2%','false',$output); |
|
985 | +} |
|
902 | 986 | print $output; |
903 | 987 | ?> |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (SpotterLive)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (SpotterLive)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -126,8 +130,11 @@ discard block |
||
126 | 130 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
127 | 131 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
128 | 132 | } |
129 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
130 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
133 | + if ($filter_query_where == '' && $where) { |
|
134 | + $filter_query_where = ' WHERE'; |
|
135 | + } elseif ($filter_query_where != '' && $and) { |
|
136 | + $filter_query_where .= ' AND'; |
|
137 | + } |
|
131 | 138 | if ($filter_query_where != '') { |
132 | 139 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
133 | 140 | } |
@@ -168,9 +175,13 @@ discard block |
||
168 | 175 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
169 | 176 | } |
170 | 177 | } |
171 | - if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
178 | + if ($orderby_query == '') { |
|
179 | + $orderby_query = ' ORDER BY date DESC'; |
|
180 | + } |
|
172 | 181 | |
173 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
182 | + if (!isset($globalLiveInterval)) { |
|
183 | + $globalLiveInterval = '200'; |
|
184 | + } |
|
174 | 185 | if ($globalDBdriver == 'mysql') { |
175 | 186 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
176 | 187 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -193,7 +204,9 @@ discard block |
||
193 | 204 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
194 | 205 | date_default_timezone_set('UTC'); |
195 | 206 | $filter_query = $this->getFilter($filter,true,true); |
196 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
207 | + if (!isset($globalLiveInterval)) { |
|
208 | + $globalLiveInterval = '200'; |
|
209 | + } |
|
197 | 210 | if ($globalDBdriver == 'mysql') { |
198 | 211 | if (isset($globalArchive) && $globalArchive === TRUE) { |
199 | 212 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
@@ -244,8 +257,12 @@ discard block |
||
244 | 257 | $id = filter_var($id,FILTER_SANITIZE_STRING); |
245 | 258 | $filter_query = $this->getFilter($filter,true,true); |
246 | 259 | |
247 | - if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200'; |
|
248 | - if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300'; |
|
260 | + if (!isset($globalLiveInterval) || $globalLiveInterval == '') { |
|
261 | + $globalLiveInterval = '200'; |
|
262 | + } |
|
263 | + if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') { |
|
264 | + $globalMap3DAircraftsLimit = '300'; |
|
265 | + } |
|
249 | 266 | if ($globalDBdriver == 'mysql') { |
250 | 267 | if (isset($globalArchive) && $globalArchive === TRUE) { |
251 | 268 | /* |
@@ -256,25 +273,41 @@ discard block |
||
256 | 273 | */ |
257 | 274 | $query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration |
258 | 275 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
259 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
260 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
276 | + if ($usecoord) { |
|
277 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
278 | + } |
|
279 | + if ($id != '') { |
|
280 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
281 | + } |
|
261 | 282 | $query .= "UNION |
262 | 283 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
263 | 284 | FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date"; |
264 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
265 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
285 | + if ($usecoord) { |
|
286 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
287 | + } |
|
288 | + if ($id != '') { |
|
289 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
290 | + } |
|
266 | 291 | $query .= ") AS spotter |
267 | 292 | WHERE latitude <> '0' AND longitude <> '0' |
268 | 293 | ORDER BY flightaware_id, date"; |
269 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
294 | + if ($limit) { |
|
295 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
296 | + } |
|
270 | 297 | } else { |
271 | 298 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
272 | 299 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date "; |
273 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
274 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
300 | + if ($usecoord) { |
|
301 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
302 | + } |
|
303 | + if ($id != '') { |
|
304 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
305 | + } |
|
275 | 306 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
276 | 307 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
277 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
308 | + if ($limit) { |
|
309 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
310 | + } |
|
278 | 311 | } |
279 | 312 | } else { |
280 | 313 | if (isset($globalArchive) && $globalArchive === TRUE) { |
@@ -286,28 +319,46 @@ discard block |
||
286 | 319 | */ |
287 | 320 | $query = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration |
288 | 321 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id "; |
289 | - if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
290 | - if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id "; |
|
322 | + if ($usecoord) { |
|
323 | + $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
324 | + } |
|
325 | + if ($id != '') { |
|
326 | + $query .= "OR spotter_archive.flightaware_id = :id "; |
|
327 | + } |
|
291 | 328 | $query .= "UNION |
292 | 329 | SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
293 | 330 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date"; |
294 | - if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
295 | - if ($id != '') $query .= " OR spotter_live.flightaware_id = :id"; |
|
331 | + if ($usecoord) { |
|
332 | + $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
333 | + } |
|
334 | + if ($id != '') { |
|
335 | + $query .= " OR spotter_live.flightaware_id = :id"; |
|
336 | + } |
|
296 | 337 | $query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' "; |
297 | 338 | $query .= "ORDER BY flightaware_id, date"; |
298 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
339 | + if ($limit) { |
|
340 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
341 | + } |
|
299 | 342 | } else { |
300 | 343 | $query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
301 | 344 | FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date "; |
302 | - if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
303 | - if ($id != '') $query .= "OR spotter_live.flightaware_id = :id "; |
|
345 | + if ($usecoord) { |
|
346 | + $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") "; |
|
347 | + } |
|
348 | + if ($id != '') { |
|
349 | + $query .= "OR spotter_live.flightaware_id = :id "; |
|
350 | + } |
|
304 | 351 | $query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
305 | 352 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
306 | - if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
353 | + if ($limit) { |
|
354 | + $query .= " LIMIT ".$globalMap3DAircraftsLimit; |
|
355 | + } |
|
307 | 356 | } |
308 | 357 | } |
309 | 358 | $query_values = array(); |
310 | - if ($id != '') $query_values = array(':id' => $id); |
|
359 | + if ($id != '') { |
|
360 | + $query_values = array(':id' => $id); |
|
361 | + } |
|
311 | 362 | try { |
312 | 363 | $sth = $this->db->prepare($query); |
313 | 364 | $sth->execute($query_values); |
@@ -330,7 +381,9 @@ discard block |
||
330 | 381 | global $globalDBdriver, $globalLiveInterval; |
331 | 382 | $filter_query = $this->getFilter($filter,true,true); |
332 | 383 | |
333 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
384 | + if (!isset($globalLiveInterval)) { |
|
385 | + $globalLiveInterval = '200'; |
|
386 | + } |
|
334 | 387 | if ($globalDBdriver == 'mysql') { |
335 | 388 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
336 | 389 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -360,7 +413,9 @@ discard block |
||
360 | 413 | { |
361 | 414 | global $globalDBdriver, $globalLiveInterval; |
362 | 415 | $Spotter = new Spotter($this->db); |
363 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
416 | + if (!isset($globalLiveInterval)) { |
|
417 | + $globalLiveInterval = '200'; |
|
418 | + } |
|
364 | 419 | $filter_query = $this->getFilter($filter); |
365 | 420 | |
366 | 421 | if (is_array($coord)) { |
@@ -368,7 +423,9 @@ discard block |
||
368 | 423 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
369 | 424 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
370 | 425 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
371 | - } else return array(); |
|
426 | + } else { |
|
427 | + return array(); |
|
428 | + } |
|
372 | 429 | if ($globalDBdriver == 'mysql') { |
373 | 430 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
374 | 431 | } else { |
@@ -389,7 +446,9 @@ discard block |
||
389 | 446 | { |
390 | 447 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
391 | 448 | $Spotter = new Spotter($this->db); |
392 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
449 | + if (!isset($globalLiveInterval)) { |
|
450 | + $globalLiveInterval = '200'; |
|
451 | + } |
|
393 | 452 | $filter_query = $this->getFilter($filter,true,true); |
394 | 453 | |
395 | 454 | if (is_array($coord)) { |
@@ -397,7 +456,9 @@ discard block |
||
397 | 456 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
398 | 457 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
399 | 458 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
400 | - } else return array(); |
|
459 | + } else { |
|
460 | + return array(); |
|
461 | + } |
|
401 | 462 | if ($globalDBdriver == 'mysql') { |
402 | 463 | if (isset($globalArchive) && $globalArchive === TRUE) { |
403 | 464 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration |
@@ -624,11 +685,15 @@ discard block |
||
624 | 685 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
625 | 686 | if ($globalDBdriver == 'mysql') { |
626 | 687 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
627 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
688 | + if ($liveinterval) { |
|
689 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
690 | + } |
|
628 | 691 | $query .= ' ORDER BY date'; |
629 | 692 | } else { |
630 | 693 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
631 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
694 | + if ($liveinterval) { |
|
695 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
696 | + } |
|
632 | 697 | $query .= ' ORDER BY date'; |
633 | 698 | } |
634 | 699 | |
@@ -723,7 +788,9 @@ discard block |
||
723 | 788 | $i++; |
724 | 789 | $j++; |
725 | 790 | if ($j == 30) { |
726 | - if ($globalDebug) echo "."; |
|
791 | + if ($globalDebug) { |
|
792 | + echo "."; |
|
793 | + } |
|
727 | 794 | try { |
728 | 795 | |
729 | 796 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -1076,7 +1143,9 @@ discard block |
||
1076 | 1143 | { |
1077 | 1144 | return false; |
1078 | 1145 | } |
1079 | - } else return ''; |
|
1146 | + } else { |
|
1147 | + return ''; |
|
1148 | + } |
|
1080 | 1149 | |
1081 | 1150 | if ($longitude != '') |
1082 | 1151 | { |
@@ -1084,7 +1153,9 @@ discard block |
||
1084 | 1153 | { |
1085 | 1154 | return false; |
1086 | 1155 | } |
1087 | - } else return ''; |
|
1156 | + } else { |
|
1157 | + return ''; |
|
1158 | + } |
|
1088 | 1159 | |
1089 | 1160 | if ($waypoints != '') |
1090 | 1161 | { |
@@ -1100,14 +1171,18 @@ discard block |
||
1100 | 1171 | { |
1101 | 1172 | return false; |
1102 | 1173 | } |
1103 | - } else $altitude = 0; |
|
1174 | + } else { |
|
1175 | + $altitude = 0; |
|
1176 | + } |
|
1104 | 1177 | if ($altitude_real != '') |
1105 | 1178 | { |
1106 | 1179 | if (!is_numeric($altitude_real)) |
1107 | 1180 | { |
1108 | 1181 | return false; |
1109 | 1182 | } |
1110 | - } else $altitude_real = 0; |
|
1183 | + } else { |
|
1184 | + $altitude_real = 0; |
|
1185 | + } |
|
1111 | 1186 | |
1112 | 1187 | if ($heading != '') |
1113 | 1188 | { |
@@ -1115,7 +1190,9 @@ discard block |
||
1115 | 1190 | { |
1116 | 1191 | return false; |
1117 | 1192 | } |
1118 | - } else $heading = 0; |
|
1193 | + } else { |
|
1194 | + $heading = 0; |
|
1195 | + } |
|
1119 | 1196 | |
1120 | 1197 | if ($groundspeed != '') |
1121 | 1198 | { |
@@ -1123,9 +1200,13 @@ discard block |
||
1123 | 1200 | { |
1124 | 1201 | return false; |
1125 | 1202 | } |
1126 | - } else $groundspeed = 0; |
|
1203 | + } else { |
|
1204 | + $groundspeed = 0; |
|
1205 | + } |
|
1127 | 1206 | date_default_timezone_set('UTC'); |
1128 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1207 | + if ($date == '') { |
|
1208 | + $date = date("Y-m-d H:i:s", time()); |
|
1209 | + } |
|
1129 | 1210 | |
1130 | 1211 | |
1131 | 1212 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1170,14 +1251,24 @@ discard block |
||
1170 | 1251 | $arrival_airport_country = ''; |
1171 | 1252 | |
1172 | 1253 | |
1173 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1174 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1175 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1176 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1254 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
1255 | + $squawk = NULL; |
|
1256 | + } |
|
1257 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
1258 | + $verticalrate = NULL; |
|
1259 | + } |
|
1260 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1261 | + $groundspeed = 0; |
|
1262 | + } |
|
1263 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1264 | + $heading = 0; |
|
1265 | + } |
|
1177 | 1266 | |
1178 | 1267 | $query = ''; |
1179 | 1268 | if ($globalArchive) { |
1180 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1269 | + if ($globalDebug) { |
|
1270 | + echo '-- Delete previous data -- '; |
|
1271 | + } |
|
1181 | 1272 | $query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;'; |
1182 | 1273 | } |
1183 | 1274 | |
@@ -1194,10 +1285,14 @@ discard block |
||
1194 | 1285 | return "error : ".$e->getMessage(); |
1195 | 1286 | } |
1196 | 1287 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1197 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1288 | + if ($globalDebug) { |
|
1289 | + echo '(Add to SBS archive : '; |
|
1290 | + } |
|
1198 | 1291 | $SpotterArchive = new SpotterArchive($this->db); |
1199 | 1292 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
1200 | - if ($globalDebug) echo $result.')'; |
|
1293 | + if ($globalDebug) { |
|
1294 | + echo $result.')'; |
|
1295 | + } |
|
1201 | 1296 | } elseif ($globalDebug && $putinarchive !== true) { |
1202 | 1297 | echo '(Not adding to archive)'; |
1203 | 1298 | } elseif ($globalDebug && $noarchive === true) { |
@@ -58,7 +58,9 @@ discard block |
||
58 | 58 | { |
59 | 59 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
60 | 60 | $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
61 | - } else $image = $spotter_item['image_thumbnail']; |
|
61 | + } else { |
|
62 | + $image = $spotter_item['image_thumbnail']; |
|
63 | + } |
|
62 | 64 | } |
63 | 65 | /* else { |
64 | 66 | $image = "images/placeholder_thumb.png"; |
@@ -75,10 +77,14 @@ discard block |
||
75 | 77 | print '<div class="callsign-details">'; |
76 | 78 | if ($spotter_item['ident'] != 'Not Available') { |
77 | 79 | print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a>'; |
78 | - if (isset($spotter_item['blocked']) && $spotter_item['blocked'] === true) print '<img src="'.$globalURL.'/images/forbidden.png" title="'._("Callsign is in blocked FAA list").'" class="blocked" />'; |
|
80 | + if (isset($spotter_item['blocked']) && $spotter_item['blocked'] === true) { |
|
81 | + print '<img src="'.$globalURL.'/images/forbidden.png" title="'._("Callsign is in blocked FAA list").'" class="blocked" />'; |
|
82 | + } |
|
79 | 83 | print '</div>'; |
80 | 84 | } |
81 | - if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') print '<div class="airline">'.$spotter_item['airline_name'].'</div>'; |
|
85 | + if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') { |
|
86 | + print '<div class="airline">'.$spotter_item['airline_name'].'</div>'; |
|
87 | + } |
|
82 | 88 | print '</div>'; |
83 | 89 | if ($spotter_item['departure_airport'] != 'NA' && $spotter_item['arrival_airport'] != 'NA') { |
84 | 90 | print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country']; |
@@ -110,15 +116,25 @@ discard block |
||
110 | 116 | print '</div>'; |
111 | 117 | print '<div id="aircraft">'; |
112 | 118 | print '<span>'._("Aircraft").'</span>'; |
113 | - if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>'; |
|
119 | + if (isset($spotter_item['aircraft_wiki'])) { |
|
120 | + print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>'; |
|
121 | + } |
|
114 | 122 | if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') { |
115 | 123 | $aircraft_names = explode('/',$spotter_item['aircraft_name']); |
116 | - if (count($aircraft_names) == 1) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>'; |
|
117 | - else print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].' ('.$spotter_item['aircraft_type'].')</a>'; |
|
118 | - } elseif (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>'; |
|
119 | - else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name']; |
|
124 | + if (count($aircraft_names) == 1) { |
|
125 | + print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>'; |
|
126 | + } else { |
|
127 | + print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].' ('.$spotter_item['aircraft_type'].')</a>'; |
|
128 | + } |
|
129 | + } elseif (isset($spotter_item['aircraft_type'])) { |
|
130 | + print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>'; |
|
131 | + } else { |
|
132 | + print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name']; |
|
133 | + } |
|
120 | 134 | print '</div>'; |
121 | - if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>'; |
|
135 | + if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') { |
|
136 | + print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>'; |
|
137 | + } |
|
122 | 138 | |
123 | 139 | print '<div id="altitude"><span>'._("Altitude").'</span>'; |
124 | 140 | if (isset($globalGroundAltitude) && $globalGroundAltitude) { |
@@ -131,11 +147,17 @@ discard block |
||
131 | 147 | |
132 | 148 | print '<span class="altitude">'; |
133 | 149 | if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
134 | - if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')'; |
|
135 | - else print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')'; |
|
150 | + if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') { |
|
151 | + print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')'; |
|
152 | + } else { |
|
153 | + print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')'; |
|
154 | + } |
|
136 | 155 | } else { |
137 | - if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')'; |
|
138 | - else print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')'; |
|
156 | + if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') { |
|
157 | + print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')'; |
|
158 | + } else { |
|
159 | + print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')'; |
|
160 | + } |
|
139 | 161 | } |
140 | 162 | print '</span>'; |
141 | 163 | |
@@ -200,8 +222,11 @@ discard block |
||
200 | 222 | } |
201 | 223 | if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') { |
202 | 224 | print '<div id="pilot"><span>'._("Pilot").'</span>'; |
203 | - if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
204 | - else print $spotter_item['pilot_name']; |
|
225 | + if (isset($spotter_item['pilot_id'])) { |
|
226 | + print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
227 | + } else { |
|
228 | + print $spotter_item['pilot_name']; |
|
229 | + } |
|
205 | 230 | print '</div>'; |
206 | 231 | } |
207 | 232 | if (isset($spotter_item['aircraft_owner']) && $spotter_item['aircraft_owner'] != '') { |
@@ -227,10 +252,18 @@ discard block |
||
227 | 252 | } |
228 | 253 | print '</div>'; |
229 | 254 | print '</div>'; |
230 | - if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
|
231 | - if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
|
232 | - if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
233 | - if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
|
255 | + if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') { |
|
256 | + print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
|
257 | + } |
|
258 | + if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') { |
|
259 | + print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
|
260 | + } |
|
261 | + if (isset($spotter_item['acars']['message'])) { |
|
262 | + print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
263 | + } |
|
264 | + if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) { |
|
265 | + print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
|
266 | + } |
|
234 | 267 | print '</div>'; |
235 | 268 | } |
236 | 269 | ?> |
@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | try { |
53 | 53 | $GeoidClass = new GeoidHeight(); |
54 | 54 | } catch(Exception $e) { |
55 | - if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
55 | + if ($globalDebug) { |
|
56 | + echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
57 | + } |
|
56 | 58 | $GeoidClass = FALSE; |
57 | 59 | } |
58 | 60 | } |
@@ -71,7 +73,9 @@ discard block |
||
71 | 73 | $dbc = $this->db; |
72 | 74 | $this->all_flights[$id]['schedule_check'] = true; |
73 | 75 | if ($globalSchedulesFetch) { |
74 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
76 | + if ($globalDebug) { |
|
77 | + echo 'Getting schedule info...'."\n"; |
|
78 | + } |
|
75 | 79 | $Spotter = new Spotter($dbc); |
76 | 80 | $Schedule = new Schedule($dbc); |
77 | 81 | $Translation = new Translation($dbc); |
@@ -82,7 +86,9 @@ discard block |
||
82 | 86 | if ($Schedule->checkSchedule($operator) == 0) { |
83 | 87 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 88 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
89 | + if ($globalDebug) { |
|
90 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
91 | + } |
|
86 | 92 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
87 | 93 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
88 | 94 | // Should also check if route schedule = route from DB |
@@ -91,7 +97,9 @@ discard block |
||
91 | 97 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
92 | 98 | if (trim($airport_icao) != '') { |
93 | 99 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
94 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
100 | + if ($globalDebug) { |
|
101 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
102 | + } |
|
95 | 103 | } |
96 | 104 | } |
97 | 105 | } |
@@ -100,20 +108,30 @@ discard block |
||
100 | 108 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
101 | 109 | if (trim($airport_icao) != '') { |
102 | 110 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
103 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
111 | + if ($globalDebug) { |
|
112 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
113 | + } |
|
104 | 114 | } |
105 | 115 | } |
106 | 116 | } |
107 | 117 | $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
108 | 118 | } |
109 | - } else $scheduleexist = true; |
|
110 | - } else $scheduleexist = true; |
|
119 | + } else { |
|
120 | + $scheduleexist = true; |
|
121 | + } |
|
122 | + } else { |
|
123 | + $scheduleexist = true; |
|
124 | + } |
|
111 | 125 | // close connection, at least one way will work ? |
112 | 126 | if ($scheduleexist) { |
113 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
127 | + if ($globalDebug) { |
|
128 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
129 | + } |
|
114 | 130 | $sch = $Schedule->getSchedule($operator); |
115 | 131 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
116 | - if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
|
132 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
133 | + $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']); |
|
134 | + } |
|
117 | 135 | } |
118 | 136 | $Spotter->db = null; |
119 | 137 | $Schedule->db = null; |
@@ -133,14 +151,18 @@ discard block |
||
133 | 151 | |
134 | 152 | public function checkAll() { |
135 | 153 | global $globalDebug, $globalNoImport; |
136 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
154 | + if ($globalDebug) { |
|
155 | + echo "Update last seen flights data...\n"; |
|
156 | + } |
|
137 | 157 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
138 | 158 | foreach ($this->all_flights as $key => $flight) { |
139 | 159 | if (isset($this->all_flights[$key]['id'])) { |
140 | 160 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
141 | 161 | $Spotter = new Spotter($this->db); |
142 | 162 | $real_arrival = $this->arrival($key); |
143 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
163 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) { |
|
164 | + $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
165 | + } |
|
144 | 166 | } |
145 | 167 | } |
146 | 168 | } |
@@ -148,24 +170,32 @@ discard block |
||
148 | 170 | |
149 | 171 | public function arrival($key) { |
150 | 172 | global $globalClosestMinDist, $globalDebug; |
151 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
173 | + if ($globalDebug) { |
|
174 | + echo 'Update arrival...'."\n"; |
|
175 | + } |
|
152 | 176 | $Spotter = new Spotter($this->db); |
153 | 177 | $airport_icao = ''; |
154 | 178 | $airport_time = ''; |
155 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
179 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
180 | + $globalClosestMinDist = 50; |
|
181 | + } |
|
156 | 182 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
157 | 183 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
158 | 184 | if (isset($closestAirports[0])) { |
159 | 185 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
160 | 186 | $airport_icao = $closestAirports[0]['icao']; |
161 | 187 | $airport_time = $this->all_flights[$key]['datetime']; |
162 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
188 | + if ($globalDebug) { |
|
189 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
190 | + } |
|
163 | 191 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
164 | 192 | foreach ($closestAirports as $airport) { |
165 | 193 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
166 | 194 | $airport_icao = $airport['icao']; |
167 | 195 | $airport_time = $this->all_flights[$key]['datetime']; |
168 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
196 | + if ($globalDebug) { |
|
197 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
198 | + } |
|
169 | 199 | break; |
170 | 200 | } |
171 | 201 | } |
@@ -173,14 +203,20 @@ discard block |
||
173 | 203 | $airport_icao = $closestAirports[0]['icao']; |
174 | 204 | $airport_time = $this->all_flights[$key]['datetime']; |
175 | 205 | } else { |
176 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
206 | + if ($globalDebug) { |
|
207 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
208 | + } |
|
177 | 209 | } |
178 | 210 | } else { |
179 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
211 | + if ($globalDebug) { |
|
212 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
213 | + } |
|
180 | 214 | } |
181 | 215 | |
182 | 216 | } else { |
183 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
217 | + if ($globalDebug) { |
|
218 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
219 | + } |
|
184 | 220 | } |
185 | 221 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
186 | 222 | } |
@@ -190,7 +226,9 @@ discard block |
||
190 | 226 | public function del() { |
191 | 227 | global $globalDebug, $globalNoImport, $globalNoDB; |
192 | 228 | // Delete old infos |
193 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
229 | + if ($globalDebug) { |
|
230 | + echo 'Delete old values and update latest data...'."\n"; |
|
231 | + } |
|
194 | 232 | |
195 | 233 | foreach ($this->all_flights as $key => $flight) { |
196 | 234 | if (isset($flight['lastupdate'])) { |
@@ -205,22 +243,30 @@ discard block |
||
205 | 243 | global $globalDebug, $globalNoImport, $globalNoDB; |
206 | 244 | // Delete old infos |
207 | 245 | if (isset($this->all_flights[$key]['id'])) { |
208 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
246 | + if ($globalDebug) { |
|
247 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
248 | + } |
|
209 | 249 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
210 | 250 | $real_arrival = $this->arrival($key); |
211 | 251 | $Spotter = new Spotter($this->db); |
212 | 252 | $SpotterLive = new SpotterLive($this->db); |
213 | 253 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
214 | 254 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
215 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
255 | + if ($globalDebug && $result != 'success') { |
|
256 | + echo '!!! ERROR : '.$result."\n"; |
|
257 | + } |
|
216 | 258 | $this->all_flights[$key]['putinarchive'] = true; |
217 | 259 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']); |
218 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
260 | + if ($globalDebug && $result != 'success') { |
|
261 | + echo '!!! ERROR : '.$result."\n"; |
|
262 | + } |
|
219 | 263 | } |
220 | 264 | $Spotter->db = null; |
221 | 265 | $SpotterLive->db = null; |
222 | 266 | } |
223 | - if ($globalDebug) echo "\n"; |
|
267 | + if ($globalDebug) { |
|
268 | + echo "\n"; |
|
269 | + } |
|
224 | 270 | } |
225 | 271 | unset($this->all_flights[$key]); |
226 | 272 | } |
@@ -228,9 +274,13 @@ discard block |
||
228 | 274 | public function add($line) { |
229 | 275 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive; |
230 | 276 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
231 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
|
232 | - if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000; |
|
233 | -/* |
|
277 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
278 | + $globalCoordMinChange = '0.01'; |
|
279 | + } |
|
280 | + if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') { |
|
281 | + $globalAircraftMaxUpdate = 3000; |
|
282 | + } |
|
283 | + /* |
|
234 | 284 | $Spotter = new Spotter(); |
235 | 285 | $dbc = $Spotter->db; |
236 | 286 | $SpotterLive = new SpotterLive($dbc); |
@@ -252,19 +302,28 @@ discard block |
||
252 | 302 | // SBS format is CSV format |
253 | 303 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
254 | 304 | //print_r($line); |
255 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
305 | + if (isset($line['hex'])) { |
|
306 | + $line['hex'] = strtoupper($line['hex']); |
|
307 | + } |
|
256 | 308 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
257 | 309 | |
258 | 310 | // Increment message number |
259 | 311 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
260 | 312 | $current_date = date('Y-m-d'); |
261 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
262 | - else $source = ''; |
|
263 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
313 | + if (isset($line['source_name'])) { |
|
314 | + $source = $line['source_name']; |
|
315 | + } else { |
|
316 | + $source = ''; |
|
317 | + } |
|
318 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
319 | + $source = $line['format_source']; |
|
320 | + } |
|
264 | 321 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
265 | 322 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
266 | 323 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
267 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
324 | + } else { |
|
325 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
326 | + } |
|
268 | 327 | } |
269 | 328 | |
270 | 329 | /* |
@@ -280,23 +339,38 @@ discard block |
||
280 | 339 | //$this->db = $dbc; |
281 | 340 | |
282 | 341 | //$hex = trim($line['hex']); |
283 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
284 | - else $id = trim($line['id']); |
|
342 | + if (!isset($line['id'])) { |
|
343 | + $id = trim($line['hex']); |
|
344 | + } else { |
|
345 | + $id = trim($line['id']); |
|
346 | + } |
|
285 | 347 | |
286 | 348 | if (!isset($this->all_flights[$id])) { |
287 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
349 | + if ($globalDebug) { |
|
350 | + echo 'New flight...'."\n"; |
|
351 | + } |
|
288 | 352 | $this->all_flights[$id] = array(); |
289 | 353 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
290 | 354 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
291 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
355 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
356 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
357 | + } |
|
292 | 358 | if (!isset($line['id'])) { |
293 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
294 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
359 | + if (!isset($globalDaemon)) { |
|
360 | + $globalDaemon = TRUE; |
|
361 | + } |
|
362 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
295 | 363 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
296 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
364 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
365 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
366 | + } |
|
297 | 367 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
298 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
299 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
368 | + } else { |
|
369 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
370 | + } |
|
371 | + if ($globalAllFlights !== FALSE) { |
|
372 | + $dataFound = true; |
|
373 | + } |
|
300 | 374 | } |
301 | 375 | if (isset($line['source_type']) && $line['source_type'] != '') { |
302 | 376 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -318,12 +392,20 @@ discard block |
||
318 | 392 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
319 | 393 | } |
320 | 394 | $Spotter->db = null; |
321 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
322 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
395 | + if ($globalDebugTimeElapsed) { |
|
396 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
397 | + } |
|
398 | + if ($aircraft_icao != '') { |
|
399 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
400 | + } |
|
323 | 401 | } |
324 | 402 | } |
325 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
326 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
403 | + if ($globalAllFlights !== FALSE) { |
|
404 | + $dataFound = true; |
|
405 | + } |
|
406 | + if ($globalDebug) { |
|
407 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
408 | + } |
|
327 | 409 | } |
328 | 410 | if (isset($line['id']) && !isset($line['hex'])) { |
329 | 411 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
@@ -332,7 +414,9 @@ discard block |
||
332 | 414 | $icao = $line['aircraft_icao']; |
333 | 415 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
334 | 416 | $Spotter = new Spotter($this->db); |
335 | - if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
417 | + if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
418 | + $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
419 | + } |
|
336 | 420 | $Spotter->db = null; |
337 | 421 | } |
338 | 422 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
@@ -342,15 +426,24 @@ discard block |
||
342 | 426 | $Spotter = new Spotter($this->db); |
343 | 427 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
344 | 428 | $Spotter->db = null; |
345 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
429 | + if ($aircraft_icao != '') { |
|
430 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
431 | + } |
|
346 | 432 | } |
347 | 433 | } |
348 | 434 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
349 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
350 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
351 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
352 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
353 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
435 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
436 | + $aircraft_icao = 'GLID'; |
|
437 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
438 | + $aircraft_icao = 'UHEL'; |
|
439 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
440 | + $aircraft_icao = 'TOWPLANE'; |
|
441 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
442 | + $aircraft_icao = 'POWAIRC'; |
|
443 | + } |
|
444 | + if (isset($aircraft_icao)) { |
|
445 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
446 | + } |
|
354 | 447 | } |
355 | 448 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
356 | 449 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -360,8 +453,11 @@ discard block |
||
360 | 453 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
361 | 454 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
362 | 455 | } else { |
363 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
364 | - elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
456 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
457 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
458 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
459 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
460 | + } |
|
365 | 461 | /* |
366 | 462 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
367 | 463 | print_r($this->all_flights[$id]); |
@@ -370,16 +466,22 @@ discard block |
||
370 | 466 | return ''; |
371 | 467 | } |
372 | 468 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
373 | - if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
469 | + if ($globalDebug) { |
|
470 | + echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
471 | + } |
|
374 | 472 | return ''; |
375 | 473 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
376 | - if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
474 | + if ($globalDebug) { |
|
475 | + echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
476 | + } |
|
377 | 477 | return ''; |
378 | 478 | } elseif (!isset($line['datetime'])) { |
379 | 479 | date_default_timezone_set('UTC'); |
380 | 480 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
381 | 481 | } else { |
382 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
482 | + if ($globalDebug) { |
|
483 | + echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
484 | + } |
|
383 | 485 | return ''; |
384 | 486 | } |
385 | 487 | |
@@ -400,30 +502,48 @@ discard block |
||
400 | 502 | |
401 | 503 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
402 | 504 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
403 | - if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
505 | + if ($globalDebug) { |
|
506 | + echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
507 | + } |
|
404 | 508 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
405 | 509 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
406 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
407 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
408 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
510 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
511 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
512 | + } elseif (isset($line['id'])) { |
|
513 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
514 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
515 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
516 | + } |
|
409 | 517 | } else { |
410 | 518 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
411 | 519 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
412 | 520 | $timeelapsed = microtime(true); |
413 | 521 | $Spotter = new Spotter($this->db); |
414 | 522 | $fromsource = NULL; |
415 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
416 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
417 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
418 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
419 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
523 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
524 | + $fromsource = $globalAirlinesSource; |
|
525 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
526 | + $fromsource = 'vatsim'; |
|
527 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
528 | + $fromsource = 'ivao'; |
|
529 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
530 | + $fromsource = 'vatsim'; |
|
531 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
532 | + $fromsource = 'ivao'; |
|
533 | + } |
|
420 | 534 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']); |
421 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
535 | + if ($globalDebug && $result != 'success') { |
|
536 | + echo '!!! ERROR : '.$result."\n"; |
|
537 | + } |
|
422 | 538 | $Spotter->db = null; |
423 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
539 | + if ($globalDebugTimeElapsed) { |
|
540 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
541 | + } |
|
424 | 542 | } |
425 | 543 | } |
426 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
544 | + } else { |
|
545 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
546 | + } |
|
427 | 547 | |
428 | 548 | /* |
429 | 549 | if (!isset($line['id'])) { |
@@ -433,7 +553,9 @@ discard block |
||
433 | 553 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
434 | 554 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
435 | 555 | */ |
436 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
556 | + if (!isset($this->all_flights[$id]['id'])) { |
|
557 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
558 | + } |
|
437 | 559 | |
438 | 560 | //$putinarchive = true; |
439 | 561 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -451,7 +573,9 @@ discard block |
||
451 | 573 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
452 | 574 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
453 | 575 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
454 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
576 | + if ($globalDebugTimeElapsed) { |
|
577 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
578 | + } |
|
455 | 579 | } |
456 | 580 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
457 | 581 | $timeelapsed = microtime(true); |
@@ -465,7 +589,9 @@ discard block |
||
465 | 589 | $Translation->db = null; |
466 | 590 | } |
467 | 591 | $Spotter->db = null; |
468 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
592 | + if ($globalDebugTimeElapsed) { |
|
593 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
594 | + } |
|
469 | 595 | } |
470 | 596 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
471 | 597 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -474,9 +600,13 @@ discard block |
||
474 | 600 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
475 | 601 | } |
476 | 602 | } |
477 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
603 | + if (!isset($globalFork)) { |
|
604 | + $globalFork = TRUE; |
|
605 | + } |
|
478 | 606 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
479 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
607 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
608 | + $this->get_Schedule($id,trim($line['ident'])); |
|
609 | + } |
|
480 | 610 | } |
481 | 611 | } |
482 | 612 | } |
@@ -494,9 +624,13 @@ discard block |
||
494 | 624 | $speed = $speed*3.6; |
495 | 625 | if ($speed < 1000) { |
496 | 626 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
497 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
627 | + if ($globalDebug) { |
|
628 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
629 | + } |
|
498 | 630 | } else { |
499 | - if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
631 | + if ($globalDebug) { |
|
632 | + echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
633 | + } |
|
500 | 634 | } |
501 | 635 | } |
502 | 636 | } |
@@ -505,13 +639,21 @@ discard block |
||
505 | 639 | |
506 | 640 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
507 | 641 | if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
508 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
642 | + if ($globalDebug) { |
|
643 | + echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
644 | + } |
|
509 | 645 | return false; |
510 | 646 | } |
511 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
512 | - else unset($timediff); |
|
513 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
514 | - else unset($timediff_archive); |
|
647 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
648 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
649 | + } else { |
|
650 | + unset($timediff); |
|
651 | + } |
|
652 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) { |
|
653 | + $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
654 | + } else { |
|
655 | + unset($timediff_archive); |
|
656 | + } |
|
515 | 657 | if ($this->tmd > 5 |
516 | 658 | || (isset($line['format_source']) |
517 | 659 | && $line['format_source'] == 'airwhere' |
@@ -548,16 +690,25 @@ discard block |
||
548 | 690 | $this->all_flights[$id]['putinarchive'] = true; |
549 | 691 | $this->tmd = 0; |
550 | 692 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
551 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
693 | + if ($globalDebug) { |
|
694 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
695 | + } |
|
552 | 696 | $timeelapsed = microtime(true); |
553 | 697 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
554 | 698 | $Spotter = new Spotter($this->db); |
555 | 699 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
556 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
557 | - else $this->all_flights[$id]['over_country'] = ''; |
|
700 | + if (!empty($all_country)) { |
|
701 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
702 | + } else { |
|
703 | + $this->all_flights[$id]['over_country'] = ''; |
|
704 | + } |
|
558 | 705 | $Spotter->db = null; |
559 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
560 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
706 | + if ($globalDebugTimeElapsed) { |
|
707 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
708 | + } |
|
709 | + if ($globalDebug) { |
|
710 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
711 | + } |
|
561 | 712 | } |
562 | 713 | } |
563 | 714 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
@@ -603,7 +754,9 @@ discard block |
||
603 | 754 | */ |
604 | 755 | } |
605 | 756 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
606 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
757 | + if ($line['longitude'] > 180) { |
|
758 | + $line['longitude'] = $line['longitude'] - 360; |
|
759 | + } |
|
607 | 760 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
608 | 761 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
609 | 762 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -640,7 +793,9 @@ discard block |
||
640 | 793 | } |
641 | 794 | } |
642 | 795 | if (isset($line['last_update']) && $line['last_update'] != '') { |
643 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
796 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
797 | + $dataFound = true; |
|
798 | + } |
|
644 | 799 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
645 | 800 | } |
646 | 801 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -662,35 +817,53 @@ discard block |
||
662 | 817 | // Here we force archive of flight because after ground it's a new one (or should be) |
663 | 818 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
664 | 819 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
665 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
666 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
667 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
820 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
821 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
822 | + } elseif (isset($line['id'])) { |
|
823 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
824 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
825 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
826 | + } |
|
827 | + } |
|
828 | + if ($line['ground'] != 1) { |
|
829 | + $line['ground'] = 0; |
|
668 | 830 | } |
669 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
670 | 831 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
671 | 832 | //$dataFound = true; |
672 | 833 | } |
673 | 834 | if (isset($line['squawk']) && $line['squawk'] != '') { |
674 | 835 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
675 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
836 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
837 | + $this->all_flights[$id]['putinarchive'] = true; |
|
838 | + } |
|
676 | 839 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
677 | 840 | $highlight = ''; |
678 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
679 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
680 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
841 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
842 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
843 | + } |
|
844 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
845 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
846 | + } |
|
847 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
848 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
849 | + } |
|
681 | 850 | if ($highlight != '') { |
682 | 851 | $timeelapsed = microtime(true); |
683 | 852 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
684 | 853 | $Spotter = new Spotter($this->db); |
685 | 854 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
686 | 855 | $Spotter->db = null; |
687 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
856 | + if ($globalDebugTimeElapsed) { |
|
857 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
858 | + } |
|
688 | 859 | } |
689 | 860 | //$putinarchive = true; |
690 | 861 | //$highlight = ''; |
691 | 862 | } |
692 | 863 | |
693 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
864 | + } else { |
|
865 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
866 | + } |
|
694 | 867 | //$dataFound = true; |
695 | 868 | } |
696 | 869 | |
@@ -703,19 +876,27 @@ discard block |
||
703 | 876 | } |
704 | 877 | } |
705 | 878 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
706 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
879 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
880 | + $this->all_flights[$id]['putinarchive'] = true; |
|
881 | + } |
|
707 | 882 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
708 | 883 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
709 | 884 | //$dataFound = true; |
710 | 885 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
711 | 886 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
712 | 887 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
713 | - if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
888 | + if ($globalDebug) { |
|
889 | + echo '--- Reset because of altitude'."\n"; |
|
890 | + } |
|
714 | 891 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
715 | 892 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
716 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
717 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
718 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
893 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
894 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
895 | + } elseif (isset($line['id'])) { |
|
896 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
897 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
898 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
899 | + } |
|
719 | 900 | } |
720 | 901 | } |
721 | 902 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
@@ -726,22 +907,32 @@ discard block |
||
726 | 907 | } |
727 | 908 | |
728 | 909 | if (isset($line['heading']) && $line['heading'] != '') { |
729 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
910 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
911 | + $this->all_flights[$id]['putinarchive'] = true; |
|
912 | + } |
|
730 | 913 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
731 | 914 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
732 | 915 | //$dataFound = true; |
733 | 916 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
734 | 917 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
735 | 918 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
736 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
737 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
919 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
920 | + $this->all_flights[$id]['putinarchive'] = true; |
|
921 | + } |
|
922 | + if ($globalDebug) { |
|
923 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
924 | + } |
|
738 | 925 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
739 | 926 | // If not enough messages and ACARS set heading to 0 |
740 | 927 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
741 | 928 | } |
742 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
743 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
744 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
929 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
930 | + $dataFound = false; |
|
931 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
932 | + $dataFound = false; |
|
933 | + } elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) { |
|
934 | + $dataFound = false; |
|
935 | + } |
|
745 | 936 | |
746 | 937 | // print_r($this->all_flights[$id]); |
747 | 938 | //gets the callsign from the last hour |
@@ -758,23 +949,38 @@ discard block |
||
758 | 949 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
759 | 950 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
760 | 951 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
761 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
952 | + if ($globalDebug) { |
|
953 | + echo "Check if aircraft is already in DB..."; |
|
954 | + } |
|
762 | 955 | $timeelapsed = microtime(true); |
763 | 956 | $SpotterLive = new SpotterLive($this->db); |
764 | 957 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
765 | 958 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
766 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
959 | + if ($globalDebugTimeElapsed) { |
|
960 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
961 | + } |
|
767 | 962 | } elseif (isset($line['id'])) { |
768 | 963 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
769 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
964 | + if ($globalDebugTimeElapsed) { |
|
965 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
966 | + } |
|
770 | 967 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
771 | 968 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
772 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
773 | - } else $recent_ident = ''; |
|
969 | + if ($globalDebugTimeElapsed) { |
|
970 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
971 | + } |
|
972 | + } else { |
|
973 | + $recent_ident = ''; |
|
974 | + } |
|
774 | 975 | $SpotterLive->db=null; |
775 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
776 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
777 | - } else $recent_ident = ''; |
|
976 | + if ($globalDebug && $recent_ident == '') { |
|
977 | + echo " Not in DB.\n"; |
|
978 | + } elseif ($globalDebug && $recent_ident != '') { |
|
979 | + echo " Already in DB.\n"; |
|
980 | + } |
|
981 | + } else { |
|
982 | + $recent_ident = ''; |
|
983 | + } |
|
778 | 984 | } else { |
779 | 985 | $recent_ident = ''; |
780 | 986 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -782,7 +988,9 @@ discard block |
||
782 | 988 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
783 | 989 | if($recent_ident == "") |
784 | 990 | { |
785 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
991 | + if ($globalDebug) { |
|
992 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
993 | + } |
|
786 | 994 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
787 | 995 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
788 | 996 | //adds the spotter data for the archive |
@@ -826,10 +1034,18 @@ discard block |
||
826 | 1034 | |
827 | 1035 | if (!$ignoreImport) { |
828 | 1036 | $highlight = ''; |
829 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
830 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
831 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
832 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1037 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
1038 | + $highlight = 'Squawk 7500 : Hijack'; |
|
1039 | + } |
|
1040 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
1041 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
1042 | + } |
|
1043 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
1044 | + $highlight = 'Squawk 7700 : Emergency'; |
|
1045 | + } |
|
1046 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1047 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1048 | + } |
|
833 | 1049 | $timeelapsed = microtime(true); |
834 | 1050 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
835 | 1051 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -837,28 +1053,43 @@ discard block |
||
837 | 1053 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
838 | 1054 | $Spotter->db = null; |
839 | 1055 | if ($globalDebug) { |
840 | - if (isset($result['error'])) echo 'Error: '.$result['error']."\n"; |
|
841 | - else echo 'Success'; |
|
1056 | + if (isset($result['error'])) { |
|
1057 | + echo 'Error: '.$result['error']."\n"; |
|
1058 | + } else { |
|
1059 | + echo 'Success'; |
|
1060 | + } |
|
842 | 1061 | } |
843 | 1062 | if (count($result) > 1) { |
844 | 1063 | // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type, |
845 | - if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
|
846 | - if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration']; |
|
1064 | + if ($this->all_flights[$id]['aircraft_icao'] == '') { |
|
1065 | + $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao']; |
|
1066 | + } |
|
1067 | + if ($this->all_flights[$id]['registration'] == '') { |
|
1068 | + $this->all_flights[$id]['registration'] = $result[':registration']; |
|
1069 | + } |
|
847 | 1070 | } |
848 | 1071 | } |
849 | 1072 | } |
850 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1073 | + if ($globalDebugTimeElapsed) { |
|
1074 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1075 | + } |
|
851 | 1076 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
852 | 1077 | |
853 | 1078 | // Add source stat in DB |
854 | 1079 | $Stats = new Stats($this->db); |
855 | 1080 | if (!empty($this->stats)) { |
856 | - if ($globalDebug) echo 'Add source stats : '; |
|
1081 | + if ($globalDebug) { |
|
1082 | + echo 'Add source stats : '; |
|
1083 | + } |
|
857 | 1084 | foreach($this->stats as $date => $data) { |
858 | 1085 | foreach($data as $source => $sourced) { |
859 | 1086 | //print_r($sourced); |
860 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
861 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
1087 | + if (isset($sourced['polar'])) { |
|
1088 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
1089 | + } |
|
1090 | + if (isset($sourced['hist'])) { |
|
1091 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
1092 | + } |
|
862 | 1093 | if (isset($sourced['msg'])) { |
863 | 1094 | if (time() - $sourced['msg']['date'] > 10) { |
864 | 1095 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -871,13 +1102,17 @@ discard block |
||
871 | 1102 | unset($this->stats[$date]); |
872 | 1103 | } |
873 | 1104 | } |
874 | - if ($globalDebug) echo 'Done'."\n"; |
|
1105 | + if ($globalDebug) { |
|
1106 | + echo 'Done'."\n"; |
|
1107 | + } |
|
875 | 1108 | |
876 | 1109 | } |
877 | 1110 | $Stats->db = null; |
878 | 1111 | } |
879 | 1112 | $this->del(); |
880 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
1113 | + } elseif ($globalDebug) { |
|
1114 | + echo 'Ignore data'."\n"; |
|
1115 | + } |
|
881 | 1116 | //$ignoreImport = false; |
882 | 1117 | $this->all_flights[$id]['addedSpotter'] = 1; |
883 | 1118 | //print_r($this->all_flights[$id]); |
@@ -894,7 +1129,9 @@ discard block |
||
894 | 1129 | */ |
895 | 1130 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
896 | 1131 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
897 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1132 | + if ($globalDebug) { |
|
1133 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1134 | + } |
|
898 | 1135 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
899 | 1136 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
900 | 1137 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -903,7 +1140,9 @@ discard block |
||
903 | 1140 | $SpotterLive->db=null; |
904 | 1141 | } |
905 | 1142 | } |
906 | - if ($globalDebug) echo " Done\n"; |
|
1143 | + if ($globalDebug) { |
|
1144 | + echo " Done\n"; |
|
1145 | + } |
|
907 | 1146 | $this->last_delete = time(); |
908 | 1147 | } |
909 | 1148 | } else { |
@@ -930,11 +1169,17 @@ discard block |
||
930 | 1169 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
931 | 1170 | if ($globalDebug) { |
932 | 1171 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
933 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
934 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
1172 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1173 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
1174 | + } else { |
|
1175 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
1176 | + } |
|
935 | 1177 | } else { |
936 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
937 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
1178 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1179 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
1180 | + } else { |
|
1181 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
1182 | + } |
|
938 | 1183 | } |
939 | 1184 | } |
940 | 1185 | $ignoreImport = false; |
@@ -980,22 +1225,30 @@ discard block |
||
980 | 1225 | |
981 | 1226 | if (!$ignoreImport) { |
982 | 1227 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
983 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1228 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1229 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1230 | + } |
|
984 | 1231 | $timeelapsed = microtime(true); |
985 | 1232 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
986 | 1233 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
987 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1234 | + if ($globalDebug) { |
|
1235 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1236 | + } |
|
988 | 1237 | $SpotterLive = new SpotterLive($this->db); |
989 | 1238 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
990 | 1239 | $SpotterLive->db = null; |
991 | - if ($globalDebug) echo $result."\n"; |
|
1240 | + if ($globalDebug) { |
|
1241 | + echo $result."\n"; |
|
1242 | + } |
|
992 | 1243 | } |
993 | 1244 | } |
994 | 1245 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
995 | 1246 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
996 | 1247 | } |
997 | 1248 | $this->all_flights[$id]['putinarchive'] = false; |
998 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1249 | + if ($globalDebugTimeElapsed) { |
|
1250 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1251 | + } |
|
999 | 1252 | |
1000 | 1253 | // Put statistics in $this->stats variable |
1001 | 1254 | //if ($line['format_source'] != 'aprs') { |
@@ -1003,7 +1256,9 @@ discard block |
||
1003 | 1256 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
1004 | 1257 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
1005 | 1258 | $source = $this->all_flights[$id]['source_name']; |
1006 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
1259 | + if ($source == '') { |
|
1260 | + $source = $this->all_flights[$id]['format_source']; |
|
1261 | + } |
|
1007 | 1262 | if (!isset($this->source_location[$source])) { |
1008 | 1263 | $Location = new Source($this->db); |
1009 | 1264 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -1024,7 +1279,9 @@ discard block |
||
1024 | 1279 | $stats_heading = round($stats_heading/22.5); |
1025 | 1280 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
1026 | 1281 | $current_date = date('Y-m-d'); |
1027 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1282 | + if ($stats_heading == 16) { |
|
1283 | + $stats_heading = 0; |
|
1284 | + } |
|
1028 | 1285 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1029 | 1286 | for ($i=0;$i<=15;$i++) { |
1030 | 1287 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -1042,7 +1299,9 @@ discard block |
||
1042 | 1299 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1043 | 1300 | end($this->stats[$current_date][$source]['hist']); |
1044 | 1301 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
1045 | - } else $mini = 0; |
|
1302 | + } else { |
|
1303 | + $mini = 0; |
|
1304 | + } |
|
1046 | 1305 | for ($i=$mini;$i<=$distance;$i+=10) { |
1047 | 1306 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1048 | 1307 | } |
@@ -1054,19 +1313,27 @@ discard block |
||
1054 | 1313 | } |
1055 | 1314 | |
1056 | 1315 | $this->all_flights[$id]['lastupdate'] = time(); |
1057 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1316 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1317 | + $send = true; |
|
1318 | + } |
|
1058 | 1319 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1059 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1320 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1321 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1322 | + } |
|
1060 | 1323 | //$this->del(); |
1061 | 1324 | |
1062 | 1325 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1063 | 1326 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
1064 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1327 | + if ($globalDebug) { |
|
1328 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1329 | + } |
|
1065 | 1330 | $SpotterLive = new SpotterLive($this->db); |
1066 | 1331 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
1067 | 1332 | $SpotterLive->db = null; |
1068 | 1333 | //SpotterLive->deleteLiveSpotterData(); |
1069 | - if ($globalDebug) echo " Done\n"; |
|
1334 | + if ($globalDebug) { |
|
1335 | + echo " Done\n"; |
|
1336 | + } |
|
1070 | 1337 | $this->last_delete_hourly = time(); |
1071 | 1338 | } else { |
1072 | 1339 | $this->del(); |
@@ -1078,7 +1345,9 @@ discard block |
||
1078 | 1345 | //$ignoreImport = false; |
1079 | 1346 | } |
1080 | 1347 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1081 | - if ($send) return $this->all_flights[$id]; |
|
1348 | + if ($send) { |
|
1349 | + return $this->all_flights[$id]; |
|
1350 | + } |
|
1082 | 1351 | } |
1083 | 1352 | } |
1084 | 1353 | } |
@@ -11,7 +11,9 @@ discard block |
||
11 | 11 | header('Content-Type: text/javascript'); |
12 | 12 | $latitude = filter_input(INPUT_GET,'latitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
13 | 13 | $longitude = filter_input(INPUT_GET,'longitude',FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
14 | -if ($latitude == '' || $longitude == '') return ''; |
|
14 | +if ($latitude == '' || $longitude == '') { |
|
15 | + return ''; |
|
16 | +} |
|
15 | 17 | //echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
16 | 18 | $airports = $Spotter->closestAirports($latitude,$longitude,200); |
17 | 19 | //print_r($airports); |
@@ -36,7 +38,9 @@ discard block |
||
36 | 38 | } |
37 | 39 | } |
38 | 40 | $i++; |
39 | - if ($i >= count($airports)) $ew = false; |
|
40 | -} |
|
41 | + if ($i >= count($airports)) { |
|
42 | + $ew = false; |
|
43 | + } |
|
44 | + } |
|
41 | 45 | |
42 | 46 | ?> |
43 | 47 | \ No newline at end of file |
@@ -26,7 +26,9 @@ discard block |
||
26 | 26 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
27 | 27 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
28 | 28 | curl_setopt($ch, CURLOPT_TIMEOUT, 200); |
29 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
29 | + if ($referer != '') { |
|
30 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
31 | + } |
|
30 | 32 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
31 | 33 | curl_setopt($ch, CURLOPT_FILE, $fp); |
32 | 34 | curl_exec($ch); |
@@ -37,12 +39,16 @@ discard block |
||
37 | 39 | public static function gunzip($in_file,$out_file_name = '') { |
38 | 40 | //echo $in_file.' -> '.$out_file_name."\n"; |
39 | 41 | $buffer_size = 4096; // read 4kb at a time |
40 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
42 | + if ($out_file_name == '') { |
|
43 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
44 | + } |
|
41 | 45 | if ($in_file != '' && file_exists($in_file)) { |
42 | 46 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
43 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
44 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
45 | - else { |
|
47 | + if (function_exists('gzopen')) { |
|
48 | + $file = gzopen($in_file,'rb'); |
|
49 | + } elseif (function_exists('gzopen64')) { |
|
50 | + $file = gzopen64($in_file,'rb'); |
|
51 | + } else { |
|
46 | 52 | echo 'gzopen not available'; |
47 | 53 | die; |
48 | 54 | } |
@@ -63,8 +69,12 @@ discard block |
||
63 | 69 | if ($res === TRUE) { |
64 | 70 | $zip->extractTo($path); |
65 | 71 | $zip->close(); |
66 | - } else return false; |
|
67 | - } else return false; |
|
72 | + } else { |
|
73 | + return false; |
|
74 | + } |
|
75 | + } else { |
|
76 | + return false; |
|
77 | + } |
|
68 | 78 | } |
69 | 79 | |
70 | 80 | public static function connect_sqlite($database) { |
@@ -79,7 +89,9 @@ discard block |
||
79 | 89 | public static function retrieve_route_sqlite_to_dest($database_file) { |
80 | 90 | global $globalDebug, $globalTransaction; |
81 | 91 | //$query = 'TRUNCATE TABLE routes'; |
82 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
92 | + if ($globalDebug) { |
|
93 | + echo " - Delete previous routes from DB -"; |
|
94 | + } |
|
83 | 95 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
84 | 96 | $Connection = new Connection(); |
85 | 97 | try { |
@@ -90,7 +102,9 @@ discard block |
||
90 | 102 | return "error : ".$e->getMessage(); |
91 | 103 | } |
92 | 104 | |
93 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
105 | + if ($globalDebug) { |
|
106 | + echo " - Add routes to DB -"; |
|
107 | + } |
|
94 | 108 | update_db::connect_sqlite($database_file); |
95 | 109 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
96 | 110 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -105,15 +119,21 @@ discard block |
||
105 | 119 | $Connection = new Connection(); |
106 | 120 | $sth_dest = $Connection->db->prepare($query_dest); |
107 | 121 | try { |
108 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
122 | + if ($globalTransaction) { |
|
123 | + $Connection->db->beginTransaction(); |
|
124 | + } |
|
109 | 125 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
110 | 126 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
111 | 127 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
112 | 128 | $sth_dest->execute($query_dest_values); |
113 | 129 | } |
114 | - if ($globalTransaction) $Connection->db->commit(); |
|
130 | + if ($globalTransaction) { |
|
131 | + $Connection->db->commit(); |
|
132 | + } |
|
115 | 133 | } catch(PDOException $e) { |
116 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
134 | + if ($globalTransaction) { |
|
135 | + $Connection->db->rollBack(); |
|
136 | + } |
|
117 | 137 | return "error : ".$e->getMessage(); |
118 | 138 | } |
119 | 139 | return ''; |
@@ -121,7 +141,9 @@ discard block |
||
121 | 141 | public static function retrieve_route_oneworld($database_file) { |
122 | 142 | global $globalDebug, $globalTransaction; |
123 | 143 | //$query = 'TRUNCATE TABLE routes'; |
124 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
144 | + if ($globalDebug) { |
|
145 | + echo " - Delete previous routes from DB -"; |
|
146 | + } |
|
125 | 147 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
126 | 148 | $Connection = new Connection(); |
127 | 149 | try { |
@@ -132,14 +154,18 @@ discard block |
||
132 | 154 | return "error : ".$e->getMessage(); |
133 | 155 | } |
134 | 156 | |
135 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
157 | + if ($globalDebug) { |
|
158 | + echo " - Add routes to DB -"; |
|
159 | + } |
|
136 | 160 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
137 | 161 | $Spotter = new Spotter(); |
138 | 162 | if ($fh = fopen($database_file,"r")) { |
139 | 163 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
140 | 164 | $Connection = new Connection(); |
141 | 165 | $sth_dest = $Connection->db->prepare($query_dest); |
142 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
166 | + if ($globalTransaction) { |
|
167 | + $Connection->db->beginTransaction(); |
|
168 | + } |
|
143 | 169 | while (!feof($fh)) { |
144 | 170 | $line = fgetcsv($fh,9999,','); |
145 | 171 | if ($line[0] != '') { |
@@ -148,13 +174,17 @@ discard block |
||
148 | 174 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
149 | 175 | $sth_dest->execute($query_dest_values); |
150 | 176 | } catch(PDOException $e) { |
151 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
177 | + if ($globalTransaction) { |
|
178 | + $Connection->db->rollBack(); |
|
179 | + } |
|
152 | 180 | return "error : ".$e->getMessage(); |
153 | 181 | } |
154 | 182 | } |
155 | 183 | } |
156 | 184 | } |
157 | - if ($globalTransaction) $Connection->db->commit(); |
|
185 | + if ($globalTransaction) { |
|
186 | + $Connection->db->commit(); |
|
187 | + } |
|
158 | 188 | } |
159 | 189 | return ''; |
160 | 190 | } |
@@ -162,7 +192,9 @@ discard block |
||
162 | 192 | public static function retrieve_route_skyteam($database_file) { |
163 | 193 | global $globalDebug, $globalTransaction; |
164 | 194 | //$query = 'TRUNCATE TABLE routes'; |
165 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
195 | + if ($globalDebug) { |
|
196 | + echo " - Delete previous routes from DB -"; |
|
197 | + } |
|
166 | 198 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
167 | 199 | $Connection = new Connection(); |
168 | 200 | try { |
@@ -173,7 +205,9 @@ discard block |
||
173 | 205 | return "error : ".$e->getMessage(); |
174 | 206 | } |
175 | 207 | |
176 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
208 | + if ($globalDebug) { |
|
209 | + echo " - Add routes to DB -"; |
|
210 | + } |
|
177 | 211 | |
178 | 212 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
179 | 213 | $Spotter = new Spotter(); |
@@ -182,7 +216,9 @@ discard block |
||
182 | 216 | $Connection = new Connection(); |
183 | 217 | $sth_dest = $Connection->db->prepare($query_dest); |
184 | 218 | try { |
185 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
219 | + if ($globalTransaction) { |
|
220 | + $Connection->db->beginTransaction(); |
|
221 | + } |
|
186 | 222 | while (!feof($fh)) { |
187 | 223 | $line = fgetcsv($fh,9999,','); |
188 | 224 | if ($line[0] != '') { |
@@ -193,9 +229,13 @@ discard block |
||
193 | 229 | } |
194 | 230 | } |
195 | 231 | } |
196 | - if ($globalTransaction) $Connection->db->commit(); |
|
232 | + if ($globalTransaction) { |
|
233 | + $Connection->db->commit(); |
|
234 | + } |
|
197 | 235 | } catch(PDOException $e) { |
198 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
236 | + if ($globalTransaction) { |
|
237 | + $Connection->db->rollBack(); |
|
238 | + } |
|
199 | 239 | return "error : ".$e->getMessage(); |
200 | 240 | } |
201 | 241 | } |
@@ -238,11 +278,16 @@ discard block |
||
238 | 278 | $sth_dest = $Connection->db->prepare($query_dest); |
239 | 279 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
240 | 280 | try { |
241 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
281 | + if ($globalTransaction) { |
|
282 | + $Connection->db->beginTransaction(); |
|
283 | + } |
|
242 | 284 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
243 | 285 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
244 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
245 | - else $type = null; |
|
286 | + if ($values['UserString4'] == 'M') { |
|
287 | + $type = 'military'; |
|
288 | + } else { |
|
289 | + $type = null; |
|
290 | + } |
|
246 | 291 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
247 | 292 | $sth_dest->execute($query_dest_values); |
248 | 293 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -250,7 +295,9 @@ discard block |
||
250 | 295 | $sth_dest_owner->execute($query_dest_owner_values); |
251 | 296 | } |
252 | 297 | } |
253 | - if ($globalTransaction) $Connection->db->commit(); |
|
298 | + if ($globalTransaction) { |
|
299 | + $Connection->db->commit(); |
|
300 | + } |
|
254 | 301 | } catch(PDOException $e) { |
255 | 302 | return "error : ".$e->getMessage(); |
256 | 303 | } |
@@ -287,7 +334,9 @@ discard block |
||
287 | 334 | $Connection = new Connection(); |
288 | 335 | $sth_dest = $Connection->db->prepare($query_dest); |
289 | 336 | try { |
290 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
337 | + if ($globalTransaction) { |
|
338 | + $Connection->db->beginTransaction(); |
|
339 | + } |
|
291 | 340 | while (!feof($fh)) { |
292 | 341 | $values = array(); |
293 | 342 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -298,7 +347,9 @@ discard block |
||
298 | 347 | // Check if we can find ICAO, else set it to GLID |
299 | 348 | $aircraft_name_split = explode(' ',$aircraft_name); |
300 | 349 | $search_more = ''; |
301 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
350 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
351 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
352 | + } |
|
302 | 353 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
303 | 354 | $sth_search = $Connection->db->prepare($query_search); |
304 | 355 | try { |
@@ -311,7 +362,9 @@ discard block |
||
311 | 362 | } catch(PDOException $e) { |
312 | 363 | return "error : ".$e->getMessage(); |
313 | 364 | } |
314 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
365 | + if (!isset($values['ICAOTypeCode'])) { |
|
366 | + $values['ICAOTypeCode'] = 'GLID'; |
|
367 | + } |
|
315 | 368 | // Add data to db |
316 | 369 | if ($values['Registration'] != '' && $values['Registration'] != '0000') { |
317 | 370 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
@@ -320,7 +373,9 @@ discard block |
||
320 | 373 | $sth_dest->execute($query_dest_values); |
321 | 374 | } |
322 | 375 | } |
323 | - if ($globalTransaction) $Connection->db->commit(); |
|
376 | + if ($globalTransaction) { |
|
377 | + $Connection->db->commit(); |
|
378 | + } |
|
324 | 379 | } catch(PDOException $e) { |
325 | 380 | return "error : ".$e->getMessage(); |
326 | 381 | } |
@@ -356,7 +411,9 @@ discard block |
||
356 | 411 | $Connection = new Connection(); |
357 | 412 | $sth_dest = $Connection->db->prepare($query_dest); |
358 | 413 | try { |
359 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
414 | + if ($globalTransaction) { |
|
415 | + $Connection->db->beginTransaction(); |
|
416 | + } |
|
360 | 417 | $tmp = fgetcsv($fh,9999,',',"'"); |
361 | 418 | while (!feof($fh)) { |
362 | 419 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -370,13 +427,17 @@ discard block |
||
370 | 427 | // Check if we can find ICAO, else set it to GLID |
371 | 428 | $aircraft_name_split = explode(' ',$aircraft_name); |
372 | 429 | $search_more = ''; |
373 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
430 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
431 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
432 | + } |
|
374 | 433 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
375 | 434 | $sth_search = $Connection->db->prepare($query_search); |
376 | 435 | try { |
377 | 436 | $sth_search->execute(); |
378 | 437 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
379 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
438 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
439 | + $values['ICAOTypeCode'] = $result['icao']; |
|
440 | + } |
|
380 | 441 | } catch(PDOException $e) { |
381 | 442 | return "error : ".$e->getMessage(); |
382 | 443 | } |
@@ -389,7 +450,9 @@ discard block |
||
389 | 450 | $sth_dest->execute($query_dest_values); |
390 | 451 | } |
391 | 452 | } |
392 | - if ($globalTransaction) $Connection->db->commit(); |
|
453 | + if ($globalTransaction) { |
|
454 | + $Connection->db->commit(); |
|
455 | + } |
|
393 | 456 | } catch(PDOException $e) { |
394 | 457 | return "error : ".$e->getMessage(); |
395 | 458 | } |
@@ -428,7 +491,9 @@ discard block |
||
428 | 491 | $sth_dest = $Connection->db->prepare($query_dest); |
429 | 492 | $sth_modes = $Connection->db->prepare($query_modes); |
430 | 493 | try { |
431 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
494 | + if ($globalTransaction) { |
|
495 | + $Connection->db->beginTransaction(); |
|
496 | + } |
|
432 | 497 | $tmp = fgetcsv($fh,9999,',','"'); |
433 | 498 | while (!feof($fh)) { |
434 | 499 | $line = fgetcsv($fh,9999,',','"'); |
@@ -438,16 +503,22 @@ discard block |
||
438 | 503 | $values['registration'] = $line[0]; |
439 | 504 | $values['base'] = $line[4]; |
440 | 505 | $values['owner'] = $line[5]; |
441 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
442 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
506 | + if ($line[6] == '') { |
|
507 | + $values['date_first_reg'] = null; |
|
508 | + } else { |
|
509 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
510 | + } |
|
443 | 511 | $values['cancel'] = $line[7]; |
444 | 512 | } elseif ($country == 'EI') { |
445 | 513 | // TODO : add modeS & reg to aircraft_modes |
446 | 514 | $values['registration'] = $line[0]; |
447 | 515 | $values['base'] = $line[3]; |
448 | 516 | $values['owner'] = $line[2]; |
449 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
517 | + if ($line[1] == '') { |
|
518 | + $values['date_first_reg'] = null; |
|
519 | + } else { |
|
520 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
521 | + } |
|
451 | 522 | $values['cancel'] = ''; |
452 | 523 | $values['modes'] = $line[7]; |
453 | 524 | $values['icao'] = $line[8]; |
@@ -466,16 +537,22 @@ discard block |
||
466 | 537 | $values['registration'] = $line[3]; |
467 | 538 | $values['base'] = null; |
468 | 539 | $values['owner'] = $line[5]; |
469 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
470 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
540 | + if ($line[18] == '') { |
|
541 | + $values['date_first_reg'] = null; |
|
542 | + } else { |
|
543 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
544 | + } |
|
471 | 545 | $values['cancel'] = ''; |
472 | 546 | } elseif ($country == 'VH') { |
473 | 547 | // TODO : add modeS & reg to aircraft_modes |
474 | 548 | $values['registration'] = $line[0]; |
475 | 549 | $values['base'] = null; |
476 | 550 | $values['owner'] = $line[12]; |
477 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
551 | + if ($line[28] == '') { |
|
552 | + $values['date_first_reg'] = null; |
|
553 | + } else { |
|
554 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
555 | + } |
|
479 | 556 | |
480 | 557 | $values['cancel'] = $line[39]; |
481 | 558 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -494,29 +571,41 @@ discard block |
||
494 | 571 | $values['registration'] = $line[0]; |
495 | 572 | $values['base'] = null; |
496 | 573 | $values['owner'] = $line[8]; |
497 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
498 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
574 | + if ($line[7] == '') { |
|
575 | + $values['date_first_reg'] = null; |
|
576 | + } else { |
|
577 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
578 | + } |
|
499 | 579 | $values['cancel'] = ''; |
500 | 580 | } elseif ($country == 'PP') { |
501 | 581 | $values['registration'] = $line[0]; |
502 | 582 | $values['base'] = null; |
503 | 583 | $values['owner'] = $line[4]; |
504 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
505 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
584 | + if ($line[6] == '') { |
|
585 | + $values['date_first_reg'] = null; |
|
586 | + } else { |
|
587 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
588 | + } |
|
506 | 589 | $values['cancel'] = $line[7]; |
507 | 590 | } elseif ($country == 'E7') { |
508 | 591 | $values['registration'] = $line[0]; |
509 | 592 | $values['base'] = null; |
510 | 593 | $values['owner'] = $line[4]; |
511 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
512 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
594 | + if ($line[5] == '') { |
|
595 | + $values['date_first_reg'] = null; |
|
596 | + } else { |
|
597 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
598 | + } |
|
513 | 599 | $values['cancel'] = ''; |
514 | 600 | } elseif ($country == '8Q') { |
515 | 601 | $values['registration'] = $line[0]; |
516 | 602 | $values['base'] = null; |
517 | 603 | $values['owner'] = $line[3]; |
518 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
519 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
604 | + if ($line[7] == '') { |
|
605 | + $values['date_first_reg'] = null; |
|
606 | + } else { |
|
607 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
608 | + } |
|
520 | 609 | $values['cancel'] = ''; |
521 | 610 | } elseif ($country == 'ZK') { |
522 | 611 | $values['registration'] = $line[0]; |
@@ -561,7 +650,9 @@ discard block |
||
561 | 650 | $sth_modes->execute($query_modes_values); |
562 | 651 | } |
563 | 652 | } |
564 | - if ($globalTransaction) $Connection->db->commit(); |
|
653 | + if ($globalTransaction) { |
|
654 | + $Connection->db->commit(); |
|
655 | + } |
|
565 | 656 | } catch(PDOException $e) { |
566 | 657 | return "error : ".$e->getMessage(); |
567 | 658 | } |
@@ -697,25 +788,45 @@ discard block |
||
697 | 788 | VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
698 | 789 | $Connection = new Connection(); |
699 | 790 | $sth_dest = $Connection->db->prepare($query_dest); |
700 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
791 | + if ($globalTransaction) { |
|
792 | + $Connection->db->beginTransaction(); |
|
793 | + } |
|
701 | 794 | |
702 | 795 | $i = 0; |
703 | 796 | while($row = sparql_fetch_array($result)) |
704 | 797 | { |
705 | 798 | if ($i >= 1) { |
706 | 799 | //print_r($row); |
707 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
708 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
709 | - if (!isset($row['type'])) $row['type'] = ''; |
|
710 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
800 | + if (!isset($row['iata'])) { |
|
801 | + $row['iata'] = ''; |
|
802 | + } |
|
803 | + if (!isset($row['icao'])) { |
|
804 | + $row['icao'] = ''; |
|
805 | + } |
|
806 | + if (!isset($row['type'])) { |
|
807 | + $row['type'] = ''; |
|
808 | + } |
|
809 | + if (!isset($row['altitude'])) { |
|
810 | + $row['altitude'] = ''; |
|
811 | + } |
|
711 | 812 | if (isset($row['city_bis'])) { |
712 | 813 | $row['city'] = $row['city_bis']; |
713 | 814 | } |
714 | - if (!isset($row['city'])) $row['city'] = ''; |
|
715 | - if (!isset($row['country'])) $row['country'] = ''; |
|
716 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
717 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
718 | - if (!isset($row['name'])) continue; |
|
815 | + if (!isset($row['city'])) { |
|
816 | + $row['city'] = ''; |
|
817 | + } |
|
818 | + if (!isset($row['country'])) { |
|
819 | + $row['country'] = ''; |
|
820 | + } |
|
821 | + if (!isset($row['homepage'])) { |
|
822 | + $row['homepage'] = ''; |
|
823 | + } |
|
824 | + if (!isset($row['wikipedia_page'])) { |
|
825 | + $row['wikipedia_page'] = ''; |
|
826 | + } |
|
827 | + if (!isset($row['name'])) { |
|
828 | + continue; |
|
829 | + } |
|
719 | 830 | if (!isset($row['image'])) { |
720 | 831 | $row['image'] = ''; |
721 | 832 | $row['image_thumb'] = ''; |
@@ -771,7 +882,9 @@ discard block |
||
771 | 882 | |
772 | 883 | $i++; |
773 | 884 | } |
774 | - if ($globalTransaction) $Connection->db->commit(); |
|
885 | + if ($globalTransaction) { |
|
886 | + $Connection->db->commit(); |
|
887 | + } |
|
775 | 888 | /* |
776 | 889 | echo "Delete duplicate rows...\n"; |
777 | 890 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
@@ -814,7 +927,9 @@ discard block |
||
814 | 927 | $delimiter = ','; |
815 | 928 | $out_file = $tmp_dir.'airports.csv'; |
816 | 929 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
817 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
930 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
931 | + return FALSE; |
|
932 | + } |
|
818 | 933 | echo "Add data from ourairports.com...\n"; |
819 | 934 | |
820 | 935 | $header = NULL; |
@@ -824,8 +939,9 @@ discard block |
||
824 | 939 | //$Connection->db->beginTransaction(); |
825 | 940 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
826 | 941 | { |
827 | - if(!$header) $header = $row; |
|
828 | - else { |
|
942 | + if(!$header) { |
|
943 | + $header = $row; |
|
944 | + } else { |
|
829 | 945 | $data = array(); |
830 | 946 | $data = array_combine($header, $row); |
831 | 947 | try { |
@@ -866,7 +982,9 @@ discard block |
||
866 | 982 | echo "Download data from another free database...\n"; |
867 | 983 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
868 | 984 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
869 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
985 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
986 | + return FALSE; |
|
987 | + } |
|
870 | 988 | update_db::unzip($out_file); |
871 | 989 | $header = NULL; |
872 | 990 | echo "Add data from another free database...\n"; |
@@ -877,8 +995,9 @@ discard block |
||
877 | 995 | //$Connection->db->beginTransaction(); |
878 | 996 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
879 | 997 | { |
880 | - if(!$header) $header = $row; |
|
881 | - else { |
|
998 | + if(!$header) { |
|
999 | + $header = $row; |
|
1000 | + } else { |
|
882 | 1001 | $data = $row; |
883 | 1002 | |
884 | 1003 | $query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao'; |
@@ -1047,7 +1166,9 @@ discard block |
||
1047 | 1166 | if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE) |
1048 | 1167 | { |
1049 | 1168 | $i = 0; |
1050 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1169 | + if ($globalTransaction) { |
|
1170 | + $Connection->db->beginTransaction(); |
|
1171 | + } |
|
1051 | 1172 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1052 | 1173 | { |
1053 | 1174 | if ($i > 0) { |
@@ -1060,7 +1181,9 @@ discard block |
||
1060 | 1181 | } |
1061 | 1182 | $result_search = $sths->fetchAll(PDO::FETCH_ASSOC); |
1062 | 1183 | if (!empty($result_search)) { |
1063 | - if ($globalDebug) echo '.'; |
|
1184 | + if ($globalDebug) { |
|
1185 | + echo '.'; |
|
1186 | + } |
|
1064 | 1187 | //if ($globalDBdriver == 'mysql') { |
1065 | 1188 | // $queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao'; |
1066 | 1189 | //} else { |
@@ -1082,8 +1205,12 @@ discard block |
||
1082 | 1205 | } |
1083 | 1206 | $result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC); |
1084 | 1207 | if (!empty($result_search_mfr)) { |
1085 | - if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23]; |
|
1086 | - if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15]; |
|
1208 | + if (trim($data[16]) == '' && trim($data[23]) != '') { |
|
1209 | + $data[16] = $data[23]; |
|
1210 | + } |
|
1211 | + if (trim($data[16]) == '' && trim($data[15]) != '') { |
|
1212 | + $data[16] = $data[15]; |
|
1213 | + } |
|
1087 | 1214 | $queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)'; |
1088 | 1215 | try { |
1089 | 1216 | $sthf = $Connection->db->prepare($queryf); |
@@ -1094,7 +1221,9 @@ discard block |
||
1094 | 1221 | } |
1095 | 1222 | } |
1096 | 1223 | if (strtotime($data[29]) > time()) { |
1097 | - if ($globalDebug) echo 'i'; |
|
1224 | + if ($globalDebug) { |
|
1225 | + echo 'i'; |
|
1226 | + } |
|
1098 | 1227 | $query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
1099 | 1228 | try { |
1100 | 1229 | $sth = $Connection->db->prepare($query); |
@@ -1105,13 +1234,19 @@ discard block |
||
1105 | 1234 | } |
1106 | 1235 | } |
1107 | 1236 | if ($i % 90 == 0) { |
1108 | - if ($globalTransaction) $Connection->db->commit(); |
|
1109 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1237 | + if ($globalTransaction) { |
|
1238 | + $Connection->db->commit(); |
|
1239 | + } |
|
1240 | + if ($globalTransaction) { |
|
1241 | + $Connection->db->beginTransaction(); |
|
1242 | + } |
|
1110 | 1243 | } |
1111 | 1244 | $i++; |
1112 | 1245 | } |
1113 | 1246 | fclose($handle); |
1114 | - if ($globalTransaction) $Connection->db->commit(); |
|
1247 | + if ($globalTransaction) { |
|
1248 | + $Connection->db->commit(); |
|
1249 | + } |
|
1115 | 1250 | } |
1116 | 1251 | return ''; |
1117 | 1252 | } |
@@ -1131,11 +1266,15 @@ discard block |
||
1131 | 1266 | if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE) |
1132 | 1267 | { |
1133 | 1268 | $i = 0; |
1134 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1269 | + if ($globalTransaction) { |
|
1270 | + $Connection->db->beginTransaction(); |
|
1271 | + } |
|
1135 | 1272 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1136 | 1273 | { |
1137 | 1274 | if ($i > 0) { |
1138 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
1275 | + if ($data[1] == 'NULL') { |
|
1276 | + $data[1] = $data[0]; |
|
1277 | + } |
|
1139 | 1278 | $query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)'; |
1140 | 1279 | try { |
1141 | 1280 | $sth = $Connection->db->prepare($query); |
@@ -1147,7 +1286,9 @@ discard block |
||
1147 | 1286 | $i++; |
1148 | 1287 | } |
1149 | 1288 | fclose($handle); |
1150 | - if ($globalTransaction) $Connection->db->commit(); |
|
1289 | + if ($globalTransaction) { |
|
1290 | + $Connection->db->commit(); |
|
1291 | + } |
|
1151 | 1292 | } |
1152 | 1293 | return ''; |
1153 | 1294 | } |
@@ -1179,11 +1320,15 @@ discard block |
||
1179 | 1320 | if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE) |
1180 | 1321 | { |
1181 | 1322 | $i = 0; |
1182 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1323 | + if ($globalTransaction) { |
|
1324 | + $Connection->db->beginTransaction(); |
|
1325 | + } |
|
1183 | 1326 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1184 | 1327 | { |
1185 | 1328 | if ($i > 0) { |
1186 | - if ($data[1] == 'NULL') $data[1] = $data[0]; |
|
1329 | + if ($data[1] == 'NULL') { |
|
1330 | + $data[1] = $data[0]; |
|
1331 | + } |
|
1187 | 1332 | $query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)'; |
1188 | 1333 | try { |
1189 | 1334 | $sth = $Connection->db->prepare($query); |
@@ -1195,7 +1340,9 @@ discard block |
||
1195 | 1340 | $i++; |
1196 | 1341 | } |
1197 | 1342 | fclose($handle); |
1198 | - if ($globalTransaction) $Connection->db->commit(); |
|
1343 | + if ($globalTransaction) { |
|
1344 | + $Connection->db->commit(); |
|
1345 | + } |
|
1199 | 1346 | } |
1200 | 1347 | /* |
1201 | 1348 | $query = "UNLOCK TABLES"; |
@@ -1225,7 +1372,9 @@ discard block |
||
1225 | 1372 | if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE) |
1226 | 1373 | { |
1227 | 1374 | $i = 0; |
1228 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1375 | + if ($globalTransaction) { |
|
1376 | + $Connection->db->beginTransaction(); |
|
1377 | + } |
|
1229 | 1378 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1230 | 1379 | { |
1231 | 1380 | if ($i > 0) { |
@@ -1241,7 +1390,9 @@ discard block |
||
1241 | 1390 | $i++; |
1242 | 1391 | } |
1243 | 1392 | fclose($handle); |
1244 | - if ($globalTransaction) $Connection->db->commit(); |
|
1393 | + if ($globalTransaction) { |
|
1394 | + $Connection->db->commit(); |
|
1395 | + } |
|
1245 | 1396 | } |
1246 | 1397 | return ''; |
1247 | 1398 | } |
@@ -1261,7 +1412,9 @@ discard block |
||
1261 | 1412 | if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE) |
1262 | 1413 | { |
1263 | 1414 | $i = 0; |
1264 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1415 | + if ($globalTransaction) { |
|
1416 | + $Connection->db->beginTransaction(); |
|
1417 | + } |
|
1265 | 1418 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1266 | 1419 | { |
1267 | 1420 | if ($i > 0) { |
@@ -1271,19 +1424,25 @@ discard block |
||
1271 | 1424 | $sth = $Connection->db->prepare($query); |
1272 | 1425 | $sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam')); |
1273 | 1426 | } catch(PDOException $e) { |
1274 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1427 | + if ($globalDebug) { |
|
1428 | + echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1429 | + } |
|
1275 | 1430 | die(); |
1276 | 1431 | } |
1277 | 1432 | } |
1278 | 1433 | if ($globalTransaction && $i % 2000 == 0) { |
1279 | 1434 | $Connection->db->commit(); |
1280 | - if ($globalDebug) echo '.'; |
|
1435 | + if ($globalDebug) { |
|
1436 | + echo '.'; |
|
1437 | + } |
|
1281 | 1438 | $Connection->db->beginTransaction(); |
1282 | 1439 | } |
1283 | 1440 | $i++; |
1284 | 1441 | } |
1285 | 1442 | fclose($handle); |
1286 | - if ($globalTransaction) $Connection->db->commit(); |
|
1443 | + if ($globalTransaction) { |
|
1444 | + $Connection->db->commit(); |
|
1445 | + } |
|
1287 | 1446 | } |
1288 | 1447 | return ''; |
1289 | 1448 | } |
@@ -1302,7 +1461,9 @@ discard block |
||
1302 | 1461 | if (($handle = fopen($tmp_dir.'block.tsv', 'r')) !== FALSE) |
1303 | 1462 | { |
1304 | 1463 | $i = 0; |
1305 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1464 | + if ($globalTransaction) { |
|
1465 | + $Connection->db->beginTransaction(); |
|
1466 | + } |
|
1306 | 1467 | while (($data = fgets($handle, 1000)) !== FALSE) |
1307 | 1468 | { |
1308 | 1469 | $query = 'INSERT INTO aircraft_block (callSign,Source) VALUES (:callSign,:source)'; |
@@ -1310,18 +1471,24 @@ discard block |
||
1310 | 1471 | $sth = $Connection->db->prepare($query); |
1311 | 1472 | $sth->execute(array(':callSign' => trim($data),':source' => 'website_fam')); |
1312 | 1473 | } catch(PDOException $e) { |
1313 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".$data; |
|
1474 | + if ($globalDebug) { |
|
1475 | + echo "error: ".$e->getMessage()." - data: ".$data; |
|
1476 | + } |
|
1314 | 1477 | die(); |
1315 | 1478 | } |
1316 | 1479 | if ($globalTransaction && $i % 2000 == 0) { |
1317 | 1480 | $Connection->db->commit(); |
1318 | - if ($globalDebug) echo '.'; |
|
1481 | + if ($globalDebug) { |
|
1482 | + echo '.'; |
|
1483 | + } |
|
1319 | 1484 | $Connection->db->beginTransaction(); |
1320 | 1485 | } |
1321 | 1486 | $i++; |
1322 | 1487 | } |
1323 | 1488 | fclose($handle); |
1324 | - if ($globalTransaction) $Connection->db->commit(); |
|
1489 | + if ($globalTransaction) { |
|
1490 | + $Connection->db->commit(); |
|
1491 | + } |
|
1325 | 1492 | } |
1326 | 1493 | return ''; |
1327 | 1494 | } |
@@ -1346,7 +1513,9 @@ discard block |
||
1346 | 1513 | $i = 0; |
1347 | 1514 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1348 | 1515 | //$Connection->db->beginTransaction(); |
1349 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1516 | + if ($globalTransaction) { |
|
1517 | + $Connection->db->beginTransaction(); |
|
1518 | + } |
|
1350 | 1519 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1351 | 1520 | { |
1352 | 1521 | if ($i > 0) { |
@@ -1362,7 +1531,9 @@ discard block |
||
1362 | 1531 | $i++; |
1363 | 1532 | } |
1364 | 1533 | fclose($handle); |
1365 | - if ($globalTransaction) $Connection->db->commit(); |
|
1534 | + if ($globalTransaction) { |
|
1535 | + $Connection->db->commit(); |
|
1536 | + } |
|
1366 | 1537 | } |
1367 | 1538 | return ''; |
1368 | 1539 | } |
@@ -1382,7 +1553,9 @@ discard block |
||
1382 | 1553 | if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE) |
1383 | 1554 | { |
1384 | 1555 | $i = 0; |
1385 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1556 | + if ($globalTransaction) { |
|
1557 | + $Connection->db->beginTransaction(); |
|
1558 | + } |
|
1386 | 1559 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1387 | 1560 | { |
1388 | 1561 | if ($i > 0) { |
@@ -1399,7 +1572,9 @@ discard block |
||
1399 | 1572 | $i++; |
1400 | 1573 | } |
1401 | 1574 | fclose($handle); |
1402 | - if ($globalTransaction) $Connection->db->commit(); |
|
1575 | + if ($globalTransaction) { |
|
1576 | + $Connection->db->commit(); |
|
1577 | + } |
|
1403 | 1578 | } |
1404 | 1579 | return ''; |
1405 | 1580 | } |
@@ -1418,7 +1593,9 @@ discard block |
||
1418 | 1593 | $Connection = new Connection(); |
1419 | 1594 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
1420 | 1595 | { |
1421 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1596 | + if ($globalTransaction) { |
|
1597 | + $Connection->db->beginTransaction(); |
|
1598 | + } |
|
1422 | 1599 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
1423 | 1600 | { |
1424 | 1601 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1433,7 +1610,9 @@ discard block |
||
1433 | 1610 | } |
1434 | 1611 | } |
1435 | 1612 | fclose($handle); |
1436 | - if ($globalTransaction) $Connection->db->commit(); |
|
1613 | + if ($globalTransaction) { |
|
1614 | + $Connection->db->commit(); |
|
1615 | + } |
|
1437 | 1616 | } |
1438 | 1617 | return ''; |
1439 | 1618 | } |
@@ -1509,9 +1688,14 @@ discard block |
||
1509 | 1688 | if ($i > 0 && $data[0] != '') { |
1510 | 1689 | $sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]); |
1511 | 1690 | $period = str_replace(',','',$data[14]); |
1512 | - if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60; |
|
1513 | - if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18])); |
|
1514 | - else $launch_date = NULL; |
|
1691 | + if (!empty($period) && strpos($period,'days')) { |
|
1692 | + $period = str_replace(' days','',$period)*24*60; |
|
1693 | + } |
|
1694 | + if ($data[18] != '') { |
|
1695 | + $launch_date = date('Y-m-d',strtotime($data[18])); |
|
1696 | + } else { |
|
1697 | + $launch_date = NULL; |
|
1698 | + } |
|
1515 | 1699 | $data = array_map(function($value) { |
1516 | 1700 | return trim($value) === '' ? null : $value; |
1517 | 1701 | }, $data); |
@@ -1874,7 +2058,9 @@ discard block |
||
1874 | 2058 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1875 | 2059 | { |
1876 | 2060 | $i = 0; |
1877 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
2061 | + if ($globalTransaction) { |
|
2062 | + $Connection->db->beginTransaction(); |
|
2063 | + } |
|
1878 | 2064 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1879 | 2065 | { |
1880 | 2066 | $i++; |
@@ -1902,7 +2088,9 @@ discard block |
||
1902 | 2088 | } |
1903 | 2089 | } |
1904 | 2090 | fclose($handle); |
1905 | - if ($globalTransaction) $Connection->db->commit(); |
|
2091 | + if ($globalTransaction) { |
|
2092 | + $Connection->db->commit(); |
|
2093 | + } |
|
1906 | 2094 | } |
1907 | 2095 | return ''; |
1908 | 2096 | } |
@@ -1945,7 +2133,9 @@ discard block |
||
1945 | 2133 | $Connection = new Connection(); |
1946 | 2134 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1947 | 2135 | { |
1948 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
2136 | + if ($globalTransaction) { |
|
2137 | + $Connection->db->beginTransaction(); |
|
2138 | + } |
|
1949 | 2139 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1950 | 2140 | { |
1951 | 2141 | if(count($row) > 1) { |
@@ -1959,7 +2149,9 @@ discard block |
||
1959 | 2149 | } |
1960 | 2150 | } |
1961 | 2151 | fclose($handle); |
1962 | - if ($globalTransaction) $Connection->db->commit(); |
|
2152 | + if ($globalTransaction) { |
|
2153 | + $Connection->db->commit(); |
|
2154 | + } |
|
1963 | 2155 | } |
1964 | 2156 | return ''; |
1965 | 2157 | } |
@@ -1979,8 +2171,9 @@ discard block |
||
1979 | 2171 | } |
1980 | 2172 | |
1981 | 2173 | |
1982 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1983 | - else { |
|
2174 | + if ($globalDBdriver == 'mysql') { |
|
2175 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
2176 | + } else { |
|
1984 | 2177 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
1985 | 2178 | $query = "CREATE EXTENSION postgis"; |
1986 | 2179 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1999,7 +2192,9 @@ discard block |
||
1999 | 2192 | global $tmp_dir, $globalDebug; |
2000 | 2193 | include_once('class.create_db.php'); |
2001 | 2194 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
2002 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
2195 | + if ($globalDebug) { |
|
2196 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
2197 | + } |
|
2003 | 2198 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5'); |
2004 | 2199 | $error = ''; |
2005 | 2200 | if (file_exists($tmp_dir.'notam.txt.gz.md5')) { |
@@ -2009,20 +2204,34 @@ discard block |
||
2009 | 2204 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
2010 | 2205 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
2011 | 2206 | if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) { |
2012 | - if ($globalDebug) echo "Gunzip..."; |
|
2207 | + if ($globalDebug) { |
|
2208 | + echo "Gunzip..."; |
|
2209 | + } |
|
2013 | 2210 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
2014 | - if ($globalDebug) echo "Add to DB..."; |
|
2211 | + if ($globalDebug) { |
|
2212 | + echo "Add to DB..."; |
|
2213 | + } |
|
2015 | 2214 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
2016 | 2215 | $NOTAM = new NOTAM(); |
2017 | 2216 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
2018 | 2217 | update_db::insert_notam_version($notam_md5); |
2019 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
2020 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
2021 | - } elseif ($globalDebug) echo "No new version."; |
|
2022 | - } else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
2218 | + } else { |
|
2219 | + $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
2220 | + } |
|
2221 | + } else { |
|
2222 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
2223 | + } |
|
2224 | + } elseif ($globalDebug) { |
|
2225 | + echo "No new version."; |
|
2226 | + } |
|
2227 | + } else { |
|
2228 | + $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
2229 | + } |
|
2023 | 2230 | if ($error != '') { |
2024 | 2231 | return $error; |
2025 | - } elseif ($globalDebug) echo "Done\n"; |
|
2232 | + } elseif ($globalDebug) { |
|
2233 | + echo "Done\n"; |
|
2234 | + } |
|
2026 | 2235 | return ''; |
2027 | 2236 | } |
2028 | 2237 | |
@@ -2077,68 +2286,114 @@ discard block |
||
2077 | 2286 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
2078 | 2287 | if (extension_loaded('zip')) { |
2079 | 2288 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
2080 | - if ($globalDebug) echo "Unzip..."; |
|
2289 | + if ($globalDebug) { |
|
2290 | + echo "Unzip..."; |
|
2291 | + } |
|
2081 | 2292 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
2082 | - if ($globalDebug) echo "Add to DB..."; |
|
2293 | + if ($globalDebug) { |
|
2294 | + echo "Add to DB..."; |
|
2295 | + } |
|
2083 | 2296 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
2084 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
2297 | + if ($globalDebug) { |
|
2298 | + echo "Copy airlines logos to airlines images directory..."; |
|
2299 | + } |
|
2085 | 2300 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
2086 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
2087 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
2088 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
2089 | - } else $error = "ZIP module not loaded but required for IVAO."; |
|
2301 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
2302 | + $error = "Failed to copy airlines logo."; |
|
2303 | + } |
|
2304 | + } else { |
|
2305 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
2306 | + } |
|
2307 | + } else { |
|
2308 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
2309 | + } |
|
2310 | + } else { |
|
2311 | + $error = "ZIP module not loaded but required for IVAO."; |
|
2312 | + } |
|
2090 | 2313 | if ($error != '') { |
2091 | 2314 | return $error; |
2092 | - } elseif ($globalDebug) echo "Done\n"; |
|
2315 | + } elseif ($globalDebug) { |
|
2316 | + echo "Done\n"; |
|
2317 | + } |
|
2093 | 2318 | return ''; |
2094 | 2319 | } |
2095 | 2320 | |
2096 | 2321 | public static function update_routes() { |
2097 | 2322 | global $tmp_dir, $globalDebug; |
2098 | 2323 | $error = ''; |
2099 | - if ($globalDebug) echo "Routes : Download..."; |
|
2324 | + if ($globalDebug) { |
|
2325 | + echo "Routes : Download..."; |
|
2326 | + } |
|
2100 | 2327 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
2101 | 2328 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
2102 | - if ($globalDebug) echo "Gunzip..."; |
|
2329 | + if ($globalDebug) { |
|
2330 | + echo "Gunzip..."; |
|
2331 | + } |
|
2103 | 2332 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
2104 | - if ($globalDebug) echo "Add to DB..."; |
|
2333 | + if ($globalDebug) { |
|
2334 | + echo "Add to DB..."; |
|
2335 | + } |
|
2105 | 2336 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
2106 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
2337 | + } else { |
|
2338 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
2339 | + } |
|
2107 | 2340 | if ($error != '') { |
2108 | 2341 | return $error; |
2109 | - } elseif ($globalDebug) echo "Done\n"; |
|
2342 | + } elseif ($globalDebug) { |
|
2343 | + echo "Done\n"; |
|
2344 | + } |
|
2110 | 2345 | return ''; |
2111 | 2346 | } |
2112 | 2347 | public static function update_oneworld() { |
2113 | 2348 | global $tmp_dir, $globalDebug; |
2114 | 2349 | $error = ''; |
2115 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
2350 | + if ($globalDebug) { |
|
2351 | + echo "Schedules Oneworld : Download..."; |
|
2352 | + } |
|
2116 | 2353 | update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
2117 | 2354 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
2118 | - if ($globalDebug) echo "Gunzip..."; |
|
2355 | + if ($globalDebug) { |
|
2356 | + echo "Gunzip..."; |
|
2357 | + } |
|
2119 | 2358 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
2120 | - if ($globalDebug) echo "Add to DB..."; |
|
2359 | + if ($globalDebug) { |
|
2360 | + echo "Add to DB..."; |
|
2361 | + } |
|
2121 | 2362 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
2122 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
2363 | + } else { |
|
2364 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
2365 | + } |
|
2123 | 2366 | if ($error != '') { |
2124 | 2367 | return $error; |
2125 | - } elseif ($globalDebug) echo "Done\n"; |
|
2368 | + } elseif ($globalDebug) { |
|
2369 | + echo "Done\n"; |
|
2370 | + } |
|
2126 | 2371 | return ''; |
2127 | 2372 | } |
2128 | 2373 | public static function update_skyteam() { |
2129 | 2374 | global $tmp_dir, $globalDebug; |
2130 | 2375 | $error = ''; |
2131 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
2376 | + if ($globalDebug) { |
|
2377 | + echo "Schedules Skyteam : Download..."; |
|
2378 | + } |
|
2132 | 2379 | update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
2133 | 2380 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
2134 | - if ($globalDebug) echo "Gunzip..."; |
|
2381 | + if ($globalDebug) { |
|
2382 | + echo "Gunzip..."; |
|
2383 | + } |
|
2135 | 2384 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
2136 | - if ($globalDebug) echo "Add to DB..."; |
|
2385 | + if ($globalDebug) { |
|
2386 | + echo "Add to DB..."; |
|
2387 | + } |
|
2137 | 2388 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
2138 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
2389 | + } else { |
|
2390 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
2391 | + } |
|
2139 | 2392 | if ($error != '') { |
2140 | 2393 | return $error; |
2141 | - } elseif ($globalDebug) echo "Done\n"; |
|
2394 | + } elseif ($globalDebug) { |
|
2395 | + echo "Done\n"; |
|
2396 | + } |
|
2142 | 2397 | return ''; |
2143 | 2398 | } |
2144 | 2399 | public static function update_ModeS() { |
@@ -2155,340 +2410,590 @@ discard block |
||
2155 | 2410 | exit; |
2156 | 2411 | } elseif ($globalDebug) echo "Done\n"; |
2157 | 2412 | */ |
2158 | - if ($globalDebug) echo "Modes : Download..."; |
|
2159 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
2413 | + if ($globalDebug) { |
|
2414 | + echo "Modes : Download..."; |
|
2415 | + } |
|
2416 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
2160 | 2417 | update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
2161 | 2418 | |
2162 | 2419 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
2163 | 2420 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
2164 | - if ($globalDebug) echo "Unzip..."; |
|
2165 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
2421 | + if ($globalDebug) { |
|
2422 | + echo "Unzip..."; |
|
2423 | + } |
|
2424 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
2166 | 2425 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
2167 | - if ($globalDebug) echo "Add to DB..."; |
|
2426 | + if ($globalDebug) { |
|
2427 | + echo "Add to DB..."; |
|
2428 | + } |
|
2168 | 2429 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
2169 | 2430 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
2170 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
2431 | + } else { |
|
2432 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
2433 | + } |
|
2171 | 2434 | if ($error != '') { |
2172 | 2435 | return $error; |
2173 | - } elseif ($globalDebug) echo "Done\n"; |
|
2436 | + } elseif ($globalDebug) { |
|
2437 | + echo "Done\n"; |
|
2438 | + } |
|
2174 | 2439 | return ''; |
2175 | 2440 | } |
2176 | 2441 | |
2177 | 2442 | public static function update_ModeS_faa() { |
2178 | 2443 | global $tmp_dir, $globalDebug; |
2179 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
2444 | + if ($globalDebug) { |
|
2445 | + echo "Modes FAA: Download..."; |
|
2446 | + } |
|
2180 | 2447 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
2181 | 2448 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
2182 | - if ($globalDebug) echo "Unzip..."; |
|
2449 | + if ($globalDebug) { |
|
2450 | + echo "Unzip..."; |
|
2451 | + } |
|
2183 | 2452 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
2184 | - if ($globalDebug) echo "Add to DB..."; |
|
2453 | + if ($globalDebug) { |
|
2454 | + echo "Add to DB..."; |
|
2455 | + } |
|
2185 | 2456 | $error = update_db::modes_faa(); |
2186 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
2457 | + } else { |
|
2458 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
2459 | + } |
|
2187 | 2460 | if ($error != '') { |
2188 | 2461 | return $error; |
2189 | - } elseif ($globalDebug) echo "Done\n"; |
|
2462 | + } elseif ($globalDebug) { |
|
2463 | + echo "Done\n"; |
|
2464 | + } |
|
2190 | 2465 | return ''; |
2191 | 2466 | } |
2192 | 2467 | |
2193 | 2468 | public static function update_ModeS_flarm() { |
2194 | 2469 | global $tmp_dir, $globalDebug; |
2195 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
2470 | + if ($globalDebug) { |
|
2471 | + echo "Modes Flarmnet: Download..."; |
|
2472 | + } |
|
2196 | 2473 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
2197 | 2474 | if (file_exists($tmp_dir.'data.fln')) { |
2198 | - if ($globalDebug) echo "Add to DB..."; |
|
2475 | + if ($globalDebug) { |
|
2476 | + echo "Add to DB..."; |
|
2477 | + } |
|
2199 | 2478 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
2200 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
2479 | + } else { |
|
2480 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
2481 | + } |
|
2201 | 2482 | if ($error != '') { |
2202 | 2483 | return $error; |
2203 | - } elseif ($globalDebug) echo "Done\n"; |
|
2484 | + } elseif ($globalDebug) { |
|
2485 | + echo "Done\n"; |
|
2486 | + } |
|
2204 | 2487 | return ''; |
2205 | 2488 | } |
2206 | 2489 | |
2207 | 2490 | public static function update_ModeS_ogn() { |
2208 | 2491 | global $tmp_dir, $globalDebug; |
2209 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
2492 | + if ($globalDebug) { |
|
2493 | + echo "Modes OGN: Download..."; |
|
2494 | + } |
|
2210 | 2495 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
2211 | 2496 | if (file_exists($tmp_dir.'ogn.csv')) { |
2212 | - if ($globalDebug) echo "Add to DB..."; |
|
2497 | + if ($globalDebug) { |
|
2498 | + echo "Add to DB..."; |
|
2499 | + } |
|
2213 | 2500 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
2214 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2501 | + } else { |
|
2502 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2503 | + } |
|
2215 | 2504 | if ($error != '') { |
2216 | 2505 | return $error; |
2217 | - } elseif ($globalDebug) echo "Done\n"; |
|
2506 | + } elseif ($globalDebug) { |
|
2507 | + echo "Done\n"; |
|
2508 | + } |
|
2218 | 2509 | return ''; |
2219 | 2510 | } |
2220 | 2511 | |
2221 | 2512 | public static function update_owner() { |
2222 | 2513 | global $tmp_dir, $globalDebug, $globalMasterSource; |
2223 | 2514 | |
2224 | - if ($globalDebug) echo "Owner France: Download..."; |
|
2515 | + if ($globalDebug) { |
|
2516 | + echo "Owner France: Download..."; |
|
2517 | + } |
|
2225 | 2518 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
2226 | 2519 | if (file_exists($tmp_dir.'owner_f.csv')) { |
2227 | - if ($globalDebug) echo "Add to DB..."; |
|
2520 | + if ($globalDebug) { |
|
2521 | + echo "Add to DB..."; |
|
2522 | + } |
|
2228 | 2523 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
2229 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2524 | + } else { |
|
2525 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2526 | + } |
|
2230 | 2527 | if ($error != '') { |
2231 | 2528 | return $error; |
2232 | - } elseif ($globalDebug) echo "Done\n"; |
|
2529 | + } elseif ($globalDebug) { |
|
2530 | + echo "Done\n"; |
|
2531 | + } |
|
2233 | 2532 | |
2234 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
2533 | + if ($globalDebug) { |
|
2534 | + echo "Owner Ireland: Download..."; |
|
2535 | + } |
|
2235 | 2536 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
2236 | 2537 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
2237 | - if ($globalDebug) echo "Add to DB..."; |
|
2538 | + if ($globalDebug) { |
|
2539 | + echo "Add to DB..."; |
|
2540 | + } |
|
2238 | 2541 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
2239 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2542 | + } else { |
|
2543 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2544 | + } |
|
2240 | 2545 | if ($error != '') { |
2241 | 2546 | return $error; |
2242 | - } elseif ($globalDebug) echo "Done\n"; |
|
2243 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
2547 | + } elseif ($globalDebug) { |
|
2548 | + echo "Done\n"; |
|
2549 | + } |
|
2550 | + if ($globalDebug) { |
|
2551 | + echo "Owner Switzerland: Download..."; |
|
2552 | + } |
|
2244 | 2553 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
2245 | 2554 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
2246 | - if ($globalDebug) echo "Add to DB..."; |
|
2555 | + if ($globalDebug) { |
|
2556 | + echo "Add to DB..."; |
|
2557 | + } |
|
2247 | 2558 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
2248 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2559 | + } else { |
|
2560 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2561 | + } |
|
2249 | 2562 | if ($error != '') { |
2250 | 2563 | return $error; |
2251 | - } elseif ($globalDebug) echo "Done\n"; |
|
2252 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
2564 | + } elseif ($globalDebug) { |
|
2565 | + echo "Done\n"; |
|
2566 | + } |
|
2567 | + if ($globalDebug) { |
|
2568 | + echo "Owner Czech Republic: Download..."; |
|
2569 | + } |
|
2253 | 2570 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
2254 | 2571 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
2255 | - if ($globalDebug) echo "Add to DB..."; |
|
2572 | + if ($globalDebug) { |
|
2573 | + echo "Add to DB..."; |
|
2574 | + } |
|
2256 | 2575 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
2257 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2576 | + } else { |
|
2577 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2578 | + } |
|
2258 | 2579 | if ($error != '') { |
2259 | 2580 | return $error; |
2260 | - } elseif ($globalDebug) echo "Done\n"; |
|
2261 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
2581 | + } elseif ($globalDebug) { |
|
2582 | + echo "Done\n"; |
|
2583 | + } |
|
2584 | + if ($globalDebug) { |
|
2585 | + echo "Owner Australia: Download..."; |
|
2586 | + } |
|
2262 | 2587 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
2263 | 2588 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
2264 | - if ($globalDebug) echo "Add to DB..."; |
|
2589 | + if ($globalDebug) { |
|
2590 | + echo "Add to DB..."; |
|
2591 | + } |
|
2265 | 2592 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
2266 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2593 | + } else { |
|
2594 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2595 | + } |
|
2267 | 2596 | if ($error != '') { |
2268 | 2597 | return $error; |
2269 | - } elseif ($globalDebug) echo "Done\n"; |
|
2270 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
2598 | + } elseif ($globalDebug) { |
|
2599 | + echo "Done\n"; |
|
2600 | + } |
|
2601 | + if ($globalDebug) { |
|
2602 | + echo "Owner Austria: Download..."; |
|
2603 | + } |
|
2271 | 2604 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
2272 | 2605 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
2273 | - if ($globalDebug) echo "Add to DB..."; |
|
2606 | + if ($globalDebug) { |
|
2607 | + echo "Add to DB..."; |
|
2608 | + } |
|
2274 | 2609 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
2275 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2610 | + } else { |
|
2611 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2612 | + } |
|
2276 | 2613 | if ($error != '') { |
2277 | 2614 | return $error; |
2278 | - } elseif ($globalDebug) echo "Done\n"; |
|
2279 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
2615 | + } elseif ($globalDebug) { |
|
2616 | + echo "Done\n"; |
|
2617 | + } |
|
2618 | + if ($globalDebug) { |
|
2619 | + echo "Owner Chile: Download..."; |
|
2620 | + } |
|
2280 | 2621 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
2281 | 2622 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
2282 | - if ($globalDebug) echo "Add to DB..."; |
|
2623 | + if ($globalDebug) { |
|
2624 | + echo "Add to DB..."; |
|
2625 | + } |
|
2283 | 2626 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
2284 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2627 | + } else { |
|
2628 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2629 | + } |
|
2285 | 2630 | if ($error != '') { |
2286 | 2631 | return $error; |
2287 | - } elseif ($globalDebug) echo "Done\n"; |
|
2288 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
2632 | + } elseif ($globalDebug) { |
|
2633 | + echo "Done\n"; |
|
2634 | + } |
|
2635 | + if ($globalDebug) { |
|
2636 | + echo "Owner Colombia: Download..."; |
|
2637 | + } |
|
2289 | 2638 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
2290 | 2639 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
2291 | - if ($globalDebug) echo "Add to DB..."; |
|
2640 | + if ($globalDebug) { |
|
2641 | + echo "Add to DB..."; |
|
2642 | + } |
|
2292 | 2643 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
2293 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2644 | + } else { |
|
2645 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2646 | + } |
|
2294 | 2647 | if ($error != '') { |
2295 | 2648 | return $error; |
2296 | - } elseif ($globalDebug) echo "Done\n"; |
|
2297 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
2649 | + } elseif ($globalDebug) { |
|
2650 | + echo "Done\n"; |
|
2651 | + } |
|
2652 | + if ($globalDebug) { |
|
2653 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
2654 | + } |
|
2298 | 2655 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
2299 | 2656 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
2300 | - if ($globalDebug) echo "Add to DB..."; |
|
2657 | + if ($globalDebug) { |
|
2658 | + echo "Add to DB..."; |
|
2659 | + } |
|
2301 | 2660 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
2302 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2661 | + } else { |
|
2662 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2663 | + } |
|
2303 | 2664 | if ($error != '') { |
2304 | 2665 | return $error; |
2305 | - } elseif ($globalDebug) echo "Done\n"; |
|
2306 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
2666 | + } elseif ($globalDebug) { |
|
2667 | + echo "Done\n"; |
|
2668 | + } |
|
2669 | + if ($globalDebug) { |
|
2670 | + echo "Owner Brazil: Download..."; |
|
2671 | + } |
|
2307 | 2672 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
2308 | 2673 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
2309 | - if ($globalDebug) echo "Add to DB..."; |
|
2674 | + if ($globalDebug) { |
|
2675 | + echo "Add to DB..."; |
|
2676 | + } |
|
2310 | 2677 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
2311 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2678 | + } else { |
|
2679 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2680 | + } |
|
2312 | 2681 | if ($error != '') { |
2313 | 2682 | return $error; |
2314 | - } elseif ($globalDebug) echo "Done\n"; |
|
2315 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
2683 | + } elseif ($globalDebug) { |
|
2684 | + echo "Done\n"; |
|
2685 | + } |
|
2686 | + if ($globalDebug) { |
|
2687 | + echo "Owner Cayman Islands: Download..."; |
|
2688 | + } |
|
2316 | 2689 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
2317 | 2690 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
2318 | - if ($globalDebug) echo "Add to DB..."; |
|
2691 | + if ($globalDebug) { |
|
2692 | + echo "Add to DB..."; |
|
2693 | + } |
|
2319 | 2694 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
2320 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2695 | + } else { |
|
2696 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2697 | + } |
|
2321 | 2698 | if ($error != '') { |
2322 | 2699 | return $error; |
2323 | - } elseif ($globalDebug) echo "Done\n"; |
|
2324 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
2700 | + } elseif ($globalDebug) { |
|
2701 | + echo "Done\n"; |
|
2702 | + } |
|
2703 | + if ($globalDebug) { |
|
2704 | + echo "Owner Croatia: Download..."; |
|
2705 | + } |
|
2325 | 2706 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
2326 | 2707 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
2327 | - if ($globalDebug) echo "Add to DB..."; |
|
2708 | + if ($globalDebug) { |
|
2709 | + echo "Add to DB..."; |
|
2710 | + } |
|
2328 | 2711 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
2329 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2712 | + } else { |
|
2713 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2714 | + } |
|
2330 | 2715 | if ($error != '') { |
2331 | 2716 | return $error; |
2332 | - } elseif ($globalDebug) echo "Done\n"; |
|
2333 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
2717 | + } elseif ($globalDebug) { |
|
2718 | + echo "Done\n"; |
|
2719 | + } |
|
2720 | + if ($globalDebug) { |
|
2721 | + echo "Owner Luxembourg: Download..."; |
|
2722 | + } |
|
2334 | 2723 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
2335 | 2724 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
2336 | - if ($globalDebug) echo "Add to DB..."; |
|
2725 | + if ($globalDebug) { |
|
2726 | + echo "Add to DB..."; |
|
2727 | + } |
|
2337 | 2728 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
2338 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2729 | + } else { |
|
2730 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2731 | + } |
|
2339 | 2732 | if ($error != '') { |
2340 | 2733 | return $error; |
2341 | - } elseif ($globalDebug) echo "Done\n"; |
|
2342 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
2734 | + } elseif ($globalDebug) { |
|
2735 | + echo "Done\n"; |
|
2736 | + } |
|
2737 | + if ($globalDebug) { |
|
2738 | + echo "Owner Maldives: Download..."; |
|
2739 | + } |
|
2343 | 2740 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
2344 | 2741 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
2345 | - if ($globalDebug) echo "Add to DB..."; |
|
2742 | + if ($globalDebug) { |
|
2743 | + echo "Add to DB..."; |
|
2744 | + } |
|
2346 | 2745 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
2347 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2746 | + } else { |
|
2747 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2748 | + } |
|
2348 | 2749 | if ($error != '') { |
2349 | 2750 | return $error; |
2350 | - } elseif ($globalDebug) echo "Done\n"; |
|
2351 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
2751 | + } elseif ($globalDebug) { |
|
2752 | + echo "Done\n"; |
|
2753 | + } |
|
2754 | + if ($globalDebug) { |
|
2755 | + echo "Owner New Zealand: Download..."; |
|
2756 | + } |
|
2352 | 2757 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
2353 | 2758 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
2354 | - if ($globalDebug) echo "Add to DB..."; |
|
2759 | + if ($globalDebug) { |
|
2760 | + echo "Add to DB..."; |
|
2761 | + } |
|
2355 | 2762 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
2356 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2763 | + } else { |
|
2764 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2765 | + } |
|
2357 | 2766 | if ($error != '') { |
2358 | 2767 | return $error; |
2359 | - } elseif ($globalDebug) echo "Done\n"; |
|
2360 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
2768 | + } elseif ($globalDebug) { |
|
2769 | + echo "Done\n"; |
|
2770 | + } |
|
2771 | + if ($globalDebug) { |
|
2772 | + echo "Owner Papua New Guinea: Download..."; |
|
2773 | + } |
|
2361 | 2774 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
2362 | 2775 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
2363 | - if ($globalDebug) echo "Add to DB..."; |
|
2776 | + if ($globalDebug) { |
|
2777 | + echo "Add to DB..."; |
|
2778 | + } |
|
2364 | 2779 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
2365 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2780 | + } else { |
|
2781 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2782 | + } |
|
2366 | 2783 | if ($error != '') { |
2367 | 2784 | return $error; |
2368 | - } elseif ($globalDebug) echo "Done\n"; |
|
2369 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
2785 | + } elseif ($globalDebug) { |
|
2786 | + echo "Done\n"; |
|
2787 | + } |
|
2788 | + if ($globalDebug) { |
|
2789 | + echo "Owner Slovakia: Download..."; |
|
2790 | + } |
|
2370 | 2791 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
2371 | 2792 | if (file_exists($tmp_dir.'owner_om.csv')) { |
2372 | - if ($globalDebug) echo "Add to DB..."; |
|
2793 | + if ($globalDebug) { |
|
2794 | + echo "Add to DB..."; |
|
2795 | + } |
|
2373 | 2796 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
2374 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2797 | + } else { |
|
2798 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2799 | + } |
|
2375 | 2800 | if ($error != '') { |
2376 | 2801 | return $error; |
2377 | - } elseif ($globalDebug) echo "Done\n"; |
|
2378 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
2802 | + } elseif ($globalDebug) { |
|
2803 | + echo "Done\n"; |
|
2804 | + } |
|
2805 | + if ($globalDebug) { |
|
2806 | + echo "Owner Ecuador: Download..."; |
|
2807 | + } |
|
2379 | 2808 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
2380 | 2809 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
2381 | - if ($globalDebug) echo "Add to DB..."; |
|
2810 | + if ($globalDebug) { |
|
2811 | + echo "Add to DB..."; |
|
2812 | + } |
|
2382 | 2813 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
2383 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2814 | + } else { |
|
2815 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2816 | + } |
|
2384 | 2817 | if ($error != '') { |
2385 | 2818 | return $error; |
2386 | - } elseif ($globalDebug) echo "Done\n"; |
|
2387 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
2819 | + } elseif ($globalDebug) { |
|
2820 | + echo "Done\n"; |
|
2821 | + } |
|
2822 | + if ($globalDebug) { |
|
2823 | + echo "Owner Iceland: Download..."; |
|
2824 | + } |
|
2388 | 2825 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
2389 | 2826 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
2390 | - if ($globalDebug) echo "Add to DB..."; |
|
2827 | + if ($globalDebug) { |
|
2828 | + echo "Add to DB..."; |
|
2829 | + } |
|
2391 | 2830 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
2392 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2831 | + } else { |
|
2832 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2833 | + } |
|
2393 | 2834 | if ($error != '') { |
2394 | 2835 | return $error; |
2395 | - } elseif ($globalDebug) echo "Done\n"; |
|
2396 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
2836 | + } elseif ($globalDebug) { |
|
2837 | + echo "Done\n"; |
|
2838 | + } |
|
2839 | + if ($globalDebug) { |
|
2840 | + echo "Owner Isle of Man: Download..."; |
|
2841 | + } |
|
2397 | 2842 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
2398 | 2843 | if (file_exists($tmp_dir.'owner_m.csv')) { |
2399 | - if ($globalDebug) echo "Add to DB..."; |
|
2844 | + if ($globalDebug) { |
|
2845 | + echo "Add to DB..."; |
|
2846 | + } |
|
2400 | 2847 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
2401 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2848 | + } else { |
|
2849 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2850 | + } |
|
2402 | 2851 | if ($error != '') { |
2403 | 2852 | return $error; |
2404 | - } elseif ($globalDebug) echo "Done\n"; |
|
2853 | + } elseif ($globalDebug) { |
|
2854 | + echo "Done\n"; |
|
2855 | + } |
|
2405 | 2856 | if ($globalMasterSource) { |
2406 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
2857 | + if ($globalDebug) { |
|
2858 | + echo "ModeS Netherlands: Download..."; |
|
2859 | + } |
|
2407 | 2860 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
2408 | 2861 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
2409 | - if ($globalDebug) echo "Add to DB..."; |
|
2862 | + if ($globalDebug) { |
|
2863 | + echo "Add to DB..."; |
|
2864 | + } |
|
2410 | 2865 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
2411 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2866 | + } else { |
|
2867 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2868 | + } |
|
2412 | 2869 | if ($error != '') { |
2413 | 2870 | return $error; |
2414 | - } elseif ($globalDebug) echo "Done\n"; |
|
2415 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
2871 | + } elseif ($globalDebug) { |
|
2872 | + echo "Done\n"; |
|
2873 | + } |
|
2874 | + if ($globalDebug) { |
|
2875 | + echo "ModeS Denmark: Download..."; |
|
2876 | + } |
|
2416 | 2877 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
2417 | 2878 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
2418 | - if ($globalDebug) echo "Add to DB..."; |
|
2879 | + if ($globalDebug) { |
|
2880 | + echo "Add to DB..."; |
|
2881 | + } |
|
2419 | 2882 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
2420 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2883 | + } else { |
|
2884 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2885 | + } |
|
2421 | 2886 | if ($error != '') { |
2422 | 2887 | return $error; |
2423 | - } elseif ($globalDebug) echo "Done\n"; |
|
2424 | - } elseif ($globalDebug) echo "Done\n"; |
|
2888 | + } elseif ($globalDebug) { |
|
2889 | + echo "Done\n"; |
|
2890 | + } |
|
2891 | + } elseif ($globalDebug) { |
|
2892 | + echo "Done\n"; |
|
2893 | + } |
|
2425 | 2894 | return ''; |
2426 | 2895 | } |
2427 | 2896 | |
2428 | 2897 | public static function update_translation() { |
2429 | 2898 | global $tmp_dir, $globalDebug; |
2430 | 2899 | $error = ''; |
2431 | - if ($globalDebug) echo "Translation : Download..."; |
|
2900 | + if ($globalDebug) { |
|
2901 | + echo "Translation : Download..."; |
|
2902 | + } |
|
2432 | 2903 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
2433 | 2904 | if (file_exists($tmp_dir.'translation.zip')) { |
2434 | - if ($globalDebug) echo "Unzip..."; |
|
2905 | + if ($globalDebug) { |
|
2906 | + echo "Unzip..."; |
|
2907 | + } |
|
2435 | 2908 | update_db::unzip($tmp_dir.'translation.zip'); |
2436 | - if ($globalDebug) echo "Add to DB..."; |
|
2909 | + if ($globalDebug) { |
|
2910 | + echo "Add to DB..."; |
|
2911 | + } |
|
2437 | 2912 | $error = update_db::translation(); |
2438 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2913 | + } else { |
|
2914 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2915 | + } |
|
2439 | 2916 | if ($error != '') { |
2440 | 2917 | return $error; |
2441 | - } elseif ($globalDebug) echo "Done\n"; |
|
2918 | + } elseif ($globalDebug) { |
|
2919 | + echo "Done\n"; |
|
2920 | + } |
|
2442 | 2921 | return ''; |
2443 | 2922 | } |
2444 | 2923 | |
2445 | 2924 | public static function update_translation_fam() { |
2446 | 2925 | global $tmp_dir, $globalDebug; |
2447 | 2926 | $error = ''; |
2448 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
2927 | + if ($globalDebug) { |
|
2928 | + echo "Translation from FlightAirMap website : Download..."; |
|
2929 | + } |
|
2449 | 2930 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
2450 | 2931 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5'); |
2451 | 2932 | if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) { |
2452 | 2933 | $translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
2453 | 2934 | $translation_md5 = $translation_md5_file[0]; |
2454 | 2935 | if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) { |
2455 | - if ($globalDebug) echo "Gunzip..."; |
|
2936 | + if ($globalDebug) { |
|
2937 | + echo "Gunzip..."; |
|
2938 | + } |
|
2456 | 2939 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
2457 | - if ($globalDebug) echo "Add to DB..."; |
|
2940 | + if ($globalDebug) { |
|
2941 | + echo "Add to DB..."; |
|
2942 | + } |
|
2458 | 2943 | $error = update_db::translation_fam(); |
2459 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
2460 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2944 | + } else { |
|
2945 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
2946 | + } |
|
2947 | + } else { |
|
2948 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2949 | + } |
|
2461 | 2950 | if ($error != '') { |
2462 | 2951 | return $error; |
2463 | - } elseif ($globalDebug) echo "Done\n"; |
|
2952 | + } elseif ($globalDebug) { |
|
2953 | + echo "Done\n"; |
|
2954 | + } |
|
2464 | 2955 | return ''; |
2465 | 2956 | } |
2466 | 2957 | public static function update_ModeS_fam() { |
2467 | 2958 | global $tmp_dir, $globalDebug; |
2468 | 2959 | $error = ''; |
2469 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
2960 | + if ($globalDebug) { |
|
2961 | + echo "ModeS from FlightAirMap website : Download..."; |
|
2962 | + } |
|
2470 | 2963 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
2471 | 2964 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5'); |
2472 | 2965 | if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) { |
2473 | 2966 | $modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
2474 | 2967 | $modes_md5 = $modes_md5_file[0]; |
2475 | 2968 | if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) { |
2476 | - if ($globalDebug) echo "Gunzip..."; |
|
2969 | + if ($globalDebug) { |
|
2970 | + echo "Gunzip..."; |
|
2971 | + } |
|
2477 | 2972 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
2478 | - if ($globalDebug) echo "Add to DB..."; |
|
2973 | + if ($globalDebug) { |
|
2974 | + echo "Add to DB..."; |
|
2975 | + } |
|
2479 | 2976 | $error = update_db::modes_fam(); |
2480 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
2481 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2977 | + } else { |
|
2978 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
2979 | + } |
|
2980 | + } else { |
|
2981 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2982 | + } |
|
2482 | 2983 | if ($error != '') { |
2483 | 2984 | return $error; |
2484 | - } elseif ($globalDebug) echo "Done\n"; |
|
2985 | + } elseif ($globalDebug) { |
|
2986 | + echo "Done\n"; |
|
2987 | + } |
|
2485 | 2988 | return ''; |
2486 | 2989 | } |
2487 | 2990 | |
2488 | 2991 | public static function update_airlines_fam() { |
2489 | 2992 | global $tmp_dir, $globalDebug; |
2490 | 2993 | $error = ''; |
2491 | - if ($globalDebug) echo "Airlines from FlightAirMap website : Download..."; |
|
2994 | + if ($globalDebug) { |
|
2995 | + echo "Airlines from FlightAirMap website : Download..."; |
|
2996 | + } |
|
2492 | 2997 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5'); |
2493 | 2998 | if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) { |
2494 | 2999 | $airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5')); |
@@ -2497,26 +3002,42 @@ discard block |
||
2497 | 3002 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz'); |
2498 | 3003 | if (file_exists($tmp_dir.'airlines.tsv.gz')) { |
2499 | 3004 | if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) { |
2500 | - if ($globalDebug) echo "Gunzip..."; |
|
3005 | + if ($globalDebug) { |
|
3006 | + echo "Gunzip..."; |
|
3007 | + } |
|
2501 | 3008 | update_db::gunzip($tmp_dir.'airlines.tsv.gz'); |
2502 | - if ($globalDebug) echo "Add to DB..."; |
|
3009 | + if ($globalDebug) { |
|
3010 | + echo "Add to DB..."; |
|
3011 | + } |
|
2503 | 3012 | $error = update_db::airlines_fam(); |
2504 | 3013 | update_db::insert_airlines_version($airlines_md5); |
2505 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
2506 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
2507 | - } elseif ($globalDebug) echo "No update."; |
|
2508 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
3014 | + } else { |
|
3015 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
3016 | + } |
|
3017 | + } else { |
|
3018 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
3019 | + } |
|
3020 | + } elseif ($globalDebug) { |
|
3021 | + echo "No update."; |
|
3022 | + } |
|
3023 | + } else { |
|
3024 | + $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
3025 | + } |
|
2509 | 3026 | if ($error != '') { |
2510 | 3027 | return $error; |
2511 | 3028 | } else { |
2512 | - if ($globalDebug) echo "Done\n"; |
|
3029 | + if ($globalDebug) { |
|
3030 | + echo "Done\n"; |
|
3031 | + } |
|
2513 | 3032 | } |
2514 | 3033 | return ''; |
2515 | 3034 | } |
2516 | 3035 | |
2517 | 3036 | public static function update_owner_fam() { |
2518 | 3037 | global $tmp_dir, $globalDebug, $globalOwner; |
2519 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
3038 | + if ($globalDebug) { |
|
3039 | + echo "owner from FlightAirMap website : Download..."; |
|
3040 | + } |
|
2520 | 3041 | $error = ''; |
2521 | 3042 | if ($globalOwner === TRUE) { |
2522 | 3043 | update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
@@ -2529,55 +3050,89 @@ discard block |
||
2529 | 3050 | $owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
2530 | 3051 | $owners_md5 = $owners_md5_file[0]; |
2531 | 3052 | if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) { |
2532 | - if ($globalDebug) echo "Gunzip..."; |
|
3053 | + if ($globalDebug) { |
|
3054 | + echo "Gunzip..."; |
|
3055 | + } |
|
2533 | 3056 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
2534 | - if ($globalDebug) echo "Add to DB..."; |
|
3057 | + if ($globalDebug) { |
|
3058 | + echo "Add to DB..."; |
|
3059 | + } |
|
2535 | 3060 | $error = update_db::owner_fam(); |
2536 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
2537 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
3061 | + } else { |
|
3062 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
3063 | + } |
|
3064 | + } else { |
|
3065 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
3066 | + } |
|
2538 | 3067 | if ($error != '') { |
2539 | 3068 | return $error; |
2540 | - } elseif ($globalDebug) echo "Done\n"; |
|
3069 | + } elseif ($globalDebug) { |
|
3070 | + echo "Done\n"; |
|
3071 | + } |
|
2541 | 3072 | return ''; |
2542 | 3073 | } |
2543 | 3074 | public static function update_routes_fam() { |
2544 | 3075 | global $tmp_dir, $globalDebug; |
2545 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
3076 | + if ($globalDebug) { |
|
3077 | + echo "Routes from FlightAirMap website : Download..."; |
|
3078 | + } |
|
2546 | 3079 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
2547 | 3080 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5'); |
2548 | 3081 | if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) { |
2549 | 3082 | $routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
2550 | 3083 | $routes_md5 = $routes_md5_file[0]; |
2551 | 3084 | if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) { |
2552 | - if ($globalDebug) echo "Gunzip..."; |
|
3085 | + if ($globalDebug) { |
|
3086 | + echo "Gunzip..."; |
|
3087 | + } |
|
2553 | 3088 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
2554 | - if ($globalDebug) echo "Add to DB..."; |
|
3089 | + if ($globalDebug) { |
|
3090 | + echo "Add to DB..."; |
|
3091 | + } |
|
2555 | 3092 | $error = update_db::routes_fam(); |
2556 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
2557 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
3093 | + } else { |
|
3094 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
3095 | + } |
|
3096 | + } else { |
|
3097 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
3098 | + } |
|
2558 | 3099 | if ($error != '') { |
2559 | 3100 | return $error; |
2560 | - } elseif ($globalDebug) echo "Done\n"; |
|
3101 | + } elseif ($globalDebug) { |
|
3102 | + echo "Done\n"; |
|
3103 | + } |
|
2561 | 3104 | return ''; |
2562 | 3105 | } |
2563 | 3106 | public static function update_block_fam() { |
2564 | 3107 | global $tmp_dir, $globalDebug; |
2565 | - if ($globalDebug) echo "Blocked aircraft from FlightAirMap website : Download..."; |
|
3108 | + if ($globalDebug) { |
|
3109 | + echo "Blocked aircraft from FlightAirMap website : Download..."; |
|
3110 | + } |
|
2566 | 3111 | update_db::download('http://data.flightairmap.com/data/block.tsv.gz',$tmp_dir.'block.tsv.gz'); |
2567 | 3112 | update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5',$tmp_dir.'block.tsv.gz.md5'); |
2568 | 3113 | if (file_exists($tmp_dir.'block.tsv.gz') && file_exists($tmp_dir.'block.tsv.gz.md5')) { |
2569 | 3114 | $block_md5_file = explode(' ',file_get_contents($tmp_dir.'block.tsv.gz.md5')); |
2570 | 3115 | $block_md5 = $block_md5_file[0]; |
2571 | 3116 | if (md5_file($tmp_dir.'block.tsv.gz') == $block_md5) { |
2572 | - if ($globalDebug) echo "Gunzip..."; |
|
3117 | + if ($globalDebug) { |
|
3118 | + echo "Gunzip..."; |
|
3119 | + } |
|
2573 | 3120 | update_db::gunzip($tmp_dir.'block.tsv.gz'); |
2574 | - if ($globalDebug) echo "Add to DB..."; |
|
3121 | + if ($globalDebug) { |
|
3122 | + echo "Add to DB..."; |
|
3123 | + } |
|
2575 | 3124 | $error = update_db::block_fam(); |
2576 | - } else $error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed."; |
|
2577 | - } else $error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed."; |
|
3125 | + } else { |
|
3126 | + $error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed."; |
|
3127 | + } |
|
3128 | + } else { |
|
3129 | + $error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed."; |
|
3130 | + } |
|
2578 | 3131 | if ($error != '') { |
2579 | 3132 | return $error; |
2580 | - } elseif ($globalDebug) echo "Done\n"; |
|
3133 | + } elseif ($globalDebug) { |
|
3134 | + echo "Done\n"; |
|
3135 | + } |
|
2581 | 3136 | return ''; |
2582 | 3137 | } |
2583 | 3138 | public static function update_marine_identity_fam() { |
@@ -2587,21 +3142,33 @@ discard block |
||
2587 | 3142 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
2588 | 3143 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
2589 | 3144 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
2590 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
3145 | + if ($globalDebug) { |
|
3146 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
3147 | + } |
|
2591 | 3148 | update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
2592 | 3149 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
2593 | 3150 | if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) { |
2594 | - if ($globalDebug) echo "Gunzip..."; |
|
3151 | + if ($globalDebug) { |
|
3152 | + echo "Gunzip..."; |
|
3153 | + } |
|
2595 | 3154 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
2596 | - if ($globalDebug) echo "Add to DB..."; |
|
3155 | + if ($globalDebug) { |
|
3156 | + echo "Add to DB..."; |
|
3157 | + } |
|
2597 | 3158 | $error = update_db::marine_identity_fam(); |
2598 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
2599 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
3159 | + } else { |
|
3160 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
3161 | + } |
|
3162 | + } else { |
|
3163 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
3164 | + } |
|
2600 | 3165 | if ($error != '') { |
2601 | 3166 | return $error; |
2602 | 3167 | } else { |
2603 | 3168 | update_db::insert_marine_identity_version($marine_identity_md5); |
2604 | - if ($globalDebug) echo "Done\n"; |
|
3169 | + if ($globalDebug) { |
|
3170 | + echo "Done\n"; |
|
3171 | + } |
|
2605 | 3172 | } |
2606 | 3173 | } |
2607 | 3174 | } |
@@ -2615,21 +3182,33 @@ discard block |
||
2615 | 3182 | $satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
2616 | 3183 | $satellite_md5 = $satellite_md5_file[0]; |
2617 | 3184 | if (!update_db::check_satellite_version($satellite_md5)) { |
2618 | - if ($globalDebug) echo "Satellite from FlightAirMap website : Download..."; |
|
3185 | + if ($globalDebug) { |
|
3186 | + echo "Satellite from FlightAirMap website : Download..."; |
|
3187 | + } |
|
2619 | 3188 | update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz'); |
2620 | 3189 | if (file_exists($tmp_dir.'satellite.tsv.gz')) { |
2621 | 3190 | if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) { |
2622 | - if ($globalDebug) echo "Gunzip..."; |
|
3191 | + if ($globalDebug) { |
|
3192 | + echo "Gunzip..."; |
|
3193 | + } |
|
2623 | 3194 | update_db::gunzip($tmp_dir.'satellite.tsv.gz'); |
2624 | - if ($globalDebug) echo "Add to DB..."; |
|
3195 | + if ($globalDebug) { |
|
3196 | + echo "Add to DB..."; |
|
3197 | + } |
|
2625 | 3198 | $error = update_db::satellite_fam(); |
2626 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
2627 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
3199 | + } else { |
|
3200 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
3201 | + } |
|
3202 | + } else { |
|
3203 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
3204 | + } |
|
2628 | 3205 | if ($error != '') { |
2629 | 3206 | return $error; |
2630 | 3207 | } else { |
2631 | 3208 | update_db::insert_satellite_version($satellite_md5); |
2632 | - if ($globalDebug) echo "Done\n"; |
|
3209 | + if ($globalDebug) { |
|
3210 | + echo "Done\n"; |
|
3211 | + } |
|
2633 | 3212 | } |
2634 | 3213 | } |
2635 | 3214 | } |
@@ -2637,17 +3216,25 @@ discard block |
||
2637 | 3216 | } |
2638 | 3217 | public static function update_banned_fam() { |
2639 | 3218 | global $tmp_dir, $globalDebug; |
2640 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
3219 | + if ($globalDebug) { |
|
3220 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
3221 | + } |
|
2641 | 3222 | update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
2642 | 3223 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
2643 | 3224 | //if ($globalDebug) echo "Gunzip..."; |
2644 | 3225 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
2645 | - if ($globalDebug) echo "Add to DB..."; |
|
3226 | + if ($globalDebug) { |
|
3227 | + echo "Add to DB..."; |
|
3228 | + } |
|
2646 | 3229 | $error = update_db::banned_fam(); |
2647 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
3230 | + } else { |
|
3231 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
3232 | + } |
|
2648 | 3233 | if ($error != '') { |
2649 | 3234 | return $error; |
2650 | - } elseif ($globalDebug) echo "Done\n"; |
|
3235 | + } elseif ($globalDebug) { |
|
3236 | + echo "Done\n"; |
|
3237 | + } |
|
2651 | 3238 | return ''; |
2652 | 3239 | } |
2653 | 3240 | |
@@ -2655,7 +3242,9 @@ discard block |
||
2655 | 3242 | global $tmp_dir, $globalDebug, $globalDBdriver; |
2656 | 3243 | include_once('class.create_db.php'); |
2657 | 3244 | $error = ''; |
2658 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
3245 | + if ($globalDebug) { |
|
3246 | + echo "Airspace from FlightAirMap website : Download..."; |
|
3247 | + } |
|
2659 | 3248 | if ($globalDBdriver == 'mysql') { |
2660 | 3249 | update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
2661 | 3250 | } else { |
@@ -2672,9 +3261,13 @@ discard block |
||
2672 | 3261 | } |
2673 | 3262 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
2674 | 3263 | if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) { |
2675 | - if ($globalDebug) echo "Gunzip..."; |
|
3264 | + if ($globalDebug) { |
|
3265 | + echo "Gunzip..."; |
|
3266 | + } |
|
2676 | 3267 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
2677 | - if ($globalDebug) echo "Add to DB..."; |
|
3268 | + if ($globalDebug) { |
|
3269 | + echo "Add to DB..."; |
|
3270 | + } |
|
2678 | 3271 | $Connection = new Connection(); |
2679 | 3272 | if ($Connection->tableExists('airspace')) { |
2680 | 3273 | $query = 'DROP TABLE airspace'; |
@@ -2687,20 +3280,30 @@ discard block |
||
2687 | 3280 | } |
2688 | 3281 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
2689 | 3282 | update_db::insert_airspace_version($airspace_md5); |
2690 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
2691 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
3283 | + } else { |
|
3284 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
3285 | + } |
|
3286 | + } else { |
|
3287 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
3288 | + } |
|
2692 | 3289 | } |
2693 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
3290 | + } else { |
|
3291 | + $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
3292 | + } |
|
2694 | 3293 | if ($error != '') { |
2695 | 3294 | return $error; |
2696 | - } elseif ($globalDebug) echo "Done\n"; |
|
3295 | + } elseif ($globalDebug) { |
|
3296 | + echo "Done\n"; |
|
3297 | + } |
|
2697 | 3298 | return ''; |
2698 | 3299 | } |
2699 | 3300 | |
2700 | 3301 | public static function update_geoid_fam() { |
2701 | 3302 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
2702 | 3303 | $error = ''; |
2703 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
3304 | + if ($globalDebug) { |
|
3305 | + echo "Geoid from FlightAirMap website : Download..."; |
|
3306 | + } |
|
2704 | 3307 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
2705 | 3308 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
2706 | 3309 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2709,76 +3312,120 @@ discard block |
||
2709 | 3312 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
2710 | 3313 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
2711 | 3314 | if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) { |
2712 | - if ($globalDebug) echo "Gunzip..."; |
|
3315 | + if ($globalDebug) { |
|
3316 | + echo "Gunzip..."; |
|
3317 | + } |
|
2713 | 3318 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
2714 | 3319 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
2715 | 3320 | update_db::insert_geoid_version($geoid_md5); |
2716 | - } else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed."; |
|
2717 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
2718 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
2719 | - } elseif ($globalDebug) echo 'No new version'."\n"; |
|
2720 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
3321 | + } else { |
|
3322 | + $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed."; |
|
3323 | + } |
|
3324 | + } else { |
|
3325 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
3326 | + } |
|
3327 | + } else { |
|
3328 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
3329 | + } |
|
3330 | + } elseif ($globalDebug) { |
|
3331 | + echo 'No new version'."\n"; |
|
3332 | + } |
|
3333 | + } else { |
|
3334 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
3335 | + } |
|
2721 | 3336 | if ($error != '') { |
2722 | 3337 | return $error; |
2723 | - } elseif ($globalDebug) echo "Done\n"; |
|
3338 | + } elseif ($globalDebug) { |
|
3339 | + echo "Done\n"; |
|
3340 | + } |
|
2724 | 3341 | return ''; |
2725 | 3342 | } |
2726 | 3343 | |
2727 | 3344 | public static function update_tle() { |
2728 | 3345 | global $tmp_dir, $globalDebug; |
2729 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
3346 | + if ($globalDebug) { |
|
3347 | + echo "Download TLE : Download..."; |
|
3348 | + } |
|
2730 | 3349 | $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
2731 | 3350 | 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
2732 | 3351 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt'); |
2733 | 3352 | foreach ($alltle as $filename) { |
2734 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
3353 | + if ($globalDebug) { |
|
3354 | + echo "downloading ".$filename.'...'; |
|
3355 | + } |
|
2735 | 3356 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
2736 | 3357 | if (file_exists($tmp_dir.$filename)) { |
2737 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
3358 | + if ($globalDebug) { |
|
3359 | + echo "Add to DB ".$filename."..."; |
|
3360 | + } |
|
2738 | 3361 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
2739 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
3362 | + } else { |
|
3363 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
3364 | + } |
|
2740 | 3365 | if ($error != '') { |
2741 | 3366 | echo $error."\n"; |
2742 | - } elseif ($globalDebug) echo "Done\n"; |
|
3367 | + } elseif ($globalDebug) { |
|
3368 | + echo "Done\n"; |
|
3369 | + } |
|
2743 | 3370 | } |
2744 | 3371 | return ''; |
2745 | 3372 | } |
2746 | 3373 | |
2747 | 3374 | public static function update_ucsdb() { |
2748 | 3375 | global $tmp_dir, $globalDebug; |
2749 | - if ($globalDebug) echo "Download UCS DB : Download..."; |
|
3376 | + if ($globalDebug) { |
|
3377 | + echo "Download UCS DB : Download..."; |
|
3378 | + } |
|
2750 | 3379 | update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
2751 | 3380 | if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) { |
2752 | - if ($globalDebug) echo "Add to DB..."; |
|
3381 | + if ($globalDebug) { |
|
3382 | + echo "Add to DB..."; |
|
3383 | + } |
|
2753 | 3384 | $error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
2754 | - } else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed."; |
|
3385 | + } else { |
|
3386 | + $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed."; |
|
3387 | + } |
|
2755 | 3388 | if ($error != '') { |
2756 | 3389 | echo $error."\n"; |
2757 | - } elseif ($globalDebug) echo "Done\n"; |
|
3390 | + } elseif ($globalDebug) { |
|
3391 | + echo "Done\n"; |
|
3392 | + } |
|
2758 | 3393 | return ''; |
2759 | 3394 | } |
2760 | 3395 | |
2761 | 3396 | public static function update_celestrak() { |
2762 | 3397 | global $tmp_dir, $globalDebug; |
2763 | - if ($globalDebug) echo "Download Celestrak DB : Download..."; |
|
3398 | + if ($globalDebug) { |
|
3399 | + echo "Download Celestrak DB : Download..."; |
|
3400 | + } |
|
2764 | 3401 | update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt'); |
2765 | 3402 | if (file_exists($tmp_dir.'satcat.txt')) { |
2766 | - if ($globalDebug) echo "Add to DB..."; |
|
3403 | + if ($globalDebug) { |
|
3404 | + echo "Add to DB..."; |
|
3405 | + } |
|
2767 | 3406 | $error = update_db::satellite_celestrak($tmp_dir.'satcat.txt'); |
2768 | - } else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
3407 | + } else { |
|
3408 | + $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
3409 | + } |
|
2769 | 3410 | if ($error != '') { |
2770 | 3411 | echo $error."\n"; |
2771 | - } elseif ($globalDebug) echo "Done\n"; |
|
3412 | + } elseif ($globalDebug) { |
|
3413 | + echo "Done\n"; |
|
3414 | + } |
|
2772 | 3415 | return ''; |
2773 | 3416 | } |
2774 | 3417 | |
2775 | 3418 | public static function update_models() { |
2776 | 3419 | global $tmp_dir, $globalDebug; |
2777 | 3420 | $error = ''; |
2778 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
3421 | + if ($globalDebug) { |
|
3422 | + echo "Models from FlightAirMap website : Download..."; |
|
3423 | + } |
|
2779 | 3424 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
2780 | 3425 | if (file_exists($tmp_dir.'models.md5sum')) { |
2781 | - if ($globalDebug) echo "Check files...\n"; |
|
3426 | + if ($globalDebug) { |
|
3427 | + echo "Check files...\n"; |
|
3428 | + } |
|
2782 | 3429 | $newmodelsdb = array(); |
2783 | 3430 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
2784 | 3431 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2797,19 +3444,29 @@ discard block |
||
2797 | 3444 | } |
2798 | 3445 | $diff = array_diff($newmodelsdb,$modelsdb); |
2799 | 3446 | foreach ($diff as $key => $value) { |
2800 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3447 | + if ($globalDebug) { |
|
3448 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3449 | + } |
|
2801 | 3450 | update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
2802 | 3451 | |
2803 | 3452 | } |
2804 | 3453 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
2805 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3454 | + } else { |
|
3455 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3456 | + } |
|
2806 | 3457 | if ($error != '') { |
2807 | 3458 | return $error; |
2808 | - } elseif ($globalDebug) echo "Done\n"; |
|
2809 | - if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
3459 | + } elseif ($globalDebug) { |
|
3460 | + echo "Done\n"; |
|
3461 | + } |
|
3462 | + if ($globalDebug) { |
|
3463 | + echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
3464 | + } |
|
2810 | 3465 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum'); |
2811 | 3466 | if (file_exists($tmp_dir.'modelsgltf2.md5sum')) { |
2812 | - if ($globalDebug) echo "Check files...\n"; |
|
3467 | + if ($globalDebug) { |
|
3468 | + echo "Check files...\n"; |
|
3469 | + } |
|
2813 | 3470 | $newmodelsdb = array(); |
2814 | 3471 | if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) { |
2815 | 3472 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2828,19 +3485,29 @@ discard block |
||
2828 | 3485 | } |
2829 | 3486 | $diff = array_diff($newmodelsdb,$modelsdb); |
2830 | 3487 | foreach ($diff as $key => $value) { |
2831 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3488 | + if ($globalDebug) { |
|
3489 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3490 | + } |
|
2832 | 3491 | update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key); |
2833 | 3492 | |
2834 | 3493 | } |
2835 | 3494 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum'); |
2836 | - } else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
3495 | + } else { |
|
3496 | + $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
3497 | + } |
|
2837 | 3498 | if ($error != '') { |
2838 | 3499 | return $error; |
2839 | - } elseif ($globalDebug) echo "Done\n"; |
|
2840 | - if ($globalDebug) echo "Weather Models from FlightAirMap website : Download..."; |
|
3500 | + } elseif ($globalDebug) { |
|
3501 | + echo "Done\n"; |
|
3502 | + } |
|
3503 | + if ($globalDebug) { |
|
3504 | + echo "Weather Models from FlightAirMap website : Download..."; |
|
3505 | + } |
|
2841 | 3506 | update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',$tmp_dir.'modelsweather.md5sum'); |
2842 | 3507 | if (file_exists($tmp_dir.'modelsweather.md5sum')) { |
2843 | - if ($globalDebug) echo "Check files...\n"; |
|
3508 | + if ($globalDebug) { |
|
3509 | + echo "Check files...\n"; |
|
3510 | + } |
|
2844 | 3511 | $newmodelsdb = array(); |
2845 | 3512 | if (($handle = fopen($tmp_dir.'modelsweather.md5sum','r')) !== FALSE) { |
2846 | 3513 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2859,25 +3526,35 @@ discard block |
||
2859 | 3526 | } |
2860 | 3527 | $diff = array_diff($newmodelsdb,$modelsdb); |
2861 | 3528 | foreach ($diff as $key => $value) { |
2862 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3529 | + if ($globalDebug) { |
|
3530 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3531 | + } |
|
2863 | 3532 | update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key,dirname(__FILE__).'/../models/gltf2/weather/'.$key); |
2864 | 3533 | |
2865 | 3534 | } |
2866 | 3535 | update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',dirname(__FILE__).'/../models/gltf2/weather/models.md5sum'); |
2867 | - } else $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed."; |
|
3536 | + } else { |
|
3537 | + $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed."; |
|
3538 | + } |
|
2868 | 3539 | if ($error != '') { |
2869 | 3540 | return $error; |
2870 | - } elseif ($globalDebug) echo "Done\n"; |
|
3541 | + } elseif ($globalDebug) { |
|
3542 | + echo "Done\n"; |
|
3543 | + } |
|
2871 | 3544 | return ''; |
2872 | 3545 | } |
2873 | 3546 | |
2874 | 3547 | public static function update_liveries() { |
2875 | 3548 | global $tmp_dir, $globalDebug; |
2876 | 3549 | $error = ''; |
2877 | - if ($globalDebug) echo "Liveries from FlightAirMap website : Download..."; |
|
3550 | + if ($globalDebug) { |
|
3551 | + echo "Liveries from FlightAirMap website : Download..."; |
|
3552 | + } |
|
2878 | 3553 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum'); |
2879 | 3554 | if (file_exists($tmp_dir.'liveries.md5sum')) { |
2880 | - if ($globalDebug) echo "Check files...\n"; |
|
3555 | + if ($globalDebug) { |
|
3556 | + echo "Check files...\n"; |
|
3557 | + } |
|
2881 | 3558 | $newmodelsdb = array(); |
2882 | 3559 | if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) { |
2883 | 3560 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2896,25 +3573,35 @@ discard block |
||
2896 | 3573 | } |
2897 | 3574 | $diff = array_diff($newmodelsdb,$modelsdb); |
2898 | 3575 | foreach ($diff as $key => $value) { |
2899 | - if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n"; |
|
3576 | + if ($globalDebug) { |
|
3577 | + echo 'Downloading liveries '.$key.' ...'."\n"; |
|
3578 | + } |
|
2900 | 3579 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key); |
2901 | 3580 | |
2902 | 3581 | } |
2903 | 3582 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum'); |
2904 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3583 | + } else { |
|
3584 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3585 | + } |
|
2905 | 3586 | if ($error != '') { |
2906 | 3587 | return $error; |
2907 | - } elseif ($globalDebug) echo "Done\n"; |
|
3588 | + } elseif ($globalDebug) { |
|
3589 | + echo "Done\n"; |
|
3590 | + } |
|
2908 | 3591 | return ''; |
2909 | 3592 | } |
2910 | 3593 | |
2911 | 3594 | public static function update_space_models() { |
2912 | 3595 | global $tmp_dir, $globalDebug; |
2913 | 3596 | $error = ''; |
2914 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
3597 | + if ($globalDebug) { |
|
3598 | + echo "Space models from FlightAirMap website : Download..."; |
|
3599 | + } |
|
2915 | 3600 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
2916 | 3601 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2917 | - if ($globalDebug) echo "Check files...\n"; |
|
3602 | + if ($globalDebug) { |
|
3603 | + echo "Check files...\n"; |
|
3604 | + } |
|
2918 | 3605 | $newmodelsdb = array(); |
2919 | 3606 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
2920 | 3607 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2933,25 +3620,35 @@ discard block |
||
2933 | 3620 | } |
2934 | 3621 | $diff = array_diff($newmodelsdb,$modelsdb); |
2935 | 3622 | foreach ($diff as $key => $value) { |
2936 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
3623 | + if ($globalDebug) { |
|
3624 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
3625 | + } |
|
2937 | 3626 | update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
2938 | 3627 | |
2939 | 3628 | } |
2940 | 3629 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
2941 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3630 | + } else { |
|
3631 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3632 | + } |
|
2942 | 3633 | if ($error != '') { |
2943 | 3634 | return $error; |
2944 | - } elseif ($globalDebug) echo "Done\n"; |
|
3635 | + } elseif ($globalDebug) { |
|
3636 | + echo "Done\n"; |
|
3637 | + } |
|
2945 | 3638 | return ''; |
2946 | 3639 | } |
2947 | 3640 | |
2948 | 3641 | public static function update_vehicules_models() { |
2949 | 3642 | global $tmp_dir, $globalDebug; |
2950 | 3643 | $error = ''; |
2951 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
3644 | + if ($globalDebug) { |
|
3645 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
3646 | + } |
|
2952 | 3647 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
2953 | 3648 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
2954 | - if ($globalDebug) echo "Check files...\n"; |
|
3649 | + if ($globalDebug) { |
|
3650 | + echo "Check files...\n"; |
|
3651 | + } |
|
2955 | 3652 | $newmodelsdb = array(); |
2956 | 3653 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
2957 | 3654 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2970,15 +3667,21 @@ discard block |
||
2970 | 3667 | } |
2971 | 3668 | $diff = array_diff($newmodelsdb,$modelsdb); |
2972 | 3669 | foreach ($diff as $key => $value) { |
2973 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
3670 | + if ($globalDebug) { |
|
3671 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
3672 | + } |
|
2974 | 3673 | update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
2975 | 3674 | |
2976 | 3675 | } |
2977 | 3676 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
2978 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3677 | + } else { |
|
3678 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3679 | + } |
|
2979 | 3680 | if ($error != '') { |
2980 | 3681 | return $error; |
2981 | - } elseif ($globalDebug) echo "Done\n"; |
|
3682 | + } elseif ($globalDebug) { |
|
3683 | + echo "Done\n"; |
|
3684 | + } |
|
2982 | 3685 | return ''; |
2983 | 3686 | } |
2984 | 3687 | |
@@ -3051,7 +3754,9 @@ discard block |
||
3051 | 3754 | } |
3052 | 3755 | |
3053 | 3756 | $error = ''; |
3054 | - if ($globalDebug) echo "Notam : Download..."; |
|
3757 | + if ($globalDebug) { |
|
3758 | + echo "Notam : Download..."; |
|
3759 | + } |
|
3055 | 3760 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
3056 | 3761 | if (file_exists($tmp_dir.'notam.rss')) { |
3057 | 3762 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -3066,14 +3771,30 @@ discard block |
||
3066 | 3771 | $data['fir'] = $q[0]; |
3067 | 3772 | $data['code'] = $q[1]; |
3068 | 3773 | $ifrvfr = $q[2]; |
3069 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
3070 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
3071 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
3072 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
3073 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
3074 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
3075 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
3076 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
3774 | + if ($ifrvfr == 'IV') { |
|
3775 | + $data['rules'] = 'IFR/VFR'; |
|
3776 | + } |
|
3777 | + if ($ifrvfr == 'I') { |
|
3778 | + $data['rules'] = 'IFR'; |
|
3779 | + } |
|
3780 | + if ($ifrvfr == 'V') { |
|
3781 | + $data['rules'] = 'VFR'; |
|
3782 | + } |
|
3783 | + if ($q[4] == 'A') { |
|
3784 | + $data['scope'] = 'Airport warning'; |
|
3785 | + } |
|
3786 | + if ($q[4] == 'E') { |
|
3787 | + $data['scope'] = 'Enroute warning'; |
|
3788 | + } |
|
3789 | + if ($q[4] == 'W') { |
|
3790 | + $data['scope'] = 'Navigation warning'; |
|
3791 | + } |
|
3792 | + if ($q[4] == 'AE') { |
|
3793 | + $data['scope'] = 'Airport/Enroute warning'; |
|
3794 | + } |
|
3795 | + if ($q[4] == 'AW') { |
|
3796 | + $data['scope'] = 'Airport/Navigation warning'; |
|
3797 | + } |
|
3077 | 3798 | //$data['scope'] = $q[4]; |
3078 | 3799 | $data['lower_limit'] = $q[5]; |
3079 | 3800 | $data['upper_limit'] = $q[6]; |
@@ -3081,8 +3802,12 @@ discard block |
||
3081 | 3802 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
3082 | 3803 | $latitude = $Common->convertDec($las,'latitude'); |
3083 | 3804 | $longitude = $Common->convertDec($lns,'longitude'); |
3084 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
3085 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
3805 | + if ($lac == 'S') { |
|
3806 | + $latitude = '-'.$latitude; |
|
3807 | + } |
|
3808 | + if ($lnc == 'W') { |
|
3809 | + $longitude = '-'.$longitude; |
|
3810 | + } |
|
3086 | 3811 | $data['center_latitude'] = $latitude; |
3087 | 3812 | $data['center_longitude'] = $longitude; |
3088 | 3813 | $data['radius'] = intval($radius); |
@@ -3112,10 +3837,14 @@ discard block |
||
3112 | 3837 | $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
3113 | 3838 | unset($data); |
3114 | 3839 | } |
3115 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
3840 | + } else { |
|
3841 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
3842 | + } |
|
3116 | 3843 | if ($error != '') { |
3117 | 3844 | return $error; |
3118 | - } elseif ($globalDebug) echo "Done\n"; |
|
3845 | + } elseif ($globalDebug) { |
|
3846 | + echo "Done\n"; |
|
3847 | + } |
|
3119 | 3848 | return ''; |
3120 | 3849 | } |
3121 | 3850 | |
@@ -3140,7 +3869,9 @@ discard block |
||
3140 | 3869 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
3141 | 3870 | $airspace_json = json_decode($airspace_lst,true); |
3142 | 3871 | foreach ($airspace_json['records'] as $airspace) { |
3143 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
3872 | + if ($globalDebug) { |
|
3873 | + echo $airspace['name']."...\n"; |
|
3874 | + } |
|
3144 | 3875 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
3145 | 3876 | if (file_exists($tmp_dir.$airspace['name'])) { |
3146 | 3877 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -3184,8 +3915,11 @@ discard block |
||
3184 | 3915 | return "error : ".$e->getMessage(); |
3185 | 3916 | } |
3186 | 3917 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3187 | - if ($row['nb'] > 0) return false; |
|
3188 | - else return true; |
|
3918 | + if ($row['nb'] > 0) { |
|
3919 | + return false; |
|
3920 | + } else { |
|
3921 | + return true; |
|
3922 | + } |
|
3189 | 3923 | } |
3190 | 3924 | |
3191 | 3925 | public static function insert_last_update() { |
@@ -3210,8 +3944,11 @@ discard block |
||
3210 | 3944 | return "error : ".$e->getMessage(); |
3211 | 3945 | } |
3212 | 3946 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3213 | - if ($row['nb'] > 0) return true; |
|
3214 | - else return false; |
|
3947 | + if ($row['nb'] > 0) { |
|
3948 | + return true; |
|
3949 | + } else { |
|
3950 | + return false; |
|
3951 | + } |
|
3215 | 3952 | } |
3216 | 3953 | |
3217 | 3954 | public static function check_geoid_version($version) { |
@@ -3224,8 +3961,11 @@ discard block |
||
3224 | 3961 | return "error : ".$e->getMessage(); |
3225 | 3962 | } |
3226 | 3963 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3227 | - if ($row['nb'] > 0) return true; |
|
3228 | - else return false; |
|
3964 | + if ($row['nb'] > 0) { |
|
3965 | + return true; |
|
3966 | + } else { |
|
3967 | + return false; |
|
3968 | + } |
|
3229 | 3969 | } |
3230 | 3970 | |
3231 | 3971 | public static function check_marine_identity_version($version) { |
@@ -3238,8 +3978,11 @@ discard block |
||
3238 | 3978 | return "error : ".$e->getMessage(); |
3239 | 3979 | } |
3240 | 3980 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3241 | - if ($row['nb'] > 0) return true; |
|
3242 | - else return false; |
|
3981 | + if ($row['nb'] > 0) { |
|
3982 | + return true; |
|
3983 | + } else { |
|
3984 | + return false; |
|
3985 | + } |
|
3243 | 3986 | } |
3244 | 3987 | |
3245 | 3988 | public static function check_satellite_version($version) { |
@@ -3252,8 +3995,11 @@ discard block |
||
3252 | 3995 | return "error : ".$e->getMessage(); |
3253 | 3996 | } |
3254 | 3997 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3255 | - if ($row['nb'] > 0) return true; |
|
3256 | - else return false; |
|
3998 | + if ($row['nb'] > 0) { |
|
3999 | + return true; |
|
4000 | + } else { |
|
4001 | + return false; |
|
4002 | + } |
|
3257 | 4003 | } |
3258 | 4004 | |
3259 | 4005 | public static function check_airlines_version($version) { |
@@ -3266,8 +4012,11 @@ discard block |
||
3266 | 4012 | return "error : ".$e->getMessage(); |
3267 | 4013 | } |
3268 | 4014 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3269 | - if ($row['nb'] > 0) return true; |
|
3270 | - else return false; |
|
4015 | + if ($row['nb'] > 0) { |
|
4016 | + return true; |
|
4017 | + } else { |
|
4018 | + return false; |
|
4019 | + } |
|
3271 | 4020 | } |
3272 | 4021 | |
3273 | 4022 | public static function check_notam_version($version) { |
@@ -3280,8 +4029,11 @@ discard block |
||
3280 | 4029 | return "error : ".$e->getMessage(); |
3281 | 4030 | } |
3282 | 4031 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3283 | - if ($row['nb'] > 0) return true; |
|
3284 | - else return false; |
|
4032 | + if ($row['nb'] > 0) { |
|
4033 | + return true; |
|
4034 | + } else { |
|
4035 | + return false; |
|
4036 | + } |
|
3285 | 4037 | } |
3286 | 4038 | |
3287 | 4039 | public static function insert_airlines_version($version) { |
@@ -3371,8 +4123,11 @@ discard block |
||
3371 | 4123 | return "error : ".$e->getMessage(); |
3372 | 4124 | } |
3373 | 4125 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3374 | - if ($row['nb'] > 0) return false; |
|
3375 | - else return true; |
|
4126 | + if ($row['nb'] > 0) { |
|
4127 | + return false; |
|
4128 | + } else { |
|
4129 | + return true; |
|
4130 | + } |
|
3376 | 4131 | } |
3377 | 4132 | |
3378 | 4133 | public static function insert_last_notam_update() { |
@@ -3402,8 +4157,11 @@ discard block |
||
3402 | 4157 | return "error : ".$e->getMessage(); |
3403 | 4158 | } |
3404 | 4159 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3405 | - if ($row['nb'] > 0) return false; |
|
3406 | - else return true; |
|
4160 | + if ($row['nb'] > 0) { |
|
4161 | + return false; |
|
4162 | + } else { |
|
4163 | + return true; |
|
4164 | + } |
|
3407 | 4165 | } |
3408 | 4166 | |
3409 | 4167 | public static function insert_last_airspace_update() { |
@@ -3433,8 +4191,11 @@ discard block |
||
3433 | 4191 | return "error : ".$e->getMessage(); |
3434 | 4192 | } |
3435 | 4193 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3436 | - if ($row['nb'] > 0) return false; |
|
3437 | - else return true; |
|
4194 | + if ($row['nb'] > 0) { |
|
4195 | + return false; |
|
4196 | + } else { |
|
4197 | + return true; |
|
4198 | + } |
|
3438 | 4199 | } |
3439 | 4200 | |
3440 | 4201 | public static function insert_last_geoid_update() { |
@@ -3464,8 +4225,11 @@ discard block |
||
3464 | 4225 | return "error : ".$e->getMessage(); |
3465 | 4226 | } |
3466 | 4227 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3467 | - if ($row['nb'] > 0) return false; |
|
3468 | - else return true; |
|
4228 | + if ($row['nb'] > 0) { |
|
4229 | + return false; |
|
4230 | + } else { |
|
4231 | + return true; |
|
4232 | + } |
|
3469 | 4233 | } |
3470 | 4234 | |
3471 | 4235 | public static function insert_last_owner_update() { |
@@ -3495,8 +4259,11 @@ discard block |
||
3495 | 4259 | return "error : ".$e->getMessage(); |
3496 | 4260 | } |
3497 | 4261 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3498 | - if ($row['nb'] > 0) return false; |
|
3499 | - else return true; |
|
4262 | + if ($row['nb'] > 0) { |
|
4263 | + return false; |
|
4264 | + } else { |
|
4265 | + return true; |
|
4266 | + } |
|
3500 | 4267 | } |
3501 | 4268 | |
3502 | 4269 | public static function insert_last_fires_update() { |
@@ -3526,8 +4293,11 @@ discard block |
||
3526 | 4293 | return "error : ".$e->getMessage(); |
3527 | 4294 | } |
3528 | 4295 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3529 | - if ($row['nb'] > 0) return false; |
|
3530 | - else return true; |
|
4296 | + if ($row['nb'] > 0) { |
|
4297 | + return false; |
|
4298 | + } else { |
|
4299 | + return true; |
|
4300 | + } |
|
3531 | 4301 | } |
3532 | 4302 | |
3533 | 4303 | public static function insert_last_airlines_update() { |
@@ -3557,8 +4327,11 @@ discard block |
||
3557 | 4327 | return "error : ".$e->getMessage(); |
3558 | 4328 | } |
3559 | 4329 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3560 | - if ($row['nb'] > 0) return false; |
|
3561 | - else return true; |
|
4330 | + if ($row['nb'] > 0) { |
|
4331 | + return false; |
|
4332 | + } else { |
|
4333 | + return true; |
|
4334 | + } |
|
3562 | 4335 | } |
3563 | 4336 | |
3564 | 4337 | public static function insert_last_schedules_update() { |
@@ -3588,8 +4361,11 @@ discard block |
||
3588 | 4361 | return "error : ".$e->getMessage(); |
3589 | 4362 | } |
3590 | 4363 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3591 | - if ($row['nb'] > 0) return false; |
|
3592 | - else return true; |
|
4364 | + if ($row['nb'] > 0) { |
|
4365 | + return false; |
|
4366 | + } else { |
|
4367 | + return true; |
|
4368 | + } |
|
3593 | 4369 | } |
3594 | 4370 | |
3595 | 4371 | public static function insert_last_tle_update() { |
@@ -3619,8 +4395,11 @@ discard block |
||
3619 | 4395 | return "error : ".$e->getMessage(); |
3620 | 4396 | } |
3621 | 4397 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3622 | - if ($row['nb'] > 0) return false; |
|
3623 | - else return true; |
|
4398 | + if ($row['nb'] > 0) { |
|
4399 | + return false; |
|
4400 | + } else { |
|
4401 | + return true; |
|
4402 | + } |
|
3624 | 4403 | } |
3625 | 4404 | |
3626 | 4405 | public static function insert_last_ucsdb_update() { |
@@ -3650,8 +4429,11 @@ discard block |
||
3650 | 4429 | return "error : ".$e->getMessage(); |
3651 | 4430 | } |
3652 | 4431 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3653 | - if ($row['nb'] > 0) return false; |
|
3654 | - else return true; |
|
4432 | + if ($row['nb'] > 0) { |
|
4433 | + return false; |
|
4434 | + } else { |
|
4435 | + return true; |
|
4436 | + } |
|
3655 | 4437 | } |
3656 | 4438 | |
3657 | 4439 | public static function insert_last_celestrak_update() { |
@@ -3681,8 +4463,11 @@ discard block |
||
3681 | 4463 | return "error : ".$e->getMessage(); |
3682 | 4464 | } |
3683 | 4465 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3684 | - if ($row['nb'] > 0) return false; |
|
3685 | - else return true; |
|
4466 | + if ($row['nb'] > 0) { |
|
4467 | + return false; |
|
4468 | + } else { |
|
4469 | + return true; |
|
4470 | + } |
|
3686 | 4471 | } |
3687 | 4472 | |
3688 | 4473 | public static function check_last_satellite_update() { |
@@ -3700,8 +4485,11 @@ discard block |
||
3700 | 4485 | return "error : ".$e->getMessage(); |
3701 | 4486 | } |
3702 | 4487 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3703 | - if ($row['nb'] > 0) return false; |
|
3704 | - else return true; |
|
4488 | + if ($row['nb'] > 0) { |
|
4489 | + return false; |
|
4490 | + } else { |
|
4491 | + return true; |
|
4492 | + } |
|
3705 | 4493 | } |
3706 | 4494 | |
3707 | 4495 | public static function insert_last_marine_identity_update() { |
@@ -27,21 +27,30 @@ discard block |
||
27 | 27 | |
28 | 28 | document.cookie = 'MapFormat=3d; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/' |
29 | 29 | <?php |
30 | - if (isset($_COOKIE['MapType3D'])) $MapType = $_COOKIE['MapType3D']; |
|
31 | - else $MapType = $globalMapProvider; |
|
32 | -// unset($_COOKIE['MapType']); |
|
30 | + if (isset($_COOKIE['MapType3D'])) { |
|
31 | + $MapType = $_COOKIE['MapType3D']; |
|
32 | + } else { |
|
33 | + $MapType = $globalMapProvider; |
|
34 | + } |
|
35 | + // unset($_COOKIE['MapType']); |
|
33 | 36 | |
34 | 37 | if ($MapType != 'Mapbox' && $MapType != 'OpenStreetMap' && $MapType != 'Bing-Aerial' && $MapType != 'Bing-Hybrid' && $MapType != 'Bing-Road' && $MapType != 'offline' && $MapType != 'ArcGIS-Streetmap' && $MapType != 'ArcGIS-Satellite' && $MapType != 'NatGeo-Street') { |
35 | - if (isset($globalBingMapKey) && $globalBingMapKey != '') $MapType = 'Bing-Aerial'; |
|
36 | - else $MapType = 'OpenStreetMap'; |
|
38 | + if (isset($globalBingMapKey) && $globalBingMapKey != '') { |
|
39 | + $MapType = 'Bing-Aerial'; |
|
40 | + } else { |
|
41 | + $MapType = 'OpenStreetMap'; |
|
42 | + } |
|
37 | 43 | } |
38 | 44 | if (($MapType == 'Bing-Aerial' || $MapType == 'Bing-Hybrid' || $MapType == 'Bing-Road') && (!isset($globalBingMapKey) || $globalBingMapKey == '')) { |
39 | 45 | $MapType = 'OpenStreetMap'; |
40 | 46 | } |
41 | 47 | if ($MapType == 'Mapbox') { |
42 | - if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId; |
|
43 | - else $MapBoxId = $_COOKIE['MapType3DId']; |
|
44 | -?> |
|
48 | + if ($_COOKIE['MapTypeId'] == 'default') { |
|
49 | + $MapBoxId = $globalMapboxId; |
|
50 | + } else { |
|
51 | + $MapBoxId = $_COOKIE['MapType3DId']; |
|
52 | + } |
|
53 | + ?> |
|
45 | 54 | var imProv = Cesium.MapboxImageryProvider({ |
46 | 55 | credit: 'Map data © OpenStreetMap contributors, ' + |
47 | 56 | 'CC-BY-SA, ' + |
@@ -108,13 +117,23 @@ discard block |
||
108 | 117 | credit : 'Imagery courtesy Natural Earth' |
109 | 118 | }); |
110 | 119 | <?php |
111 | - } elseif (isset($globalMapCustomLayer[$MapType])) { |
|
120 | + } elseif (isset($globalMapCustomLayer[$MapType])) { |
|
112 | 121 | $customid = $MapType; |
113 | 122 | ?> |
114 | 123 | var imProv = Cesium.createOpenStreetMapImageryProvider({ |
115 | 124 | url : '<?php print $globalMapCustomLayer[$customid]['url']; ?>', |
116 | - maximumLevel: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '99'; ?>, |
|
117 | - minimumLevel: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>, |
|
125 | + maximumLevel: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) { |
|
126 | + print $globalMapCustomLayer[$customid]['maxZoom']; |
|
127 | +} else { |
|
128 | + print '99'; |
|
129 | +} |
|
130 | +?>, |
|
131 | + minimumLevel: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) { |
|
132 | + print $globalMapCustomLayer[$customid]['minZoom']; |
|
133 | +} else { |
|
134 | + print '0'; |
|
135 | +} |
|
136 | +?>, |
|
118 | 137 | credit: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>' |
119 | 138 | }); |
120 | 139 | <?php |
@@ -506,7 +525,12 @@ discard block |
||
506 | 525 | imageryProvider : imProv, |
507 | 526 | timeline : archive, |
508 | 527 | animation : false, |
509 | - shadows : <?php if ((isset($globalMap3DShadows) && $globalMap3DShadows === FALSE) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'true')) print 'false'; else print 'true'; ?>, |
|
528 | + shadows : <?php if ((isset($globalMap3DShadows) && $globalMap3DShadows === FALSE) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'true')) { |
|
529 | + print 'false'; |
|
530 | +} else { |
|
531 | + print 'true'; |
|
532 | +} |
|
533 | +?>, |
|
510 | 534 | infoBox : false, |
511 | 535 | navigationHelpButton : false, |
512 | 536 | geocoder : false, |
@@ -521,8 +545,11 @@ discard block |
||
521 | 545 | if (isset($_COOKIE['lastcentercoord']) || (isset($globalCenterLatitude) && isset($globalCenterLongitude) && $globalCenterLatitude != '' && $globalCenterLongitude != '')) { |
522 | 546 | if (isset($_COOKIE['lastcentercoord'])) { |
523 | 547 | $lastcentercoord = explode(',',$_COOKIE['lastcentercoord']); |
524 | - if (!isset($lastcentercoord[3])) $zoom = $lastcentercoord[2]*1000000.0; |
|
525 | - else $zoom = $lastcentercoord[3]; |
|
548 | + if (!isset($lastcentercoord[3])) { |
|
549 | + $zoom = $lastcentercoord[2]*1000000.0; |
|
550 | + } else { |
|
551 | + $zoom = $lastcentercoord[3]; |
|
552 | + } |
|
526 | 553 | $viewcenterlatitude = $lastcentercoord[0]; |
527 | 554 | $viewcenterlongitude = $lastcentercoord[1]; |
528 | 555 | } else { |
@@ -642,7 +669,12 @@ discard block |
||
642 | 669 | ?> |
643 | 670 | |
644 | 671 | update_locationsLayer(); |
645 | -setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>); |
|
672 | +setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) { |
|
673 | + print $globalMapRefresh*1000*2; |
|
674 | +} else { |
|
675 | + print '60000'; |
|
676 | +} |
|
677 | +?>); |
|
646 | 678 | |
647 | 679 | var currentposition; |
648 | 680 | viewer.camera.moveEnd.addEventListener(function() { |
@@ -73,8 +73,11 @@ discard block |
||
73 | 73 | } |
74 | 74 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
75 | 75 | $sth->closeCursor(); |
76 | - if ($row['nb'] > 0) return false; |
|
77 | - else return true; |
|
76 | + if ($row['nb'] > 0) { |
|
77 | + return false; |
|
78 | + } else { |
|
79 | + return true; |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | |
80 | 83 | /* |
@@ -104,29 +107,48 @@ discard block |
||
104 | 107 | //$pieces = explode(' ',$data); |
105 | 108 | $pieces = preg_split('/\s/',$data); |
106 | 109 | $pos = 0; |
107 | - if ($pieces[0] == 'METAR') $pos++; |
|
108 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
109 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
110 | + if ($pieces[0] == 'METAR') { |
|
111 | + $pos++; |
|
112 | + } elseif ($pieces[0] == 'SPECI') { |
|
113 | + $pos++; |
|
114 | + } |
|
115 | + if (strlen($pieces[$pos]) != 4) { |
|
116 | + $pos++; |
|
117 | + } |
|
110 | 118 | $result = array(); |
111 | - if (!isset($pieces[$pos])) return $result; |
|
119 | + if (!isset($pieces[$pos])) { |
|
120 | + return $result; |
|
121 | + } |
|
112 | 122 | $result['location'] = $pieces[$pos]; |
113 | 123 | $pos++; |
114 | - if (!isset($pieces[$pos])) return $result; |
|
124 | + if (!isset($pieces[$pos])) { |
|
125 | + return $result; |
|
126 | + } |
|
115 | 127 | $result['dayofmonth'] = substr($pieces[$pos],0,2); |
116 | 128 | $result['time'] = substr($pieces[$pos],2,4); |
117 | 129 | $c = count($pieces); |
118 | 130 | for($pos++; $pos < $c; $pos++) { |
119 | 131 | $piece = $pieces[$pos]; |
120 | - if ($piece == 'RMK') break; |
|
121 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
122 | - if ($piece == 'COR') $result['correction'] = true; |
|
132 | + if ($piece == 'RMK') { |
|
133 | + break; |
|
134 | + } |
|
135 | + if ($piece == 'AUTO') { |
|
136 | + $result['auto'] = true; |
|
137 | + } |
|
138 | + if ($piece == 'COR') { |
|
139 | + $result['correction'] = true; |
|
140 | + } |
|
123 | 141 | // Wind Speed |
124 | 142 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
125 | 143 | $result['wind']['direction'] = (float)$matches[1]; |
126 | 144 | $result['wind']['unit'] = $matches[4]; |
127 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
128 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
129 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
145 | + if ($result['wind']['unit'] == 'KT') { |
|
146 | + $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
147 | + } elseif ($result['wind']['unit'] == 'KPH') { |
|
148 | + $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
149 | + } elseif ($result['wind']['unit'] == 'MPS') { |
|
150 | + $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
151 | + } |
|
130 | 152 | $result['wind']['gust'] = (float)$matches[3]; |
131 | 153 | $result['wind']['unit'] = $matches[4]; |
132 | 154 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
@@ -210,27 +232,49 @@ discard block |
||
210 | 232 | //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
211 | 233 | $type = $matches[1]; |
212 | 234 | $cloud = array(); |
213 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
214 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
215 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
216 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
217 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
218 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
219 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
220 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
235 | + if ($type == 'SKC') { |
|
236 | + $cloud['type'] = 'No cloud/Sky clear'; |
|
237 | + } elseif ($type == 'CLR') { |
|
238 | + $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
239 | + } elseif ($type == 'NSC') { |
|
240 | + $cloud['type'] = 'No significant cloud'; |
|
241 | + } elseif ($type == 'FEW') { |
|
242 | + $cloud['type'] = 'Few'; |
|
243 | + } elseif ($type == 'SCT') { |
|
244 | + $cloud['type'] = 'Scattered'; |
|
245 | + } elseif ($type == 'BKN') { |
|
246 | + $cloud['type'] = 'Broken'; |
|
247 | + } elseif ($type == 'OVC') { |
|
248 | + $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
249 | + } elseif ($type == 'VV') { |
|
250 | + $cloud['type'] = 'Vertical visibility'; |
|
251 | + } |
|
221 | 252 | $cloud['type_code'] = $type; |
222 | 253 | $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
223 | - if (isset($matches[3])) $significant = $matches[3]; |
|
224 | - else $significant = ''; |
|
225 | - if ($significant == 'CB') $cloud['significant'] = 'Cumulonimbus'; |
|
226 | - elseif ($significant == 'AC') $cloud['significant'] = 'Altocumulus'; |
|
227 | - elseif ($significant == 'CBS') $cloud['significant'] = 'Cumulonimbus'; |
|
228 | - elseif ($significant == 'CC') $cloud['significant'] = 'Cirrocumulus'; |
|
229 | - elseif ($significant == 'CU') $cloud['significant'] = 'Cumulus'; |
|
230 | - elseif ($significant == 'CI') $cloud['significant'] = 'Cirrus'; |
|
231 | - elseif ($significant == 'CS') $cloud['significant'] = 'Cirrostratus'; |
|
232 | - elseif ($significant == 'TCU') $cloud['significant'] = 'Towering Cumulus'; |
|
233 | - else $cloud['significant'] = $significant; |
|
254 | + if (isset($matches[3])) { |
|
255 | + $significant = $matches[3]; |
|
256 | + } else { |
|
257 | + $significant = ''; |
|
258 | + } |
|
259 | + if ($significant == 'CB') { |
|
260 | + $cloud['significant'] = 'Cumulonimbus'; |
|
261 | + } elseif ($significant == 'AC') { |
|
262 | + $cloud['significant'] = 'Altocumulus'; |
|
263 | + } elseif ($significant == 'CBS') { |
|
264 | + $cloud['significant'] = 'Cumulonimbus'; |
|
265 | + } elseif ($significant == 'CC') { |
|
266 | + $cloud['significant'] = 'Cirrocumulus'; |
|
267 | + } elseif ($significant == 'CU') { |
|
268 | + $cloud['significant'] = 'Cumulus'; |
|
269 | + } elseif ($significant == 'CI') { |
|
270 | + $cloud['significant'] = 'Cirrus'; |
|
271 | + } elseif ($significant == 'CS') { |
|
272 | + $cloud['significant'] = 'Cirrostratus'; |
|
273 | + } elseif ($significant == 'TCU') { |
|
274 | + $cloud['significant'] = 'Towering Cumulus'; |
|
275 | + } else { |
|
276 | + $cloud['significant'] = $significant; |
|
277 | + } |
|
234 | 278 | //$cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
235 | 279 | $result['cloud'][] = $cloud; |
236 | 280 | } |
@@ -254,8 +298,11 @@ discard block |
||
254 | 298 | $result['RVR']['friction'] = $matches[5]; |
255 | 299 | } |
256 | 300 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
257 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
258 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
301 | + if (isset($matches[5])) { |
|
302 | + $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
303 | + } else { |
|
304 | + $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
305 | + } |
|
259 | 306 | if (isset($matches[3])) { |
260 | 307 | $range = Array( |
261 | 308 | 'from' => (float)$matches[2], |
@@ -288,8 +335,11 @@ discard block |
||
288 | 335 | if (isset($matches[3])) { |
289 | 336 | $text[] = $this->texts[$matches[3]]; |
290 | 337 | } |
291 | - if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
|
292 | - else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
338 | + if (!isset($result['weather'])) { |
|
339 | + $result['weather'] = implode(' ', $text); |
|
340 | + } else { |
|
341 | + $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
342 | + } |
|
293 | 343 | } |
294 | 344 | } |
295 | 345 | return $result; |
@@ -305,8 +355,11 @@ discard block |
||
305 | 355 | if (isset($globalMETARcycle) && $globalMETARcycle) { |
306 | 356 | $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
307 | 357 | } else { |
308 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
309 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
358 | + if ($globalDBdriver == 'mysql') { |
|
359 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
360 | + } else { |
|
361 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
362 | + } |
|
310 | 363 | } |
311 | 364 | $query_values = array(':icao' => $icao); |
312 | 365 | try { |
@@ -378,7 +431,9 @@ discard block |
||
378 | 431 | */ |
379 | 432 | public function addMETARCycle() { |
380 | 433 | global $globalDebug, $globalIVAO, $globalTransaction; |
381 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
434 | + if (isset($globalDebug) && $globalDebug) { |
|
435 | + echo "Downloading METAR cycle..."; |
|
436 | + } |
|
382 | 437 | date_default_timezone_set("UTC"); |
383 | 438 | $Common = new Common(); |
384 | 439 | if (isset($globalIVAO) && $globalIVAO) { |
@@ -389,28 +444,42 @@ discard block |
||
389 | 444 | $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
390 | 445 | } |
391 | 446 | if ($handle) { |
392 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
447 | + if (isset($globalDebug) && $globalDebug) { |
|
448 | + echo "Done - Updating DB..."; |
|
449 | + } |
|
393 | 450 | $date = ''; |
394 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
451 | + if ($globalTransaction) { |
|
452 | + $this->db->beginTransaction(); |
|
453 | + } |
|
395 | 454 | while(($line = fgets($handle,4096)) !== false) { |
396 | 455 | $line = str_replace(array("\r\n","\r", "\n"), '', $line); |
397 | 456 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
398 | 457 | $date = $line; |
399 | 458 | } elseif (trim($line) != '') { |
400 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
459 | + if ($date == '') { |
|
460 | + $date = date('Y/m/d H:m'); |
|
461 | + } |
|
401 | 462 | $pos = 0; |
402 | 463 | $pieces = preg_split('/\s/',$line); |
403 | - if ($pieces[0] == 'METAR') $pos++; |
|
404 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
464 | + if ($pieces[0] == 'METAR') { |
|
465 | + $pos++; |
|
466 | + } |
|
467 | + if (strlen($pieces[$pos]) != 4) { |
|
468 | + $pos++; |
|
469 | + } |
|
405 | 470 | $location = $pieces[$pos]; |
406 | 471 | //if ($location == 'LFLL') echo 'location: '.$location.' - date: '.$date.' - data: '.$line."\n"; |
407 | 472 | echo $this->addMETAR($location,$line,$date); |
408 | 473 | } |
409 | 474 | } |
410 | 475 | fclose($handle); |
411 | - if ($globalTransaction) $this->db->commit(); |
|
476 | + if ($globalTransaction) { |
|
477 | + $this->db->commit(); |
|
478 | + } |
|
479 | + } |
|
480 | + if (isset($globalDebug) && $globalDebug) { |
|
481 | + echo "Done\n"; |
|
412 | 482 | } |
413 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
414 | 483 | } |
415 | 484 | |
416 | 485 | /* |
@@ -420,7 +489,9 @@ discard block |
||
420 | 489 | */ |
421 | 490 | public function downloadMETAR($icao) { |
422 | 491 | global $globalMETARurl; |
423 | - if ($globalMETARurl == '') return array(); |
|
492 | + if ($globalMETARurl == '') { |
|
493 | + return array(); |
|
494 | + } |
|
424 | 495 | date_default_timezone_set("UTC"); |
425 | 496 | $Common = new Common(); |
426 | 497 | $url = str_replace('{icao}',$icao,$globalMETARurl); |
@@ -432,16 +503,24 @@ discard block |
||
432 | 503 | $date = $line; |
433 | 504 | } |
434 | 505 | if (trim($line) != '') { |
435 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
506 | + if ($date == '') { |
|
507 | + $date = date('Y/m/d H:m'); |
|
508 | + } |
|
436 | 509 | $pos = 0; |
437 | 510 | $pieces = preg_split('/\s/',$line); |
438 | - if ($pieces[0] == 'METAR') $pos++; |
|
439 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
511 | + if ($pieces[0] == 'METAR') { |
|
512 | + $pos++; |
|
513 | + } |
|
514 | + if (strlen($pieces[$pos]) != 4) { |
|
515 | + $pos++; |
|
516 | + } |
|
440 | 517 | $location = $pieces[$pos]; |
441 | 518 | if (strlen($location == 4)) { |
442 | 519 | $this->addMETAR($location,$line,$date); |
443 | 520 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
444 | - } else return array(); |
|
521 | + } else { |
|
522 | + return array(); |
|
523 | + } |
|
445 | 524 | } |
446 | 525 | } |
447 | 526 | return array(); |
@@ -5,11 +5,18 @@ discard block |
||
5 | 5 | setcookie("MapFormat",'2d'); |
6 | 6 | |
7 | 7 | // Compressed GeoJson is used if true |
8 | -if (!isset($globalJsonCompress)) $compress = true; |
|
9 | -else $compress = $globalJsonCompress; |
|
10 | -if (isset($_COOKIE['MarineIconColor'])) $MarineIconColor = $_COOKIE['MarineIconColor']; |
|
11 | -elseif (isset($globalMarineIconColor)) $MarineIconColor = $globalMarineIconColor; |
|
12 | -else $MarineIconColor = '1a3151'; |
|
8 | +if (!isset($globalJsonCompress)) { |
|
9 | + $compress = true; |
|
10 | +} else { |
|
11 | + $compress = $globalJsonCompress; |
|
12 | +} |
|
13 | +if (isset($_COOKIE['MarineIconColor'])) { |
|
14 | + $MarineIconColor = $_COOKIE['MarineIconColor']; |
|
15 | +} elseif (isset($globalMarineIconColor)) { |
|
16 | + $MarineIconColor = $globalMarineIconColor; |
|
17 | +} else { |
|
18 | + $MarineIconColor = '1a3151'; |
|
19 | +} |
|
13 | 20 | |
14 | 21 | ?> |
15 | 22 | |
@@ -181,7 +188,12 @@ discard block |
||
181 | 188 | <?php |
182 | 189 | } else { |
183 | 190 | ?> |
184 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
191 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
192 | + print $archiveupdatetime*1000; |
|
193 | +} else { |
|
194 | + print $globalMapRefresh*1000+20000; |
|
195 | +} |
|
196 | +?>+feature.properties.sqt*1000); |
|
185 | 197 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
186 | 198 | <?php |
187 | 199 | } |
@@ -238,7 +250,12 @@ discard block |
||
238 | 250 | <?php |
239 | 251 | } else { |
240 | 252 | ?> |
241 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
253 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
254 | + print $archiveupdatetime*1000; |
|
255 | +} else { |
|
256 | + print $globalMapRefresh*1000+20000; |
|
257 | +} |
|
258 | +?>+feature.properties.sqt*1000); |
|
242 | 259 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
243 | 260 | <?php |
244 | 261 | } |
@@ -294,7 +311,12 @@ discard block |
||
294 | 311 | <?php |
295 | 312 | } else { |
296 | 313 | ?> |
297 | - var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000); |
|
314 | + var movingtime = Math.round(<?php if (isset($archiveupdatetime)) { |
|
315 | + print $archiveupdatetime*1000; |
|
316 | +} else { |
|
317 | + print $globalMapRefresh*1000+20000; |
|
318 | +} |
|
319 | +?>+feature.properties.sqt*1000); |
|
298 | 320 | return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{ |
299 | 321 | <?php |
300 | 322 | } |
@@ -702,7 +724,12 @@ discard block |
||
702 | 724 | } else { |
703 | 725 | //then load it again every 30 seconds |
704 | 726 | reloadMarinePage = setInterval( |
705 | - function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>); |
|
727 | + function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) { |
|
728 | + print $globalMapRefresh*1000; |
|
729 | +} else { |
|
730 | + print '30000'; |
|
731 | +} |
|
732 | +?>); |
|
706 | 733 | } |
707 | 734 | |
708 | 735 | if (getCookie('openseamap') == 'true') loadOpenSeaMap(getCookie('openseamap')); |