@@ -37,8 +37,11 @@ discard block |
||
37 | 37 | } else { |
38 | 38 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
39 | 39 | } |
40 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
41 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
40 | + if ($timeout == '') { |
|
41 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
42 | + } else { |
|
43 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
44 | + } |
|
42 | 45 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
43 | 46 | if ($type == 'post') { |
44 | 47 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -95,8 +98,9 @@ discard block |
||
95 | 98 | private function curlResponseHeaderCallback($ch, $headerLine) { |
96 | 99 | //global $cookies; |
97 | 100 | $cookies = array(); |
98 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
99 | - $cookies[] = $cookie; |
|
101 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
102 | + $cookies[] = $cookie; |
|
103 | + } |
|
100 | 104 | return strlen($headerLine); // Needed by curl |
101 | 105 | } |
102 | 106 | |
@@ -107,7 +111,9 @@ discard block |
||
107 | 111 | curl_setopt($ch, CURLOPT_URL, $url); |
108 | 112 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
109 | 113 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
110 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
114 | + if ($referer != '') { |
|
115 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
116 | + } |
|
111 | 117 | if (isset($globalForceIPv4) && $globalForceIPv4) { |
112 | 118 | if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){ |
113 | 119 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); |
@@ -119,7 +125,9 @@ discard block |
||
119 | 125 | 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'); |
120 | 126 | curl_setopt($ch, CURLOPT_FILE, $fp); |
121 | 127 | curl_exec($ch); |
122 | - if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch); |
|
128 | + if (curl_errno($ch) && $globalDebug) { |
|
129 | + echo 'Download error: '.curl_error($ch); |
|
130 | + } |
|
123 | 131 | curl_close($ch); |
124 | 132 | fclose($fp); |
125 | 133 | } |
@@ -127,12 +135,16 @@ discard block |
||
127 | 135 | public static function gunzip($in_file,$out_file_name = '') { |
128 | 136 | //echo $in_file.' -> '.$out_file_name."\n"; |
129 | 137 | $buffer_size = 4096; // read 4kb at a time |
130 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
138 | + if ($out_file_name == '') { |
|
139 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
140 | + } |
|
131 | 141 | if ($in_file != '' && file_exists($in_file)) { |
132 | 142 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
133 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
134 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
135 | - else { |
|
143 | + if (function_exists('gzopen')) { |
|
144 | + $file = gzopen($in_file,'rb'); |
|
145 | + } elseif (function_exists('gzopen64')) { |
|
146 | + $file = gzopen64($in_file,'rb'); |
|
147 | + } else { |
|
136 | 148 | echo 'gzopen not available'; |
137 | 149 | die; |
138 | 150 | } |
@@ -148,11 +160,14 @@ discard block |
||
148 | 160 | public static function bunzip2($in_file,$out_file_name = '') { |
149 | 161 | //echo $in_file.' -> '.$out_file_name."\n"; |
150 | 162 | $buffer_size = 4096; // read 4kb at a time |
151 | - if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); |
|
163 | + if ($out_file_name == '') { |
|
164 | + $out_file_name = str_replace('.bz2', '', $in_file); |
|
165 | + } |
|
152 | 166 | if ($in_file != '' && file_exists($in_file)) { |
153 | 167 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
154 | - if (function_exists('bzopen')) $file = bzopen($in_file,'rb'); |
|
155 | - else { |
|
168 | + if (function_exists('bzopen')) { |
|
169 | + $file = bzopen($in_file,'rb'); |
|
170 | + } else { |
|
156 | 171 | echo 'bzopen not available'; |
157 | 172 | die; |
158 | 173 | } |
@@ -171,10 +186,16 @@ discard block |
||
171 | 186 | * @return Array array of the tables in HTML page |
172 | 187 | */ |
173 | 188 | public function table2array($data) { |
174 | - if (!is_string($data)) return array(); |
|
175 | - if ($data == '') return array(); |
|
189 | + if (!is_string($data)) { |
|
190 | + return array(); |
|
191 | + } |
|
192 | + if ($data == '') { |
|
193 | + return array(); |
|
194 | + } |
|
176 | 195 | $html = str_get_html($data); |
177 | - if ($html === false) return array(); |
|
196 | + if ($html === false) { |
|
197 | + return array(); |
|
198 | + } |
|
178 | 199 | $tabledata=array(); |
179 | 200 | foreach($html->find('tr') as $element) |
180 | 201 | { |
@@ -209,7 +230,9 @@ discard block |
||
209 | 230 | */ |
210 | 231 | public function text2array($data) { |
211 | 232 | $html = str_get_html($data); |
212 | - if ($html === false) return array(); |
|
233 | + if ($html === false) { |
|
234 | + return array(); |
|
235 | + } |
|
213 | 236 | $tabledata=array(); |
214 | 237 | foreach($html->find('p') as $element) |
215 | 238 | { |
@@ -230,7 +253,9 @@ discard block |
||
230 | 253 | * @return Float Distance in $unit |
231 | 254 | */ |
232 | 255 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
233 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
256 | + if ($lat == $latc && $lon == $lonc) { |
|
257 | + return 0; |
|
258 | + } |
|
234 | 259 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
235 | 260 | if ($unit == "km") { |
236 | 261 | return round($dist * 1.609344); |
@@ -269,7 +294,9 @@ discard block |
||
269 | 294 | $dX = $latc - $lat; |
270 | 295 | $dY = $lonc - $lon; |
271 | 296 | $azimuth = rad2deg(atan2($dY,$dX)); |
272 | - if ($azimuth < 0) return $azimuth+360; |
|
297 | + if ($azimuth < 0) { |
|
298 | + return $azimuth+360; |
|
299 | + } |
|
273 | 300 | return $azimuth; |
274 | 301 | } |
275 | 302 | |
@@ -283,10 +310,16 @@ discard block |
||
283 | 310 | public function withinThreshold ($timeDifference, $distance) { |
284 | 311 | $x = abs($timeDifference); |
285 | 312 | $d = abs($distance); |
286 | - if ($x == 0 || $d == 0) return true; |
|
313 | + if ($x == 0 || $d == 0) { |
|
314 | + return true; |
|
315 | + } |
|
287 | 316 | // may be due to Internet jitter; distance is realistic |
288 | - if ($x < 0.7 && $d < 2000) return true; |
|
289 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
317 | + if ($x < 0.7 && $d < 2000) { |
|
318 | + return true; |
|
319 | + } else { |
|
320 | + return $d/$x < 1500*0.27778; |
|
321 | + } |
|
322 | + // 1500 km/h max |
|
290 | 323 | } |
291 | 324 | |
292 | 325 | |
@@ -314,11 +347,17 @@ discard block |
||
314 | 347 | |
315 | 348 | public function convertDM($coord,$latlong) { |
316 | 349 | if ($latlong == 'latitude') { |
317 | - if ($coord < 0) $NSEW = 'S'; |
|
318 | - else $NSEW = 'N'; |
|
350 | + if ($coord < 0) { |
|
351 | + $NSEW = 'S'; |
|
352 | + } else { |
|
353 | + $NSEW = 'N'; |
|
354 | + } |
|
319 | 355 | } else { |
320 | - if ($coord < 0) $NSEW = 'W'; |
|
321 | - else $NSEW = 'E'; |
|
356 | + if ($coord < 0) { |
|
357 | + $NSEW = 'W'; |
|
358 | + } else { |
|
359 | + $NSEW = 'E'; |
|
360 | + } |
|
322 | 361 | } |
323 | 362 | $coord = abs($coord); |
324 | 363 | $deg = floor($coord); |
@@ -361,7 +400,9 @@ discard block |
||
361 | 400 | public function hex2str($hex) { |
362 | 401 | $str = ''; |
363 | 402 | $hexln = strlen($hex); |
364 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
403 | + for($i=0;$i<$hexln;$i+=2) { |
|
404 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
405 | + } |
|
365 | 406 | return $str; |
366 | 407 | } |
367 | 408 | |
@@ -398,8 +439,11 @@ discard block |
||
398 | 439 | $b = $lat2 - $lat1; |
399 | 440 | $c = -($a*$lat1+$b*$lon1); |
400 | 441 | $d = $a*$lat3+$b*$lon3+$c; |
401 | - if ($d > -$approx && $d < $approx) return true; |
|
402 | - else return false; |
|
442 | + if ($d > -$approx && $d < $approx) { |
|
443 | + return true; |
|
444 | + } else { |
|
445 | + return false; |
|
446 | + } |
|
403 | 447 | } |
404 | 448 | |
405 | 449 | public function array_merge_noappend() { |
@@ -458,7 +502,9 @@ discard block |
||
458 | 502 | return $result; |
459 | 503 | } |
460 | 504 | $handle = @opendir('./locale'); |
461 | - if ($handle === false) return $result; |
|
505 | + if ($handle === false) { |
|
506 | + return $result; |
|
507 | + } |
|
462 | 508 | while (false !== ($file = readdir($handle))) { |
463 | 509 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
464 | 510 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -529,8 +575,9 @@ discard block |
||
529 | 575 | $error = false; |
530 | 576 | if ($fp_out = gzopen($dest, $mode)) { |
531 | 577 | if ($fp_in = fopen($source,'rb')) { |
532 | - while (!feof($fp_in)) |
|
533 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
578 | + while (!feof($fp_in)) { |
|
579 | + gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
580 | + } |
|
534 | 581 | fclose($fp_in); |
535 | 582 | } else { |
536 | 583 | $error = true; |
@@ -539,14 +586,17 @@ discard block |
||
539 | 586 | } else { |
540 | 587 | $error = true; |
541 | 588 | } |
542 | - if ($error) |
|
543 | - return false; |
|
544 | - else |
|
545 | - return $dest; |
|
589 | + if ($error) { |
|
590 | + return false; |
|
591 | + } else { |
|
592 | + return $dest; |
|
593 | + } |
|
546 | 594 | } |
547 | 595 | |
548 | 596 | public function remove_accents($string) { |
549 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
597 | + if ( !preg_match('/[\x80-\xff]/', $string) ) { |
|
598 | + return $string; |
|
599 | + } |
|
550 | 600 | $chars = array( |
551 | 601 | // Decompositions for Latin-1 Supplement |
552 | 602 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -670,7 +720,9 @@ discard block |
||
670 | 720 | $ip = gethostbyname($host); |
671 | 721 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
672 | 722 | $r = @socket_connect($s, $ip, $port); |
673 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
723 | + if (!socket_set_nonblock($s)) { |
|
724 | + echo "Unable to set nonblock on socket\n"; |
|
725 | + } |
|
674 | 726 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
675 | 727 | return $s; |
676 | 728 | } |
@@ -715,18 +767,22 @@ discard block |
||
715 | 767 | //NOTE: use a trailing slash for folders!!! |
716 | 768 | //see http://bugs.php.net/bug.php?id=27609 |
717 | 769 | //see http://bugs.php.net/bug.php?id=30931 |
718 | - if ($path{strlen($path)-1}=='/') // recursively return a temporary file path |
|
770 | + if ($path{strlen($path)-1}=='/') { |
|
771 | + // recursively return a temporary file path |
|
719 | 772 | return $this->is__writable($path.uniqid(mt_rand()).'.tmp'); |
720 | - else if (is_dir($path)) |
|
721 | - return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
773 | + } else if (is_dir($path)) { |
|
774 | + return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
775 | + } |
|
722 | 776 | // check tmp file for read/write capabilities |
723 | 777 | $rm = file_exists($path); |
724 | 778 | $f = @fopen($path, 'a'); |
725 | - if ($f===false) |
|
726 | - return false; |
|
779 | + if ($f===false) { |
|
780 | + return false; |
|
781 | + } |
|
727 | 782 | fclose($f); |
728 | - if (!$rm) |
|
729 | - unlink($path); |
|
783 | + if (!$rm) { |
|
784 | + unlink($path); |
|
785 | + } |
|
730 | 786 | return true; |
731 | 787 | } |
732 | 788 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | $limit_start = 0; |
16 | 16 | $limit_end = 25; |
17 | 17 | $absolute_difference = 25; |
18 | - } else { |
|
18 | + } else { |
|
19 | 19 | $limit_explode = explode(",", $_GET['limit']); |
20 | 20 | $limit_start = $limit_explode[0]; |
21 | 21 | $limit_end = $limit_explode[1]; |
@@ -47,7 +47,9 @@ discard block |
||
47 | 47 | $METAR = new METAR(); |
48 | 48 | $metar_info = $METAR->getMETAR($airport_icao); |
49 | 49 | //print_r($metar_info); |
50 | - if (isset($metar_info[0]['metar'])) $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
50 | + if (isset($metar_info[0]['metar'])) { |
|
51 | + $metar_parse = $METAR->parse($metar_info[0]['metar']); |
|
52 | + } |
|
51 | 53 | //print_r($metar_parse); |
52 | 54 | } |
53 | 55 | |
@@ -61,7 +63,9 @@ discard block |
||
61 | 63 | print '<option></option>'; |
62 | 64 | $Stats = new Stats(); |
63 | 65 | $airport_names = $Stats->getAllAirportNames(); |
64 | - if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
|
66 | + if (empty($airport_names)) { |
|
67 | + $airport_names = $Spotter->getAllAirportNames(); |
|
68 | + } |
|
65 | 69 | ksort($airport_names); |
66 | 70 | foreach($airport_names as $airport_name) |
67 | 71 | { |
@@ -95,7 +99,9 @@ discard block |
||
95 | 99 | print '</div>'; |
96 | 100 | print '<div><span class="label">'._("Coordinates").'</span><a href="http://maps.google.ca/maps?z=10&t=k&q='.$airport_array[0]['latitude'].','.$airport_array[0]['longitude'].'" target="_blank">Google Map<i class="fa fa-angle-double-right"></i></a></div>'; |
97 | 101 | print '<div><span class="label">'._("Live Air Traffic").'</span><a href="http://www.liveatc.net/search/?icao='.$airport_array[0]['icao'].'" target="_blank">LiveATC.net<i class="fa fa-angle-double-right"></i></a></div>'; |
98 | - if (isset($airport_array[0]['diagram_pdf']) && $airport_array[0]['diagram_pdf'] != '') print '<div><span class="label">'._("Diagram").'</span><a href="'.$airport_array[0]['diagram_pdf'].'" target="_blank">'.$airport_array[0]['icao'].'<i class="fa fa-angle-double-right"></i></a></div>'; |
|
102 | + if (isset($airport_array[0]['diagram_pdf']) && $airport_array[0]['diagram_pdf'] != '') { |
|
103 | + print '<div><span class="label">'._("Diagram").'</span><a href="'.$airport_array[0]['diagram_pdf'].'" target="_blank">'.$airport_array[0]['icao'].'<i class="fa fa-angle-double-right"></i></a></div>'; |
|
104 | + } |
|
99 | 105 | print '</div>'; |
100 | 106 | |
101 | 107 | $Stats = new Stats(); |
@@ -103,7 +109,9 @@ discard block |
||
103 | 109 | // Use spotter also |
104 | 110 | if (isset($globalTimezone)) { |
105 | 111 | date_default_timezone_set($globalTimezone); |
106 | - } else date_default_timezone_set('UTC'); |
|
112 | + } else { |
|
113 | + date_default_timezone_set('UTC'); |
|
114 | + } |
|
107 | 115 | if (count($all_data) > 0) { |
108 | 116 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
109 | 117 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -105,8 +105,11 @@ |
||
105 | 105 | } elseif (isset($_GET['satellite'])) { |
106 | 106 | readfile(dirname(__FILE__).'/images/satellites/'.$filename); |
107 | 107 | } else { |
108 | - if ($color == 'FF0000') readfile(dirname(__FILE__).'/images/aircrafts/selected/'.$filename); |
|
109 | - else readfile(dirname(__FILE__).'/images/aircrafts/'.$filename); |
|
108 | + if ($color == 'FF0000') { |
|
109 | + readfile(dirname(__FILE__).'/images/aircrafts/selected/'.$filename); |
|
110 | + } else { |
|
111 | + readfile(dirname(__FILE__).'/images/aircrafts/'.$filename); |
|
112 | + } |
|
110 | 113 | } |
111 | 114 | } |
112 | 115 | ?> |
113 | 116 | \ No newline at end of file |
@@ -75,7 +75,9 @@ discard block |
||
75 | 75 | if ($error != '') { |
76 | 76 | $_SESSION['error'] = $error; |
77 | 77 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create database')); |
78 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database')); |
|
78 | + } else { |
|
79 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Create database')); |
|
80 | + } |
|
79 | 81 | $_SESSION['install'] = 'database_import'; |
80 | 82 | $_SESSION['next'] = 'Create and import tables'; |
81 | 83 | $result = array('error' => $error,'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -93,7 +95,9 @@ discard block |
||
93 | 95 | if ($error != '') { |
94 | 96 | $_SESSION['error'] = $error; |
95 | 97 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
96 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables')); |
|
98 | + } else { |
|
99 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Create and import tables')); |
|
100 | + } |
|
97 | 101 | if ($globalSBS1 && !$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
98 | 102 | $_SESSION['install'] = 'populate'; |
99 | 103 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B'; |
@@ -107,7 +111,9 @@ discard block |
||
107 | 111 | $error .= $check_version; |
108 | 112 | $_SESSION['error'] = $error; |
109 | 113 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Create and import tables')); |
110 | - if (!isset($_SESSION['next'])) $_SESSION['next'] = ''; |
|
114 | + if (!isset($_SESSION['next'])) { |
|
115 | + $_SESSION['next'] = ''; |
|
116 | + } |
|
111 | 117 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
112 | 118 | print json_encode($result); |
113 | 119 | } else { |
@@ -115,7 +121,9 @@ discard block |
||
115 | 121 | if ($error != '') { |
116 | 122 | $_SESSION['error'] = $error; |
117 | 123 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Update schema if needed')); |
118 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed')); |
|
124 | + } else { |
|
125 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Update schema if needed')); |
|
126 | + } |
|
119 | 127 | $_SESSION['install'] = 'sources'; |
120 | 128 | $_SESSION['next'] = 'Insert data in source table'; |
121 | 129 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -128,8 +136,10 @@ discard block |
||
128 | 136 | if ($error != '') { |
129 | 137 | $_SESSION['error'] = $error; |
130 | 138 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate waypoints database')); |
131 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database')); |
|
132 | -/* |
|
139 | + } else { |
|
140 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate waypoints database')); |
|
141 | + } |
|
142 | + /* |
|
133 | 143 | $_SESSION['install'] = 'airspace'; |
134 | 144 | $_SESSION['next'] = 'Populate airspace table'; |
135 | 145 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -154,7 +164,9 @@ discard block |
||
154 | 164 | if ($error != '') { |
155 | 165 | $_SESSION['error'] = $error; |
156 | 166 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database')); |
157 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database')); |
|
167 | + } else { |
|
168 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database')); |
|
169 | + } |
|
158 | 170 | if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') { |
159 | 171 | $_SESSION['install'] = 'notam'; |
160 | 172 | $_SESSION['next'] = 'Populate NOTAM table with externals data'; |
@@ -188,7 +200,9 @@ discard block |
||
188 | 200 | if ($error != '') { |
189 | 201 | $_SESSION['error'] = $error; |
190 | 202 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for ADS-B')); |
191 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
203 | + } else { |
|
204 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for ADS-B')); |
|
205 | + } |
|
192 | 206 | $_SESSION['install'] = 'populate_flarm'; |
193 | 207 | $_SESSION['next'] = 'Populate aircraft_modes table with externals data for FLARM'; |
194 | 208 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -209,18 +223,26 @@ discard block |
||
209 | 223 | if ($error != '') { |
210 | 224 | $_SESSION['error'] = $error; |
211 | 225 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate aircraft_modes table with externals data for FLARM')); |
212 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
226 | + } else { |
|
227 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate aircraft_modes table with externals data for FLARM')); |
|
228 | + } |
|
213 | 229 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
214 | 230 | $_SESSION['install'] = 'vatsim'; |
215 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
216 | - else $_SESSION['next'] = 'Insert VATSIM data'; |
|
231 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
232 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
233 | + } else { |
|
234 | + $_SESSION['next'] = 'Insert VATSIM data'; |
|
235 | + } |
|
217 | 236 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
218 | 237 | $_SESSION['install'] = 'vatsim'; |
219 | 238 | $_SESSION['next'] = 'Insert VATSIM data'; |
220 | 239 | } elseif (isset($globalIVAO) && $globalIVAO) { |
221 | 240 | $_SESSION['install'] = 'vatsim'; |
222 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
223 | - else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
241 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
242 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
243 | + } else { |
|
244 | + $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
245 | + } |
|
224 | 246 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
225 | 247 | $_SESSION['install'] = 'vatsim'; |
226 | 248 | $_SESSION['next'] = 'Insert phpVMS data'; |
@@ -245,7 +267,9 @@ discard block |
||
245 | 267 | if ($error != '') { |
246 | 268 | $_SESSION['error'] = $error; |
247 | 269 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate routes table with externals data')); |
248 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data')); |
|
270 | + } else { |
|
271 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate routes table with externals data')); |
|
272 | + } |
|
249 | 273 | $_SESSION['install'] = 'translation'; |
250 | 274 | $_SESSION['next'] = 'Populate translation table with externals data'; |
251 | 275 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -265,7 +289,9 @@ discard block |
||
265 | 289 | if ($error != '') { |
266 | 290 | $_SESSION['error'] = $error; |
267 | 291 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate translation table with externals data')); |
268 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data')); |
|
292 | + } else { |
|
293 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate translation table with externals data')); |
|
294 | + } |
|
269 | 295 | if ($_SESSION['waypoints'] == 1) { |
270 | 296 | $_SESSION['install'] = 'waypoints'; |
271 | 297 | $_SESSION['next'] = 'Populate waypoints table'; |
@@ -300,7 +326,9 @@ discard block |
||
300 | 326 | if ($error != '') { |
301 | 327 | $_SESSION['error'] = $error; |
302 | 328 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate owner table with externals data')); |
303 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data')); |
|
329 | + } else { |
|
330 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate owner table with externals data')); |
|
331 | + } |
|
304 | 332 | $_SESSION['install'] = 'sources'; |
305 | 333 | $_SESSION['next'] = 'Insert data in source table'; |
306 | 334 | $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']); |
@@ -321,12 +349,16 @@ discard block |
||
321 | 349 | if ($error != '') { |
322 | 350 | $_SESSION['error'] = $error; |
323 | 351 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data')); |
324 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data')); |
|
352 | + } else { |
|
353 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data')); |
|
354 | + } |
|
325 | 355 | } else { |
326 | 356 | if ($error != '') { |
327 | 357 | $_SESSION['error'] = $error; |
328 | 358 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate notam table with externals data (no source defined)')); |
329 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)')); |
|
359 | + } else { |
|
360 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate notam table with externals data (no source defined)')); |
|
361 | + } |
|
330 | 362 | } |
331 | 363 | /* |
332 | 364 | if (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) { |
@@ -376,7 +408,9 @@ discard block |
||
376 | 408 | $Source = new Source(); |
377 | 409 | $Source->deleteAllLocation(); |
378 | 410 | foreach ($sources as $src) { |
379 | - if (isset($src['latitude']) && $src['latitude'] != '') $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png'); |
|
411 | + if (isset($src['latitude']) && $src['latitude'] != '') { |
|
412 | + $Source->addLocation($src['name'],$src['latitude'],$src['longitude'],$src['altitude'],$src['city'],$src['country'],$src['source'],'antenna.png'); |
|
413 | + } |
|
380 | 414 | } |
381 | 415 | $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert data in source table')); |
382 | 416 | unset($_SESSION['sources']); |
@@ -387,15 +421,21 @@ discard block |
||
387 | 421 | */ |
388 | 422 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
389 | 423 | $_SESSION['install'] = 'vatsim'; |
390 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
391 | - else $_SESSION['next'] = 'Insert VATSIM data'; |
|
424 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
425 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
426 | + } else { |
|
427 | + $_SESSION['next'] = 'Insert VATSIM data'; |
|
428 | + } |
|
392 | 429 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
393 | 430 | $_SESSION['install'] = 'vatsim'; |
394 | 431 | $_SESSION['next'] = 'Insert VATSIM data'; |
395 | 432 | } elseif (isset($globalIVAO) && $globalIVAO) { |
396 | 433 | $_SESSION['install'] = 'vatsim'; |
397 | - if (file_exists('tmp/ivae_feb2013.zip')) $_SESSION['next'] = 'Insert IVAO data'; |
|
398 | - else $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
434 | + if (file_exists('tmp/ivae_feb2013.zip')) { |
|
435 | + $_SESSION['next'] = 'Insert IVAO data'; |
|
436 | + } else { |
|
437 | + $_SESSION['next'] = 'Insert VATSIM data (IVAO not found)'; |
|
438 | + } |
|
399 | 439 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
400 | 440 | $_SESSION['install'] = 'vatsim'; |
401 | 441 | $_SESSION['next'] = 'Insert phpVMS data'; |
@@ -416,33 +456,43 @@ discard block |
||
416 | 456 | if ($error != '') { |
417 | 457 | $_SESSION['error'] = $error; |
418 | 458 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
419 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
459 | + } else { |
|
460 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
461 | + } |
|
420 | 462 | } else { |
421 | 463 | $error .= update_db::update_vatsim(); |
422 | 464 | if ($error != '') { |
423 | 465 | $_SESSION['error'] = $error; |
424 | 466 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
425 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
467 | + } else { |
|
468 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
469 | + } |
|
426 | 470 | } |
427 | 471 | } elseif (isset($globalVATSIM) && $globalVATSIM) { |
428 | 472 | $error .= update_db::update_vatsim(); |
429 | 473 | if ($error != '') { |
430 | 474 | $_SESSION['error'] = $error; |
431 | 475 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data')); |
432 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
476 | + } else { |
|
477 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data')); |
|
478 | + } |
|
433 | 479 | } elseif (isset($globalIVAO) && $globalIVAO) { |
434 | 480 | if (file_exists('tmp/ivae_feb2013.zip')) { |
435 | 481 | $error .= update_db::update_IVAO(); |
436 | 482 | if ($error != '') { |
437 | 483 | $_SESSION['error'] = $error; |
438 | 484 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert IVAO data')); |
439 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
485 | + } else { |
|
486 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert IVAO data')); |
|
487 | + } |
|
440 | 488 | } else { |
441 | 489 | $error .= update_db::update_vatsim(); |
442 | 490 | if ($error != '') { |
443 | 491 | $_SESSION['error'] = $error; |
444 | 492 | $_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Insert VATSIM data (IVAO not found)')); |
445 | - } else $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)')); |
|
493 | + } else { |
|
494 | + $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert VATSIM data (IVAO not found)')); |
|
495 | + } |
|
446 | 496 | } |
447 | 497 | } elseif (isset($globalphpVMS) && $globalphpVMS) { |
448 | 498 | $_SESSION['done'] = array_merge($_SESSION['done'],array('Insert phpVMS data')); |
@@ -258,7 +258,9 @@ discard block |
||
258 | 258 | // Update table countries |
259 | 259 | if ($Connection->tableExists('airspace')) { |
260 | 260 | $error .= update_db::update_countries(); |
261 | - if ($error != '') return $error; |
|
261 | + if ($error != '') { |
|
262 | + return $error; |
|
263 | + } |
|
262 | 264 | } |
263 | 265 | // Update schema_version to 7 |
264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
@@ -314,7 +316,9 @@ discard block |
||
314 | 316 | $error = ''; |
315 | 317 | // Update table aircraft |
316 | 318 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | - if ($error != '') return $error; |
|
319 | + if ($error != '') { |
|
320 | + return $error; |
|
321 | + } |
|
318 | 322 | // Update schema_version to 6 |
319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | 324 | try { |
@@ -331,7 +335,9 @@ discard block |
||
331 | 335 | $error = ''; |
332 | 336 | // Update table aircraft |
333 | 337 | $error .= create_db::import_file('../db/notam.sql'); |
334 | - if ($error != '') return $error; |
|
338 | + if ($error != '') { |
|
339 | + return $error; |
|
340 | + } |
|
335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 342 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
@@ -365,7 +371,9 @@ discard block |
||
365 | 371 | $error = ''; |
366 | 372 | // Update table atc |
367 | 373 | $error .= create_db::import_file('../db/atc.sql'); |
368 | - if ($error != '') return $error; |
|
374 | + if ($error != '') { |
|
375 | + return $error; |
|
376 | + } |
|
369 | 377 | |
370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | 379 | try { |
@@ -389,13 +397,21 @@ discard block |
||
389 | 397 | $error = ''; |
390 | 398 | // Add tables |
391 | 399 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | - if ($error != '') return $error; |
|
400 | + if ($error != '') { |
|
401 | + return $error; |
|
402 | + } |
|
393 | 403 | $error .= create_db::import_file('../db/metar.sql'); |
394 | - if ($error != '') return $error; |
|
404 | + if ($error != '') { |
|
405 | + return $error; |
|
406 | + } |
|
395 | 407 | $error .= create_db::import_file('../db/taf.sql'); |
396 | - if ($error != '') return $error; |
|
408 | + if ($error != '') { |
|
409 | + return $error; |
|
410 | + } |
|
397 | 411 | $error .= create_db::import_file('../db/airport.sql'); |
398 | - if ($error != '') return $error; |
|
412 | + if ($error != '') { |
|
413 | + return $error; |
|
414 | + } |
|
399 | 415 | |
400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | 417 | try { |
@@ -469,19 +485,33 @@ discard block |
||
469 | 485 | $error = ''; |
470 | 486 | // Add tables |
471 | 487 | $error .= create_db::import_file('../db/stats.sql'); |
472 | - if ($error != '') return $error; |
|
488 | + if ($error != '') { |
|
489 | + return $error; |
|
490 | + } |
|
473 | 491 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
474 | - if ($error != '') return $error; |
|
492 | + if ($error != '') { |
|
493 | + return $error; |
|
494 | + } |
|
475 | 495 | $error .= create_db::import_file('../db/stats_airline.sql'); |
476 | - if ($error != '') return $error; |
|
496 | + if ($error != '') { |
|
497 | + return $error; |
|
498 | + } |
|
477 | 499 | $error .= create_db::import_file('../db/stats_airport.sql'); |
478 | - if ($error != '') return $error; |
|
500 | + if ($error != '') { |
|
501 | + return $error; |
|
502 | + } |
|
479 | 503 | $error .= create_db::import_file('../db/stats_owner.sql'); |
480 | - if ($error != '') return $error; |
|
504 | + if ($error != '') { |
|
505 | + return $error; |
|
506 | + } |
|
481 | 507 | $error .= create_db::import_file('../db/stats_pilot.sql'); |
482 | - if ($error != '') return $error; |
|
508 | + if ($error != '') { |
|
509 | + return $error; |
|
510 | + } |
|
483 | 511 | $error .= create_db::import_file('../db/spotter_archive_output.sql'); |
484 | - if ($error != '') return $error; |
|
512 | + if ($error != '') { |
|
513 | + return $error; |
|
514 | + } |
|
485 | 515 | |
486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | 517 | try { |
@@ -521,7 +551,9 @@ discard block |
||
521 | 551 | // Add tables |
522 | 552 | if (!$Connection->tableExists('stats_flight')) { |
523 | 553 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | - if ($error != '') return $error; |
|
554 | + if ($error != '') { |
|
555 | + return $error; |
|
556 | + } |
|
525 | 557 | } |
526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | 559 | try { |
@@ -545,7 +577,9 @@ discard block |
||
545 | 577 | } catch(PDOException $e) { |
546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; |
547 | 579 | } |
548 | - if ($error != '') return $error; |
|
580 | + if ($error != '') { |
|
581 | + return $error; |
|
582 | + } |
|
549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | 584 | try { |
551 | 585 | $sth = $Connection->db->prepare($query); |
@@ -566,7 +600,9 @@ discard block |
||
566 | 600 | if (!$Connection->tableExists('stats_callsign')) { |
567 | 601 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 602 | } |
569 | - if ($error != '') return $error; |
|
603 | + if ($error != '') { |
|
604 | + return $error; |
|
605 | + } |
|
570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | 607 | try { |
572 | 608 | $sth = $Connection->db->prepare($query); |
@@ -584,7 +620,9 @@ discard block |
||
584 | 620 | if (!$Connection->tableExists('stats_country')) { |
585 | 621 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 622 | } |
587 | - if ($error != '') return $error; |
|
623 | + if ($error != '') { |
|
624 | + return $error; |
|
625 | + } |
|
588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | 627 | try { |
590 | 628 | $sth = $Connection->db->prepare($query); |
@@ -607,7 +645,9 @@ discard block |
||
607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; |
608 | 646 | } |
609 | 647 | } |
610 | - if ($error != '') return $error; |
|
648 | + if ($error != '') { |
|
649 | + return $error; |
|
650 | + } |
|
611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | 652 | try { |
613 | 653 | $sth = $Connection->db->prepare($query); |
@@ -623,7 +663,9 @@ discard block |
||
623 | 663 | $error = ''; |
624 | 664 | // Update airport table |
625 | 665 | $error .= create_db::import_file('../db/airport.sql'); |
626 | - if ($error != '') return 'Import airport.sql : '.$error; |
|
666 | + if ($error != '') { |
|
667 | + return 'Import airport.sql : '.$error; |
|
668 | + } |
|
627 | 669 | // Remove primary key on Spotter_Archive |
628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | 671 | try { |
@@ -699,7 +741,9 @@ discard block |
||
699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | 742 | } |
701 | 743 | } |
702 | - if ($error != '') return $error; |
|
744 | + if ($error != '') { |
|
745 | + return $error; |
|
746 | + } |
|
703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | 748 | try { |
705 | 749 | $sth = $Connection->db->prepare($query); |
@@ -717,7 +761,9 @@ discard block |
||
717 | 761 | // Update airline table |
718 | 762 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
719 | 763 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
764 | + if ($error != '') { |
|
765 | + return 'Import airlines.sql : '.$error; |
|
766 | + } |
|
721 | 767 | } |
722 | 768 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 769 | // Add column over_country |
@@ -729,7 +775,9 @@ discard block |
||
729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | 776 | } |
731 | 777 | } |
732 | - if ($error != '') return $error; |
|
778 | + if ($error != '') { |
|
779 | + return $error; |
|
780 | + } |
|
733 | 781 | /* |
734 | 782 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
735 | 783 | // Force update ModeS (this will put type_flight data |
@@ -759,7 +807,9 @@ discard block |
||
759 | 807 | } catch(PDOException $e) { |
760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; |
761 | 809 | } |
762 | - if ($error != '') return $error; |
|
810 | + if ($error != '') { |
|
811 | + return $error; |
|
812 | + } |
|
763 | 813 | } |
764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | 815 | try { |
@@ -782,7 +832,9 @@ discard block |
||
782 | 832 | } else { |
783 | 833 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 834 | } |
785 | - if ($error != '') return $error; |
|
835 | + if ($error != '') { |
|
836 | + return $error; |
|
837 | + } |
|
786 | 838 | } |
787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | 840 | try { |
@@ -803,12 +855,16 @@ discard block |
||
803 | 855 | if ($globalDBdriver == 'mysql') { |
804 | 856 | if (!$Connection->tableExists('tle')) { |
805 | 857 | $error .= create_db::import_file('../db/tle.sql'); |
806 | - if ($error != '') return $error; |
|
858 | + if ($error != '') { |
|
859 | + return $error; |
|
860 | + } |
|
807 | 861 | } |
808 | 862 | } else { |
809 | 863 | if (!$Connection->tableExists('tle')) { |
810 | 864 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
811 | - if ($error != '') return $error; |
|
865 | + if ($error != '') { |
|
866 | + return $error; |
|
867 | + } |
|
812 | 868 | } |
813 | 869 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
814 | 870 | try { |
@@ -848,7 +904,9 @@ discard block |
||
848 | 904 | } else { |
849 | 905 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
850 | 906 | } |
851 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
907 | + if ($error != '') { |
|
908 | + return 'Import airlines.sql : '.$error; |
|
909 | + } |
|
852 | 910 | if (!$Connection->checkColumnName('airlines','forsource')) { |
853 | 911 | // Add forsource to airlines |
854 | 912 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1331,20 +1389,28 @@ discard block |
||
1331 | 1389 | } |
1332 | 1390 | if ($globalDBdriver == 'mysql') { |
1333 | 1391 | $error .= create_db::import_file('../db/airlines.sql'); |
1334 | - if ($error != '') return $error; |
|
1392 | + if ($error != '') { |
|
1393 | + return $error; |
|
1394 | + } |
|
1335 | 1395 | } else { |
1336 | 1396 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
1337 | - if ($error != '') return $error; |
|
1397 | + if ($error != '') { |
|
1398 | + return $error; |
|
1399 | + } |
|
1338 | 1400 | } |
1339 | 1401 | if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) { |
1340 | 1402 | include_once(dirname(__FILE__).'/class.update_db.php'); |
1341 | 1403 | if (isset($globalVATSIM) && $globalVATSIM) { |
1342 | 1404 | $error .= update_db::update_vatsim(); |
1343 | - if ($error != '') return $error; |
|
1405 | + if ($error != '') { |
|
1406 | + return $error; |
|
1407 | + } |
|
1344 | 1408 | } |
1345 | 1409 | if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) { |
1346 | 1410 | $error .= update_db::update_IVAO(); |
1347 | - if ($error != '') return $error; |
|
1411 | + if ($error != '') { |
|
1412 | + return $error; |
|
1413 | + } |
|
1348 | 1414 | } |
1349 | 1415 | } |
1350 | 1416 | |
@@ -1607,41 +1673,65 @@ discard block |
||
1607 | 1673 | if ($globalDBdriver == 'mysql') { |
1608 | 1674 | if (!$Connection->tableExists('tracker_output')) { |
1609 | 1675 | $error .= create_db::import_file('../db/tracker_output.sql'); |
1610 | - if ($error != '') return $error; |
|
1676 | + if ($error != '') { |
|
1677 | + return $error; |
|
1678 | + } |
|
1611 | 1679 | } |
1612 | 1680 | if (!$Connection->tableExists('tracker_live')) { |
1613 | 1681 | $error .= create_db::import_file('../db/tracker_live.sql'); |
1614 | - if ($error != '') return $error; |
|
1682 | + if ($error != '') { |
|
1683 | + return $error; |
|
1684 | + } |
|
1615 | 1685 | } |
1616 | 1686 | if (!$Connection->tableExists('marine_output')) { |
1617 | 1687 | $error .= create_db::import_file('../db/marine_output.sql'); |
1618 | - if ($error != '') return $error; |
|
1688 | + if ($error != '') { |
|
1689 | + return $error; |
|
1690 | + } |
|
1619 | 1691 | } |
1620 | 1692 | if (!$Connection->tableExists('marine_live')) { |
1621 | 1693 | $error .= create_db::import_file('../db/marine_live.sql'); |
1622 | - if ($error != '') return $error; |
|
1694 | + if ($error != '') { |
|
1695 | + return $error; |
|
1696 | + } |
|
1623 | 1697 | } |
1624 | 1698 | if (!$Connection->tableExists('marine_identity')) { |
1625 | 1699 | $error .= create_db::import_file('../db/marine_identity.sql'); |
1626 | - if ($error != '') return $error; |
|
1700 | + if ($error != '') { |
|
1701 | + return $error; |
|
1702 | + } |
|
1627 | 1703 | } |
1628 | 1704 | if (!$Connection->tableExists('marine_mid')) { |
1629 | 1705 | $error .= create_db::import_file('../db/marine_mid.sql'); |
1630 | - if ($error != '') return $error; |
|
1706 | + if ($error != '') { |
|
1707 | + return $error; |
|
1708 | + } |
|
1631 | 1709 | } |
1632 | 1710 | } else { |
1633 | 1711 | $error .= create_db::import_file('../db/pgsql/tracker_output.sql'); |
1634 | - if ($error != '') return $error; |
|
1712 | + if ($error != '') { |
|
1713 | + return $error; |
|
1714 | + } |
|
1635 | 1715 | $error .= create_db::import_file('../db/pgsql/tracker_live.sql'); |
1636 | - if ($error != '') return $error; |
|
1716 | + if ($error != '') { |
|
1717 | + return $error; |
|
1718 | + } |
|
1637 | 1719 | $error .= create_db::import_file('../db/pgsql/marine_output.sql'); |
1638 | - if ($error != '') return $error; |
|
1720 | + if ($error != '') { |
|
1721 | + return $error; |
|
1722 | + } |
|
1639 | 1723 | $error .= create_db::import_file('../db/pgsql/marine_live.sql'); |
1640 | - if ($error != '') return $error; |
|
1724 | + if ($error != '') { |
|
1725 | + return $error; |
|
1726 | + } |
|
1641 | 1727 | $error .= create_db::import_file('../db/pgsql/marine_identity.sql'); |
1642 | - if ($error != '') return $error; |
|
1728 | + if ($error != '') { |
|
1729 | + return $error; |
|
1730 | + } |
|
1643 | 1731 | $error .= create_db::import_file('../db/pgsql/marine_mid.sql'); |
1644 | - if ($error != '') return $error; |
|
1732 | + if ($error != '') { |
|
1733 | + return $error; |
|
1734 | + } |
|
1645 | 1735 | } |
1646 | 1736 | $query = "UPDATE config SET value = '37' WHERE name = 'schema_version'"; |
1647 | 1737 | try { |
@@ -1660,39 +1750,61 @@ discard block |
||
1660 | 1750 | if ($globalDBdriver == 'mysql') { |
1661 | 1751 | if (!$Connection->tableExists('marine_image')) { |
1662 | 1752 | $error .= create_db::import_file('../db/marine_image.sql'); |
1663 | - if ($error != '') return $error; |
|
1753 | + if ($error != '') { |
|
1754 | + return $error; |
|
1755 | + } |
|
1664 | 1756 | } |
1665 | 1757 | if (!$Connection->tableExists('marine_archive')) { |
1666 | 1758 | $error .= create_db::import_file('../db/marine_archive.sql'); |
1667 | - if ($error != '') return $error; |
|
1759 | + if ($error != '') { |
|
1760 | + return $error; |
|
1761 | + } |
|
1668 | 1762 | } |
1669 | 1763 | if (!$Connection->tableExists('marine_archive_output')) { |
1670 | 1764 | $error .= create_db::import_file('../db/marine_archive_output.sql'); |
1671 | - if ($error != '') return $error; |
|
1765 | + if ($error != '') { |
|
1766 | + return $error; |
|
1767 | + } |
|
1672 | 1768 | } |
1673 | 1769 | if (!$Connection->tableExists('tracker_archive')) { |
1674 | 1770 | $error .= create_db::import_file('../db/tracker_archive.sql'); |
1675 | - if ($error != '') return $error; |
|
1771 | + if ($error != '') { |
|
1772 | + return $error; |
|
1773 | + } |
|
1676 | 1774 | } |
1677 | 1775 | if (!$Connection->tableExists('tracker_archive_output')) { |
1678 | 1776 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
1679 | - if ($error != '') return $error; |
|
1777 | + if ($error != '') { |
|
1778 | + return $error; |
|
1779 | + } |
|
1680 | 1780 | } |
1681 | 1781 | if (!$Connection->tableExists('marine_archive_output')) { |
1682 | 1782 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
1683 | - if ($error != '') return $error; |
|
1783 | + if ($error != '') { |
|
1784 | + return $error; |
|
1785 | + } |
|
1684 | 1786 | } |
1685 | 1787 | } else { |
1686 | 1788 | $error .= create_db::import_file('../db/pgsql/marine_image.sql'); |
1687 | - if ($error != '') return $error; |
|
1789 | + if ($error != '') { |
|
1790 | + return $error; |
|
1791 | + } |
|
1688 | 1792 | $error .= create_db::import_file('../db/pgsql/marine_archive.sql'); |
1689 | - if ($error != '') return $error; |
|
1793 | + if ($error != '') { |
|
1794 | + return $error; |
|
1795 | + } |
|
1690 | 1796 | $error .= create_db::import_file('../db/pgsql/marine_archive_output.sql'); |
1691 | - if ($error != '') return $error; |
|
1797 | + if ($error != '') { |
|
1798 | + return $error; |
|
1799 | + } |
|
1692 | 1800 | $error .= create_db::import_file('../db/pgsql/tracker_archive.sql'); |
1693 | - if ($error != '') return $error; |
|
1801 | + if ($error != '') { |
|
1802 | + return $error; |
|
1803 | + } |
|
1694 | 1804 | $error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql'); |
1695 | - if ($error != '') return $error; |
|
1805 | + if ($error != '') { |
|
1806 | + return $error; |
|
1807 | + } |
|
1696 | 1808 | } |
1697 | 1809 | if ($globalDBdriver == 'mysql') { |
1698 | 1810 | $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
@@ -2063,7 +2175,9 @@ discard block |
||
2063 | 2175 | if ($globalDBdriver == 'mysql') { |
2064 | 2176 | if (!$Connection->tableExists('tracker_archive_output')) { |
2065 | 2177 | $error .= create_db::import_file('../db/tracker_archive_output.sql'); |
2066 | - if ($error != '') return $error; |
|
2178 | + if ($error != '') { |
|
2179 | + return $error; |
|
2180 | + } |
|
2067 | 2181 | } |
2068 | 2182 | $query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;"; |
2069 | 2183 | } else { |
@@ -2091,14 +2205,22 @@ discard block |
||
2091 | 2205 | $error = ''; |
2092 | 2206 | if ($globalDBdriver == 'mysql') { |
2093 | 2207 | $error .= create_db::import_file('../db/airport.sql'); |
2094 | - if ($error != '') return $error; |
|
2208 | + if ($error != '') { |
|
2209 | + return $error; |
|
2210 | + } |
|
2095 | 2211 | $error .= create_db::import_file('../db/airlines.sql'); |
2096 | - if ($error != '') return $error; |
|
2212 | + if ($error != '') { |
|
2213 | + return $error; |
|
2214 | + } |
|
2097 | 2215 | } else { |
2098 | 2216 | $error .= create_db::import_file('../db/pgsql/airport.sql'); |
2099 | - if ($error != '') return $error; |
|
2217 | + if ($error != '') { |
|
2218 | + return $error; |
|
2219 | + } |
|
2100 | 2220 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
2101 | - if ($error != '') return $error; |
|
2221 | + if ($error != '') { |
|
2222 | + return $error; |
|
2223 | + } |
|
2102 | 2224 | } |
2103 | 2225 | if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) { |
2104 | 2226 | if (file_exists('tmp/ivae_feb2013.zip')) { |
@@ -2115,7 +2237,9 @@ discard block |
||
2115 | 2237 | $error .= update_db::update_vatsim(); |
2116 | 2238 | } |
2117 | 2239 | } |
2118 | - if ($error != '') return $error; |
|
2240 | + if ($error != '') { |
|
2241 | + return $error; |
|
2242 | + } |
|
2119 | 2243 | $query = "UPDATE config SET value = '45' WHERE name = 'schema_version'"; |
2120 | 2244 | try { |
2121 | 2245 | $sth = $Connection->db->prepare($query); |
@@ -2133,10 +2257,14 @@ discard block |
||
2133 | 2257 | if (!$Connection->tableExists('satellite')) { |
2134 | 2258 | if ($globalDBdriver == 'mysql') { |
2135 | 2259 | $error .= create_db::import_file('../db/satellite.sql'); |
2136 | - if ($error != '') return $error; |
|
2260 | + if ($error != '') { |
|
2261 | + return $error; |
|
2262 | + } |
|
2137 | 2263 | } else { |
2138 | 2264 | $error .= create_db::import_file('../db/pgsql/satellite.sql'); |
2139 | - if ($error != '') return $error; |
|
2265 | + if ($error != '') { |
|
2266 | + return $error; |
|
2267 | + } |
|
2140 | 2268 | } |
2141 | 2269 | } |
2142 | 2270 | $query = "UPDATE config SET value = '46' WHERE name = 'schema_version'"; |
@@ -2156,37 +2284,53 @@ discard block |
||
2156 | 2284 | if (!$Connection->tableExists('stats_marine')) { |
2157 | 2285 | if ($globalDBdriver == 'mysql') { |
2158 | 2286 | $error .= create_db::import_file('../db/stats_marine.sql'); |
2159 | - if ($error != '') return $error; |
|
2287 | + if ($error != '') { |
|
2288 | + return $error; |
|
2289 | + } |
|
2160 | 2290 | } else { |
2161 | 2291 | $error .= create_db::import_file('../db/pgsql/stats_marine.sql'); |
2162 | - if ($error != '') return $error; |
|
2292 | + if ($error != '') { |
|
2293 | + return $error; |
|
2294 | + } |
|
2163 | 2295 | } |
2164 | 2296 | } |
2165 | 2297 | if (!$Connection->tableExists('stats_marine_country')) { |
2166 | 2298 | if ($globalDBdriver == 'mysql') { |
2167 | 2299 | $error .= create_db::import_file('../db/stats_marine_country.sql'); |
2168 | - if ($error != '') return $error; |
|
2300 | + if ($error != '') { |
|
2301 | + return $error; |
|
2302 | + } |
|
2169 | 2303 | } else { |
2170 | 2304 | $error .= create_db::import_file('../db/pgsql/stats_marine_country.sql'); |
2171 | - if ($error != '') return $error; |
|
2305 | + if ($error != '') { |
|
2306 | + return $error; |
|
2307 | + } |
|
2172 | 2308 | } |
2173 | 2309 | } |
2174 | 2310 | if (!$Connection->tableExists('stats_tracker')) { |
2175 | 2311 | if ($globalDBdriver == 'mysql') { |
2176 | 2312 | $error .= create_db::import_file('../db/stats_tracker.sql'); |
2177 | - if ($error != '') return $error; |
|
2313 | + if ($error != '') { |
|
2314 | + return $error; |
|
2315 | + } |
|
2178 | 2316 | } else { |
2179 | 2317 | $error .= create_db::import_file('../db/pgsql/stats_tracker.sql'); |
2180 | - if ($error != '') return $error; |
|
2318 | + if ($error != '') { |
|
2319 | + return $error; |
|
2320 | + } |
|
2181 | 2321 | } |
2182 | 2322 | } |
2183 | 2323 | if (!$Connection->tableExists('stats_tracker_country')) { |
2184 | 2324 | if ($globalDBdriver == 'mysql') { |
2185 | 2325 | $error .= create_db::import_file('../db/stats_tracker_country.sql'); |
2186 | - if ($error != '') return $error; |
|
2326 | + if ($error != '') { |
|
2327 | + return $error; |
|
2328 | + } |
|
2187 | 2329 | } else { |
2188 | 2330 | $error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql'); |
2189 | - if ($error != '') return $error; |
|
2331 | + if ($error != '') { |
|
2332 | + return $error; |
|
2333 | + } |
|
2190 | 2334 | } |
2191 | 2335 | } |
2192 | 2336 | $query = "UPDATE config SET value = '47' WHERE name = 'schema_version'"; |
@@ -2206,10 +2350,14 @@ discard block |
||
2206 | 2350 | if (!$Connection->tableExists('stats_marine_type')) { |
2207 | 2351 | if ($globalDBdriver == 'mysql') { |
2208 | 2352 | $error .= create_db::import_file('../db/stats_marine_type.sql'); |
2209 | - if ($error != '') return $error; |
|
2353 | + if ($error != '') { |
|
2354 | + return $error; |
|
2355 | + } |
|
2210 | 2356 | } else { |
2211 | 2357 | $error .= create_db::import_file('../db/pgsql/stats_marine_type.sql'); |
2212 | - if ($error != '') return $error; |
|
2358 | + if ($error != '') { |
|
2359 | + return $error; |
|
2360 | + } |
|
2213 | 2361 | } |
2214 | 2362 | } |
2215 | 2363 | $query = "UPDATE config SET value = '48' WHERE name = 'schema_version'"; |
@@ -2229,10 +2377,14 @@ discard block |
||
2229 | 2377 | if (!$Connection->tableExists('stats_tracker_type')) { |
2230 | 2378 | if ($globalDBdriver == 'mysql') { |
2231 | 2379 | $error .= create_db::import_file('../db/stats_tracker_type.sql'); |
2232 | - if ($error != '') return $error; |
|
2380 | + if ($error != '') { |
|
2381 | + return $error; |
|
2382 | + } |
|
2233 | 2383 | } else { |
2234 | 2384 | $error .= create_db::import_file('../db/pgsql/stats_tracker_type.sql'); |
2235 | - if ($error != '') return $error; |
|
2385 | + if ($error != '') { |
|
2386 | + return $error; |
|
2387 | + } |
|
2236 | 2388 | } |
2237 | 2389 | } |
2238 | 2390 | $query = "UPDATE config SET value = '49' WHERE name = 'schema_version'"; |
@@ -2251,10 +2403,14 @@ discard block |
||
2251 | 2403 | $error = ''; |
2252 | 2404 | if ($globalDBdriver == 'mysql') { |
2253 | 2405 | $error .= create_db::import_file('../db/airport.sql'); |
2254 | - if ($error != '') return $error; |
|
2406 | + if ($error != '') { |
|
2407 | + return $error; |
|
2408 | + } |
|
2255 | 2409 | } else { |
2256 | 2410 | $error .= create_db::import_file('../db/pgsql/airport.sql'); |
2257 | - if ($error != '') return $error; |
|
2411 | + if ($error != '') { |
|
2412 | + return $error; |
|
2413 | + } |
|
2258 | 2414 | } |
2259 | 2415 | $query = "UPDATE config SET value = '50' WHERE name = 'schema_version'"; |
2260 | 2416 | try { |
@@ -2276,8 +2432,11 @@ discard block |
||
2276 | 2432 | if ($Connection->tableExists('aircraft')) { |
2277 | 2433 | if (!$Connection->tableExists('config')) { |
2278 | 2434 | $version = '1'; |
2279 | - if ($update) return self::update_from_1(); |
|
2280 | - else return $version; |
|
2435 | + if ($update) { |
|
2436 | + return self::update_from_1(); |
|
2437 | + } else { |
|
2438 | + return $version; |
|
2439 | + } |
|
2281 | 2440 | } else { |
2282 | 2441 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
2283 | 2442 | try { |
@@ -2290,203 +2449,354 @@ discard block |
||
2290 | 2449 | if ($update) { |
2291 | 2450 | if ($result['value'] == '2') { |
2292 | 2451 | $error = self::update_from_2(); |
2293 | - if ($error != '') return $error; |
|
2294 | - else return self::check_version(true); |
|
2452 | + if ($error != '') { |
|
2453 | + return $error; |
|
2454 | + } else { |
|
2455 | + return self::check_version(true); |
|
2456 | + } |
|
2295 | 2457 | } elseif ($result['value'] == '3') { |
2296 | 2458 | $error = self::update_from_3(); |
2297 | - if ($error != '') return $error; |
|
2298 | - else return self::check_version(true); |
|
2459 | + if ($error != '') { |
|
2460 | + return $error; |
|
2461 | + } else { |
|
2462 | + return self::check_version(true); |
|
2463 | + } |
|
2299 | 2464 | } elseif ($result['value'] == '4') { |
2300 | 2465 | $error = self::update_from_4(); |
2301 | - if ($error != '') return $error; |
|
2302 | - else return self::check_version(true); |
|
2466 | + if ($error != '') { |
|
2467 | + return $error; |
|
2468 | + } else { |
|
2469 | + return self::check_version(true); |
|
2470 | + } |
|
2303 | 2471 | } elseif ($result['value'] == '5') { |
2304 | 2472 | $error = self::update_from_5(); |
2305 | - if ($error != '') return $error; |
|
2306 | - else return self::check_version(true); |
|
2473 | + if ($error != '') { |
|
2474 | + return $error; |
|
2475 | + } else { |
|
2476 | + return self::check_version(true); |
|
2477 | + } |
|
2307 | 2478 | } elseif ($result['value'] == '6') { |
2308 | 2479 | $error = self::update_from_6(); |
2309 | - if ($error != '') return $error; |
|
2310 | - else return self::check_version(true); |
|
2480 | + if ($error != '') { |
|
2481 | + return $error; |
|
2482 | + } else { |
|
2483 | + return self::check_version(true); |
|
2484 | + } |
|
2311 | 2485 | } elseif ($result['value'] == '7') { |
2312 | 2486 | $error = self::update_from_7(); |
2313 | - if ($error != '') return $error; |
|
2314 | - else return self::check_version(true); |
|
2487 | + if ($error != '') { |
|
2488 | + return $error; |
|
2489 | + } else { |
|
2490 | + return self::check_version(true); |
|
2491 | + } |
|
2315 | 2492 | } elseif ($result['value'] == '8') { |
2316 | 2493 | $error = self::update_from_8(); |
2317 | - if ($error != '') return $error; |
|
2318 | - else return self::check_version(true); |
|
2494 | + if ($error != '') { |
|
2495 | + return $error; |
|
2496 | + } else { |
|
2497 | + return self::check_version(true); |
|
2498 | + } |
|
2319 | 2499 | } elseif ($result['value'] == '9') { |
2320 | 2500 | $error = self::update_from_9(); |
2321 | - if ($error != '') return $error; |
|
2322 | - else return self::check_version(true); |
|
2501 | + if ($error != '') { |
|
2502 | + return $error; |
|
2503 | + } else { |
|
2504 | + return self::check_version(true); |
|
2505 | + } |
|
2323 | 2506 | } elseif ($result['value'] == '10') { |
2324 | 2507 | $error = self::update_from_10(); |
2325 | - if ($error != '') return $error; |
|
2326 | - else return self::check_version(true); |
|
2508 | + if ($error != '') { |
|
2509 | + return $error; |
|
2510 | + } else { |
|
2511 | + return self::check_version(true); |
|
2512 | + } |
|
2327 | 2513 | } elseif ($result['value'] == '11') { |
2328 | 2514 | $error = self::update_from_11(); |
2329 | - if ($error != '') return $error; |
|
2330 | - else return self::check_version(true); |
|
2515 | + if ($error != '') { |
|
2516 | + return $error; |
|
2517 | + } else { |
|
2518 | + return self::check_version(true); |
|
2519 | + } |
|
2331 | 2520 | } elseif ($result['value'] == '12') { |
2332 | 2521 | $error = self::update_from_12(); |
2333 | - if ($error != '') return $error; |
|
2334 | - else return self::check_version(true); |
|
2522 | + if ($error != '') { |
|
2523 | + return $error; |
|
2524 | + } else { |
|
2525 | + return self::check_version(true); |
|
2526 | + } |
|
2335 | 2527 | } elseif ($result['value'] == '13') { |
2336 | 2528 | $error = self::update_from_13(); |
2337 | - if ($error != '') return $error; |
|
2338 | - else return self::check_version(true); |
|
2529 | + if ($error != '') { |
|
2530 | + return $error; |
|
2531 | + } else { |
|
2532 | + return self::check_version(true); |
|
2533 | + } |
|
2339 | 2534 | } elseif ($result['value'] == '14') { |
2340 | 2535 | $error = self::update_from_14(); |
2341 | - if ($error != '') return $error; |
|
2342 | - else return self::check_version(true); |
|
2536 | + if ($error != '') { |
|
2537 | + return $error; |
|
2538 | + } else { |
|
2539 | + return self::check_version(true); |
|
2540 | + } |
|
2343 | 2541 | } elseif ($result['value'] == '15') { |
2344 | 2542 | $error = self::update_from_15(); |
2345 | - if ($error != '') return $error; |
|
2346 | - else return self::check_version(true); |
|
2543 | + if ($error != '') { |
|
2544 | + return $error; |
|
2545 | + } else { |
|
2546 | + return self::check_version(true); |
|
2547 | + } |
|
2347 | 2548 | } elseif ($result['value'] == '16') { |
2348 | 2549 | $error = self::update_from_16(); |
2349 | - if ($error != '') return $error; |
|
2350 | - else return self::check_version(true); |
|
2550 | + if ($error != '') { |
|
2551 | + return $error; |
|
2552 | + } else { |
|
2553 | + return self::check_version(true); |
|
2554 | + } |
|
2351 | 2555 | } elseif ($result['value'] == '17') { |
2352 | 2556 | $error = self::update_from_17(); |
2353 | - if ($error != '') return $error; |
|
2354 | - else return self::check_version(true); |
|
2557 | + if ($error != '') { |
|
2558 | + return $error; |
|
2559 | + } else { |
|
2560 | + return self::check_version(true); |
|
2561 | + } |
|
2355 | 2562 | } elseif ($result['value'] == '18') { |
2356 | 2563 | $error = self::update_from_18(); |
2357 | - if ($error != '') return $error; |
|
2358 | - else return self::check_version(true); |
|
2564 | + if ($error != '') { |
|
2565 | + return $error; |
|
2566 | + } else { |
|
2567 | + return self::check_version(true); |
|
2568 | + } |
|
2359 | 2569 | } elseif ($result['value'] == '19') { |
2360 | 2570 | $error = self::update_from_19(); |
2361 | - if ($error != '') return $error; |
|
2362 | - else return self::check_version(true); |
|
2571 | + if ($error != '') { |
|
2572 | + return $error; |
|
2573 | + } else { |
|
2574 | + return self::check_version(true); |
|
2575 | + } |
|
2363 | 2576 | } elseif ($result['value'] == '20') { |
2364 | 2577 | $error = self::update_from_20(); |
2365 | - if ($error != '') return $error; |
|
2366 | - else return self::check_version(true); |
|
2578 | + if ($error != '') { |
|
2579 | + return $error; |
|
2580 | + } else { |
|
2581 | + return self::check_version(true); |
|
2582 | + } |
|
2367 | 2583 | } elseif ($result['value'] == '21') { |
2368 | 2584 | $error = self::update_from_21(); |
2369 | - if ($error != '') return $error; |
|
2370 | - else return self::check_version(true); |
|
2585 | + if ($error != '') { |
|
2586 | + return $error; |
|
2587 | + } else { |
|
2588 | + return self::check_version(true); |
|
2589 | + } |
|
2371 | 2590 | } elseif ($result['value'] == '22') { |
2372 | 2591 | $error = self::update_from_22(); |
2373 | - if ($error != '') return $error; |
|
2374 | - else return self::check_version(true); |
|
2592 | + if ($error != '') { |
|
2593 | + return $error; |
|
2594 | + } else { |
|
2595 | + return self::check_version(true); |
|
2596 | + } |
|
2375 | 2597 | } elseif ($result['value'] == '23') { |
2376 | 2598 | $error = self::update_from_23(); |
2377 | - if ($error != '') return $error; |
|
2378 | - else return self::check_version(true); |
|
2599 | + if ($error != '') { |
|
2600 | + return $error; |
|
2601 | + } else { |
|
2602 | + return self::check_version(true); |
|
2603 | + } |
|
2379 | 2604 | } elseif ($result['value'] == '24') { |
2380 | 2605 | $error = self::update_from_24(); |
2381 | - if ($error != '') return $error; |
|
2382 | - else return self::check_version(true); |
|
2606 | + if ($error != '') { |
|
2607 | + return $error; |
|
2608 | + } else { |
|
2609 | + return self::check_version(true); |
|
2610 | + } |
|
2383 | 2611 | } elseif ($result['value'] == '25') { |
2384 | 2612 | $error = self::update_from_25(); |
2385 | - if ($error != '') return $error; |
|
2386 | - else return self::check_version(true); |
|
2613 | + if ($error != '') { |
|
2614 | + return $error; |
|
2615 | + } else { |
|
2616 | + return self::check_version(true); |
|
2617 | + } |
|
2387 | 2618 | } elseif ($result['value'] == '26') { |
2388 | 2619 | $error = self::update_from_26(); |
2389 | - if ($error != '') return $error; |
|
2390 | - else return self::check_version(true); |
|
2620 | + if ($error != '') { |
|
2621 | + return $error; |
|
2622 | + } else { |
|
2623 | + return self::check_version(true); |
|
2624 | + } |
|
2391 | 2625 | } elseif ($result['value'] == '27') { |
2392 | 2626 | $error = self::update_from_27(); |
2393 | - if ($error != '') return $error; |
|
2394 | - else return self::check_version(true); |
|
2627 | + if ($error != '') { |
|
2628 | + return $error; |
|
2629 | + } else { |
|
2630 | + return self::check_version(true); |
|
2631 | + } |
|
2395 | 2632 | } elseif ($result['value'] == '28') { |
2396 | 2633 | $error = self::update_from_28(); |
2397 | - if ($error != '') return $error; |
|
2398 | - else return self::check_version(true); |
|
2634 | + if ($error != '') { |
|
2635 | + return $error; |
|
2636 | + } else { |
|
2637 | + return self::check_version(true); |
|
2638 | + } |
|
2399 | 2639 | } elseif ($result['value'] == '29') { |
2400 | 2640 | $error = self::update_from_29(); |
2401 | - if ($error != '') return $error; |
|
2402 | - else return self::check_version(true); |
|
2641 | + if ($error != '') { |
|
2642 | + return $error; |
|
2643 | + } else { |
|
2644 | + return self::check_version(true); |
|
2645 | + } |
|
2403 | 2646 | } elseif ($result['value'] == '30') { |
2404 | 2647 | $error = self::update_from_30(); |
2405 | - if ($error != '') return $error; |
|
2406 | - else return self::check_version(true); |
|
2648 | + if ($error != '') { |
|
2649 | + return $error; |
|
2650 | + } else { |
|
2651 | + return self::check_version(true); |
|
2652 | + } |
|
2407 | 2653 | } elseif ($result['value'] == '31') { |
2408 | 2654 | $error = self::update_from_31(); |
2409 | - if ($error != '') return $error; |
|
2410 | - else return self::check_version(true); |
|
2655 | + if ($error != '') { |
|
2656 | + return $error; |
|
2657 | + } else { |
|
2658 | + return self::check_version(true); |
|
2659 | + } |
|
2411 | 2660 | } elseif ($result['value'] == '32') { |
2412 | 2661 | $error = self::update_from_32(); |
2413 | - if ($error != '') return $error; |
|
2414 | - else return self::check_version(true); |
|
2662 | + if ($error != '') { |
|
2663 | + return $error; |
|
2664 | + } else { |
|
2665 | + return self::check_version(true); |
|
2666 | + } |
|
2415 | 2667 | } elseif ($result['value'] == '33') { |
2416 | 2668 | $error = self::update_from_33(); |
2417 | - if ($error != '') return $error; |
|
2418 | - else return self::check_version(true); |
|
2669 | + if ($error != '') { |
|
2670 | + return $error; |
|
2671 | + } else { |
|
2672 | + return self::check_version(true); |
|
2673 | + } |
|
2419 | 2674 | } elseif ($result['value'] == '34') { |
2420 | 2675 | $error = self::update_from_34(); |
2421 | - if ($error != '') return $error; |
|
2422 | - else return self::check_version(true); |
|
2676 | + if ($error != '') { |
|
2677 | + return $error; |
|
2678 | + } else { |
|
2679 | + return self::check_version(true); |
|
2680 | + } |
|
2423 | 2681 | } elseif ($result['value'] == '35') { |
2424 | 2682 | $error = self::update_from_35(); |
2425 | - if ($error != '') return $error; |
|
2426 | - else return self::check_version(true); |
|
2683 | + if ($error != '') { |
|
2684 | + return $error; |
|
2685 | + } else { |
|
2686 | + return self::check_version(true); |
|
2687 | + } |
|
2427 | 2688 | } elseif ($result['value'] == '36') { |
2428 | 2689 | $error = self::update_from_36(); |
2429 | - if ($error != '') return $error; |
|
2430 | - else return self::check_version(true); |
|
2690 | + if ($error != '') { |
|
2691 | + return $error; |
|
2692 | + } else { |
|
2693 | + return self::check_version(true); |
|
2694 | + } |
|
2431 | 2695 | } elseif ($result['value'] == '37') { |
2432 | 2696 | $error = self::update_from_37(); |
2433 | - if ($error != '') return $error; |
|
2434 | - else return self::check_version(true); |
|
2697 | + if ($error != '') { |
|
2698 | + return $error; |
|
2699 | + } else { |
|
2700 | + return self::check_version(true); |
|
2701 | + } |
|
2435 | 2702 | } elseif ($result['value'] == '38') { |
2436 | 2703 | $error = self::update_from_38(); |
2437 | - if ($error != '') return $error; |
|
2438 | - else return self::check_version(true); |
|
2704 | + if ($error != '') { |
|
2705 | + return $error; |
|
2706 | + } else { |
|
2707 | + return self::check_version(true); |
|
2708 | + } |
|
2439 | 2709 | } elseif ($result['value'] == '39') { |
2440 | 2710 | $error = self::update_from_39(); |
2441 | - if ($error != '') return $error; |
|
2442 | - else return self::check_version(true); |
|
2711 | + if ($error != '') { |
|
2712 | + return $error; |
|
2713 | + } else { |
|
2714 | + return self::check_version(true); |
|
2715 | + } |
|
2443 | 2716 | } elseif ($result['value'] == '40') { |
2444 | 2717 | $error = self::update_from_40(); |
2445 | - if ($error != '') return $error; |
|
2446 | - else return self::check_version(true); |
|
2718 | + if ($error != '') { |
|
2719 | + return $error; |
|
2720 | + } else { |
|
2721 | + return self::check_version(true); |
|
2722 | + } |
|
2447 | 2723 | } elseif ($result['value'] == '41') { |
2448 | 2724 | $error = self::update_from_41(); |
2449 | - if ($error != '') return $error; |
|
2450 | - else return self::check_version(true); |
|
2725 | + if ($error != '') { |
|
2726 | + return $error; |
|
2727 | + } else { |
|
2728 | + return self::check_version(true); |
|
2729 | + } |
|
2451 | 2730 | } elseif ($result['value'] == '42') { |
2452 | 2731 | $error = self::update_from_42(); |
2453 | - if ($error != '') return $error; |
|
2454 | - else return self::check_version(true); |
|
2732 | + if ($error != '') { |
|
2733 | + return $error; |
|
2734 | + } else { |
|
2735 | + return self::check_version(true); |
|
2736 | + } |
|
2455 | 2737 | } elseif ($result['value'] == '43') { |
2456 | 2738 | $error = self::update_from_43(); |
2457 | - if ($error != '') return $error; |
|
2458 | - else return self::check_version(true); |
|
2739 | + if ($error != '') { |
|
2740 | + return $error; |
|
2741 | + } else { |
|
2742 | + return self::check_version(true); |
|
2743 | + } |
|
2459 | 2744 | } elseif ($result['value'] == '44') { |
2460 | 2745 | $error = self::update_from_44(); |
2461 | - if ($error != '') return $error; |
|
2462 | - else return self::check_version(true); |
|
2746 | + if ($error != '') { |
|
2747 | + return $error; |
|
2748 | + } else { |
|
2749 | + return self::check_version(true); |
|
2750 | + } |
|
2463 | 2751 | } elseif ($result['value'] == '45') { |
2464 | 2752 | $error = self::update_from_45(); |
2465 | - if ($error != '') return $error; |
|
2466 | - else return self::check_version(true); |
|
2753 | + if ($error != '') { |
|
2754 | + return $error; |
|
2755 | + } else { |
|
2756 | + return self::check_version(true); |
|
2757 | + } |
|
2467 | 2758 | } elseif ($result['value'] == '46') { |
2468 | 2759 | $error = self::update_from_46(); |
2469 | - if ($error != '') return $error; |
|
2470 | - else return self::check_version(true); |
|
2760 | + if ($error != '') { |
|
2761 | + return $error; |
|
2762 | + } else { |
|
2763 | + return self::check_version(true); |
|
2764 | + } |
|
2471 | 2765 | } elseif ($result['value'] == '47') { |
2472 | 2766 | $error = self::update_from_47(); |
2473 | - if ($error != '') return $error; |
|
2474 | - else return self::check_version(true); |
|
2767 | + if ($error != '') { |
|
2768 | + return $error; |
|
2769 | + } else { |
|
2770 | + return self::check_version(true); |
|
2771 | + } |
|
2475 | 2772 | } elseif ($result['value'] == '48') { |
2476 | 2773 | $error = self::update_from_48(); |
2477 | - if ($error != '') return $error; |
|
2478 | - else return self::check_version(true); |
|
2774 | + if ($error != '') { |
|
2775 | + return $error; |
|
2776 | + } else { |
|
2777 | + return self::check_version(true); |
|
2778 | + } |
|
2479 | 2779 | } elseif ($result['value'] == '49') { |
2480 | 2780 | $error = self::update_from_49(); |
2481 | - if ($error != '') return $error; |
|
2482 | - else return self::check_version(true); |
|
2483 | - } else return ''; |
|
2781 | + if ($error != '') { |
|
2782 | + return $error; |
|
2783 | + } else { |
|
2784 | + return self::check_version(true); |
|
2785 | + } |
|
2786 | + } else { |
|
2787 | + return ''; |
|
2788 | + } |
|
2484 | 2789 | } else { |
2485 | - if (isset($result['value']) && $result['value'] != '') return $result['value']; |
|
2486 | - else return 0; |
|
2790 | + if (isset($result['value']) && $result['value'] != '') { |
|
2791 | + return $result['value']; |
|
2792 | + } else { |
|
2793 | + return 0; |
|
2794 | + } |
|
2487 | 2795 | } |
2488 | 2796 | } |
2489 | - } else return $version; |
|
2797 | + } else { |
|
2798 | + return $version; |
|
2799 | + } |
|
2490 | 2800 | } |
2491 | 2801 | } |
2492 | 2802 | } |
@@ -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) { |
@@ -1270,13 +1423,17 @@ discard block |
||
1270 | 1423 | $sth = $Connection->db->prepare($query); |
1271 | 1424 | $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')); |
1272 | 1425 | } catch(PDOException $e) { |
1273 | - if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1426 | + if ($globalDebug) { |
|
1427 | + echo "error: ".$e->getMessage()." - data: ".implode(',',$data); |
|
1428 | + } |
|
1274 | 1429 | } |
1275 | 1430 | } |
1276 | 1431 | $i++; |
1277 | 1432 | } |
1278 | 1433 | fclose($handle); |
1279 | - if ($globalTransaction) $Connection->db->commit(); |
|
1434 | + if ($globalTransaction) { |
|
1435 | + $Connection->db->commit(); |
|
1436 | + } |
|
1280 | 1437 | } |
1281 | 1438 | return ''; |
1282 | 1439 | } |
@@ -1301,7 +1458,9 @@ discard block |
||
1301 | 1458 | $i = 0; |
1302 | 1459 | //$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE); |
1303 | 1460 | //$Connection->db->beginTransaction(); |
1304 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1461 | + if ($globalTransaction) { |
|
1462 | + $Connection->db->beginTransaction(); |
|
1463 | + } |
|
1305 | 1464 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1306 | 1465 | { |
1307 | 1466 | if ($i > 0) { |
@@ -1317,7 +1476,9 @@ discard block |
||
1317 | 1476 | $i++; |
1318 | 1477 | } |
1319 | 1478 | fclose($handle); |
1320 | - if ($globalTransaction) $Connection->db->commit(); |
|
1479 | + if ($globalTransaction) { |
|
1480 | + $Connection->db->commit(); |
|
1481 | + } |
|
1321 | 1482 | } |
1322 | 1483 | return ''; |
1323 | 1484 | } |
@@ -1337,7 +1498,9 @@ discard block |
||
1337 | 1498 | if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE) |
1338 | 1499 | { |
1339 | 1500 | $i = 0; |
1340 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1501 | + if ($globalTransaction) { |
|
1502 | + $Connection->db->beginTransaction(); |
|
1503 | + } |
|
1341 | 1504 | while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1342 | 1505 | { |
1343 | 1506 | if ($i > 0) { |
@@ -1354,7 +1517,9 @@ discard block |
||
1354 | 1517 | $i++; |
1355 | 1518 | } |
1356 | 1519 | fclose($handle); |
1357 | - if ($globalTransaction) $Connection->db->commit(); |
|
1520 | + if ($globalTransaction) { |
|
1521 | + $Connection->db->commit(); |
|
1522 | + } |
|
1358 | 1523 | } |
1359 | 1524 | return ''; |
1360 | 1525 | } |
@@ -1373,7 +1538,9 @@ discard block |
||
1373 | 1538 | $Connection = new Connection(); |
1374 | 1539 | if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE) |
1375 | 1540 | { |
1376 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
1541 | + if ($globalTransaction) { |
|
1542 | + $Connection->db->beginTransaction(); |
|
1543 | + } |
|
1377 | 1544 | while (($data = fgetcsv($handle, 1000)) !== FALSE) |
1378 | 1545 | { |
1379 | 1546 | $query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL'; |
@@ -1388,7 +1555,9 @@ discard block |
||
1388 | 1555 | } |
1389 | 1556 | } |
1390 | 1557 | fclose($handle); |
1391 | - if ($globalTransaction) $Connection->db->commit(); |
|
1558 | + if ($globalTransaction) { |
|
1559 | + $Connection->db->commit(); |
|
1560 | + } |
|
1392 | 1561 | } |
1393 | 1562 | return ''; |
1394 | 1563 | } |
@@ -1464,9 +1633,14 @@ discard block |
||
1464 | 1633 | if ($i > 0 && $data[0] != '') { |
1465 | 1634 | $sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]); |
1466 | 1635 | $period = str_replace(',','',$data[14]); |
1467 | - if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60; |
|
1468 | - if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18])); |
|
1469 | - else $launch_date = NULL; |
|
1636 | + if (!empty($period) && strpos($period,'days')) { |
|
1637 | + $period = str_replace(' days','',$period)*24*60; |
|
1638 | + } |
|
1639 | + if ($data[18] != '') { |
|
1640 | + $launch_date = date('Y-m-d',strtotime($data[18])); |
|
1641 | + } else { |
|
1642 | + $launch_date = NULL; |
|
1643 | + } |
|
1470 | 1644 | $data = array_map(function($value) { |
1471 | 1645 | return trim($value) === '' ? null : $value; |
1472 | 1646 | }, $data); |
@@ -1829,7 +2003,9 @@ discard block |
||
1829 | 2003 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1830 | 2004 | { |
1831 | 2005 | $i = 0; |
1832 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
2006 | + if ($globalTransaction) { |
|
2007 | + $Connection->db->beginTransaction(); |
|
2008 | + } |
|
1833 | 2009 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1834 | 2010 | { |
1835 | 2011 | $i++; |
@@ -1857,7 +2033,9 @@ discard block |
||
1857 | 2033 | } |
1858 | 2034 | } |
1859 | 2035 | fclose($handle); |
1860 | - if ($globalTransaction) $Connection->db->commit(); |
|
2036 | + if ($globalTransaction) { |
|
2037 | + $Connection->db->commit(); |
|
2038 | + } |
|
1861 | 2039 | } |
1862 | 2040 | return ''; |
1863 | 2041 | } |
@@ -1900,7 +2078,9 @@ discard block |
||
1900 | 2078 | $Connection = new Connection(); |
1901 | 2079 | if (($handle = fopen($filename, 'r')) !== FALSE) |
1902 | 2080 | { |
1903 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
2081 | + if ($globalTransaction) { |
|
2082 | + $Connection->db->beginTransaction(); |
|
2083 | + } |
|
1904 | 2084 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
1905 | 2085 | { |
1906 | 2086 | if(count($row) > 1) { |
@@ -1914,7 +2094,9 @@ discard block |
||
1914 | 2094 | } |
1915 | 2095 | } |
1916 | 2096 | fclose($handle); |
1917 | - if ($globalTransaction) $Connection->db->commit(); |
|
2097 | + if ($globalTransaction) { |
|
2098 | + $Connection->db->commit(); |
|
2099 | + } |
|
1918 | 2100 | } |
1919 | 2101 | return ''; |
1920 | 2102 | } |
@@ -1934,8 +2116,9 @@ discard block |
||
1934 | 2116 | } |
1935 | 2117 | |
1936 | 2118 | |
1937 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
1938 | - else { |
|
2119 | + if ($globalDBdriver == 'mysql') { |
|
2120 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
2121 | + } else { |
|
1939 | 2122 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
1940 | 2123 | $query = "CREATE EXTENSION postgis"; |
1941 | 2124 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1954,7 +2137,9 @@ discard block |
||
1954 | 2137 | global $tmp_dir, $globalDebug; |
1955 | 2138 | include_once('class.create_db.php'); |
1956 | 2139 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
1957 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
2140 | + if ($globalDebug) { |
|
2141 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
2142 | + } |
|
1958 | 2143 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5'); |
1959 | 2144 | $error = ''; |
1960 | 2145 | if (file_exists($tmp_dir.'notam.txt.gz.md5')) { |
@@ -1964,20 +2149,34 @@ discard block |
||
1964 | 2149 | update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
1965 | 2150 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
1966 | 2151 | if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) { |
1967 | - if ($globalDebug) echo "Gunzip..."; |
|
2152 | + if ($globalDebug) { |
|
2153 | + echo "Gunzip..."; |
|
2154 | + } |
|
1968 | 2155 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
1969 | - if ($globalDebug) echo "Add to DB..."; |
|
2156 | + if ($globalDebug) { |
|
2157 | + echo "Add to DB..."; |
|
2158 | + } |
|
1970 | 2159 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
1971 | 2160 | $NOTAM = new NOTAM(); |
1972 | 2161 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
1973 | 2162 | update_db::insert_notam_version($notam_md5); |
1974 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
1975 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
1976 | - } elseif ($globalDebug) echo "No new version."; |
|
1977 | - } else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
2163 | + } else { |
|
2164 | + $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed."; |
|
2165 | + } |
|
2166 | + } else { |
|
2167 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
2168 | + } |
|
2169 | + } elseif ($globalDebug) { |
|
2170 | + echo "No new version."; |
|
2171 | + } |
|
2172 | + } else { |
|
2173 | + $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed."; |
|
2174 | + } |
|
1978 | 2175 | if ($error != '') { |
1979 | 2176 | return $error; |
1980 | - } elseif ($globalDebug) echo "Done\n"; |
|
2177 | + } elseif ($globalDebug) { |
|
2178 | + echo "Done\n"; |
|
2179 | + } |
|
1981 | 2180 | return ''; |
1982 | 2181 | } |
1983 | 2182 | |
@@ -2032,68 +2231,114 @@ discard block |
||
2032 | 2231 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
2033 | 2232 | if (extension_loaded('zip')) { |
2034 | 2233 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
2035 | - if ($globalDebug) echo "Unzip..."; |
|
2234 | + if ($globalDebug) { |
|
2235 | + echo "Unzip..."; |
|
2236 | + } |
|
2036 | 2237 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
2037 | - if ($globalDebug) echo "Add to DB..."; |
|
2238 | + if ($globalDebug) { |
|
2239 | + echo "Add to DB..."; |
|
2240 | + } |
|
2038 | 2241 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
2039 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
2242 | + if ($globalDebug) { |
|
2243 | + echo "Copy airlines logos to airlines images directory..."; |
|
2244 | + } |
|
2040 | 2245 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
2041 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
2042 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
2043 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
2044 | - } else $error = "ZIP module not loaded but required for IVAO."; |
|
2246 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
2247 | + $error = "Failed to copy airlines logo."; |
|
2248 | + } |
|
2249 | + } else { |
|
2250 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
2251 | + } |
|
2252 | + } else { |
|
2253 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
2254 | + } |
|
2255 | + } else { |
|
2256 | + $error = "ZIP module not loaded but required for IVAO."; |
|
2257 | + } |
|
2045 | 2258 | if ($error != '') { |
2046 | 2259 | return $error; |
2047 | - } elseif ($globalDebug) echo "Done\n"; |
|
2260 | + } elseif ($globalDebug) { |
|
2261 | + echo "Done\n"; |
|
2262 | + } |
|
2048 | 2263 | return ''; |
2049 | 2264 | } |
2050 | 2265 | |
2051 | 2266 | public static function update_routes() { |
2052 | 2267 | global $tmp_dir, $globalDebug; |
2053 | 2268 | $error = ''; |
2054 | - if ($globalDebug) echo "Routes : Download..."; |
|
2269 | + if ($globalDebug) { |
|
2270 | + echo "Routes : Download..."; |
|
2271 | + } |
|
2055 | 2272 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
2056 | 2273 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
2057 | - if ($globalDebug) echo "Gunzip..."; |
|
2274 | + if ($globalDebug) { |
|
2275 | + echo "Gunzip..."; |
|
2276 | + } |
|
2058 | 2277 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
2059 | - if ($globalDebug) echo "Add to DB..."; |
|
2278 | + if ($globalDebug) { |
|
2279 | + echo "Add to DB..."; |
|
2280 | + } |
|
2060 | 2281 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
2061 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
2282 | + } else { |
|
2283 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
2284 | + } |
|
2062 | 2285 | if ($error != '') { |
2063 | 2286 | return $error; |
2064 | - } elseif ($globalDebug) echo "Done\n"; |
|
2287 | + } elseif ($globalDebug) { |
|
2288 | + echo "Done\n"; |
|
2289 | + } |
|
2065 | 2290 | return ''; |
2066 | 2291 | } |
2067 | 2292 | public static function update_oneworld() { |
2068 | 2293 | global $tmp_dir, $globalDebug; |
2069 | 2294 | $error = ''; |
2070 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
2295 | + if ($globalDebug) { |
|
2296 | + echo "Schedules Oneworld : Download..."; |
|
2297 | + } |
|
2071 | 2298 | update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
2072 | 2299 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
2073 | - if ($globalDebug) echo "Gunzip..."; |
|
2300 | + if ($globalDebug) { |
|
2301 | + echo "Gunzip..."; |
|
2302 | + } |
|
2074 | 2303 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
2075 | - if ($globalDebug) echo "Add to DB..."; |
|
2304 | + if ($globalDebug) { |
|
2305 | + echo "Add to DB..."; |
|
2306 | + } |
|
2076 | 2307 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
2077 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
2308 | + } else { |
|
2309 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
2310 | + } |
|
2078 | 2311 | if ($error != '') { |
2079 | 2312 | return $error; |
2080 | - } elseif ($globalDebug) echo "Done\n"; |
|
2313 | + } elseif ($globalDebug) { |
|
2314 | + echo "Done\n"; |
|
2315 | + } |
|
2081 | 2316 | return ''; |
2082 | 2317 | } |
2083 | 2318 | public static function update_skyteam() { |
2084 | 2319 | global $tmp_dir, $globalDebug; |
2085 | 2320 | $error = ''; |
2086 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
2321 | + if ($globalDebug) { |
|
2322 | + echo "Schedules Skyteam : Download..."; |
|
2323 | + } |
|
2087 | 2324 | update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
2088 | 2325 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
2089 | - if ($globalDebug) echo "Gunzip..."; |
|
2326 | + if ($globalDebug) { |
|
2327 | + echo "Gunzip..."; |
|
2328 | + } |
|
2090 | 2329 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
2091 | - if ($globalDebug) echo "Add to DB..."; |
|
2330 | + if ($globalDebug) { |
|
2331 | + echo "Add to DB..."; |
|
2332 | + } |
|
2092 | 2333 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
2093 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
2334 | + } else { |
|
2335 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
2336 | + } |
|
2094 | 2337 | if ($error != '') { |
2095 | 2338 | return $error; |
2096 | - } elseif ($globalDebug) echo "Done\n"; |
|
2339 | + } elseif ($globalDebug) { |
|
2340 | + echo "Done\n"; |
|
2341 | + } |
|
2097 | 2342 | return ''; |
2098 | 2343 | } |
2099 | 2344 | public static function update_ModeS() { |
@@ -2110,340 +2355,590 @@ discard block |
||
2110 | 2355 | exit; |
2111 | 2356 | } elseif ($globalDebug) echo "Done\n"; |
2112 | 2357 | */ |
2113 | - if ($globalDebug) echo "Modes : Download..."; |
|
2114 | -// update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
2358 | + if ($globalDebug) { |
|
2359 | + echo "Modes : Download..."; |
|
2360 | + } |
|
2361 | + // update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
2115 | 2362 | update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz'); |
2116 | 2363 | |
2117 | 2364 | // if (file_exists($tmp_dir.'basestation_latest.zip')) { |
2118 | 2365 | if (file_exists($tmp_dir.'BaseStation.sqb.gz')) { |
2119 | - if ($globalDebug) echo "Unzip..."; |
|
2120 | -// update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
2366 | + if ($globalDebug) { |
|
2367 | + echo "Unzip..."; |
|
2368 | + } |
|
2369 | + // update_db::unzip($tmp_dir.'basestation_latest.zip'); |
|
2121 | 2370 | update_db::gunzip($tmp_dir.'BaseStation.sqb.gz'); |
2122 | - if ($globalDebug) echo "Add to DB..."; |
|
2371 | + if ($globalDebug) { |
|
2372 | + echo "Add to DB..."; |
|
2373 | + } |
|
2123 | 2374 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
2124 | 2375 | // $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb'); |
2125 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
2376 | + } else { |
|
2377 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
2378 | + } |
|
2126 | 2379 | if ($error != '') { |
2127 | 2380 | return $error; |
2128 | - } elseif ($globalDebug) echo "Done\n"; |
|
2381 | + } elseif ($globalDebug) { |
|
2382 | + echo "Done\n"; |
|
2383 | + } |
|
2129 | 2384 | return ''; |
2130 | 2385 | } |
2131 | 2386 | |
2132 | 2387 | public static function update_ModeS_faa() { |
2133 | 2388 | global $tmp_dir, $globalDebug; |
2134 | - if ($globalDebug) echo "Modes FAA: Download..."; |
|
2389 | + if ($globalDebug) { |
|
2390 | + echo "Modes FAA: Download..."; |
|
2391 | + } |
|
2135 | 2392 | update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip'); |
2136 | 2393 | if (file_exists($tmp_dir.'ReleasableAircraft.zip')) { |
2137 | - if ($globalDebug) echo "Unzip..."; |
|
2394 | + if ($globalDebug) { |
|
2395 | + echo "Unzip..."; |
|
2396 | + } |
|
2138 | 2397 | update_db::unzip($tmp_dir.'ReleasableAircraft.zip'); |
2139 | - if ($globalDebug) echo "Add to DB..."; |
|
2398 | + if ($globalDebug) { |
|
2399 | + echo "Add to DB..."; |
|
2400 | + } |
|
2140 | 2401 | $error = update_db::modes_faa(); |
2141 | - } else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
2402 | + } else { |
|
2403 | + $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed."; |
|
2404 | + } |
|
2142 | 2405 | if ($error != '') { |
2143 | 2406 | return $error; |
2144 | - } elseif ($globalDebug) echo "Done\n"; |
|
2407 | + } elseif ($globalDebug) { |
|
2408 | + echo "Done\n"; |
|
2409 | + } |
|
2145 | 2410 | return ''; |
2146 | 2411 | } |
2147 | 2412 | |
2148 | 2413 | public static function update_ModeS_flarm() { |
2149 | 2414 | global $tmp_dir, $globalDebug; |
2150 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
2415 | + if ($globalDebug) { |
|
2416 | + echo "Modes Flarmnet: Download..."; |
|
2417 | + } |
|
2151 | 2418 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
2152 | 2419 | if (file_exists($tmp_dir.'data.fln')) { |
2153 | - if ($globalDebug) echo "Add to DB..."; |
|
2420 | + if ($globalDebug) { |
|
2421 | + echo "Add to DB..."; |
|
2422 | + } |
|
2154 | 2423 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
2155 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
2424 | + } else { |
|
2425 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
2426 | + } |
|
2156 | 2427 | if ($error != '') { |
2157 | 2428 | return $error; |
2158 | - } elseif ($globalDebug) echo "Done\n"; |
|
2429 | + } elseif ($globalDebug) { |
|
2430 | + echo "Done\n"; |
|
2431 | + } |
|
2159 | 2432 | return ''; |
2160 | 2433 | } |
2161 | 2434 | |
2162 | 2435 | public static function update_ModeS_ogn() { |
2163 | 2436 | global $tmp_dir, $globalDebug; |
2164 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
2437 | + if ($globalDebug) { |
|
2438 | + echo "Modes OGN: Download..."; |
|
2439 | + } |
|
2165 | 2440 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
2166 | 2441 | if (file_exists($tmp_dir.'ogn.csv')) { |
2167 | - if ($globalDebug) echo "Add to DB..."; |
|
2442 | + if ($globalDebug) { |
|
2443 | + echo "Add to DB..."; |
|
2444 | + } |
|
2168 | 2445 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
2169 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2446 | + } else { |
|
2447 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
2448 | + } |
|
2170 | 2449 | if ($error != '') { |
2171 | 2450 | return $error; |
2172 | - } elseif ($globalDebug) echo "Done\n"; |
|
2451 | + } elseif ($globalDebug) { |
|
2452 | + echo "Done\n"; |
|
2453 | + } |
|
2173 | 2454 | return ''; |
2174 | 2455 | } |
2175 | 2456 | |
2176 | 2457 | public static function update_owner() { |
2177 | 2458 | global $tmp_dir, $globalDebug, $globalMasterSource; |
2178 | 2459 | |
2179 | - if ($globalDebug) echo "Owner France: Download..."; |
|
2460 | + if ($globalDebug) { |
|
2461 | + echo "Owner France: Download..."; |
|
2462 | + } |
|
2180 | 2463 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
2181 | 2464 | if (file_exists($tmp_dir.'owner_f.csv')) { |
2182 | - if ($globalDebug) echo "Add to DB..."; |
|
2465 | + if ($globalDebug) { |
|
2466 | + echo "Add to DB..."; |
|
2467 | + } |
|
2183 | 2468 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
2184 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2469 | + } else { |
|
2470 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
2471 | + } |
|
2185 | 2472 | if ($error != '') { |
2186 | 2473 | return $error; |
2187 | - } elseif ($globalDebug) echo "Done\n"; |
|
2474 | + } elseif ($globalDebug) { |
|
2475 | + echo "Done\n"; |
|
2476 | + } |
|
2188 | 2477 | |
2189 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
2478 | + if ($globalDebug) { |
|
2479 | + echo "Owner Ireland: Download..."; |
|
2480 | + } |
|
2190 | 2481 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
2191 | 2482 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
2192 | - if ($globalDebug) echo "Add to DB..."; |
|
2483 | + if ($globalDebug) { |
|
2484 | + echo "Add to DB..."; |
|
2485 | + } |
|
2193 | 2486 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
2194 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2487 | + } else { |
|
2488 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
2489 | + } |
|
2195 | 2490 | if ($error != '') { |
2196 | 2491 | return $error; |
2197 | - } elseif ($globalDebug) echo "Done\n"; |
|
2198 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
2492 | + } elseif ($globalDebug) { |
|
2493 | + echo "Done\n"; |
|
2494 | + } |
|
2495 | + if ($globalDebug) { |
|
2496 | + echo "Owner Switzerland: Download..."; |
|
2497 | + } |
|
2199 | 2498 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
2200 | 2499 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
2201 | - if ($globalDebug) echo "Add to DB..."; |
|
2500 | + if ($globalDebug) { |
|
2501 | + echo "Add to DB..."; |
|
2502 | + } |
|
2202 | 2503 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
2203 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2504 | + } else { |
|
2505 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
2506 | + } |
|
2204 | 2507 | if ($error != '') { |
2205 | 2508 | return $error; |
2206 | - } elseif ($globalDebug) echo "Done\n"; |
|
2207 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
2509 | + } elseif ($globalDebug) { |
|
2510 | + echo "Done\n"; |
|
2511 | + } |
|
2512 | + if ($globalDebug) { |
|
2513 | + echo "Owner Czech Republic: Download..."; |
|
2514 | + } |
|
2208 | 2515 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
2209 | 2516 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
2210 | - if ($globalDebug) echo "Add to DB..."; |
|
2517 | + if ($globalDebug) { |
|
2518 | + echo "Add to DB..."; |
|
2519 | + } |
|
2211 | 2520 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
2212 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2521 | + } else { |
|
2522 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
2523 | + } |
|
2213 | 2524 | if ($error != '') { |
2214 | 2525 | return $error; |
2215 | - } elseif ($globalDebug) echo "Done\n"; |
|
2216 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
2526 | + } elseif ($globalDebug) { |
|
2527 | + echo "Done\n"; |
|
2528 | + } |
|
2529 | + if ($globalDebug) { |
|
2530 | + echo "Owner Australia: Download..."; |
|
2531 | + } |
|
2217 | 2532 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
2218 | 2533 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
2219 | - if ($globalDebug) echo "Add to DB..."; |
|
2534 | + if ($globalDebug) { |
|
2535 | + echo "Add to DB..."; |
|
2536 | + } |
|
2220 | 2537 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
2221 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2538 | + } else { |
|
2539 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
2540 | + } |
|
2222 | 2541 | if ($error != '') { |
2223 | 2542 | return $error; |
2224 | - } elseif ($globalDebug) echo "Done\n"; |
|
2225 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
2543 | + } elseif ($globalDebug) { |
|
2544 | + echo "Done\n"; |
|
2545 | + } |
|
2546 | + if ($globalDebug) { |
|
2547 | + echo "Owner Austria: Download..."; |
|
2548 | + } |
|
2226 | 2549 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
2227 | 2550 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
2228 | - if ($globalDebug) echo "Add to DB..."; |
|
2551 | + if ($globalDebug) { |
|
2552 | + echo "Add to DB..."; |
|
2553 | + } |
|
2229 | 2554 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
2230 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2555 | + } else { |
|
2556 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
2557 | + } |
|
2231 | 2558 | if ($error != '') { |
2232 | 2559 | return $error; |
2233 | - } elseif ($globalDebug) echo "Done\n"; |
|
2234 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
2560 | + } elseif ($globalDebug) { |
|
2561 | + echo "Done\n"; |
|
2562 | + } |
|
2563 | + if ($globalDebug) { |
|
2564 | + echo "Owner Chile: Download..."; |
|
2565 | + } |
|
2235 | 2566 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
2236 | 2567 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
2237 | - if ($globalDebug) echo "Add to DB..."; |
|
2568 | + if ($globalDebug) { |
|
2569 | + echo "Add to DB..."; |
|
2570 | + } |
|
2238 | 2571 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
2239 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2572 | + } else { |
|
2573 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
2574 | + } |
|
2240 | 2575 | if ($error != '') { |
2241 | 2576 | return $error; |
2242 | - } elseif ($globalDebug) echo "Done\n"; |
|
2243 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
2577 | + } elseif ($globalDebug) { |
|
2578 | + echo "Done\n"; |
|
2579 | + } |
|
2580 | + if ($globalDebug) { |
|
2581 | + echo "Owner Colombia: Download..."; |
|
2582 | + } |
|
2244 | 2583 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
2245 | 2584 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
2246 | - if ($globalDebug) echo "Add to DB..."; |
|
2585 | + if ($globalDebug) { |
|
2586 | + echo "Add to DB..."; |
|
2587 | + } |
|
2247 | 2588 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
2248 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2589 | + } else { |
|
2590 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
2591 | + } |
|
2249 | 2592 | if ($error != '') { |
2250 | 2593 | return $error; |
2251 | - } elseif ($globalDebug) echo "Done\n"; |
|
2252 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
2594 | + } elseif ($globalDebug) { |
|
2595 | + echo "Done\n"; |
|
2596 | + } |
|
2597 | + if ($globalDebug) { |
|
2598 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
2599 | + } |
|
2253 | 2600 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
2254 | 2601 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
2255 | - if ($globalDebug) echo "Add to DB..."; |
|
2602 | + if ($globalDebug) { |
|
2603 | + echo "Add to DB..."; |
|
2604 | + } |
|
2256 | 2605 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
2257 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2606 | + } else { |
|
2607 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
2608 | + } |
|
2258 | 2609 | if ($error != '') { |
2259 | 2610 | return $error; |
2260 | - } elseif ($globalDebug) echo "Done\n"; |
|
2261 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
2611 | + } elseif ($globalDebug) { |
|
2612 | + echo "Done\n"; |
|
2613 | + } |
|
2614 | + if ($globalDebug) { |
|
2615 | + echo "Owner Brazil: Download..."; |
|
2616 | + } |
|
2262 | 2617 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
2263 | 2618 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
2264 | - if ($globalDebug) echo "Add to DB..."; |
|
2619 | + if ($globalDebug) { |
|
2620 | + echo "Add to DB..."; |
|
2621 | + } |
|
2265 | 2622 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
2266 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2623 | + } else { |
|
2624 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
2625 | + } |
|
2267 | 2626 | if ($error != '') { |
2268 | 2627 | return $error; |
2269 | - } elseif ($globalDebug) echo "Done\n"; |
|
2270 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
2628 | + } elseif ($globalDebug) { |
|
2629 | + echo "Done\n"; |
|
2630 | + } |
|
2631 | + if ($globalDebug) { |
|
2632 | + echo "Owner Cayman Islands: Download..."; |
|
2633 | + } |
|
2271 | 2634 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
2272 | 2635 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
2273 | - if ($globalDebug) echo "Add to DB..."; |
|
2636 | + if ($globalDebug) { |
|
2637 | + echo "Add to DB..."; |
|
2638 | + } |
|
2274 | 2639 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
2275 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2640 | + } else { |
|
2641 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
2642 | + } |
|
2276 | 2643 | if ($error != '') { |
2277 | 2644 | return $error; |
2278 | - } elseif ($globalDebug) echo "Done\n"; |
|
2279 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
2645 | + } elseif ($globalDebug) { |
|
2646 | + echo "Done\n"; |
|
2647 | + } |
|
2648 | + if ($globalDebug) { |
|
2649 | + echo "Owner Croatia: Download..."; |
|
2650 | + } |
|
2280 | 2651 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
2281 | 2652 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
2282 | - if ($globalDebug) echo "Add to DB..."; |
|
2653 | + if ($globalDebug) { |
|
2654 | + echo "Add to DB..."; |
|
2655 | + } |
|
2283 | 2656 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
2284 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2657 | + } else { |
|
2658 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
2659 | + } |
|
2285 | 2660 | if ($error != '') { |
2286 | 2661 | return $error; |
2287 | - } elseif ($globalDebug) echo "Done\n"; |
|
2288 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
2662 | + } elseif ($globalDebug) { |
|
2663 | + echo "Done\n"; |
|
2664 | + } |
|
2665 | + if ($globalDebug) { |
|
2666 | + echo "Owner Luxembourg: Download..."; |
|
2667 | + } |
|
2289 | 2668 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
2290 | 2669 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
2291 | - if ($globalDebug) echo "Add to DB..."; |
|
2670 | + if ($globalDebug) { |
|
2671 | + echo "Add to DB..."; |
|
2672 | + } |
|
2292 | 2673 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
2293 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2674 | + } else { |
|
2675 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
2676 | + } |
|
2294 | 2677 | if ($error != '') { |
2295 | 2678 | return $error; |
2296 | - } elseif ($globalDebug) echo "Done\n"; |
|
2297 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
2679 | + } elseif ($globalDebug) { |
|
2680 | + echo "Done\n"; |
|
2681 | + } |
|
2682 | + if ($globalDebug) { |
|
2683 | + echo "Owner Maldives: Download..."; |
|
2684 | + } |
|
2298 | 2685 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
2299 | 2686 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
2300 | - if ($globalDebug) echo "Add to DB..."; |
|
2687 | + if ($globalDebug) { |
|
2688 | + echo "Add to DB..."; |
|
2689 | + } |
|
2301 | 2690 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
2302 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2691 | + } else { |
|
2692 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
2693 | + } |
|
2303 | 2694 | if ($error != '') { |
2304 | 2695 | return $error; |
2305 | - } elseif ($globalDebug) echo "Done\n"; |
|
2306 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
2696 | + } elseif ($globalDebug) { |
|
2697 | + echo "Done\n"; |
|
2698 | + } |
|
2699 | + if ($globalDebug) { |
|
2700 | + echo "Owner New Zealand: Download..."; |
|
2701 | + } |
|
2307 | 2702 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
2308 | 2703 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
2309 | - if ($globalDebug) echo "Add to DB..."; |
|
2704 | + if ($globalDebug) { |
|
2705 | + echo "Add to DB..."; |
|
2706 | + } |
|
2310 | 2707 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
2311 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2708 | + } else { |
|
2709 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
2710 | + } |
|
2312 | 2711 | if ($error != '') { |
2313 | 2712 | return $error; |
2314 | - } elseif ($globalDebug) echo "Done\n"; |
|
2315 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
2713 | + } elseif ($globalDebug) { |
|
2714 | + echo "Done\n"; |
|
2715 | + } |
|
2716 | + if ($globalDebug) { |
|
2717 | + echo "Owner Papua New Guinea: Download..."; |
|
2718 | + } |
|
2316 | 2719 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
2317 | 2720 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
2318 | - if ($globalDebug) echo "Add to DB..."; |
|
2721 | + if ($globalDebug) { |
|
2722 | + echo "Add to DB..."; |
|
2723 | + } |
|
2319 | 2724 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
2320 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2725 | + } else { |
|
2726 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
2727 | + } |
|
2321 | 2728 | if ($error != '') { |
2322 | 2729 | return $error; |
2323 | - } elseif ($globalDebug) echo "Done\n"; |
|
2324 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
2730 | + } elseif ($globalDebug) { |
|
2731 | + echo "Done\n"; |
|
2732 | + } |
|
2733 | + if ($globalDebug) { |
|
2734 | + echo "Owner Slovakia: Download..."; |
|
2735 | + } |
|
2325 | 2736 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
2326 | 2737 | if (file_exists($tmp_dir.'owner_om.csv')) { |
2327 | - if ($globalDebug) echo "Add to DB..."; |
|
2738 | + if ($globalDebug) { |
|
2739 | + echo "Add to DB..."; |
|
2740 | + } |
|
2328 | 2741 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
2329 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2742 | + } else { |
|
2743 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
2744 | + } |
|
2330 | 2745 | if ($error != '') { |
2331 | 2746 | return $error; |
2332 | - } elseif ($globalDebug) echo "Done\n"; |
|
2333 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
2747 | + } elseif ($globalDebug) { |
|
2748 | + echo "Done\n"; |
|
2749 | + } |
|
2750 | + if ($globalDebug) { |
|
2751 | + echo "Owner Ecuador: Download..."; |
|
2752 | + } |
|
2334 | 2753 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
2335 | 2754 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
2336 | - if ($globalDebug) echo "Add to DB..."; |
|
2755 | + if ($globalDebug) { |
|
2756 | + echo "Add to DB..."; |
|
2757 | + } |
|
2337 | 2758 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
2338 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2759 | + } else { |
|
2760 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
2761 | + } |
|
2339 | 2762 | if ($error != '') { |
2340 | 2763 | return $error; |
2341 | - } elseif ($globalDebug) echo "Done\n"; |
|
2342 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
2764 | + } elseif ($globalDebug) { |
|
2765 | + echo "Done\n"; |
|
2766 | + } |
|
2767 | + if ($globalDebug) { |
|
2768 | + echo "Owner Iceland: Download..."; |
|
2769 | + } |
|
2343 | 2770 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
2344 | 2771 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
2345 | - if ($globalDebug) echo "Add to DB..."; |
|
2772 | + if ($globalDebug) { |
|
2773 | + echo "Add to DB..."; |
|
2774 | + } |
|
2346 | 2775 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
2347 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2776 | + } else { |
|
2777 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
2778 | + } |
|
2348 | 2779 | if ($error != '') { |
2349 | 2780 | return $error; |
2350 | - } elseif ($globalDebug) echo "Done\n"; |
|
2351 | - if ($globalDebug) echo "Owner Isle of Man: Download..."; |
|
2781 | + } elseif ($globalDebug) { |
|
2782 | + echo "Done\n"; |
|
2783 | + } |
|
2784 | + if ($globalDebug) { |
|
2785 | + echo "Owner Isle of Man: Download..."; |
|
2786 | + } |
|
2352 | 2787 | update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv'); |
2353 | 2788 | if (file_exists($tmp_dir.'owner_m.csv')) { |
2354 | - if ($globalDebug) echo "Add to DB..."; |
|
2789 | + if ($globalDebug) { |
|
2790 | + echo "Add to DB..."; |
|
2791 | + } |
|
2355 | 2792 | $error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M'); |
2356 | - } else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2793 | + } else { |
|
2794 | + $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed."; |
|
2795 | + } |
|
2357 | 2796 | if ($error != '') { |
2358 | 2797 | return $error; |
2359 | - } elseif ($globalDebug) echo "Done\n"; |
|
2798 | + } elseif ($globalDebug) { |
|
2799 | + echo "Done\n"; |
|
2800 | + } |
|
2360 | 2801 | if ($globalMasterSource) { |
2361 | - if ($globalDebug) echo "ModeS Netherlands: Download..."; |
|
2802 | + if ($globalDebug) { |
|
2803 | + echo "ModeS Netherlands: Download..."; |
|
2804 | + } |
|
2362 | 2805 | update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv'); |
2363 | 2806 | if (file_exists($tmp_dir.'owner_ph.csv')) { |
2364 | - if ($globalDebug) echo "Add to DB..."; |
|
2807 | + if ($globalDebug) { |
|
2808 | + echo "Add to DB..."; |
|
2809 | + } |
|
2365 | 2810 | $error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH'); |
2366 | - } else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2811 | + } else { |
|
2812 | + $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed."; |
|
2813 | + } |
|
2367 | 2814 | if ($error != '') { |
2368 | 2815 | return $error; |
2369 | - } elseif ($globalDebug) echo "Done\n"; |
|
2370 | - if ($globalDebug) echo "ModeS Denmark: Download..."; |
|
2816 | + } elseif ($globalDebug) { |
|
2817 | + echo "Done\n"; |
|
2818 | + } |
|
2819 | + if ($globalDebug) { |
|
2820 | + echo "ModeS Denmark: Download..."; |
|
2821 | + } |
|
2371 | 2822 | update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv'); |
2372 | 2823 | if (file_exists($tmp_dir.'owner_oy.csv')) { |
2373 | - if ($globalDebug) echo "Add to DB..."; |
|
2824 | + if ($globalDebug) { |
|
2825 | + echo "Add to DB..."; |
|
2826 | + } |
|
2374 | 2827 | $error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY'); |
2375 | - } else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2828 | + } else { |
|
2829 | + $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed."; |
|
2830 | + } |
|
2376 | 2831 | if ($error != '') { |
2377 | 2832 | return $error; |
2378 | - } elseif ($globalDebug) echo "Done\n"; |
|
2379 | - } elseif ($globalDebug) echo "Done\n"; |
|
2833 | + } elseif ($globalDebug) { |
|
2834 | + echo "Done\n"; |
|
2835 | + } |
|
2836 | + } elseif ($globalDebug) { |
|
2837 | + echo "Done\n"; |
|
2838 | + } |
|
2380 | 2839 | return ''; |
2381 | 2840 | } |
2382 | 2841 | |
2383 | 2842 | public static function update_translation() { |
2384 | 2843 | global $tmp_dir, $globalDebug; |
2385 | 2844 | $error = ''; |
2386 | - if ($globalDebug) echo "Translation : Download..."; |
|
2845 | + if ($globalDebug) { |
|
2846 | + echo "Translation : Download..."; |
|
2847 | + } |
|
2387 | 2848 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
2388 | 2849 | if (file_exists($tmp_dir.'translation.zip')) { |
2389 | - if ($globalDebug) echo "Unzip..."; |
|
2850 | + if ($globalDebug) { |
|
2851 | + echo "Unzip..."; |
|
2852 | + } |
|
2390 | 2853 | update_db::unzip($tmp_dir.'translation.zip'); |
2391 | - if ($globalDebug) echo "Add to DB..."; |
|
2854 | + if ($globalDebug) { |
|
2855 | + echo "Add to DB..."; |
|
2856 | + } |
|
2392 | 2857 | $error = update_db::translation(); |
2393 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2858 | + } else { |
|
2859 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
2860 | + } |
|
2394 | 2861 | if ($error != '') { |
2395 | 2862 | return $error; |
2396 | - } elseif ($globalDebug) echo "Done\n"; |
|
2863 | + } elseif ($globalDebug) { |
|
2864 | + echo "Done\n"; |
|
2865 | + } |
|
2397 | 2866 | return ''; |
2398 | 2867 | } |
2399 | 2868 | |
2400 | 2869 | public static function update_translation_fam() { |
2401 | 2870 | global $tmp_dir, $globalDebug; |
2402 | 2871 | $error = ''; |
2403 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
2872 | + if ($globalDebug) { |
|
2873 | + echo "Translation from FlightAirMap website : Download..."; |
|
2874 | + } |
|
2404 | 2875 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
2405 | 2876 | update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5'); |
2406 | 2877 | if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) { |
2407 | 2878 | $translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5')); |
2408 | 2879 | $translation_md5 = $translation_md5_file[0]; |
2409 | 2880 | if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) { |
2410 | - if ($globalDebug) echo "Gunzip..."; |
|
2881 | + if ($globalDebug) { |
|
2882 | + echo "Gunzip..."; |
|
2883 | + } |
|
2411 | 2884 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
2412 | - if ($globalDebug) echo "Add to DB..."; |
|
2885 | + if ($globalDebug) { |
|
2886 | + echo "Add to DB..."; |
|
2887 | + } |
|
2413 | 2888 | $error = update_db::translation_fam(); |
2414 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
2415 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2889 | + } else { |
|
2890 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed."; |
|
2891 | + } |
|
2892 | + } else { |
|
2893 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
2894 | + } |
|
2416 | 2895 | if ($error != '') { |
2417 | 2896 | return $error; |
2418 | - } elseif ($globalDebug) echo "Done\n"; |
|
2897 | + } elseif ($globalDebug) { |
|
2898 | + echo "Done\n"; |
|
2899 | + } |
|
2419 | 2900 | return ''; |
2420 | 2901 | } |
2421 | 2902 | public static function update_ModeS_fam() { |
2422 | 2903 | global $tmp_dir, $globalDebug; |
2423 | 2904 | $error = ''; |
2424 | - if ($globalDebug) echo "ModeS from FlightAirMap website : Download..."; |
|
2905 | + if ($globalDebug) { |
|
2906 | + echo "ModeS from FlightAirMap website : Download..."; |
|
2907 | + } |
|
2425 | 2908 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz'); |
2426 | 2909 | update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5'); |
2427 | 2910 | if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) { |
2428 | 2911 | $modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5')); |
2429 | 2912 | $modes_md5 = $modes_md5_file[0]; |
2430 | 2913 | if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) { |
2431 | - if ($globalDebug) echo "Gunzip..."; |
|
2914 | + if ($globalDebug) { |
|
2915 | + echo "Gunzip..."; |
|
2916 | + } |
|
2432 | 2917 | update_db::gunzip($tmp_dir.'modes.tsv.gz'); |
2433 | - if ($globalDebug) echo "Add to DB..."; |
|
2918 | + if ($globalDebug) { |
|
2919 | + echo "Add to DB..."; |
|
2920 | + } |
|
2434 | 2921 | $error = update_db::modes_fam(); |
2435 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
2436 | - } else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2922 | + } else { |
|
2923 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed."; |
|
2924 | + } |
|
2925 | + } else { |
|
2926 | + $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed."; |
|
2927 | + } |
|
2437 | 2928 | if ($error != '') { |
2438 | 2929 | return $error; |
2439 | - } elseif ($globalDebug) echo "Done\n"; |
|
2930 | + } elseif ($globalDebug) { |
|
2931 | + echo "Done\n"; |
|
2932 | + } |
|
2440 | 2933 | return ''; |
2441 | 2934 | } |
2442 | 2935 | |
2443 | 2936 | public static function update_airlines_fam() { |
2444 | 2937 | global $tmp_dir, $globalDebug; |
2445 | 2938 | $error = ''; |
2446 | - if ($globalDebug) echo "Airlines from FlightAirMap website : Download..."; |
|
2939 | + if ($globalDebug) { |
|
2940 | + echo "Airlines from FlightAirMap website : Download..."; |
|
2941 | + } |
|
2447 | 2942 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5'); |
2448 | 2943 | if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) { |
2449 | 2944 | $airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5')); |
@@ -2452,26 +2947,42 @@ discard block |
||
2452 | 2947 | update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz'); |
2453 | 2948 | if (file_exists($tmp_dir.'airlines.tsv.gz')) { |
2454 | 2949 | if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) { |
2455 | - if ($globalDebug) echo "Gunzip..."; |
|
2950 | + if ($globalDebug) { |
|
2951 | + echo "Gunzip..."; |
|
2952 | + } |
|
2456 | 2953 | update_db::gunzip($tmp_dir.'airlines.tsv.gz'); |
2457 | - if ($globalDebug) echo "Add to DB..."; |
|
2954 | + if ($globalDebug) { |
|
2955 | + echo "Add to DB..."; |
|
2956 | + } |
|
2458 | 2957 | $error = update_db::airlines_fam(); |
2459 | 2958 | update_db::insert_airlines_version($airlines_md5); |
2460 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
2461 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
2462 | - } elseif ($globalDebug) echo "No update."; |
|
2463 | - } else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
2959 | + } else { |
|
2960 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed."; |
|
2961 | + } |
|
2962 | + } else { |
|
2963 | + $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed."; |
|
2964 | + } |
|
2965 | + } elseif ($globalDebug) { |
|
2966 | + echo "No update."; |
|
2967 | + } |
|
2968 | + } else { |
|
2969 | + $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed."; |
|
2970 | + } |
|
2464 | 2971 | if ($error != '') { |
2465 | 2972 | return $error; |
2466 | 2973 | } else { |
2467 | - if ($globalDebug) echo "Done\n"; |
|
2974 | + if ($globalDebug) { |
|
2975 | + echo "Done\n"; |
|
2976 | + } |
|
2468 | 2977 | } |
2469 | 2978 | return ''; |
2470 | 2979 | } |
2471 | 2980 | |
2472 | 2981 | public static function update_owner_fam() { |
2473 | 2982 | global $tmp_dir, $globalDebug, $globalOwner; |
2474 | - if ($globalDebug) echo "owner from FlightAirMap website : Download..."; |
|
2983 | + if ($globalDebug) { |
|
2984 | + echo "owner from FlightAirMap website : Download..."; |
|
2985 | + } |
|
2475 | 2986 | $error = ''; |
2476 | 2987 | if ($globalOwner === TRUE) { |
2477 | 2988 | update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz'); |
@@ -2484,35 +2995,57 @@ discard block |
||
2484 | 2995 | $owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5')); |
2485 | 2996 | $owners_md5 = $owners_md5_file[0]; |
2486 | 2997 | if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) { |
2487 | - if ($globalDebug) echo "Gunzip..."; |
|
2998 | + if ($globalDebug) { |
|
2999 | + echo "Gunzip..."; |
|
3000 | + } |
|
2488 | 3001 | update_db::gunzip($tmp_dir.'owners.tsv.gz'); |
2489 | - if ($globalDebug) echo "Add to DB..."; |
|
3002 | + if ($globalDebug) { |
|
3003 | + echo "Add to DB..."; |
|
3004 | + } |
|
2490 | 3005 | $error = update_db::owner_fam(); |
2491 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
2492 | - } else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
3006 | + } else { |
|
3007 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed."; |
|
3008 | + } |
|
3009 | + } else { |
|
3010 | + $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed."; |
|
3011 | + } |
|
2493 | 3012 | if ($error != '') { |
2494 | 3013 | return $error; |
2495 | - } elseif ($globalDebug) echo "Done\n"; |
|
3014 | + } elseif ($globalDebug) { |
|
3015 | + echo "Done\n"; |
|
3016 | + } |
|
2496 | 3017 | return ''; |
2497 | 3018 | } |
2498 | 3019 | public static function update_routes_fam() { |
2499 | 3020 | global $tmp_dir, $globalDebug; |
2500 | - if ($globalDebug) echo "Routes from FlightAirMap website : Download..."; |
|
3021 | + if ($globalDebug) { |
|
3022 | + echo "Routes from FlightAirMap website : Download..."; |
|
3023 | + } |
|
2501 | 3024 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz'); |
2502 | 3025 | update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5'); |
2503 | 3026 | if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) { |
2504 | 3027 | $routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5')); |
2505 | 3028 | $routes_md5 = $routes_md5_file[0]; |
2506 | 3029 | if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) { |
2507 | - if ($globalDebug) echo "Gunzip..."; |
|
3030 | + if ($globalDebug) { |
|
3031 | + echo "Gunzip..."; |
|
3032 | + } |
|
2508 | 3033 | update_db::gunzip($tmp_dir.'routes.tsv.gz'); |
2509 | - if ($globalDebug) echo "Add to DB..."; |
|
3034 | + if ($globalDebug) { |
|
3035 | + echo "Add to DB..."; |
|
3036 | + } |
|
2510 | 3037 | $error = update_db::routes_fam(); |
2511 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
2512 | - } else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
3038 | + } else { |
|
3039 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed."; |
|
3040 | + } |
|
3041 | + } else { |
|
3042 | + $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed."; |
|
3043 | + } |
|
2513 | 3044 | if ($error != '') { |
2514 | 3045 | return $error; |
2515 | - } elseif ($globalDebug) echo "Done\n"; |
|
3046 | + } elseif ($globalDebug) { |
|
3047 | + echo "Done\n"; |
|
3048 | + } |
|
2516 | 3049 | return ''; |
2517 | 3050 | } |
2518 | 3051 | public static function update_marine_identity_fam() { |
@@ -2522,21 +3055,33 @@ discard block |
||
2522 | 3055 | $marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5')); |
2523 | 3056 | $marine_identity_md5 = $marine_identity_md5_file[0]; |
2524 | 3057 | if (!update_db::check_marine_identity_version($marine_identity_md5)) { |
2525 | - if ($globalDebug) echo "Marine identity from FlightAirMap website : Download..."; |
|
3058 | + if ($globalDebug) { |
|
3059 | + echo "Marine identity from FlightAirMap website : Download..."; |
|
3060 | + } |
|
2526 | 3061 | update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz'); |
2527 | 3062 | if (file_exists($tmp_dir.'marine_identity.tsv.gz')) { |
2528 | 3063 | if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) { |
2529 | - if ($globalDebug) echo "Gunzip..."; |
|
3064 | + if ($globalDebug) { |
|
3065 | + echo "Gunzip..."; |
|
3066 | + } |
|
2530 | 3067 | update_db::gunzip($tmp_dir.'marine_identity.tsv.gz'); |
2531 | - if ($globalDebug) echo "Add to DB..."; |
|
3068 | + if ($globalDebug) { |
|
3069 | + echo "Add to DB..."; |
|
3070 | + } |
|
2532 | 3071 | $error = update_db::marine_identity_fam(); |
2533 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
2534 | - } else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
3072 | + } else { |
|
3073 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed."; |
|
3074 | + } |
|
3075 | + } else { |
|
3076 | + $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed."; |
|
3077 | + } |
|
2535 | 3078 | if ($error != '') { |
2536 | 3079 | return $error; |
2537 | 3080 | } else { |
2538 | 3081 | update_db::insert_marine_identity_version($marine_identity_md5); |
2539 | - if ($globalDebug) echo "Done\n"; |
|
3082 | + if ($globalDebug) { |
|
3083 | + echo "Done\n"; |
|
3084 | + } |
|
2540 | 3085 | } |
2541 | 3086 | } |
2542 | 3087 | } |
@@ -2550,21 +3095,33 @@ discard block |
||
2550 | 3095 | $satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5')); |
2551 | 3096 | $satellite_md5 = $satellite_md5_file[0]; |
2552 | 3097 | if (!update_db::check_satellite_version($satellite_md5)) { |
2553 | - if ($globalDebug) echo "Satellite from FlightAirMap website : Download..."; |
|
3098 | + if ($globalDebug) { |
|
3099 | + echo "Satellite from FlightAirMap website : Download..."; |
|
3100 | + } |
|
2554 | 3101 | update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz'); |
2555 | 3102 | if (file_exists($tmp_dir.'satellite.tsv.gz')) { |
2556 | 3103 | if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) { |
2557 | - if ($globalDebug) echo "Gunzip..."; |
|
3104 | + if ($globalDebug) { |
|
3105 | + echo "Gunzip..."; |
|
3106 | + } |
|
2558 | 3107 | update_db::gunzip($tmp_dir.'satellite.tsv.gz'); |
2559 | - if ($globalDebug) echo "Add to DB..."; |
|
3108 | + if ($globalDebug) { |
|
3109 | + echo "Add to DB..."; |
|
3110 | + } |
|
2560 | 3111 | $error = update_db::satellite_fam(); |
2561 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
2562 | - } else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
3112 | + } else { |
|
3113 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed."; |
|
3114 | + } |
|
3115 | + } else { |
|
3116 | + $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed."; |
|
3117 | + } |
|
2563 | 3118 | if ($error != '') { |
2564 | 3119 | return $error; |
2565 | 3120 | } else { |
2566 | 3121 | update_db::insert_satellite_version($satellite_md5); |
2567 | - if ($globalDebug) echo "Done\n"; |
|
3122 | + if ($globalDebug) { |
|
3123 | + echo "Done\n"; |
|
3124 | + } |
|
2568 | 3125 | } |
2569 | 3126 | } |
2570 | 3127 | } |
@@ -2572,17 +3129,25 @@ discard block |
||
2572 | 3129 | } |
2573 | 3130 | public static function update_banned_fam() { |
2574 | 3131 | global $tmp_dir, $globalDebug; |
2575 | - if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
3132 | + if ($globalDebug) { |
|
3133 | + echo "Banned airlines in Europe from FlightAirMap website : Download..."; |
|
3134 | + } |
|
2576 | 3135 | update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv'); |
2577 | 3136 | if (file_exists($tmp_dir.'ban_eu.csv')) { |
2578 | 3137 | //if ($globalDebug) echo "Gunzip..."; |
2579 | 3138 | //update_db::gunzip($tmp_dir.'ban_ue.csv'); |
2580 | - if ($globalDebug) echo "Add to DB..."; |
|
3139 | + if ($globalDebug) { |
|
3140 | + echo "Add to DB..."; |
|
3141 | + } |
|
2581 | 3142 | $error = update_db::banned_fam(); |
2582 | - } else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
3143 | + } else { |
|
3144 | + $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed."; |
|
3145 | + } |
|
2583 | 3146 | if ($error != '') { |
2584 | 3147 | return $error; |
2585 | - } elseif ($globalDebug) echo "Done\n"; |
|
3148 | + } elseif ($globalDebug) { |
|
3149 | + echo "Done\n"; |
|
3150 | + } |
|
2586 | 3151 | return ''; |
2587 | 3152 | } |
2588 | 3153 | |
@@ -2590,7 +3155,9 @@ discard block |
||
2590 | 3155 | global $tmp_dir, $globalDebug, $globalDBdriver; |
2591 | 3156 | include_once('class.create_db.php'); |
2592 | 3157 | $error = ''; |
2593 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
3158 | + if ($globalDebug) { |
|
3159 | + echo "Airspace from FlightAirMap website : Download..."; |
|
3160 | + } |
|
2594 | 3161 | if ($globalDBdriver == 'mysql') { |
2595 | 3162 | update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
2596 | 3163 | } else { |
@@ -2607,9 +3174,13 @@ discard block |
||
2607 | 3174 | } |
2608 | 3175 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
2609 | 3176 | if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) { |
2610 | - if ($globalDebug) echo "Gunzip..."; |
|
3177 | + if ($globalDebug) { |
|
3178 | + echo "Gunzip..."; |
|
3179 | + } |
|
2611 | 3180 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
2612 | - if ($globalDebug) echo "Add to DB..."; |
|
3181 | + if ($globalDebug) { |
|
3182 | + echo "Add to DB..."; |
|
3183 | + } |
|
2613 | 3184 | $Connection = new Connection(); |
2614 | 3185 | if ($Connection->tableExists('airspace')) { |
2615 | 3186 | $query = 'DROP TABLE airspace'; |
@@ -2622,20 +3193,30 @@ discard block |
||
2622 | 3193 | } |
2623 | 3194 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
2624 | 3195 | update_db::insert_airspace_version($airspace_md5); |
2625 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
2626 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
3196 | + } else { |
|
3197 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed."; |
|
3198 | + } |
|
3199 | + } else { |
|
3200 | + $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed."; |
|
3201 | + } |
|
2627 | 3202 | } |
2628 | - } else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
3203 | + } else { |
|
3204 | + $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed."; |
|
3205 | + } |
|
2629 | 3206 | if ($error != '') { |
2630 | 3207 | return $error; |
2631 | - } elseif ($globalDebug) echo "Done\n"; |
|
3208 | + } elseif ($globalDebug) { |
|
3209 | + echo "Done\n"; |
|
3210 | + } |
|
2632 | 3211 | return ''; |
2633 | 3212 | } |
2634 | 3213 | |
2635 | 3214 | public static function update_geoid_fam() { |
2636 | 3215 | global $tmp_dir, $globalDebug, $globalGeoidSource; |
2637 | 3216 | $error = ''; |
2638 | - if ($globalDebug) echo "Geoid from FlightAirMap website : Download..."; |
|
3217 | + if ($globalDebug) { |
|
3218 | + echo "Geoid from FlightAirMap website : Download..."; |
|
3219 | + } |
|
2639 | 3220 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'); |
2640 | 3221 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) { |
2641 | 3222 | $geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')); |
@@ -2644,76 +3225,116 @@ discard block |
||
2644 | 3225 | update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz'); |
2645 | 3226 | if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) { |
2646 | 3227 | if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) { |
2647 | - if ($globalDebug) echo "Gunzip..."; |
|
3228 | + if ($globalDebug) { |
|
3229 | + echo "Gunzip..."; |
|
3230 | + } |
|
2648 | 3231 | update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm'); |
2649 | 3232 | if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) { |
2650 | 3233 | update_db::insert_geoid_version($geoid_md5); |
2651 | 3234 | } |
2652 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
2653 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
3235 | + } else { |
|
3236 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed."; |
|
3237 | + } |
|
3238 | + } else { |
|
3239 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed."; |
|
3240 | + } |
|
2654 | 3241 | } |
2655 | - } else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
3242 | + } else { |
|
3243 | + $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed."; |
|
3244 | + } |
|
2656 | 3245 | if ($error != '') { |
2657 | 3246 | return $error; |
2658 | - } elseif ($globalDebug) echo "Done\n"; |
|
3247 | + } elseif ($globalDebug) { |
|
3248 | + echo "Done\n"; |
|
3249 | + } |
|
2659 | 3250 | return ''; |
2660 | 3251 | } |
2661 | 3252 | |
2662 | 3253 | public static function update_tle() { |
2663 | 3254 | global $tmp_dir, $globalDebug; |
2664 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
3255 | + if ($globalDebug) { |
|
3256 | + echo "Download TLE : Download..."; |
|
3257 | + } |
|
2665 | 3258 | $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', |
2666 | 3259 | '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', |
2667 | 3260 | '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'); |
2668 | 3261 | foreach ($alltle as $filename) { |
2669 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
3262 | + if ($globalDebug) { |
|
3263 | + echo "downloading ".$filename.'...'; |
|
3264 | + } |
|
2670 | 3265 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
2671 | 3266 | if (file_exists($tmp_dir.$filename)) { |
2672 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
3267 | + if ($globalDebug) { |
|
3268 | + echo "Add to DB ".$filename."..."; |
|
3269 | + } |
|
2673 | 3270 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
2674 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
3271 | + } else { |
|
3272 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
3273 | + } |
|
2675 | 3274 | if ($error != '') { |
2676 | 3275 | echo $error."\n"; |
2677 | - } elseif ($globalDebug) echo "Done\n"; |
|
3276 | + } elseif ($globalDebug) { |
|
3277 | + echo "Done\n"; |
|
3278 | + } |
|
2678 | 3279 | } |
2679 | 3280 | return ''; |
2680 | 3281 | } |
2681 | 3282 | |
2682 | 3283 | public static function update_ucsdb() { |
2683 | 3284 | global $tmp_dir, $globalDebug; |
2684 | - if ($globalDebug) echo "Download UCS DB : Download..."; |
|
3285 | + if ($globalDebug) { |
|
3286 | + echo "Download UCS DB : Download..."; |
|
3287 | + } |
|
2685 | 3288 | 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'); |
2686 | 3289 | if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) { |
2687 | - if ($globalDebug) echo "Add to DB..."; |
|
3290 | + if ($globalDebug) { |
|
3291 | + echo "Add to DB..."; |
|
3292 | + } |
|
2688 | 3293 | $error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'); |
2689 | - } else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed."; |
|
3294 | + } else { |
|
3295 | + $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed."; |
|
3296 | + } |
|
2690 | 3297 | if ($error != '') { |
2691 | 3298 | echo $error."\n"; |
2692 | - } elseif ($globalDebug) echo "Done\n"; |
|
3299 | + } elseif ($globalDebug) { |
|
3300 | + echo "Done\n"; |
|
3301 | + } |
|
2693 | 3302 | return ''; |
2694 | 3303 | } |
2695 | 3304 | |
2696 | 3305 | public static function update_celestrak() { |
2697 | 3306 | global $tmp_dir, $globalDebug; |
2698 | - if ($globalDebug) echo "Download Celestrak DB : Download..."; |
|
3307 | + if ($globalDebug) { |
|
3308 | + echo "Download Celestrak DB : Download..."; |
|
3309 | + } |
|
2699 | 3310 | update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt'); |
2700 | 3311 | if (file_exists($tmp_dir.'satcat.txt')) { |
2701 | - if ($globalDebug) echo "Add to DB..."; |
|
3312 | + if ($globalDebug) { |
|
3313 | + echo "Add to DB..."; |
|
3314 | + } |
|
2702 | 3315 | $error = update_db::satellite_celestrak($tmp_dir.'satcat.txt'); |
2703 | - } else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
3316 | + } else { |
|
3317 | + $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed."; |
|
3318 | + } |
|
2704 | 3319 | if ($error != '') { |
2705 | 3320 | echo $error."\n"; |
2706 | - } elseif ($globalDebug) echo "Done\n"; |
|
3321 | + } elseif ($globalDebug) { |
|
3322 | + echo "Done\n"; |
|
3323 | + } |
|
2707 | 3324 | return ''; |
2708 | 3325 | } |
2709 | 3326 | |
2710 | 3327 | public static function update_models() { |
2711 | 3328 | global $tmp_dir, $globalDebug; |
2712 | 3329 | $error = ''; |
2713 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
3330 | + if ($globalDebug) { |
|
3331 | + echo "Models from FlightAirMap website : Download..."; |
|
3332 | + } |
|
2714 | 3333 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
2715 | 3334 | if (file_exists($tmp_dir.'models.md5sum')) { |
2716 | - if ($globalDebug) echo "Check files...\n"; |
|
3335 | + if ($globalDebug) { |
|
3336 | + echo "Check files...\n"; |
|
3337 | + } |
|
2717 | 3338 | $newmodelsdb = array(); |
2718 | 3339 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
2719 | 3340 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2732,19 +3353,29 @@ discard block |
||
2732 | 3353 | } |
2733 | 3354 | $diff = array_diff($newmodelsdb,$modelsdb); |
2734 | 3355 | foreach ($diff as $key => $value) { |
2735 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3356 | + if ($globalDebug) { |
|
3357 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3358 | + } |
|
2736 | 3359 | update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
2737 | 3360 | |
2738 | 3361 | } |
2739 | 3362 | update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
2740 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3363 | + } else { |
|
3364 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3365 | + } |
|
2741 | 3366 | if ($error != '') { |
2742 | 3367 | return $error; |
2743 | - } elseif ($globalDebug) echo "Done\n"; |
|
2744 | - if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
3368 | + } elseif ($globalDebug) { |
|
3369 | + echo "Done\n"; |
|
3370 | + } |
|
3371 | + if ($globalDebug) { |
|
3372 | + echo "glTF 2.0 Models from FlightAirMap website : Download..."; |
|
3373 | + } |
|
2745 | 3374 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum'); |
2746 | 3375 | if (file_exists($tmp_dir.'modelsgltf2.md5sum')) { |
2747 | - if ($globalDebug) echo "Check files...\n"; |
|
3376 | + if ($globalDebug) { |
|
3377 | + echo "Check files...\n"; |
|
3378 | + } |
|
2748 | 3379 | $newmodelsdb = array(); |
2749 | 3380 | if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) { |
2750 | 3381 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2763,25 +3394,35 @@ discard block |
||
2763 | 3394 | } |
2764 | 3395 | $diff = array_diff($newmodelsdb,$modelsdb); |
2765 | 3396 | foreach ($diff as $key => $value) { |
2766 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
3397 | + if ($globalDebug) { |
|
3398 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
3399 | + } |
|
2767 | 3400 | update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key); |
2768 | 3401 | |
2769 | 3402 | } |
2770 | 3403 | update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum'); |
2771 | - } else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
3404 | + } else { |
|
3405 | + $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed."; |
|
3406 | + } |
|
2772 | 3407 | if ($error != '') { |
2773 | 3408 | return $error; |
2774 | - } elseif ($globalDebug) echo "Done\n"; |
|
3409 | + } elseif ($globalDebug) { |
|
3410 | + echo "Done\n"; |
|
3411 | + } |
|
2775 | 3412 | return ''; |
2776 | 3413 | } |
2777 | 3414 | |
2778 | 3415 | public static function update_liveries() { |
2779 | 3416 | global $tmp_dir, $globalDebug; |
2780 | 3417 | $error = ''; |
2781 | - if ($globalDebug) echo "Liveries from FlightAirMap website : Download..."; |
|
3418 | + if ($globalDebug) { |
|
3419 | + echo "Liveries from FlightAirMap website : Download..."; |
|
3420 | + } |
|
2782 | 3421 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum'); |
2783 | 3422 | if (file_exists($tmp_dir.'liveries.md5sum')) { |
2784 | - if ($globalDebug) echo "Check files...\n"; |
|
3423 | + if ($globalDebug) { |
|
3424 | + echo "Check files...\n"; |
|
3425 | + } |
|
2785 | 3426 | $newmodelsdb = array(); |
2786 | 3427 | if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) { |
2787 | 3428 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2800,25 +3441,35 @@ discard block |
||
2800 | 3441 | } |
2801 | 3442 | $diff = array_diff($newmodelsdb,$modelsdb); |
2802 | 3443 | foreach ($diff as $key => $value) { |
2803 | - if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n"; |
|
3444 | + if ($globalDebug) { |
|
3445 | + echo 'Downloading liveries '.$key.' ...'."\n"; |
|
3446 | + } |
|
2804 | 3447 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key); |
2805 | 3448 | |
2806 | 3449 | } |
2807 | 3450 | update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum'); |
2808 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3451 | + } else { |
|
3452 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3453 | + } |
|
2809 | 3454 | if ($error != '') { |
2810 | 3455 | return $error; |
2811 | - } elseif ($globalDebug) echo "Done\n"; |
|
3456 | + } elseif ($globalDebug) { |
|
3457 | + echo "Done\n"; |
|
3458 | + } |
|
2812 | 3459 | return ''; |
2813 | 3460 | } |
2814 | 3461 | |
2815 | 3462 | public static function update_space_models() { |
2816 | 3463 | global $tmp_dir, $globalDebug; |
2817 | 3464 | $error = ''; |
2818 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
3465 | + if ($globalDebug) { |
|
3466 | + echo "Space models from FlightAirMap website : Download..."; |
|
3467 | + } |
|
2819 | 3468 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
2820 | 3469 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
2821 | - if ($globalDebug) echo "Check files...\n"; |
|
3470 | + if ($globalDebug) { |
|
3471 | + echo "Check files...\n"; |
|
3472 | + } |
|
2822 | 3473 | $newmodelsdb = array(); |
2823 | 3474 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
2824 | 3475 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2837,25 +3488,35 @@ discard block |
||
2837 | 3488 | } |
2838 | 3489 | $diff = array_diff($newmodelsdb,$modelsdb); |
2839 | 3490 | foreach ($diff as $key => $value) { |
2840 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
3491 | + if ($globalDebug) { |
|
3492 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
3493 | + } |
|
2841 | 3494 | update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
2842 | 3495 | |
2843 | 3496 | } |
2844 | 3497 | update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
2845 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3498 | + } else { |
|
3499 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3500 | + } |
|
2846 | 3501 | if ($error != '') { |
2847 | 3502 | return $error; |
2848 | - } elseif ($globalDebug) echo "Done\n"; |
|
3503 | + } elseif ($globalDebug) { |
|
3504 | + echo "Done\n"; |
|
3505 | + } |
|
2849 | 3506 | return ''; |
2850 | 3507 | } |
2851 | 3508 | |
2852 | 3509 | public static function update_vehicules_models() { |
2853 | 3510 | global $tmp_dir, $globalDebug; |
2854 | 3511 | $error = ''; |
2855 | - if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download..."; |
|
3512 | + if ($globalDebug) { |
|
3513 | + echo "Vehicules models from FlightAirMap website : Download..."; |
|
3514 | + } |
|
2856 | 3515 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum'); |
2857 | 3516 | if (file_exists($tmp_dir.'vehicules_models.md5sum')) { |
2858 | - if ($globalDebug) echo "Check files...\n"; |
|
3517 | + if ($globalDebug) { |
|
3518 | + echo "Check files...\n"; |
|
3519 | + } |
|
2859 | 3520 | $newmodelsdb = array(); |
2860 | 3521 | if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) { |
2861 | 3522 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -2874,15 +3535,21 @@ discard block |
||
2874 | 3535 | } |
2875 | 3536 | $diff = array_diff($newmodelsdb,$modelsdb); |
2876 | 3537 | foreach ($diff as $key => $value) { |
2877 | - if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
3538 | + if ($globalDebug) { |
|
3539 | + echo 'Downloading vehicules model '.$key.' ...'."\n"; |
|
3540 | + } |
|
2878 | 3541 | update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key); |
2879 | 3542 | |
2880 | 3543 | } |
2881 | 3544 | update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum'); |
2882 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3545 | + } else { |
|
3546 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
3547 | + } |
|
2883 | 3548 | if ($error != '') { |
2884 | 3549 | return $error; |
2885 | - } elseif ($globalDebug) echo "Done\n"; |
|
3550 | + } elseif ($globalDebug) { |
|
3551 | + echo "Done\n"; |
|
3552 | + } |
|
2886 | 3553 | return ''; |
2887 | 3554 | } |
2888 | 3555 | |
@@ -2925,7 +3592,9 @@ discard block |
||
2925 | 3592 | } |
2926 | 3593 | |
2927 | 3594 | $error = ''; |
2928 | - if ($globalDebug) echo "Notam : Download..."; |
|
3595 | + if ($globalDebug) { |
|
3596 | + echo "Notam : Download..."; |
|
3597 | + } |
|
2929 | 3598 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
2930 | 3599 | if (file_exists($tmp_dir.'notam.rss')) { |
2931 | 3600 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -2940,14 +3609,30 @@ discard block |
||
2940 | 3609 | $data['fir'] = $q[0]; |
2941 | 3610 | $data['code'] = $q[1]; |
2942 | 3611 | $ifrvfr = $q[2]; |
2943 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
2944 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
2945 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
2946 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
2947 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
2948 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
2949 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
2950 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
3612 | + if ($ifrvfr == 'IV') { |
|
3613 | + $data['rules'] = 'IFR/VFR'; |
|
3614 | + } |
|
3615 | + if ($ifrvfr == 'I') { |
|
3616 | + $data['rules'] = 'IFR'; |
|
3617 | + } |
|
3618 | + if ($ifrvfr == 'V') { |
|
3619 | + $data['rules'] = 'VFR'; |
|
3620 | + } |
|
3621 | + if ($q[4] == 'A') { |
|
3622 | + $data['scope'] = 'Airport warning'; |
|
3623 | + } |
|
3624 | + if ($q[4] == 'E') { |
|
3625 | + $data['scope'] = 'Enroute warning'; |
|
3626 | + } |
|
3627 | + if ($q[4] == 'W') { |
|
3628 | + $data['scope'] = 'Navigation warning'; |
|
3629 | + } |
|
3630 | + if ($q[4] == 'AE') { |
|
3631 | + $data['scope'] = 'Airport/Enroute warning'; |
|
3632 | + } |
|
3633 | + if ($q[4] == 'AW') { |
|
3634 | + $data['scope'] = 'Airport/Navigation warning'; |
|
3635 | + } |
|
2951 | 3636 | //$data['scope'] = $q[4]; |
2952 | 3637 | $data['lower_limit'] = $q[5]; |
2953 | 3638 | $data['upper_limit'] = $q[6]; |
@@ -2955,8 +3640,12 @@ discard block |
||
2955 | 3640 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
2956 | 3641 | $latitude = $Common->convertDec($las,'latitude'); |
2957 | 3642 | $longitude = $Common->convertDec($lns,'longitude'); |
2958 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
2959 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
3643 | + if ($lac == 'S') { |
|
3644 | + $latitude = '-'.$latitude; |
|
3645 | + } |
|
3646 | + if ($lnc == 'W') { |
|
3647 | + $longitude = '-'.$longitude; |
|
3648 | + } |
|
2960 | 3649 | $data['center_latitude'] = $latitude; |
2961 | 3650 | $data['center_longitude'] = $longitude; |
2962 | 3651 | $data['radius'] = intval($radius); |
@@ -2986,10 +3675,14 @@ discard block |
||
2986 | 3675 | $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']); |
2987 | 3676 | unset($data); |
2988 | 3677 | } |
2989 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
3678 | + } else { |
|
3679 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
3680 | + } |
|
2990 | 3681 | if ($error != '') { |
2991 | 3682 | return $error; |
2992 | - } elseif ($globalDebug) echo "Done\n"; |
|
3683 | + } elseif ($globalDebug) { |
|
3684 | + echo "Done\n"; |
|
3685 | + } |
|
2993 | 3686 | return ''; |
2994 | 3687 | } |
2995 | 3688 | |
@@ -3014,7 +3707,9 @@ discard block |
||
3014 | 3707 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
3015 | 3708 | $airspace_json = json_decode($airspace_lst,true); |
3016 | 3709 | foreach ($airspace_json['records'] as $airspace) { |
3017 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
3710 | + if ($globalDebug) { |
|
3711 | + echo $airspace['name']."...\n"; |
|
3712 | + } |
|
3018 | 3713 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
3019 | 3714 | if (file_exists($tmp_dir.$airspace['name'])) { |
3020 | 3715 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -3058,8 +3753,11 @@ discard block |
||
3058 | 3753 | return "error : ".$e->getMessage(); |
3059 | 3754 | } |
3060 | 3755 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3061 | - if ($row['nb'] > 0) return false; |
|
3062 | - else return true; |
|
3756 | + if ($row['nb'] > 0) { |
|
3757 | + return false; |
|
3758 | + } else { |
|
3759 | + return true; |
|
3760 | + } |
|
3063 | 3761 | } |
3064 | 3762 | |
3065 | 3763 | public static function insert_last_update() { |
@@ -3084,8 +3782,11 @@ discard block |
||
3084 | 3782 | return "error : ".$e->getMessage(); |
3085 | 3783 | } |
3086 | 3784 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3087 | - if ($row['nb'] > 0) return true; |
|
3088 | - else return false; |
|
3785 | + if ($row['nb'] > 0) { |
|
3786 | + return true; |
|
3787 | + } else { |
|
3788 | + return false; |
|
3789 | + } |
|
3089 | 3790 | } |
3090 | 3791 | |
3091 | 3792 | public static function check_geoid_version($version) { |
@@ -3098,8 +3799,11 @@ discard block |
||
3098 | 3799 | return "error : ".$e->getMessage(); |
3099 | 3800 | } |
3100 | 3801 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3101 | - if ($row['nb'] > 0) return true; |
|
3102 | - else return false; |
|
3802 | + if ($row['nb'] > 0) { |
|
3803 | + return true; |
|
3804 | + } else { |
|
3805 | + return false; |
|
3806 | + } |
|
3103 | 3807 | } |
3104 | 3808 | |
3105 | 3809 | public static function check_marine_identity_version($version) { |
@@ -3112,8 +3816,11 @@ discard block |
||
3112 | 3816 | return "error : ".$e->getMessage(); |
3113 | 3817 | } |
3114 | 3818 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3115 | - if ($row['nb'] > 0) return true; |
|
3116 | - else return false; |
|
3819 | + if ($row['nb'] > 0) { |
|
3820 | + return true; |
|
3821 | + } else { |
|
3822 | + return false; |
|
3823 | + } |
|
3117 | 3824 | } |
3118 | 3825 | |
3119 | 3826 | public static function check_satellite_version($version) { |
@@ -3126,8 +3833,11 @@ discard block |
||
3126 | 3833 | return "error : ".$e->getMessage(); |
3127 | 3834 | } |
3128 | 3835 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3129 | - if ($row['nb'] > 0) return true; |
|
3130 | - else return false; |
|
3836 | + if ($row['nb'] > 0) { |
|
3837 | + return true; |
|
3838 | + } else { |
|
3839 | + return false; |
|
3840 | + } |
|
3131 | 3841 | } |
3132 | 3842 | |
3133 | 3843 | public static function check_airlines_version($version) { |
@@ -3140,8 +3850,11 @@ discard block |
||
3140 | 3850 | return "error : ".$e->getMessage(); |
3141 | 3851 | } |
3142 | 3852 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3143 | - if ($row['nb'] > 0) return true; |
|
3144 | - else return false; |
|
3853 | + if ($row['nb'] > 0) { |
|
3854 | + return true; |
|
3855 | + } else { |
|
3856 | + return false; |
|
3857 | + } |
|
3145 | 3858 | } |
3146 | 3859 | |
3147 | 3860 | public static function check_notam_version($version) { |
@@ -3154,8 +3867,11 @@ discard block |
||
3154 | 3867 | return "error : ".$e->getMessage(); |
3155 | 3868 | } |
3156 | 3869 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3157 | - if ($row['nb'] > 0) return true; |
|
3158 | - else return false; |
|
3870 | + if ($row['nb'] > 0) { |
|
3871 | + return true; |
|
3872 | + } else { |
|
3873 | + return false; |
|
3874 | + } |
|
3159 | 3875 | } |
3160 | 3876 | |
3161 | 3877 | public static function insert_airlines_version($version) { |
@@ -3245,8 +3961,11 @@ discard block |
||
3245 | 3961 | return "error : ".$e->getMessage(); |
3246 | 3962 | } |
3247 | 3963 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3248 | - if ($row['nb'] > 0) return false; |
|
3249 | - else return true; |
|
3964 | + if ($row['nb'] > 0) { |
|
3965 | + return false; |
|
3966 | + } else { |
|
3967 | + return true; |
|
3968 | + } |
|
3250 | 3969 | } |
3251 | 3970 | |
3252 | 3971 | public static function insert_last_notam_update() { |
@@ -3276,8 +3995,11 @@ discard block |
||
3276 | 3995 | return "error : ".$e->getMessage(); |
3277 | 3996 | } |
3278 | 3997 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3279 | - if ($row['nb'] > 0) return false; |
|
3280 | - else return true; |
|
3998 | + if ($row['nb'] > 0) { |
|
3999 | + return false; |
|
4000 | + } else { |
|
4001 | + return true; |
|
4002 | + } |
|
3281 | 4003 | } |
3282 | 4004 | |
3283 | 4005 | public static function insert_last_airspace_update() { |
@@ -3307,8 +4029,11 @@ discard block |
||
3307 | 4029 | return "error : ".$e->getMessage(); |
3308 | 4030 | } |
3309 | 4031 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3310 | - if ($row['nb'] > 0) return false; |
|
3311 | - else return true; |
|
4032 | + if ($row['nb'] > 0) { |
|
4033 | + return false; |
|
4034 | + } else { |
|
4035 | + return true; |
|
4036 | + } |
|
3312 | 4037 | } |
3313 | 4038 | |
3314 | 4039 | public static function insert_last_geoid_update() { |
@@ -3338,8 +4063,11 @@ discard block |
||
3338 | 4063 | return "error : ".$e->getMessage(); |
3339 | 4064 | } |
3340 | 4065 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3341 | - if ($row['nb'] > 0) return false; |
|
3342 | - else return true; |
|
4066 | + if ($row['nb'] > 0) { |
|
4067 | + return false; |
|
4068 | + } else { |
|
4069 | + return true; |
|
4070 | + } |
|
3343 | 4071 | } |
3344 | 4072 | |
3345 | 4073 | public static function insert_last_owner_update() { |
@@ -3369,8 +4097,11 @@ discard block |
||
3369 | 4097 | return "error : ".$e->getMessage(); |
3370 | 4098 | } |
3371 | 4099 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3372 | - if ($row['nb'] > 0) return false; |
|
3373 | - else return true; |
|
4100 | + if ($row['nb'] > 0) { |
|
4101 | + return false; |
|
4102 | + } else { |
|
4103 | + return true; |
|
4104 | + } |
|
3374 | 4105 | } |
3375 | 4106 | |
3376 | 4107 | public static function insert_last_fires_update() { |
@@ -3400,8 +4131,11 @@ discard block |
||
3400 | 4131 | return "error : ".$e->getMessage(); |
3401 | 4132 | } |
3402 | 4133 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3403 | - if ($row['nb'] > 0) return false; |
|
3404 | - else return true; |
|
4134 | + if ($row['nb'] > 0) { |
|
4135 | + return false; |
|
4136 | + } else { |
|
4137 | + return true; |
|
4138 | + } |
|
3405 | 4139 | } |
3406 | 4140 | |
3407 | 4141 | public static function insert_last_airlines_update() { |
@@ -3431,8 +4165,11 @@ discard block |
||
3431 | 4165 | return "error : ".$e->getMessage(); |
3432 | 4166 | } |
3433 | 4167 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3434 | - if ($row['nb'] > 0) return false; |
|
3435 | - else return true; |
|
4168 | + if ($row['nb'] > 0) { |
|
4169 | + return false; |
|
4170 | + } else { |
|
4171 | + return true; |
|
4172 | + } |
|
3436 | 4173 | } |
3437 | 4174 | |
3438 | 4175 | public static function insert_last_schedules_update() { |
@@ -3462,8 +4199,11 @@ discard block |
||
3462 | 4199 | return "error : ".$e->getMessage(); |
3463 | 4200 | } |
3464 | 4201 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3465 | - if ($row['nb'] > 0) return false; |
|
3466 | - else return true; |
|
4202 | + if ($row['nb'] > 0) { |
|
4203 | + return false; |
|
4204 | + } else { |
|
4205 | + return true; |
|
4206 | + } |
|
3467 | 4207 | } |
3468 | 4208 | |
3469 | 4209 | public static function insert_last_tle_update() { |
@@ -3493,8 +4233,11 @@ discard block |
||
3493 | 4233 | return "error : ".$e->getMessage(); |
3494 | 4234 | } |
3495 | 4235 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3496 | - if ($row['nb'] > 0) return false; |
|
3497 | - else return true; |
|
4236 | + if ($row['nb'] > 0) { |
|
4237 | + return false; |
|
4238 | + } else { |
|
4239 | + return true; |
|
4240 | + } |
|
3498 | 4241 | } |
3499 | 4242 | |
3500 | 4243 | public static function insert_last_ucsdb_update() { |
@@ -3524,8 +4267,11 @@ discard block |
||
3524 | 4267 | return "error : ".$e->getMessage(); |
3525 | 4268 | } |
3526 | 4269 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3527 | - if ($row['nb'] > 0) return false; |
|
3528 | - else return true; |
|
4270 | + if ($row['nb'] > 0) { |
|
4271 | + return false; |
|
4272 | + } else { |
|
4273 | + return true; |
|
4274 | + } |
|
3529 | 4275 | } |
3530 | 4276 | |
3531 | 4277 | public static function insert_last_celestrak_update() { |
@@ -3555,8 +4301,11 @@ discard block |
||
3555 | 4301 | return "error : ".$e->getMessage(); |
3556 | 4302 | } |
3557 | 4303 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3558 | - if ($row['nb'] > 0) return false; |
|
3559 | - else return true; |
|
4304 | + if ($row['nb'] > 0) { |
|
4305 | + return false; |
|
4306 | + } else { |
|
4307 | + return true; |
|
4308 | + } |
|
3560 | 4309 | } |
3561 | 4310 | |
3562 | 4311 | public static function check_last_satellite_update() { |
@@ -3574,8 +4323,11 @@ discard block |
||
3574 | 4323 | return "error : ".$e->getMessage(); |
3575 | 4324 | } |
3576 | 4325 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
3577 | - if ($row['nb'] > 0) return false; |
|
3578 | - else return true; |
|
4326 | + if ($row['nb'] > 0) { |
|
4327 | + return false; |
|
4328 | + } else { |
|
4329 | + return true; |
|
4330 | + } |
|
3579 | 4331 | } |
3580 | 4332 | |
3581 | 4333 | public static function insert_last_marine_identity_update() { |
@@ -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,17 +108,25 @@ 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 | 132 | } |
@@ -132,14 +148,18 @@ discard block |
||
132 | 148 | |
133 | 149 | public function checkAll() { |
134 | 150 | global $globalDebug, $globalNoImport; |
135 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
151 | + if ($globalDebug) { |
|
152 | + echo "Update last seen flights data...\n"; |
|
153 | + } |
|
136 | 154 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
137 | 155 | foreach ($this->all_flights as $key => $flight) { |
138 | 156 | if (isset($this->all_flights[$key]['id'])) { |
139 | 157 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
140 | 158 | $Spotter = new Spotter($this->db); |
141 | 159 | $real_arrival = $this->arrival($key); |
142 | - 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']); |
|
160 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) { |
|
161 | + $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']); |
|
162 | + } |
|
143 | 163 | } |
144 | 164 | } |
145 | 165 | } |
@@ -147,24 +167,32 @@ discard block |
||
147 | 167 | |
148 | 168 | public function arrival($key) { |
149 | 169 | global $globalClosestMinDist, $globalDebug; |
150 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
170 | + if ($globalDebug) { |
|
171 | + echo 'Update arrival...'."\n"; |
|
172 | + } |
|
151 | 173 | $Spotter = new Spotter($this->db); |
152 | 174 | $airport_icao = ''; |
153 | 175 | $airport_time = ''; |
154 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
176 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
177 | + $globalClosestMinDist = 50; |
|
178 | + } |
|
155 | 179 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | 180 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
157 | 181 | if (isset($closestAirports[0])) { |
158 | 182 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
159 | 183 | $airport_icao = $closestAirports[0]['icao']; |
160 | 184 | $airport_time = $this->all_flights[$key]['datetime']; |
161 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
185 | + if ($globalDebug) { |
|
186 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
187 | + } |
|
162 | 188 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
163 | 189 | foreach ($closestAirports as $airport) { |
164 | 190 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
165 | 191 | $airport_icao = $airport['icao']; |
166 | 192 | $airport_time = $this->all_flights[$key]['datetime']; |
167 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
193 | + if ($globalDebug) { |
|
194 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
195 | + } |
|
168 | 196 | break; |
169 | 197 | } |
170 | 198 | } |
@@ -172,14 +200,20 @@ discard block |
||
172 | 200 | $airport_icao = $closestAirports[0]['icao']; |
173 | 201 | $airport_time = $this->all_flights[$key]['datetime']; |
174 | 202 | } else { |
175 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
203 | + if ($globalDebug) { |
|
204 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
205 | + } |
|
176 | 206 | } |
177 | 207 | } else { |
178 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
208 | + if ($globalDebug) { |
|
209 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
210 | + } |
|
179 | 211 | } |
180 | 212 | |
181 | 213 | } else { |
182 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
214 | + if ($globalDebug) { |
|
215 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
216 | + } |
|
183 | 217 | } |
184 | 218 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
185 | 219 | } |
@@ -189,7 +223,9 @@ discard block |
||
189 | 223 | public function del() { |
190 | 224 | global $globalDebug, $globalNoImport, $globalNoDB; |
191 | 225 | // Delete old infos |
192 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
226 | + if ($globalDebug) { |
|
227 | + echo 'Delete old values and update latest data...'."\n"; |
|
228 | + } |
|
193 | 229 | foreach ($this->all_flights as $key => $flight) { |
194 | 230 | if (isset($flight['lastupdate'])) { |
195 | 231 | if ($flight['lastupdate'] < (time()-1800)) { |
@@ -203,13 +239,17 @@ discard block |
||
203 | 239 | global $globalDebug, $globalNoImport, $globalNoDB; |
204 | 240 | // Delete old infos |
205 | 241 | if (isset($this->all_flights[$key]['id'])) { |
206 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
244 | + } |
|
207 | 245 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
208 | 246 | $real_arrival = $this->arrival($key); |
209 | 247 | $Spotter = new Spotter($this->db); |
210 | 248 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
211 | 249 | $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']); |
212 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
250 | + if ($globalDebug && $result != 'success') { |
|
251 | + echo '!!! ERROR : '.$result."\n"; |
|
252 | + } |
|
213 | 253 | } |
214 | 254 | } |
215 | 255 | } |
@@ -219,9 +259,13 @@ discard block |
||
219 | 259 | public function add($line) { |
220 | 260 | 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; |
221 | 261 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
222 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
|
223 | - if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000; |
|
224 | -/* |
|
262 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
263 | + $globalCoordMinChange = '0.01'; |
|
264 | + } |
|
265 | + if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') { |
|
266 | + $globalAircraftMaxUpdate = 3000; |
|
267 | + } |
|
268 | + /* |
|
225 | 269 | $Spotter = new Spotter(); |
226 | 270 | $dbc = $Spotter->db; |
227 | 271 | $SpotterLive = new SpotterLive($dbc); |
@@ -243,19 +287,28 @@ discard block |
||
243 | 287 | // SBS format is CSV format |
244 | 288 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
245 | 289 | //print_r($line); |
246 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
290 | + if (isset($line['hex'])) { |
|
291 | + $line['hex'] = strtoupper($line['hex']); |
|
292 | + } |
|
247 | 293 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
248 | 294 | |
249 | 295 | // Increment message number |
250 | 296 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
251 | 297 | $current_date = date('Y-m-d'); |
252 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
253 | - else $source = ''; |
|
254 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
298 | + if (isset($line['source_name'])) { |
|
299 | + $source = $line['source_name']; |
|
300 | + } else { |
|
301 | + $source = ''; |
|
302 | + } |
|
303 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
304 | + $source = $line['format_source']; |
|
305 | + } |
|
255 | 306 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
256 | 307 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
257 | 308 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
258 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
309 | + } else { |
|
310 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
311 | + } |
|
259 | 312 | } |
260 | 313 | |
261 | 314 | /* |
@@ -271,23 +324,38 @@ discard block |
||
271 | 324 | //$this->db = $dbc; |
272 | 325 | |
273 | 326 | //$hex = trim($line['hex']); |
274 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
275 | - else $id = trim($line['id']); |
|
327 | + if (!isset($line['id'])) { |
|
328 | + $id = trim($line['hex']); |
|
329 | + } else { |
|
330 | + $id = trim($line['id']); |
|
331 | + } |
|
276 | 332 | |
277 | 333 | if (!isset($this->all_flights[$id])) { |
278 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
334 | + if ($globalDebug) { |
|
335 | + echo 'New flight...'."\n"; |
|
336 | + } |
|
279 | 337 | $this->all_flights[$id] = array(); |
280 | 338 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
281 | 339 | $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' => '')); |
282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
340 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
341 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
342 | + } |
|
283 | 343 | if (!isset($line['id'])) { |
284 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
285 | -// 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'))); |
|
344 | + if (!isset($globalDaemon)) { |
|
345 | + $globalDaemon = TRUE; |
|
346 | + } |
|
347 | + // 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'))); |
|
286 | 348 | // 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'))); |
287 | - 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'))); |
|
349 | + 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')) { |
|
350 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
351 | + } |
|
288 | 352 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
353 | + } else { |
|
354 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
355 | + } |
|
356 | + if ($globalAllFlights !== FALSE) { |
|
357 | + $dataFound = true; |
|
358 | + } |
|
291 | 359 | } |
292 | 360 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | 361 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -309,12 +377,20 @@ discard block |
||
309 | 377 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | 378 | } |
311 | 379 | $Spotter->db = null; |
312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
380 | + if ($globalDebugTimeElapsed) { |
|
381 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
382 | + } |
|
383 | + if ($aircraft_icao != '') { |
|
384 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
385 | + } |
|
314 | 386 | } |
315 | 387 | } |
316 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
388 | + if ($globalAllFlights !== FALSE) { |
|
389 | + $dataFound = true; |
|
390 | + } |
|
391 | + if ($globalDebug) { |
|
392 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
393 | + } |
|
318 | 394 | } |
319 | 395 | if (isset($line['id']) && !isset($line['hex'])) { |
320 | 396 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
@@ -323,7 +399,9 @@ discard block |
||
323 | 399 | $icao = $line['aircraft_icao']; |
324 | 400 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
325 | 401 | $Spotter = new Spotter($this->db); |
326 | - if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
402 | + if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
403 | + $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
404 | + } |
|
327 | 405 | $Spotter->db = null; |
328 | 406 | } |
329 | 407 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
@@ -333,15 +411,24 @@ discard block |
||
333 | 411 | $Spotter = new Spotter($this->db); |
334 | 412 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
335 | 413 | $Spotter->db = null; |
336 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
414 | + if ($aircraft_icao != '') { |
|
415 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
416 | + } |
|
337 | 417 | } |
338 | 418 | } |
339 | 419 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
340 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
341 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
342 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
343 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
344 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
420 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
421 | + $aircraft_icao = 'GLID'; |
|
422 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
423 | + $aircraft_icao = 'UHEL'; |
|
424 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
425 | + $aircraft_icao = 'TOWPLANE'; |
|
426 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
427 | + $aircraft_icao = 'POWAIRC'; |
|
428 | + } |
|
429 | + if (isset($aircraft_icao)) { |
|
430 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
431 | + } |
|
345 | 432 | } |
346 | 433 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
347 | 434 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -351,8 +438,11 @@ discard block |
||
351 | 438 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
352 | 439 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
353 | 440 | } else { |
354 | - 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"; |
|
355 | - 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"; |
|
441 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
442 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
443 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
444 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
445 | + } |
|
356 | 446 | /* |
357 | 447 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
358 | 448 | print_r($this->all_flights[$id]); |
@@ -361,16 +451,22 @@ discard block |
||
361 | 451 | return ''; |
362 | 452 | } |
363 | 453 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
364 | - if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
454 | + if ($globalDebug) { |
|
455 | + echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
456 | + } |
|
365 | 457 | return ''; |
366 | 458 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
367 | - if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
459 | + if ($globalDebug) { |
|
460 | + echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
461 | + } |
|
368 | 462 | return ''; |
369 | 463 | } elseif (!isset($line['datetime'])) { |
370 | 464 | date_default_timezone_set('UTC'); |
371 | 465 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
372 | 466 | } else { |
373 | - if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
467 | + if ($globalDebug) { |
|
468 | + echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
469 | + } |
|
374 | 470 | return ''; |
375 | 471 | } |
376 | 472 | |
@@ -391,30 +487,48 @@ discard block |
||
391 | 487 | |
392 | 488 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
393 | 489 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
394 | - if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
490 | + if ($globalDebug) { |
|
491 | + echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
492 | + } |
|
395 | 493 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
396 | 494 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
397 | - 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'))); |
|
398 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
399 | - 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'])); |
|
495 | + 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')) { |
|
496 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
497 | + } elseif (isset($line['id'])) { |
|
498 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
499 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
500 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
501 | + } |
|
400 | 502 | } else { |
401 | 503 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
402 | 504 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
403 | 505 | $timeelapsed = microtime(true); |
404 | 506 | $Spotter = new Spotter($this->db); |
405 | 507 | $fromsource = NULL; |
406 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
407 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
408 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
409 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
410 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
508 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
509 | + $fromsource = $globalAirlinesSource; |
|
510 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
511 | + $fromsource = 'vatsim'; |
|
512 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
513 | + $fromsource = 'ivao'; |
|
514 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
515 | + $fromsource = 'vatsim'; |
|
516 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
517 | + $fromsource = 'ivao'; |
|
518 | + } |
|
411 | 519 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
412 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
520 | + if ($globalDebug && $result != 'success') { |
|
521 | + echo '!!! ERROR : '.$result."\n"; |
|
522 | + } |
|
413 | 523 | $Spotter->db = null; |
414 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
524 | + if ($globalDebugTimeElapsed) { |
|
525 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
526 | + } |
|
415 | 527 | } |
416 | 528 | } |
417 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
529 | + } else { |
|
530 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
531 | + } |
|
418 | 532 | |
419 | 533 | /* |
420 | 534 | if (!isset($line['id'])) { |
@@ -424,7 +538,9 @@ discard block |
||
424 | 538 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
425 | 539 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
426 | 540 | */ |
427 | - 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'])); |
|
541 | + if (!isset($this->all_flights[$id]['id'])) { |
|
542 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
543 | + } |
|
428 | 544 | |
429 | 545 | //$putinarchive = true; |
430 | 546 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -442,7 +558,9 @@ discard block |
||
442 | 558 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
443 | 559 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
444 | 560 | $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' => '')); |
445 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
561 | + if ($globalDebugTimeElapsed) { |
|
562 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
563 | + } |
|
446 | 564 | } |
447 | 565 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
448 | 566 | $timeelapsed = microtime(true); |
@@ -456,7 +574,9 @@ discard block |
||
456 | 574 | $Translation->db = null; |
457 | 575 | } |
458 | 576 | $Spotter->db = null; |
459 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
577 | + if ($globalDebugTimeElapsed) { |
|
578 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
579 | + } |
|
460 | 580 | } |
461 | 581 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
462 | 582 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -465,9 +585,13 @@ discard block |
||
465 | 585 | $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'])); |
466 | 586 | } |
467 | 587 | } |
468 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
588 | + if (!isset($globalFork)) { |
|
589 | + $globalFork = TRUE; |
|
590 | + } |
|
469 | 591 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
470 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
592 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
593 | + $this->get_Schedule($id,trim($line['ident'])); |
|
594 | + } |
|
471 | 595 | } |
472 | 596 | } |
473 | 597 | } |
@@ -485,9 +609,13 @@ discard block |
||
485 | 609 | $speed = $speed*3.6; |
486 | 610 | if ($speed < 1000) { |
487 | 611 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
488 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
612 | + if ($globalDebug) { |
|
613 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
614 | + } |
|
489 | 615 | } else { |
490 | - if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
616 | + if ($globalDebug) { |
|
617 | + echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
618 | + } |
|
491 | 619 | } |
492 | 620 | } |
493 | 621 | } |
@@ -496,13 +624,21 @@ discard block |
||
496 | 624 | |
497 | 625 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
498 | 626 | if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
499 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
627 | + if ($globalDebug) { |
|
628 | + echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
629 | + } |
|
500 | 630 | return false; |
501 | 631 | } |
502 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
503 | - else unset($timediff); |
|
504 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
505 | - else unset($timediff_archive); |
|
632 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
633 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
634 | + } else { |
|
635 | + unset($timediff); |
|
636 | + } |
|
637 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) { |
|
638 | + $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
639 | + } else { |
|
640 | + unset($timediff_archive); |
|
641 | + } |
|
506 | 642 | if ($this->tmd > 5 |
507 | 643 | || (isset($line['format_source']) |
508 | 644 | && $line['format_source'] == 'airwhere' |
@@ -539,16 +675,25 @@ discard block |
||
539 | 675 | $this->all_flights[$id]['putinarchive'] = true; |
540 | 676 | $this->tmd = 0; |
541 | 677 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
542 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
678 | + if ($globalDebug) { |
|
679 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
680 | + } |
|
543 | 681 | $timeelapsed = microtime(true); |
544 | 682 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
545 | 683 | $Spotter = new Spotter($this->db); |
546 | 684 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
547 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
548 | - else $this->all_flights[$id]['over_country'] = ''; |
|
685 | + if (!empty($all_country)) { |
|
686 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
687 | + } else { |
|
688 | + $this->all_flights[$id]['over_country'] = ''; |
|
689 | + } |
|
549 | 690 | $Spotter->db = null; |
550 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
551 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
691 | + if ($globalDebugTimeElapsed) { |
|
692 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
693 | + } |
|
694 | + if ($globalDebug) { |
|
695 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
696 | + } |
|
552 | 697 | } |
553 | 698 | } |
554 | 699 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
@@ -594,7 +739,9 @@ discard block |
||
594 | 739 | */ |
595 | 740 | } |
596 | 741 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
597 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
742 | + if ($line['longitude'] > 180) { |
|
743 | + $line['longitude'] = $line['longitude'] - 360; |
|
744 | + } |
|
598 | 745 | //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) { |
599 | 746 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
600 | 747 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -631,7 +778,9 @@ discard block |
||
631 | 778 | } |
632 | 779 | } |
633 | 780 | if (isset($line['last_update']) && $line['last_update'] != '') { |
634 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
781 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
782 | + $dataFound = true; |
|
783 | + } |
|
635 | 784 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
636 | 785 | } |
637 | 786 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -653,35 +802,53 @@ discard block |
||
653 | 802 | // Here we force archive of flight because after ground it's a new one (or should be) |
654 | 803 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
655 | 804 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
656 | - 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'))); |
|
657 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
658 | - 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'])); |
|
805 | + 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')) { |
|
806 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
807 | + } elseif (isset($line['id'])) { |
|
808 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
809 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
810 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
811 | + } |
|
812 | + } |
|
813 | + if ($line['ground'] != 1) { |
|
814 | + $line['ground'] = 0; |
|
659 | 815 | } |
660 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
661 | 816 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
662 | 817 | //$dataFound = true; |
663 | 818 | } |
664 | 819 | if (isset($line['squawk']) && $line['squawk'] != '') { |
665 | 820 | 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'])) { |
666 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
821 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
822 | + $this->all_flights[$id]['putinarchive'] = true; |
|
823 | + } |
|
667 | 824 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
668 | 825 | $highlight = ''; |
669 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
670 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
671 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
826 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
827 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
828 | + } |
|
829 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
830 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
831 | + } |
|
832 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
833 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
834 | + } |
|
672 | 835 | if ($highlight != '') { |
673 | 836 | $timeelapsed = microtime(true); |
674 | 837 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
675 | 838 | $Spotter = new Spotter($this->db); |
676 | 839 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
677 | 840 | $Spotter->db = null; |
678 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
841 | + if ($globalDebugTimeElapsed) { |
|
842 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
843 | + } |
|
679 | 844 | } |
680 | 845 | //$putinarchive = true; |
681 | 846 | //$highlight = ''; |
682 | 847 | } |
683 | 848 | |
684 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
849 | + } else { |
|
850 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
851 | + } |
|
685 | 852 | //$dataFound = true; |
686 | 853 | } |
687 | 854 | |
@@ -694,19 +861,27 @@ discard block |
||
694 | 861 | } |
695 | 862 | } |
696 | 863 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
697 | - 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; |
|
864 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
865 | + $this->all_flights[$id]['putinarchive'] = true; |
|
866 | + } |
|
698 | 867 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
699 | 868 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
700 | 869 | //$dataFound = true; |
701 | 870 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
702 | 871 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
703 | 872 | 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) { |
704 | - if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
873 | + if ($globalDebug) { |
|
874 | + echo '--- Reset because of altitude'."\n"; |
|
875 | + } |
|
705 | 876 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
706 | 877 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
707 | - 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'))); |
|
708 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
709 | - 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'])); |
|
878 | + 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')) { |
|
879 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
880 | + } elseif (isset($line['id'])) { |
|
881 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
882 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
883 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
884 | + } |
|
710 | 885 | } |
711 | 886 | } |
712 | 887 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
@@ -717,22 +892,32 @@ discard block |
||
717 | 892 | } |
718 | 893 | |
719 | 894 | if (isset($line['heading']) && $line['heading'] != '') { |
720 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
895 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
896 | + $this->all_flights[$id]['putinarchive'] = true; |
|
897 | + } |
|
721 | 898 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
722 | 899 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
723 | 900 | //$dataFound = true; |
724 | 901 | } 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']) { |
725 | 902 | $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']); |
726 | 903 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
727 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
728 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
904 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
905 | + $this->all_flights[$id]['putinarchive'] = true; |
|
906 | + } |
|
907 | + if ($globalDebug) { |
|
908 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
909 | + } |
|
729 | 910 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
730 | 911 | // If not enough messages and ACARS set heading to 0 |
731 | 912 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
732 | 913 | } |
733 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
734 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
735 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
914 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
915 | + $dataFound = false; |
|
916 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
917 | + $dataFound = false; |
|
918 | + } elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) { |
|
919 | + $dataFound = false; |
|
920 | + } |
|
736 | 921 | |
737 | 922 | // print_r($this->all_flights[$id]); |
738 | 923 | //gets the callsign from the last hour |
@@ -749,23 +934,38 @@ discard block |
||
749 | 934 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
750 | 935 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
751 | 936 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
752 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
937 | + if ($globalDebug) { |
|
938 | + echo "Check if aircraft is already in DB..."; |
|
939 | + } |
|
753 | 940 | $timeelapsed = microtime(true); |
754 | 941 | $SpotterLive = new SpotterLive($this->db); |
755 | 942 | 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')) { |
756 | 943 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
757 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
944 | + if ($globalDebugTimeElapsed) { |
|
945 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
946 | + } |
|
758 | 947 | } elseif (isset($line['id'])) { |
759 | 948 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
760 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
949 | + if ($globalDebugTimeElapsed) { |
|
950 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
951 | + } |
|
761 | 952 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
762 | 953 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
763 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
764 | - } else $recent_ident = ''; |
|
954 | + if ($globalDebugTimeElapsed) { |
|
955 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
956 | + } |
|
957 | + } else { |
|
958 | + $recent_ident = ''; |
|
959 | + } |
|
765 | 960 | $SpotterLive->db=null; |
766 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
767 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
768 | - } else $recent_ident = ''; |
|
961 | + if ($globalDebug && $recent_ident == '') { |
|
962 | + echo " Not in DB.\n"; |
|
963 | + } elseif ($globalDebug && $recent_ident != '') { |
|
964 | + echo " Already in DB.\n"; |
|
965 | + } |
|
966 | + } else { |
|
967 | + $recent_ident = ''; |
|
968 | + } |
|
769 | 969 | } else { |
770 | 970 | $recent_ident = ''; |
771 | 971 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -773,7 +973,9 @@ discard block |
||
773 | 973 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
774 | 974 | if($recent_ident == "") |
775 | 975 | { |
776 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
976 | + if ($globalDebug) { |
|
977 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
978 | + } |
|
777 | 979 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
778 | 980 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
779 | 981 | //adds the spotter data for the archive |
@@ -817,31 +1019,49 @@ discard block |
||
817 | 1019 | |
818 | 1020 | if (!$ignoreImport) { |
819 | 1021 | $highlight = ''; |
820 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
821 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
822 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
823 | - 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'))); |
|
1022 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
1023 | + $highlight = 'Squawk 7500 : Hijack'; |
|
1024 | + } |
|
1025 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
1026 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
1027 | + } |
|
1028 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
1029 | + $highlight = 'Squawk 7700 : Emergency'; |
|
1030 | + } |
|
1031 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1032 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1033 | + } |
|
824 | 1034 | $timeelapsed = microtime(true); |
825 | 1035 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
826 | 1036 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
827 | 1037 | $Spotter = new Spotter($this->db); |
828 | 1038 | $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']); |
829 | 1039 | $Spotter->db = null; |
830 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
1040 | + if ($globalDebug && isset($result)) { |
|
1041 | + echo $result."\n"; |
|
1042 | + } |
|
831 | 1043 | } |
832 | 1044 | } |
833 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1045 | + if ($globalDebugTimeElapsed) { |
|
1046 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1047 | + } |
|
834 | 1048 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
835 | 1049 | |
836 | 1050 | // Add source stat in DB |
837 | 1051 | $Stats = new Stats($this->db); |
838 | 1052 | if (!empty($this->stats)) { |
839 | - if ($globalDebug) echo 'Add source stats : '; |
|
1053 | + if ($globalDebug) { |
|
1054 | + echo 'Add source stats : '; |
|
1055 | + } |
|
840 | 1056 | foreach($this->stats as $date => $data) { |
841 | 1057 | foreach($data as $source => $sourced) { |
842 | 1058 | //print_r($sourced); |
843 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
844 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
1059 | + if (isset($sourced['polar'])) { |
|
1060 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
1061 | + } |
|
1062 | + if (isset($sourced['hist'])) { |
|
1063 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
1064 | + } |
|
845 | 1065 | if (isset($sourced['msg'])) { |
846 | 1066 | if (time() - $sourced['msg']['date'] > 10) { |
847 | 1067 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -854,13 +1074,17 @@ discard block |
||
854 | 1074 | unset($this->stats[$date]); |
855 | 1075 | } |
856 | 1076 | } |
857 | - if ($globalDebug) echo 'Done'."\n"; |
|
1077 | + if ($globalDebug) { |
|
1078 | + echo 'Done'."\n"; |
|
1079 | + } |
|
858 | 1080 | |
859 | 1081 | } |
860 | 1082 | $Stats->db = null; |
861 | 1083 | } |
862 | 1084 | $this->del(); |
863 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
1085 | + } elseif ($globalDebug) { |
|
1086 | + echo 'Ignore data'."\n"; |
|
1087 | + } |
|
864 | 1088 | //$ignoreImport = false; |
865 | 1089 | $this->all_flights[$id]['addedSpotter'] = 1; |
866 | 1090 | //print_r($this->all_flights[$id]); |
@@ -877,7 +1101,9 @@ discard block |
||
877 | 1101 | */ |
878 | 1102 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
879 | 1103 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
880 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1104 | + if ($globalDebug) { |
|
1105 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
1106 | + } |
|
881 | 1107 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
882 | 1108 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
883 | 1109 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -886,7 +1112,9 @@ discard block |
||
886 | 1112 | $SpotterLive->db=null; |
887 | 1113 | } |
888 | 1114 | } |
889 | - if ($globalDebug) echo " Done\n"; |
|
1115 | + if ($globalDebug) { |
|
1116 | + echo " Done\n"; |
|
1117 | + } |
|
890 | 1118 | $this->last_delete = time(); |
891 | 1119 | } |
892 | 1120 | } else { |
@@ -913,11 +1141,17 @@ discard block |
||
913 | 1141 | //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"; |
914 | 1142 | if ($globalDebug) { |
915 | 1143 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
916 | - 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"; |
|
917 | - 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"; |
|
1144 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1145 | + 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"; |
|
1146 | + } else { |
|
1147 | + 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"; |
|
1148 | + } |
|
918 | 1149 | } else { |
919 | - 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"; |
|
920 | - 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"; |
|
1150 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1151 | + 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"; |
|
1152 | + } else { |
|
1153 | + 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"; |
|
1154 | + } |
|
921 | 1155 | } |
922 | 1156 | } |
923 | 1157 | $ignoreImport = false; |
@@ -963,22 +1197,30 @@ discard block |
||
963 | 1197 | |
964 | 1198 | if (!$ignoreImport) { |
965 | 1199 | 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'])) { |
966 | - 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'))); |
|
1200 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1201 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1202 | + } |
|
967 | 1203 | $timeelapsed = microtime(true); |
968 | 1204 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
969 | 1205 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
970 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1206 | + if ($globalDebug) { |
|
1207 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1208 | + } |
|
971 | 1209 | $SpotterLive = new SpotterLive($this->db); |
972 | 1210 | $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']); |
973 | 1211 | $SpotterLive->db = null; |
974 | - if ($globalDebug) echo $result."\n"; |
|
1212 | + if ($globalDebug) { |
|
1213 | + echo $result."\n"; |
|
1214 | + } |
|
975 | 1215 | } |
976 | 1216 | } |
977 | 1217 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
978 | 1218 | $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']); |
979 | 1219 | } |
980 | 1220 | $this->all_flights[$id]['putinarchive'] = false; |
981 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1221 | + if ($globalDebugTimeElapsed) { |
|
1222 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1223 | + } |
|
982 | 1224 | |
983 | 1225 | // Put statistics in $this->stats variable |
984 | 1226 | //if ($line['format_source'] != 'aprs') { |
@@ -986,7 +1228,9 @@ discard block |
||
986 | 1228 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
987 | 1229 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
988 | 1230 | $source = $this->all_flights[$id]['source_name']; |
989 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
1231 | + if ($source == '') { |
|
1232 | + $source = $this->all_flights[$id]['format_source']; |
|
1233 | + } |
|
990 | 1234 | if (!isset($this->source_location[$source])) { |
991 | 1235 | $Location = new Source($this->db); |
992 | 1236 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -1007,7 +1251,9 @@ discard block |
||
1007 | 1251 | $stats_heading = round($stats_heading/22.5); |
1008 | 1252 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
1009 | 1253 | $current_date = date('Y-m-d'); |
1010 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1254 | + if ($stats_heading == 16) { |
|
1255 | + $stats_heading = 0; |
|
1256 | + } |
|
1011 | 1257 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1012 | 1258 | for ($i=0;$i<=15;$i++) { |
1013 | 1259 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -1025,7 +1271,9 @@ discard block |
||
1025 | 1271 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1026 | 1272 | end($this->stats[$current_date][$source]['hist']); |
1027 | 1273 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
1028 | - } else $mini = 0; |
|
1274 | + } else { |
|
1275 | + $mini = 0; |
|
1276 | + } |
|
1029 | 1277 | for ($i=$mini;$i<=$distance;$i+=10) { |
1030 | 1278 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1031 | 1279 | } |
@@ -1037,19 +1285,27 @@ discard block |
||
1037 | 1285 | } |
1038 | 1286 | |
1039 | 1287 | $this->all_flights[$id]['lastupdate'] = time(); |
1040 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1288 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1289 | + $send = true; |
|
1290 | + } |
|
1041 | 1291 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1042 | - } 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"; |
|
1292 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1293 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1294 | + } |
|
1043 | 1295 | //$this->del(); |
1044 | 1296 | |
1045 | 1297 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1046 | 1298 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
1047 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1299 | + if ($globalDebug) { |
|
1300 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1301 | + } |
|
1048 | 1302 | $SpotterLive = new SpotterLive($this->db); |
1049 | 1303 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
1050 | 1304 | $SpotterLive->db = null; |
1051 | 1305 | //SpotterLive->deleteLiveSpotterData(); |
1052 | - if ($globalDebug) echo " Done\n"; |
|
1306 | + if ($globalDebug) { |
|
1307 | + echo " Done\n"; |
|
1308 | + } |
|
1053 | 1309 | $this->last_delete_hourly = time(); |
1054 | 1310 | } else { |
1055 | 1311 | $this->del(); |
@@ -1061,7 +1317,9 @@ discard block |
||
1061 | 1317 | //$ignoreImport = false; |
1062 | 1318 | } |
1063 | 1319 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1064 | - if ($send) return $this->all_flights[$id]; |
|
1320 | + if ($send) { |
|
1321 | + return $this->all_flights[$id]; |
|
1322 | + } |
|
1065 | 1323 | } |
1066 | 1324 | } |
1067 | 1325 | } |
@@ -123,7 +123,9 @@ discard block |
||
123 | 123 | $temp += 1; |
124 | 124 | $flat = (float)($temp / (60.0 * 10000.0)); |
125 | 125 | $flat *= -1.0; |
126 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
126 | + } else { |
|
127 | + $flat = (float)($temp / (60.0 * 10000.0)); |
|
128 | + } |
|
127 | 129 | return $flat; // float |
128 | 130 | } |
129 | 131 | |
@@ -135,7 +137,9 @@ discard block |
||
135 | 137 | $temp += 1; |
136 | 138 | $flon = (float)($temp / (60.0 * 10000.0)); |
137 | 139 | $flon *= -1.0; |
138 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
140 | + } else { |
|
141 | + $flon = (float)($temp / (60.0 * 10000.0)); |
|
142 | + } |
|
139 | 143 | return $flon; |
140 | 144 | } |
141 | 145 | |
@@ -158,10 +162,8 @@ discard block |
||
158 | 162 | */ |
159 | 163 | private function asciidec_2_8bit($ascii) { |
160 | 164 | //only process in the following range: 48-87, 96-119 |
161 | - if ($ascii < 48) { } |
|
162 | - else { |
|
163 | - if($ascii>119) { } |
|
164 | - else { |
|
165 | + if ($ascii < 48) { } else { |
|
166 | + if($ascii>119) { } else { |
|
165 | 167 | if ($ascii>87 && $ascii<96) ; |
166 | 168 | else { |
167 | 169 | $ascii=$ascii+40; |
@@ -263,7 +265,9 @@ discard block |
||
263 | 265 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
264 | 266 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
265 | 267 | $ro->heading = bindec(substr($_aisdata,124,9)); |
266 | - if ($ro->heading == 511) $ro->heading = ''; |
|
268 | + if ($ro->heading == 511) { |
|
269 | + $ro->heading = ''; |
|
270 | + } |
|
267 | 271 | $ro->cls = 2; // class B |
268 | 272 | } else if ($ro->id == 19) { |
269 | 273 | $ro->cog = bindec(substr($_aisdata,112,12))/10; |
@@ -273,7 +277,9 @@ discard block |
||
273 | 277 | $ro->name = $this->binchar($_aisdata,143,120); |
274 | 278 | $ro->cls = 2; // class B |
275 | 279 | $ro->heading = bindec(substr($_aisdata,124,9)); |
276 | - if ($ro->heading == 511) $ro->heading = ''; |
|
280 | + if ($ro->heading == 511) { |
|
281 | + $ro->heading = ''; |
|
282 | + } |
|
277 | 283 | $ro->typeid = bindec(substr($_aisdata,263,8)); |
278 | 284 | $ro->type = $this->getShipType($ro->typeid); |
279 | 285 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
@@ -304,9 +310,13 @@ discard block |
||
304 | 310 | $ro->cls = 2; // class B |
305 | 311 | } else if ($ro->id == 27) { |
306 | 312 | $ro->cog = bindec(substr($_aisdata,85,9)); |
307 | - if ($ro->cog == 511) $ro->cog = 0.0; |
|
313 | + if ($ro->cog == 511) { |
|
314 | + $ro->cog = 0.0; |
|
315 | + } |
|
308 | 316 | $ro->sog = bindec(substr($_aisdata,79,6)); |
309 | - if ($ro->sog == 63) $ro->sog = 0.0; |
|
317 | + if ($ro->sog == 63) { |
|
318 | + $ro->sog = 0.0; |
|
319 | + } |
|
310 | 320 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
311 | 321 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
312 | 322 | $ro->cls = 1; // class A |
@@ -354,28 +364,48 @@ discard block |
||
354 | 364 | } |
355 | 365 | |
356 | 366 | public function getShipType($code) { |
357 | - if (isset($this->shiptype[$code])) return $this->shiptype[$code]; |
|
358 | - else return ''; |
|
367 | + if (isset($this->shiptype[$code])) { |
|
368 | + return $this->shiptype[$code]; |
|
369 | + } else { |
|
370 | + return ''; |
|
371 | + } |
|
359 | 372 | } |
360 | 373 | |
361 | 374 | public function getShipTypeID($type) { |
362 | 375 | $typeid = array_search($type,$this->shiptype); |
363 | - if ($typeid !== FALSE) return $typeid; |
|
364 | - elseif ($type == 'Cargo' || $type == 'General Cargo' || $type == 'Bulk Carrier' || $type == 'Container Ship' || $type == 'Cargo A' || $type == 'Reefer' || $type == 'Vehicles Carrier' || $type == 'Ro-Ro Cargo') return 70; |
|
365 | - elseif ($type == 'Passengers Ship' || $type == 'Passenger' || $type == 'Ro-Ro/Passenger Ship' || $type == 'Motor Passenger') return 60; |
|
366 | - elseif ($type == 'Tanker' || $type == 'Crude Oil Tanker' || $type == 'Oil Products Tanker' || $type == 'Oil/Chemical Tanker' || $type == 'Bunkering Tanker') return 80; |
|
367 | - elseif ($type == 'Lpg Tanker' || $type == 'Lng Tanker') return 84; |
|
368 | - elseif ($type == 'Sailing Vessel') return 36; |
|
369 | - elseif ($type == 'Yacht') return 37; |
|
370 | - elseif ($type == 'Trailing Suction Hopper Dredger' || $type == 'Drilling Jack Up' || $type == 'Suction Dredger' || $type == 'Hopper Dredger') return 33; |
|
371 | - elseif ($type == 'High speed craft') return 40; |
|
372 | - elseif ($type == 'Crew Boat') return 53; |
|
373 | - elseif ($type == 'Icebreaker') return 52; |
|
374 | - elseif ($type == 'Pollution Control Vessel') return 54; |
|
375 | - elseif ($type == 'Other Type') return 90; |
|
376 | - elseif ($type == 'Anchor Handling Vessel' || $type == 'Offshore Supply Ship' || $type == 'Research/Survey Vessel' || $type == 'Utility Vessel' || $type == 'Pipe Burying Vessel' || $type == 'Heavy Lift Vessel' || $type == 'Crane Ship' || $type == 'Buoy-laying Vessel') return 59; |
|
377 | - elseif ($type == 'Fish Carrier' || $type == 'Trawler' || $type == 'Trawlers' || $type == 'Fishing Vessel' || $type == 'Trawlers|unknown Not Fishing' || $type == 'Purse Seines|trawlers' || $type == 'Purse Seines' || $type == 'Trollers' || $type == 'Set Longlines' || $type == 'Set Gillnets|trawlers') return 30; |
|
378 | - else return 0; |
|
376 | + if ($typeid !== FALSE) { |
|
377 | + return $typeid; |
|
378 | + } elseif ($type == 'Cargo' || $type == 'General Cargo' || $type == 'Bulk Carrier' || $type == 'Container Ship' || $type == 'Cargo A' || $type == 'Reefer' || $type == 'Vehicles Carrier' || $type == 'Ro-Ro Cargo') { |
|
379 | + return 70; |
|
380 | + } elseif ($type == 'Passengers Ship' || $type == 'Passenger' || $type == 'Ro-Ro/Passenger Ship' || $type == 'Motor Passenger') { |
|
381 | + return 60; |
|
382 | + } elseif ($type == 'Tanker' || $type == 'Crude Oil Tanker' || $type == 'Oil Products Tanker' || $type == 'Oil/Chemical Tanker' || $type == 'Bunkering Tanker') { |
|
383 | + return 80; |
|
384 | + } elseif ($type == 'Lpg Tanker' || $type == 'Lng Tanker') { |
|
385 | + return 84; |
|
386 | + } elseif ($type == 'Sailing Vessel') { |
|
387 | + return 36; |
|
388 | + } elseif ($type == 'Yacht') { |
|
389 | + return 37; |
|
390 | + } elseif ($type == 'Trailing Suction Hopper Dredger' || $type == 'Drilling Jack Up' || $type == 'Suction Dredger' || $type == 'Hopper Dredger') { |
|
391 | + return 33; |
|
392 | + } elseif ($type == 'High speed craft') { |
|
393 | + return 40; |
|
394 | + } elseif ($type == 'Crew Boat') { |
|
395 | + return 53; |
|
396 | + } elseif ($type == 'Icebreaker') { |
|
397 | + return 52; |
|
398 | + } elseif ($type == 'Pollution Control Vessel') { |
|
399 | + return 54; |
|
400 | + } elseif ($type == 'Other Type') { |
|
401 | + return 90; |
|
402 | + } elseif ($type == 'Anchor Handling Vessel' || $type == 'Offshore Supply Ship' || $type == 'Research/Survey Vessel' || $type == 'Utility Vessel' || $type == 'Pipe Burying Vessel' || $type == 'Heavy Lift Vessel' || $type == 'Crane Ship' || $type == 'Buoy-laying Vessel') { |
|
403 | + return 59; |
|
404 | + } elseif ($type == 'Fish Carrier' || $type == 'Trawler' || $type == 'Trawlers' || $type == 'Fishing Vessel' || $type == 'Trawlers|unknown Not Fishing' || $type == 'Purse Seines|trawlers' || $type == 'Purse Seines' || $type == 'Trollers' || $type == 'Set Longlines' || $type == 'Set Gillnets|trawlers') { |
|
405 | + return 30; |
|
406 | + } else { |
|
407 | + return 0; |
|
408 | + } |
|
379 | 409 | } |
380 | 410 | |
381 | 411 | public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) { |
@@ -412,11 +442,20 @@ discard block |
||
412 | 442 | // assume 1st ! is valid |
413 | 443 | // find * ensure that it is at correct position |
414 | 444 | $end = strrpos ( $rawdata , '*' ); |
415 | - if ($end === FALSE) return -1; // check for NULLS!!! |
|
445 | + if ($end === FALSE) { |
|
446 | + return -1; |
|
447 | + } |
|
448 | + // check for NULLS!!! |
|
416 | 449 | $cs = substr( $rawdata, $end + 1 ); |
417 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
450 | + if ( strlen($cs) != 2 ) { |
|
451 | + return -1; |
|
452 | + } |
|
453 | + // correct cs length |
|
418 | 454 | $dcs = (int)hexdec( $cs ); |
419 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
455 | + for ( $alias=1; $alias<$end; $alias++) { |
|
456 | + $chksum ^= ord( $rawdata[$alias] ); |
|
457 | + } |
|
458 | + // perform XOR for NMEA checksum |
|
420 | 459 | if ( $chksum == $dcs ) { // NMEA checksum pass |
421 | 460 | $pcs = explode(',', $rawdata); |
422 | 461 | // !AI??? identifier |
@@ -427,8 +466,14 @@ discard block |
||
427 | 466 | $num_seq = (int)$pcs[1]; // number of sequences |
428 | 467 | $seq = (int)$pcs[2]; // get sequence |
429 | 468 | // get msg sequence id |
430 | - if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
|
431 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
469 | + if ($pcs[3] == '') { |
|
470 | + $msg_sid = -1; |
|
471 | + } |
|
472 | + // non-multipart message, set to -1 |
|
473 | + else { |
|
474 | + $msg_sid = (int)$pcs[3]; |
|
475 | + } |
|
476 | + // multipart message |
|
432 | 477 | $ais_ch = $pcs[4]; // get AIS channel |
433 | 478 | // message sequence checking |
434 | 479 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -491,10 +536,18 @@ discard block |
||
491 | 536 | //DEBUG echo "[$start $end $tst]\n"; |
492 | 537 | $result = $this->process_ais_raw( $tst, "" ); |
493 | 538 | $last_pos = $end + 1; |
494 | - } else break; |
|
539 | + } else { |
|
540 | + break; |
|
541 | + } |
|
542 | + } |
|
543 | + if ($last_pos > 0) { |
|
544 | + $cbuf = substr($cbuf, $last_pos); |
|
495 | 545 | } |
496 | - if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move... |
|
497 | - if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode... |
|
546 | + // move... |
|
547 | + if (strlen($cbuf) > 1024) { |
|
548 | + $cbuf = ""; |
|
549 | + } |
|
550 | + // prevent overflow simple mode... |
|
498 | 551 | return $result; |
499 | 552 | } |
500 | 553 | |
@@ -514,7 +567,9 @@ discard block |
||
514 | 567 | if ($lat<0.0) { |
515 | 568 | $lat = -$lat; |
516 | 569 | $neg=true; |
517 | - } else $neg=false; |
|
570 | + } else { |
|
571 | + $neg=false; |
|
572 | + } |
|
518 | 573 | $latd = 0x00000000; |
519 | 574 | $latd = intval ($lat * 600000.0); |
520 | 575 | if ($neg==true) { |
@@ -530,7 +585,9 @@ discard block |
||
530 | 585 | if ($lon<0.0) { |
531 | 586 | $lon = -$lon; |
532 | 587 | $neg=true; |
533 | - } else $neg=false; |
|
588 | + } else { |
|
589 | + $neg=false; |
|
590 | + } |
|
534 | 591 | $lond = 0x00000000; |
535 | 592 | $lond = intval ($lon * 600000.0); |
536 | 593 | if ($neg==true) { |
@@ -543,9 +600,14 @@ discard block |
||
543 | 600 | |
544 | 601 | private function char2bin($name, $max_len) { |
545 | 602 | $len = strlen($name); |
546 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
547 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
548 | - else $pad = ''; |
|
603 | + if ($len > $max_len) { |
|
604 | + $name = substr($name,0,$max_len); |
|
605 | + } |
|
606 | + if ($len < $max_len) { |
|
607 | + $pad = str_repeat('0', ($max_len - $len) * 6); |
|
608 | + } else { |
|
609 | + $pad = ''; |
|
610 | + } |
|
549 | 611 | $rv = ''; |
550 | 612 | $ais_chars = array( |
551 | 613 | '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
@@ -558,9 +620,12 @@ discard block |
||
558 | 620 | ); |
559 | 621 | // " |
560 | 622 | $_a = str_split($name); |
561 | - if ($_a) foreach ($_a as $_1) { |
|
623 | + if ($_a) { |
|
624 | + foreach ($_a as $_1) { |
|
562 | 625 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
563 | - else $dec = 0; |
|
626 | + } else { |
|
627 | + $dec = 0; |
|
628 | + } |
|
564 | 629 | $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
565 | 630 | $rv .= $bin; |
566 | 631 | //echo "$_1 $dec ($bin)<br/>"; |
@@ -572,7 +637,9 @@ discard block |
||
572 | 637 | $len_bit = strlen($_enc); |
573 | 638 | $rem6 = $len_bit % 6; |
574 | 639 | $pad6_len = 0; |
575 | - if ($rem6) $pad6_len = 6 - $rem6; |
|
640 | + if ($rem6) { |
|
641 | + $pad6_len = 6 - $rem6; |
|
642 | + } |
|
576 | 643 | //echo $pad6_len.'<br>'; |
577 | 644 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
578 | 645 | $len_enc = strlen($_enc) / 6; |
@@ -581,8 +648,11 @@ discard block |
||
581 | 648 | for ($i=0; $i<$len_enc; $i++) { |
582 | 649 | $offset = $i * 6; |
583 | 650 | $dec = bindec(substr($_enc,$offset,6)); |
584 | - if ($dec < 40) $dec += 48; |
|
585 | - else $dec += 56; |
|
651 | + if ($dec < 40) { |
|
652 | + $dec += 48; |
|
653 | + } else { |
|
654 | + $dec += 56; |
|
655 | + } |
|
586 | 656 | //echo chr($dec)." $dec<br/>"; |
587 | 657 | $itu .= chr($dec); |
588 | 658 | } |
@@ -595,26 +665,42 @@ discard block |
||
595 | 665 | } |
596 | 666 | $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
597 | 667 | $lsb = $chksum & 0x0F; |
598 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
599 | - else $lsbc = '0'; |
|
668 | + if ($lsb >=0 && $lsb <= 15 ) { |
|
669 | + $lsbc = $hex_arr[$lsb]; |
|
670 | + } else { |
|
671 | + $lsbc = '0'; |
|
672 | + } |
|
600 | 673 | $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
601 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
602 | - else $msbc = '0'; |
|
674 | + if ($msb >=0 && $msb <= 15 ) { |
|
675 | + $msbc = $hex_arr[$msb]; |
|
676 | + } else { |
|
677 | + $msbc = '0'; |
|
678 | + } |
|
603 | 679 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
604 | 680 | return $itu; |
605 | 681 | } |
606 | 682 | |
607 | 683 | public function parse($buffer) { |
608 | 684 | $data = $this->process_ais_buf($buffer); |
609 | - if (!is_object($data)) return array(); |
|
685 | + if (!is_object($data)) { |
|
686 | + return array(); |
|
687 | + } |
|
610 | 688 | $result = array(); |
611 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
612 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
689 | + if ($data->lon != 0) { |
|
690 | + $result['longitude'] = $data->lon; |
|
691 | + } |
|
692 | + if ($data->lat != 0) { |
|
693 | + $result['latitude'] = $data->lat; |
|
694 | + } |
|
613 | 695 | $result['ident'] = trim($data->name); |
614 | 696 | $result['timestamp'] = $data->ts; |
615 | 697 | $result['mmsi'] = $data->mmsi; |
616 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
617 | - if ($data->cog != 0) $result['heading'] = $data->cog; |
|
698 | + if ($data->sog != -1.0) { |
|
699 | + $result['speed'] = $data->sog; |
|
700 | + } |
|
701 | + if ($data->cog != 0) { |
|
702 | + $result['heading'] = $data->cog; |
|
703 | + } |
|
618 | 704 | /* |
619 | 705 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
620 | 706 | $ro->id = bindec(substr($_aisdata,0,6)); |
@@ -624,15 +710,25 @@ discard block |
||
624 | 710 | |
625 | 711 | public function mmsitype($mmsi) { |
626 | 712 | if (strlen($mmsi) == 9) { |
627 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
628 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
629 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
630 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
631 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
632 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
633 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
634 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
635 | - else return 'Ship'; |
|
713 | + if (substr($mmsi,0,3) == '974') { |
|
714 | + return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
715 | + } elseif (substr($mmsi,0,3) == '972') { |
|
716 | + return 'MOB (Man Overboard) device'; |
|
717 | + } elseif (substr($mmsi,0,3) == '970') { |
|
718 | + return 'AIS SART (Search and Rescue Transmitter)'; |
|
719 | + } elseif (substr($mmsi,0,3) == '111') { |
|
720 | + return 'SAR (Search and Rescue) aircraft'; |
|
721 | + } elseif (substr($mmsi,0,2) == '98') { |
|
722 | + return 'Auxiliary craft associated with a parent ship'; |
|
723 | + } elseif (substr($mmsi,0,2) == '99') { |
|
724 | + return 'Aids to Navigation'; |
|
725 | + } elseif (substr($mmsi,0,2) == '00') { |
|
726 | + return 'Coastal stations'; |
|
727 | + } elseif (substr($mmsi,0,1) == '0') { |
|
728 | + return 'Group of ships'; |
|
729 | + } else { |
|
730 | + return 'Ship'; |
|
731 | + } |
|
636 | 732 | } |
637 | 733 | |
638 | 734 | |
@@ -648,32 +744,61 @@ discard block |
||
648 | 744 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
649 | 745 | return array(); |
650 | 746 | } |
651 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
652 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
747 | + if ($data->lon != 0) { |
|
748 | + $result['longitude'] = $data->lon; |
|
749 | + } |
|
750 | + if ($data->lat != 0) { |
|
751 | + $result['latitude'] = $data->lat; |
|
752 | + } |
|
653 | 753 | $result['ident'] = trim(str_replace('@','',$data->name)); |
654 | 754 | $result['timestamp'] = $data->ts; |
655 | 755 | $result['mmsi'] = $data->mmsi; |
656 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
756 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') { |
|
757 | + $result['mmsi'] = '3'.$result['mmsi']; |
|
758 | + } |
|
657 | 759 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
658 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
659 | - if ($data->heading !== '') $result['heading'] = $data->heading; |
|
660 | - elseif ($data->cog != 0) $result['heading'] = $data->cog; |
|
661 | - if ($data->status != '') $result['status'] = $data->status; |
|
662 | - if ($data->statusid !== '') $result['statusid'] = $data->statusid; |
|
663 | - if ($data->type !== '') $result['type'] = $data->type; |
|
664 | - if ($data->typeid !== '') $result['typeid'] = $data->typeid; |
|
665 | - if ($data->imo !== '') $result['imo'] = $data->imo; |
|
666 | - if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
760 | + if ($data->sog != -1.0) { |
|
761 | + $result['speed'] = $data->sog; |
|
762 | + } |
|
763 | + if ($data->heading !== '') { |
|
764 | + $result['heading'] = $data->heading; |
|
765 | + } elseif ($data->cog != 0) { |
|
766 | + $result['heading'] = $data->cog; |
|
767 | + } |
|
768 | + if ($data->status != '') { |
|
769 | + $result['status'] = $data->status; |
|
770 | + } |
|
771 | + if ($data->statusid !== '') { |
|
772 | + $result['statusid'] = $data->statusid; |
|
773 | + } |
|
774 | + if ($data->type !== '') { |
|
775 | + $result['type'] = $data->type; |
|
776 | + } |
|
777 | + if ($data->typeid !== '') { |
|
778 | + $result['typeid'] = $data->typeid; |
|
779 | + } |
|
780 | + if ($data->imo !== '') { |
|
781 | + $result['imo'] = $data->imo; |
|
782 | + } |
|
783 | + if ($data->callsign !== '') { |
|
784 | + $result['callsign'] = trim(str_replace('@','',$data->callsign)); |
|
785 | + } |
|
667 | 786 | if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') { |
668 | 787 | $eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
669 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
788 | + if ($eta_ts != '') { |
|
789 | + $result['eta_ts'] = $eta_ts; |
|
790 | + } |
|
670 | 791 | } elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) { |
671 | 792 | $eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00'); |
672 | - if ($eta_ts != '') $result['eta_ts'] = $eta_ts; |
|
793 | + if ($eta_ts != '') { |
|
794 | + $result['eta_ts'] = $eta_ts; |
|
795 | + } |
|
673 | 796 | } |
674 | 797 | if ($data->destination != '') { |
675 | 798 | $dest = trim(str_replace('@','',$data->destination)); |
676 | - if ($dest != '') $result['destination'] = $dest; |
|
799 | + if ($dest != '') { |
|
800 | + $result['destination'] = $dest; |
|
801 | + } |
|
677 | 802 | } |
678 | 803 | $result['all'] = (array) $data; |
679 | 804 | /* |
@@ -14,13 +14,17 @@ discard block |
||
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
17 | +if (isset($globalTracker) && $globalTracker) { |
|
18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
19 | +} |
|
18 | 20 | if (isset($globalMarine) && $globalMarine) { |
19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
21 | 23 | } |
22 | 24 | |
23 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
25 | +if (!isset($globalDebug)) { |
|
26 | + $globalDebug = FALSE; |
|
27 | +} |
|
24 | 28 | |
25 | 29 | // Check if schema is at latest version |
26 | 30 | $Connection = new Connection(); |
@@ -59,66 +63,107 @@ discard block |
||
59 | 63 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 64 | if (isset($options['s'])) { |
61 | 65 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
64 | -} elseif (isset($options['source'])) { |
|
66 | + if (isset($options['format'])) { |
|
67 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
68 | + } else { |
|
69 | + $globalSources[] = array('host' => $options['s']); |
|
70 | + } |
|
71 | + } elseif (isset($options['source'])) { |
|
65 | 72 | $globalSources = array(); |
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
68 | -} |
|
73 | + if (isset($options['format'])) { |
|
74 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
75 | + } else { |
|
76 | + $globalSources[] = array('host' => $options['source']); |
|
77 | + } |
|
78 | + } |
|
69 | 79 | if (isset($options['aprsserverhost'])) { |
70 | 80 | $globalServerAPRS = TRUE; |
71 | 81 | $globalServerAPRShost = $options['aprsserverhost']; |
72 | 82 | } |
73 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
74 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
75 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
76 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
83 | +if (isset($options['aprsserverport'])) { |
|
84 | + $globalServerAPRSport = $options['aprsserverport']; |
|
85 | +} |
|
86 | +if (isset($options['aprsserverssid'])) { |
|
87 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
88 | +} |
|
89 | +if (isset($options['aprsserverpass'])) { |
|
90 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
91 | +} |
|
92 | +if (isset($options['noaprsserver'])) { |
|
93 | + $globalServerAPRS = FALSE; |
|
94 | +} |
|
77 | 95 | if (isset($options['enable-aircraft'])) { |
78 | - if ($globalDebug) echo 'Enable Aircraft mode'."\n"; |
|
96 | + if ($globalDebug) { |
|
97 | + echo 'Enable Aircraft mode'."\n"; |
|
98 | + } |
|
79 | 99 | $globalAircraft = TRUE; |
80 | 100 | } |
81 | 101 | if (isset($options['disable-aircraft'])) { |
82 | - if ($globalDebug) echo 'Disable Aircraft mode'."\n"; |
|
102 | + if ($globalDebug) { |
|
103 | + echo 'Disable Aircraft mode'."\n"; |
|
104 | + } |
|
83 | 105 | $globalAircraft = FALSE; |
84 | 106 | } |
85 | 107 | if (isset($options['enable-tracker'])) { |
86 | - if ($globalDebug) echo 'Enable Tracker mode'."\n"; |
|
108 | + if ($globalDebug) { |
|
109 | + echo 'Enable Tracker mode'."\n"; |
|
110 | + } |
|
87 | 111 | $globalTracker = TRUE; |
88 | 112 | } |
89 | 113 | if (isset($options['disable-tracker'])) { |
90 | - if ($globalDebug) echo 'Disable Tracker mode'."\n"; |
|
114 | + if ($globalDebug) { |
|
115 | + echo 'Disable Tracker mode'."\n"; |
|
116 | + } |
|
91 | 117 | $globalTracker = FALSE; |
92 | 118 | } |
93 | 119 | if (isset($options['enable-marine'])) { |
94 | - if ($globalDebug) echo 'Enable Marine mode'."\n"; |
|
120 | + if ($globalDebug) { |
|
121 | + echo 'Enable Marine mode'."\n"; |
|
122 | + } |
|
95 | 123 | $globalMarine = TRUE; |
96 | 124 | } |
97 | 125 | if (isset($options['disable-marine'])) { |
98 | - if ($globalDebug) echo 'Disable Marine mode'."\n"; |
|
126 | + if ($globalDebug) { |
|
127 | + echo 'Disable Marine mode'."\n"; |
|
128 | + } |
|
99 | 129 | $globalMarine = FALSE; |
100 | 130 | } |
101 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
102 | -if (isset($options['server'])) $globalServer = TRUE; |
|
103 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
104 | -else $id_source = 1; |
|
131 | +if (isset($options['nodaemon'])) { |
|
132 | + $globalDaemon = FALSE; |
|
133 | +} |
|
134 | +if (isset($options['server'])) { |
|
135 | + $globalServer = TRUE; |
|
136 | +} |
|
137 | +if (isset($options['idsource'])) { |
|
138 | + $id_source = $options['idsource']; |
|
139 | +} else { |
|
140 | + $id_source = 1; |
|
141 | +} |
|
105 | 142 | if (isset($globalServer) && $globalServer) { |
106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
143 | + if ($globalDebug) { |
|
144 | + echo "Using Server Mode\n"; |
|
145 | + } |
|
107 | 146 | $SI=new SpotterServer(); |
108 | 147 | /* |
109 | 148 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 149 | $SI = new adsb2aprs(); |
111 | 150 | $SI->connect(); |
112 | 151 | */ |
113 | -} else $SI=new SpotterImport($Connection->db); |
|
152 | +} else { |
|
153 | + $SI=new SpotterImport($Connection->db); |
|
154 | +} |
|
114 | 155 | |
115 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
156 | +if (isset($globalTracker) && $globalTracker) { |
|
157 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
158 | +} |
|
116 | 159 | if (isset($globalMarine) && $globalMarine) { |
117 | 160 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
118 | 161 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
119 | 162 | } |
120 | 163 | |
121 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
164 | +if (isset($globalTracker) && $globalTracker) { |
|
165 | + $TI = new TrackerImport($Connection->db); |
|
166 | +} |
|
122 | 167 | if (isset($globalMarine) && $globalMarine) { |
123 | 168 | $AIS = new AIS(); |
124 | 169 | $MI = new MarineImport($Connection->db); |
@@ -143,7 +188,9 @@ discard block |
||
143 | 188 | } |
144 | 189 | |
145 | 190 | // let's try and connect |
146 | -if ($globalDebug) echo "Connecting...\n"; |
|
191 | +if ($globalDebug) { |
|
192 | + echo "Connecting...\n"; |
|
193 | +} |
|
147 | 194 | $use_aprs = false; |
148 | 195 | $aprs_full = false; |
149 | 196 | $reset = 0; |
@@ -152,7 +199,9 @@ discard block |
||
152 | 199 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
153 | 200 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
154 | 201 | $reset++; |
155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
202 | + if ($globalDebug) { |
|
203 | + echo 'Connect to all...'."\n"; |
|
204 | + } |
|
156 | 205 | foreach ($hosts as $id => $value) { |
157 | 206 | $host = $value['host']; |
158 | 207 | $globalSources[$id]['last_exec'] = 0; |
@@ -162,27 +211,37 @@ discard block |
||
162 | 211 | //$formats[$id] = 'deltadbtxt'; |
163 | 212 | $globalSources[$id]['format'] = 'deltadbtxt'; |
164 | 213 | //$last_exec['deltadbtxt'] = 0; |
165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
214 | + if ($globalDebug) { |
|
215 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
216 | + } |
|
166 | 217 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
167 | 218 | //$formats[$id] = 'vatsimtxt'; |
168 | 219 | $globalSources[$id]['format'] = 'vatsimtxt'; |
169 | 220 | //$last_exec['vatsimtxt'] = 0; |
170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
221 | + if ($globalDebug) { |
|
222 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
223 | + } |
|
171 | 224 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
172 | 225 | //$formats[$id] = 'aircraftlistjson'; |
173 | 226 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
174 | 227 | //$last_exec['aircraftlistjson'] = 0; |
175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
228 | + if ($globalDebug) { |
|
229 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
230 | + } |
|
176 | 231 | } else if (preg_match('/aircraft.json$/i',$host)) { |
177 | 232 | //$formats[$id] = 'aircraftjson'; |
178 | 233 | $globalSources[$id]['format'] = 'aircraftjson'; |
179 | 234 | //$last_exec['aircraftlistjson'] = 0; |
180 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
235 | + if ($globalDebug) { |
|
236 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
237 | + } |
|
181 | 238 | } else if (preg_match('/opensky/i',$host)) { |
182 | 239 | //$formats[$id] = 'aircraftlistjson'; |
183 | 240 | $globalSources[$id]['format'] = 'opensky'; |
184 | 241 | //$last_exec['aircraftlistjson'] = 0; |
185 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
242 | + if ($globalDebug) { |
|
243 | + echo "Connect to opensky source (".$host.")...\n"; |
|
244 | + } |
|
186 | 245 | /* |
187 | 246 | // Disabled for now, site change source format |
188 | 247 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
@@ -199,7 +258,9 @@ discard block |
||
199 | 258 | //$formats[$id] = 'planeupdatefaa'; |
200 | 259 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
201 | 260 | //$last_exec['planeupdatefaa'] = 0; |
202 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
261 | + if ($globalDebug) { |
|
262 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
263 | + } |
|
203 | 264 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
204 | 265 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
205 | 266 | exit(0); |
@@ -208,37 +269,53 @@ discard block |
||
208 | 269 | //$formats[$id] = 'phpvmacars'; |
209 | 270 | $globalSources[$id]['format'] = 'phpvmacars'; |
210 | 271 | //$last_exec['phpvmacars'] = 0; |
211 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
272 | + if ($globalDebug) { |
|
273 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
274 | + } |
|
212 | 275 | } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
213 | 276 | //$formats[$id] = 'phpvmacars'; |
214 | 277 | $globalSources[$id]['format'] = 'vaos'; |
215 | 278 | //$last_exec['phpvmacars'] = 0; |
216 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
279 | + if ($globalDebug) { |
|
280 | + echo "Connect to vaos source (".$host.")...\n"; |
|
281 | + } |
|
217 | 282 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
218 | 283 | //$formats[$id] = 'phpvmacars'; |
219 | 284 | $globalSources[$id]['format'] = 'vam'; |
220 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
285 | + if ($globalDebug) { |
|
286 | + echo "Connect to Vam source (".$host.")...\n"; |
|
287 | + } |
|
221 | 288 | } else if (preg_match('/whazzup/i',$host)) { |
222 | 289 | //$formats[$id] = 'whazzup'; |
223 | 290 | $globalSources[$id]['format'] = 'whazzup'; |
224 | 291 | //$last_exec['whazzup'] = 0; |
225 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
292 | + if ($globalDebug) { |
|
293 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
294 | + } |
|
226 | 295 | } else if (preg_match('/blitzortung/i',$host)) { |
227 | 296 | $globalSources[$id]['format'] = 'blitzortung'; |
228 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
297 | + if ($globalDebug) { |
|
298 | + echo "Connect to blitzortung source (".$host.")...\n"; |
|
299 | + } |
|
229 | 300 | } else if (preg_match('/airwhere/i',$host)) { |
230 | 301 | $globalSources[$id]['format'] = 'airwhere'; |
231 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
302 | + if ($globalDebug) { |
|
303 | + echo "Connect to airwhere source (".$host.")...\n"; |
|
304 | + } |
|
232 | 305 | } else if (preg_match('/recentpireps/i',$host)) { |
233 | 306 | //$formats[$id] = 'pirepsjson'; |
234 | 307 | $globalSources[$id]['format'] = 'pirepsjson'; |
235 | 308 | //$last_exec['pirepsjson'] = 0; |
236 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
309 | + if ($globalDebug) { |
|
310 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
311 | + } |
|
237 | 312 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
238 | 313 | //$formats[$id] = 'fr24json'; |
239 | 314 | $globalSources[$id]['format'] = 'fr24json'; |
240 | 315 | //$last_exec['fr24json'] = 0; |
241 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
316 | + if ($globalDebug) { |
|
317 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
318 | + } |
|
242 | 319 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
243 | 320 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
244 | 321 | exit(0); |
@@ -247,7 +324,9 @@ discard block |
||
247 | 324 | //$formats[$id] = 'fr24json'; |
248 | 325 | $globalSources[$id]['format'] = 'myshiptracking'; |
249 | 326 | //$last_exec['fr24json'] = 0; |
250 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
327 | + if ($globalDebug) { |
|
328 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
329 | + } |
|
251 | 330 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
252 | 331 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
253 | 332 | exit(0); |
@@ -256,16 +335,24 @@ discard block |
||
256 | 335 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
257 | 336 | //$formats[$id] = 'tsv'; |
258 | 337 | $globalSources[$id]['format'] = 'tsv'; |
259 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
338 | + if ($globalDebug) { |
|
339 | + echo "Connect to tsv source (".$host.")...\n"; |
|
340 | + } |
|
260 | 341 | } |
261 | 342 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
262 | 343 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
263 | 344 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
264 | 345 | if ($idf !== false) { |
265 | 346 | $httpfeeds[$id] = $idf; |
266 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
267 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
268 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
347 | + if ($globalDebug) { |
|
348 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
349 | + } |
|
350 | + } elseif ($globalDebug) { |
|
351 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
352 | + } |
|
353 | + } elseif ($globalDebug) { |
|
354 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
355 | + } |
|
269 | 356 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
270 | 357 | $hostport = explode(':',$host); |
271 | 358 | if (isset($hostport[1])) { |
@@ -305,17 +392,25 @@ discard block |
||
305 | 392 | //$formats[$id] = 'beast'; |
306 | 393 | $globalSources[$id]['format'] = 'beast'; |
307 | 394 | //} else $formats[$id] = 'sbs'; |
308 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
395 | + } else { |
|
396 | + $globalSources[$id]['format'] = 'sbs'; |
|
397 | + } |
|
309 | 398 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
310 | 399 | } |
311 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
400 | + if ($globalDebug) { |
|
401 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
402 | + } |
|
312 | 403 | } else { |
313 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
404 | + if ($globalDebug) { |
|
405 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
406 | + } |
|
314 | 407 | } |
315 | 408 | } |
316 | 409 | } |
317 | 410 | } |
318 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
411 | +if (!isset($globalMinFetch)) { |
|
412 | + $globalMinFetch = 15; |
|
413 | +} |
|
319 | 414 | |
320 | 415 | // Initialize all |
321 | 416 | $status = array(); |
@@ -324,13 +419,19 @@ discard block |
||
324 | 419 | $formats = array(); |
325 | 420 | $last_exec = array(); |
326 | 421 | $time = time(); |
327 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
328 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
329 | -else $timeout = 20; |
|
422 | +if (isset($globalSourcesTimeout)) { |
|
423 | + $timeout = $globalSourcesTimeOut; |
|
424 | +} else if (isset($globalSBS1TimeOut)) { |
|
425 | + $timeout = $globalSBS1TimeOut; |
|
426 | +} else { |
|
427 | + $timeout = 20; |
|
428 | +} |
|
330 | 429 | $errno = ''; |
331 | 430 | $errstr=''; |
332 | 431 | |
333 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
432 | +if (!isset($globalDaemon)) { |
|
433 | + $globalDaemon = TRUE; |
|
434 | +} |
|
334 | 435 | /* Initiate connections to all the hosts simultaneously */ |
335 | 436 | //connect_all($hosts); |
336 | 437 | //connect_all($globalSources); |
@@ -359,7 +460,9 @@ discard block |
||
359 | 460 | if (isset($source['format']) && $source['format'] == 'aprs') { |
360 | 461 | $aprs_connect = 0; |
361 | 462 | $use_aprs = true; |
362 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
463 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
464 | + $aprs_full = true; |
|
465 | + } |
|
363 | 466 | break; |
364 | 467 | } |
365 | 468 | } |
@@ -370,25 +473,46 @@ discard block |
||
370 | 473 | $aprs_connect = 0; |
371 | 474 | $aprs_keep = 120; |
372 | 475 | $aprs_last_tx = time(); |
373 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
374 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
375 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
376 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
377 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
378 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
379 | - if ($aprs_full) $aprs_filter = ''; |
|
380 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
381 | - else $aprs_pass = '-1'; |
|
476 | + if (isset($globalAPRSversion)) { |
|
477 | + $aprs_version = $globalAPRSversion; |
|
478 | + } else { |
|
479 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
480 | + } |
|
481 | + if (isset($globalAPRSssid)) { |
|
482 | + $aprs_ssid = $globalAPRSssid; |
|
483 | + } else { |
|
484 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
485 | + } |
|
486 | + if (isset($globalAPRSfilter)) { |
|
487 | + $aprs_filter = $globalAPRSfilter; |
|
488 | + } else { |
|
489 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
490 | + } |
|
491 | + if ($aprs_full) { |
|
492 | + $aprs_filter = ''; |
|
493 | + } |
|
494 | + if (isset($globalAPRSpass)) { |
|
495 | + $aprs_pass = $globalAPRSpass; |
|
496 | + } else { |
|
497 | + $aprs_pass = '-1'; |
|
498 | + } |
|
382 | 499 | |
383 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
384 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
385 | -} |
|
500 | + if ($aprs_filter != '') { |
|
501 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
502 | + } else { |
|
503 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
504 | + } |
|
505 | + } |
|
386 | 506 | |
387 | 507 | // connected - lets do some work |
388 | 508 | //if ($globalDebug) echo "Connected!\n"; |
389 | 509 | sleep(1); |
390 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
391 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
510 | +if ($globalDebug) { |
|
511 | + echo "SCAN MODE \n\n"; |
|
512 | +} |
|
513 | +if (!isset($globalCronEnd)) { |
|
514 | + $globalCronEnd = 60; |
|
515 | +} |
|
392 | 516 | $endtime = time()+$globalCronEnd; |
393 | 517 | $i = 1; |
394 | 518 | $tt = array(); |
@@ -402,22 +526,32 @@ discard block |
||
402 | 526 | |
403 | 527 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
404 | 528 | while ($i > 0) { |
405 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
529 | + if (function_exists('pcntl_fork')) { |
|
530 | + pcntl_signal_dispatch(); |
|
531 | + } |
|
406 | 532 | |
407 | - if (!$globalDaemon) $i = $endtime-time(); |
|
533 | + if (!$globalDaemon) { |
|
534 | + $i = $endtime-time(); |
|
535 | + } |
|
408 | 536 | // Delete old ATC |
409 | 537 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
410 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
538 | + if ($globalDebug) { |
|
539 | + echo 'Delete old ATC...'."\n"; |
|
540 | + } |
|
411 | 541 | $ATC->deleteOldATC(); |
412 | 542 | } |
413 | 543 | |
414 | 544 | if (count($last_exec) == count($globalSources)) { |
415 | 545 | $max = $globalMinFetch; |
416 | 546 | foreach ($last_exec as $last) { |
417 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
547 | + if ((time() - $last['last']) < $max) { |
|
548 | + $max = time() - $last['last']; |
|
549 | + } |
|
418 | 550 | } |
419 | 551 | if ($max < $globalMinFetch) { |
420 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
552 | + if ($globalDebug) { |
|
553 | + echo 'Sleeping...'."\n"; |
|
554 | + } |
|
421 | 555 | sleep($globalMinFetch-$max+2); |
422 | 556 | } |
423 | 557 | } |
@@ -427,7 +561,9 @@ discard block |
||
427 | 561 | foreach ($globalSources as $id => $value) { |
428 | 562 | date_default_timezone_set('UTC'); |
429 | 563 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
430 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
564 | + if (!isset($last_exec[$id]['last'])) { |
|
565 | + $last_exec[$id]['last'] = 0; |
|
566 | + } |
|
431 | 567 | if ($value['format'] === 'deltadbtxt' && |
432 | 568 | ( |
433 | 569 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
@@ -436,7 +572,9 @@ discard block |
||
436 | 572 | ) { |
437 | 573 | //$buffer = $Common->getData($hosts[$id]); |
438 | 574 | $buffer = $Common->getData($value['host']); |
439 | - if ($buffer != '') $reset = 0; |
|
575 | + if ($buffer != '') { |
|
576 | + $reset = 0; |
|
577 | + } |
|
440 | 578 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
441 | 579 | $buffer = explode('\n',$buffer); |
442 | 580 | foreach ($buffer as $line) { |
@@ -445,20 +583,41 @@ discard block |
||
445 | 583 | $data = array(); |
446 | 584 | $data['hex'] = $line[1]; // hex |
447 | 585 | $data['ident'] = $line[2]; // ident |
448 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
449 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
450 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
451 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
452 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
586 | + if (isset($line[3])) { |
|
587 | + $data['altitude'] = $line[3]; |
|
588 | + } |
|
589 | + // altitude |
|
590 | + if (isset($line[4])) { |
|
591 | + $data['speed'] = $line[4]; |
|
592 | + } |
|
593 | + // speed |
|
594 | + if (isset($line[5])) { |
|
595 | + $data['heading'] = $line[5]; |
|
596 | + } |
|
597 | + // heading |
|
598 | + if (isset($line[6])) { |
|
599 | + $data['latitude'] = $line[6]; |
|
600 | + } |
|
601 | + // lat |
|
602 | + if (isset($line[7])) { |
|
603 | + $data['longitude'] = $line[7]; |
|
604 | + } |
|
605 | + // long |
|
453 | 606 | $data['verticalrate'] = ''; // vertical rate |
454 | 607 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
455 | 608 | $data['emergency'] = ''; // emergency |
456 | 609 | $data['datetime'] = date('Y-m-d H:i:s'); |
457 | 610 | $data['format_source'] = 'deltadbtxt'; |
458 | 611 | $data['id_source'] = $id_source; |
459 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
460 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
461 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
612 | + if (isset($value['name']) && $value['name'] != '') { |
|
613 | + $data['source_name'] = $value['name']; |
|
614 | + } |
|
615 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
616 | + $data['noarchive'] = true; |
|
617 | + } |
|
618 | + if (isset($value['sourcestats'])) { |
|
619 | + $data['sourcestats'] = $value['sourcestats']; |
|
620 | + } |
|
462 | 621 | $SI->add($data); |
463 | 622 | unset($data); |
464 | 623 | } |
@@ -473,7 +632,9 @@ discard block |
||
473 | 632 | date_default_timezone_set('CET'); |
474 | 633 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
475 | 634 | date_default_timezone_set('UTC'); |
476 | - if ($buffer != '') $reset = 0; |
|
635 | + if ($buffer != '') { |
|
636 | + $reset = 0; |
|
637 | + } |
|
477 | 638 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
478 | 639 | $buffer = explode('\n',$buffer); |
479 | 640 | foreach ($buffer as $line) { |
@@ -482,18 +643,42 @@ discard block |
||
482 | 643 | $add = false; |
483 | 644 | $ais_data = $AIS->parse_line(trim($line)); |
484 | 645 | $data = array(); |
485 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
486 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
487 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
488 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
489 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
490 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
491 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
492 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
493 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
494 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
495 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
496 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
646 | + if (isset($ais_data['ident'])) { |
|
647 | + $data['ident'] = $ais_data['ident']; |
|
648 | + } |
|
649 | + if (isset($ais_data['mmsi'])) { |
|
650 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
651 | + } |
|
652 | + if (isset($ais_data['speed'])) { |
|
653 | + $data['speed'] = $ais_data['speed']; |
|
654 | + } |
|
655 | + if (isset($ais_data['heading'])) { |
|
656 | + $data['heading'] = $ais_data['heading']; |
|
657 | + } |
|
658 | + if (isset($ais_data['latitude'])) { |
|
659 | + $data['latitude'] = $ais_data['latitude']; |
|
660 | + } |
|
661 | + if (isset($ais_data['longitude'])) { |
|
662 | + $data['longitude'] = $ais_data['longitude']; |
|
663 | + } |
|
664 | + if (isset($ais_data['status'])) { |
|
665 | + $data['status'] = $ais_data['status']; |
|
666 | + } |
|
667 | + if (isset($ais_data['statusid'])) { |
|
668 | + $data['status_id'] = $ais_data['statusid']; |
|
669 | + } |
|
670 | + if (isset($ais_data['type'])) { |
|
671 | + $data['type'] = $ais_data['type']; |
|
672 | + } |
|
673 | + if (isset($ais_data['typeid'])) { |
|
674 | + $data['type_id'] = $ais_data['typeid']; |
|
675 | + } |
|
676 | + if (isset($ais_data['imo'])) { |
|
677 | + $data['imo'] = $ais_data['imo']; |
|
678 | + } |
|
679 | + if (isset($ais_data['callsign'])) { |
|
680 | + $data['callsign'] = $ais_data['callsign']; |
|
681 | + } |
|
497 | 682 | if (isset($ais_data['timestamp'])) { |
498 | 683 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
499 | 684 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -507,8 +692,12 @@ discard block |
||
507 | 692 | $data['format_source'] = 'aisnmeatxt'; |
508 | 693 | $data['id_source'] = $id_source; |
509 | 694 | //print_r($data); |
510 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
511 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
695 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
696 | + $data['noarchive'] = true; |
|
697 | + } |
|
698 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
699 | + $MI->add($data); |
|
700 | + } |
|
512 | 701 | unset($data); |
513 | 702 | } |
514 | 703 | } |
@@ -531,20 +720,48 @@ discard block |
||
531 | 720 | if ($line != '') { |
532 | 721 | $ais_data = $AIS->parse_line(trim($line)); |
533 | 722 | $data = array(); |
534 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
535 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
536 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
537 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
538 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
539 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
540 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
541 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
542 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
543 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
544 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
545 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
546 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
547 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
723 | + if (isset($ais_data['ident'])) { |
|
724 | + $data['ident'] = $ais_data['ident']; |
|
725 | + } |
|
726 | + if (isset($ais_data['mmsi'])) { |
|
727 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
728 | + } |
|
729 | + if (isset($ais_data['speed'])) { |
|
730 | + $data['speed'] = $ais_data['speed']; |
|
731 | + } |
|
732 | + if (isset($ais_data['heading'])) { |
|
733 | + $data['heading'] = $ais_data['heading']; |
|
734 | + } |
|
735 | + if (isset($ais_data['latitude'])) { |
|
736 | + $data['latitude'] = $ais_data['latitude']; |
|
737 | + } |
|
738 | + if (isset($ais_data['longitude'])) { |
|
739 | + $data['longitude'] = $ais_data['longitude']; |
|
740 | + } |
|
741 | + if (isset($ais_data['status'])) { |
|
742 | + $data['status'] = $ais_data['status']; |
|
743 | + } |
|
744 | + if (isset($ais_data['statusid'])) { |
|
745 | + $data['status_id'] = $ais_data['statusid']; |
|
746 | + } |
|
747 | + if (isset($ais_data['type'])) { |
|
748 | + $data['type'] = $ais_data['type']; |
|
749 | + } |
|
750 | + if (isset($ais_data['typeid'])) { |
|
751 | + $data['type_id'] = $ais_data['typeid']; |
|
752 | + } |
|
753 | + if (isset($ais_data['imo'])) { |
|
754 | + $data['imo'] = $ais_data['imo']; |
|
755 | + } |
|
756 | + if (isset($ais_data['callsign'])) { |
|
757 | + $data['callsign'] = $ais_data['callsign']; |
|
758 | + } |
|
759 | + if (isset($ais_data['destination'])) { |
|
760 | + $data['arrival_code'] = $ais_data['destination']; |
|
761 | + } |
|
762 | + if (isset($ais_data['eta_ts'])) { |
|
763 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
764 | + } |
|
548 | 765 | if (isset($ais_data['timestamp'])) { |
549 | 766 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
550 | 767 | } else { |
@@ -552,18 +769,27 @@ discard block |
||
552 | 769 | } |
553 | 770 | $data['format_source'] = 'aisnmeahttp'; |
554 | 771 | $data['id_source'] = $id_source; |
555 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
556 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
772 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
773 | + $data['noarchive'] = true; |
|
774 | + } |
|
775 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
776 | + $MI->add($data); |
|
777 | + } |
|
557 | 778 | unset($data); |
558 | 779 | } |
559 | 780 | } |
560 | 781 | } |
561 | 782 | } else { |
562 | 783 | $format = $value['format']; |
563 | - if (isset($tt[$format])) $tt[$format]++; |
|
564 | - else $tt[$format] = 0; |
|
784 | + if (isset($tt[$format])) { |
|
785 | + $tt[$format]++; |
|
786 | + } else { |
|
787 | + $tt[$format] = 0; |
|
788 | + } |
|
565 | 789 | if ($tt[$format] > 30) { |
566 | - if ($globalDebug) echo 'Reconnect...'."\n"; |
|
790 | + if ($globalDebug) { |
|
791 | + echo 'Reconnect...'."\n"; |
|
792 | + } |
|
567 | 793 | sleep(2); |
568 | 794 | //$sourceeen[] = $value; |
569 | 795 | //connect_all($sourceeen); |
@@ -599,12 +825,18 @@ discard block |
||
599 | 825 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
600 | 826 | //$data['type_id'] = $line['TYPE']; |
601 | 827 | $data['imo'] = $line['IMO']; |
602 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
603 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
828 | + if ($line['DEST'] != '') { |
|
829 | + $data['arrival_code'] = $line['DEST']; |
|
830 | + } |
|
831 | + if ($line['ARV'] != '') { |
|
832 | + $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
833 | + } |
|
604 | 834 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
605 | 835 | $data['format_source'] = 'myshiptracking'; |
606 | 836 | $data['id_source'] = $id_source; |
607 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
837 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
838 | + $data['noarchive'] = true; |
|
839 | + } |
|
608 | 840 | $MI->add($data); |
609 | 841 | unset($data); |
610 | 842 | } |
@@ -629,7 +861,9 @@ discard block |
||
629 | 861 | $data['callsign'] = $line['callsign']; |
630 | 862 | $data['mmsi'] = substr($line['mmsi'],-9); |
631 | 863 | $data['speed'] = $line['sog']; |
632 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
864 | + if ($line['heading'] != '511') { |
|
865 | + $data['heading'] = $line['heading']; |
|
866 | + } |
|
633 | 867 | $data['latitude'] = $line['latitude']; |
634 | 868 | $data['longitude'] = $line['longitude']; |
635 | 869 | $data['type_id'] = $line['shiptype']; |
@@ -637,7 +871,9 @@ discard block |
||
637 | 871 | $data['datetime'] = $line['time']; |
638 | 872 | $data['format_source'] = 'boatbeaconapp'; |
639 | 873 | $data['id_source'] = $id_source; |
640 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
874 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
875 | + $data['noarchive'] = true; |
|
876 | + } |
|
641 | 877 | $MI->add($data); |
642 | 878 | unset($data); |
643 | 879 | } |
@@ -659,22 +895,44 @@ discard block |
||
659 | 895 | foreach ($all_data['features'] as $line) { |
660 | 896 | print_r($line); |
661 | 897 | $data = array(); |
662 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
|
663 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; |
|
664 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
665 | - if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo']; |
|
666 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; |
|
667 | - if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading']; |
|
898 | + if (isset($line['properties']['name'])) { |
|
899 | + $data['ident'] = $line['properties']['name']; |
|
900 | + } |
|
901 | + if (isset($line['properties']['callsign'])) { |
|
902 | + $data['callsign'] = $line['properties']['callsign']; |
|
903 | + } |
|
904 | + if (isset($line['properties']['mmsi'])) { |
|
905 | + $data['mmsi'] = substr($line['properties']['mmsi'],-9); |
|
906 | + } |
|
907 | + if (isset($line['properties']['imo'])) { |
|
908 | + $data['imo'] = $line['properties']['imo']; |
|
909 | + } |
|
910 | + if (isset($line['properties']['speed'])) { |
|
911 | + $data['speed'] = $line['properties']['speed']; |
|
912 | + } |
|
913 | + if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) { |
|
914 | + $data['heading'] = $line['properties']['heading']; |
|
915 | + } |
|
668 | 916 | $data['latitude'] = $line['geometry']['coordinates'][1]; |
669 | 917 | $data['longitude'] = $line['geometry']['coordinates'][0]; |
670 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; |
|
671 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; |
|
672 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; |
|
918 | + if (isset($line['properties']['vesselType'])) { |
|
919 | + $data['type'] = $line['properties']['vesselType']; |
|
920 | + } |
|
921 | + if (isset($line['properties']['destination'])) { |
|
922 | + $data['arrival_code'] = $line['properties']['destination']; |
|
923 | + } |
|
924 | + if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { |
|
925 | + $data['arrival_date'] = $line['properties']['eta']; |
|
926 | + } |
|
673 | 927 | $data['format_source'] = 'boatnerd'; |
674 | 928 | $data['id_source'] = $id_source; |
675 | 929 | $data['datetime'] = date('Y-m-d H:i:s'); |
676 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
677 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
|
930 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
931 | + $data['noarchive'] = true; |
|
932 | + } |
|
933 | + if ($line['properties']['vesselType'] != 'Navigation Aid') { |
|
934 | + $MI->add($data); |
|
935 | + } |
|
678 | 936 | unset($data); |
679 | 937 | } |
680 | 938 | } |
@@ -691,7 +949,9 @@ discard block |
||
691 | 949 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
692 | 950 | echo 'done !'."\n"; |
693 | 951 | // FIXME: Need more work |
694 | - if ($buffer != '') $reset = 0; |
|
952 | + if ($buffer != '') { |
|
953 | + $reset = 0; |
|
954 | + } |
|
695 | 955 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
696 | 956 | $buffer = explode('\n',$buffer); |
697 | 957 | foreach ($buffer as $line) { |
@@ -717,7 +977,9 @@ discard block |
||
717 | 977 | //$data['etaTime'] = substr($line,135,5); |
718 | 978 | $data['format_source'] = 'shipplotter'; |
719 | 979 | $data['id_source'] = $id_source; |
720 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
980 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
981 | + $data['noarchive'] = true; |
|
982 | + } |
|
721 | 983 | //print_r($data); |
722 | 984 | echo 'Add...'."\n"; |
723 | 985 | $MI->add($data); |
@@ -751,16 +1013,28 @@ discard block |
||
751 | 1013 | $line = explode(':', $line); |
752 | 1014 | if (count($line) > 30 && $line[0] != 'callsign') { |
753 | 1015 | $data = array(); |
754 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
755 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1016 | + if (isset($line[37]) && $line[37] != '') { |
|
1017 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
1018 | + } else { |
|
1019 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
1020 | + } |
|
756 | 1021 | $data['pilot_id'] = $line[1]; |
757 | 1022 | $data['pilot_name'] = $line[2]; |
758 | 1023 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
759 | 1024 | $data['ident'] = $line[0]; // ident |
760 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
1025 | + if ($line[7] != '' && $line[7] != 0) { |
|
1026 | + $data['altitude'] = $line[7]; |
|
1027 | + } |
|
1028 | + // altitude |
|
761 | 1029 | $data['speed'] = $line[8]; // speed |
762 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
763 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
1030 | + if (isset($line[45])) { |
|
1031 | + $data['heading'] = $line[45]; |
|
1032 | + } |
|
1033 | + // heading |
|
1034 | + elseif (isset($line[38])) { |
|
1035 | + $data['heading'] = $line[38]; |
|
1036 | + } |
|
1037 | + // heading |
|
764 | 1038 | $data['latitude'] = $line[5]; // lat |
765 | 1039 | $data['longitude'] = $line[6]; // long |
766 | 1040 | $data['verticalrate'] = ''; // vertical rate |
@@ -776,7 +1050,9 @@ discard block |
||
776 | 1050 | $data['frequency'] = $line[4]; |
777 | 1051 | $data['type'] = $line[18]; |
778 | 1052 | $data['range'] = $line[19]; |
779 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
1053 | + if (isset($line[35])) { |
|
1054 | + $data['info'] = $line[35]; |
|
1055 | + } |
|
780 | 1056 | $data['id_source'] = $id_source; |
781 | 1057 | //$data['arrival_airport_time'] = ; |
782 | 1058 | if ($line[9] != '') { |
@@ -790,27 +1066,47 @@ discard block |
||
790 | 1066 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
791 | 1067 | */ |
792 | 1068 | $data['format_source'] = $value['format']; |
793 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
794 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
795 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
796 | - elseif ($line[3] === 'ATC') { |
|
1069 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1070 | + $data['noarchive'] = true; |
|
1071 | + } |
|
1072 | + if (isset($value['name']) && $value['name'] != '') { |
|
1073 | + $data['source_name'] = $value['name']; |
|
1074 | + } |
|
1075 | + if ($line[3] === 'PILOT') { |
|
1076 | + $SI->add($data); |
|
1077 | + } elseif ($line[3] === 'ATC') { |
|
797 | 1078 | //print_r($data); |
798 | 1079 | $data['info'] = str_replace('^§','<br />',$data['info']); |
799 | 1080 | $data['info'] = str_replace('&sect;','',$data['info']); |
800 | 1081 | $typec = substr($data['ident'],-3); |
801 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
802 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
803 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
804 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
805 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
806 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
807 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
808 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
809 | - elseif ($data['type'] === '') $data['type'] = 'Observer'; |
|
810 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
1082 | + if ($typec === 'APP') { |
|
1083 | + $data['type'] = 'Approach'; |
|
1084 | + } elseif ($typec === 'TWR') { |
|
1085 | + $data['type'] = 'Tower'; |
|
1086 | + } elseif ($typec === 'OBS') { |
|
1087 | + $data['type'] = 'Observer'; |
|
1088 | + } elseif ($typec === 'GND') { |
|
1089 | + $data['type'] = 'Ground'; |
|
1090 | + } elseif ($typec === 'DEL') { |
|
1091 | + $data['type'] = 'Delivery'; |
|
1092 | + } elseif ($typec === 'DEP') { |
|
1093 | + $data['type'] = 'Departure'; |
|
1094 | + } elseif ($typec === 'FSS') { |
|
1095 | + $data['type'] = 'Flight Service Station'; |
|
1096 | + } elseif ($typec === 'CTR') { |
|
1097 | + $data['type'] = 'Control Radar or Centre'; |
|
1098 | + } elseif ($data['type'] === '') { |
|
1099 | + $data['type'] = 'Observer'; |
|
1100 | + } |
|
1101 | + if (!isset($data['source_name'])) { |
|
1102 | + $data['source_name'] = ''; |
|
1103 | + } |
|
811 | 1104 | if (isset($ATC)) { |
812 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
813 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
1105 | + if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { |
|
1106 | + echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
1107 | + } else { |
|
1108 | + echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
1109 | + } |
|
814 | 1110 | } |
815 | 1111 | } |
816 | 1112 | unset($data); |
@@ -837,14 +1133,20 @@ discard block |
||
837 | 1133 | $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
838 | 1134 | $data['latitude'] = (float)$line['pktLatitude']; |
839 | 1135 | $data['longitude'] = (float)$line['pktLongitude']; |
840 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
841 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
1136 | + if ((float)$line['pktTrack'] != 0) { |
|
1137 | + $data['heading'] = (float)$line['pktTrack']; |
|
1138 | + } |
|
1139 | + if ((int)$line['pktSpeed'] != 0) { |
|
1140 | + $data['speed'] = (int)$line['pktSpeed']; |
|
1141 | + } |
|
842 | 1142 | $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
843 | 1143 | $data['altitude_relative'] = 'AMSL'; |
844 | 1144 | $data['pilot_id'] = (int)$line['pktPilotID']; |
845 | 1145 | $data['aircraft_icao'] = 'PARAGLIDER'; |
846 | 1146 | $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
847 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
|
1147 | + if (isset($pilot_data[4])) { |
|
1148 | + $data['pilot_name'] = $pilot_data[4]; |
|
1149 | + } |
|
848 | 1150 | $data['format_source'] = $value['format']; |
849 | 1151 | $SI->add($data); |
850 | 1152 | unset($data); |
@@ -892,25 +1194,59 @@ discard block |
||
892 | 1194 | foreach ($all_data['acList'] as $line) { |
893 | 1195 | $data = array(); |
894 | 1196 | $data['hex'] = $line['Icao']; // hex |
895 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
896 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
897 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
898 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
899 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
900 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1197 | + if (isset($line['Call'])) { |
|
1198 | + $data['ident'] = $line['Call']; |
|
1199 | + } |
|
1200 | + // ident |
|
1201 | + if (isset($line['Alt'])) { |
|
1202 | + $data['altitude'] = $line['Alt']; |
|
1203 | + } |
|
1204 | + // altitude |
|
1205 | + if (isset($line['Spd'])) { |
|
1206 | + $data['speed'] = $line['Spd']; |
|
1207 | + } |
|
1208 | + // speed |
|
1209 | + if (isset($line['Trak'])) { |
|
1210 | + $data['heading'] = $line['Trak']; |
|
1211 | + } |
|
1212 | + // heading |
|
1213 | + if (isset($line['Lat'])) { |
|
1214 | + $data['latitude'] = $line['Lat']; |
|
1215 | + } |
|
1216 | + // lat |
|
1217 | + if (isset($line['Long'])) { |
|
1218 | + $data['longitude'] = $line['Long']; |
|
1219 | + } |
|
1220 | + // long |
|
901 | 1221 | //$data['verticalrate'] = $line['']; // verticale rate |
902 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1222 | + if (isset($line['Sqk'])) { |
|
1223 | + $data['squawk'] = $line['Sqk']; |
|
1224 | + } |
|
1225 | + // squawk |
|
903 | 1226 | $data['emergency'] = ''; // emergency |
904 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
905 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
906 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1227 | + if (isset($line['Reg'])) { |
|
1228 | + $data['registration'] = $line['Reg']; |
|
1229 | + } |
|
1230 | + if (isset($line['PosTime'])) { |
|
1231 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1232 | + } else { |
|
1233 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1234 | + } |
|
907 | 1235 | //$data['datetime'] = date('Y-m-d H:i:s'); |
908 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1236 | + if (isset($line['Type'])) { |
|
1237 | + $data['aircraft_icao'] = $line['Type']; |
|
1238 | + } |
|
909 | 1239 | $data['format_source'] = 'aircraftlistjson'; |
910 | 1240 | $data['id_source'] = $id_source; |
911 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
912 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
913 | - if (isset($data['latitude'])) $SI->add($data); |
|
1241 | + if (isset($value['name']) && $value['name'] != '') { |
|
1242 | + $data['source_name'] = $value['name']; |
|
1243 | + } |
|
1244 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1245 | + $data['noarchive'] = true; |
|
1246 | + } |
|
1247 | + if (isset($data['latitude'])) { |
|
1248 | + $SI->add($data); |
|
1249 | + } |
|
914 | 1250 | unset($data); |
915 | 1251 | } |
916 | 1252 | } elseif (is_array($all_data)) { |
@@ -927,17 +1263,26 @@ discard block |
||
927 | 1263 | $data['verticalrate'] = $line['vrt']; // verticale rate |
928 | 1264 | $data['squawk'] = $line['squawk']; // squawk |
929 | 1265 | $data['emergency'] = ''; // emergency |
930 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
931 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1266 | + if (isset($line['PosTime'])) { |
|
1267 | + $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
1268 | + } else { |
|
1269 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1270 | + } |
|
932 | 1271 | $data['format_source'] = 'aircraftlistjson'; |
933 | 1272 | $data['id_source'] = $id_source; |
934 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
935 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1273 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1274 | + $data['noarchive'] = true; |
|
1275 | + } |
|
1276 | + if (isset($value['name']) && $value['name'] != '') { |
|
1277 | + $data['source_name'] = $value['name']; |
|
1278 | + } |
|
936 | 1279 | $SI->add($data); |
937 | 1280 | unset($data); |
938 | 1281 | } |
939 | 1282 | } |
940 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
1283 | + } elseif ($globalDebug) { |
|
1284 | + echo 'No data'."\n"; |
|
1285 | + } |
|
941 | 1286 | //$last_exec['aircraftlistjson'] = time(); |
942 | 1287 | $last_exec[$id]['last'] = time(); |
943 | 1288 | //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
@@ -973,8 +1318,12 @@ discard block |
||
973 | 1318 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
974 | 1319 | $data['format_source'] = 'planeupdatefaa'; |
975 | 1320 | $data['id_source'] = $id_source; |
976 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
977 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1321 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1322 | + $data['noarchive'] = true; |
|
1323 | + } |
|
1324 | + if (isset($value['name']) && $value['name'] != '') { |
|
1325 | + $data['source_name'] = $value['name']; |
|
1326 | + } |
|
978 | 1327 | $SI->add($data); |
979 | 1328 | unset($data); |
980 | 1329 | } |
@@ -1008,7 +1357,9 @@ discard block |
||
1008 | 1357 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
1009 | 1358 | $data['format_source'] = 'opensky'; |
1010 | 1359 | $data['id_source'] = $id_source; |
1011 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1360 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1361 | + $data['noarchive'] = true; |
|
1362 | + } |
|
1012 | 1363 | $SI->add($data); |
1013 | 1364 | unset($data); |
1014 | 1365 | } |
@@ -1027,22 +1378,51 @@ discard block |
||
1027 | 1378 | $reset = 0; |
1028 | 1379 | foreach ($all_data['aircraft'] as $key => $line) { |
1029 | 1380 | $data = array(); |
1030 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1031 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1032 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1033 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1034 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1035 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1036 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1037 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1038 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1381 | + if (isset($line['hex'])) { |
|
1382 | + $data['hex'] = $line['hex']; |
|
1383 | + } |
|
1384 | + // hex |
|
1385 | + if (isset($line['flight'])) { |
|
1386 | + $data['ident'] = trim($line['flight']); |
|
1387 | + } |
|
1388 | + // ident |
|
1389 | + if (isset($line['altitude'])) { |
|
1390 | + $data['altitude'] = $line['altitude']; |
|
1391 | + } |
|
1392 | + // altitude |
|
1393 | + if (isset($line['speed'])) { |
|
1394 | + $data['speed'] = $line['speed']; |
|
1395 | + } |
|
1396 | + // speed |
|
1397 | + if (isset($line['track'])) { |
|
1398 | + $data['heading'] = $line['track']; |
|
1399 | + } |
|
1400 | + // heading |
|
1401 | + if (isset($line['lat'])) { |
|
1402 | + $data['latitude'] = $line['lat']; |
|
1403 | + } |
|
1404 | + // lat |
|
1405 | + if (isset($line['lon'])) { |
|
1406 | + $data['longitude'] = $line['lon']; |
|
1407 | + } |
|
1408 | + // long |
|
1409 | + if (isset($line['vert_rate'])) { |
|
1410 | + $data['verticalrate'] = $line['vert_rate']; |
|
1411 | + } |
|
1412 | + // verticale rate |
|
1413 | + if (isset($line['squawk'])) { |
|
1414 | + $data['squawk'] = $line['squawk']; |
|
1415 | + } |
|
1416 | + // squawk |
|
1039 | 1417 | //$data['emergency'] = ''; // emergency |
1040 | 1418 | //$data['registration'] = $line[2]; |
1041 | 1419 | //$data['aircraft_icao'] = $line[0]; |
1042 | 1420 | $data['datetime'] = date('Y-m-d H:i:s'); |
1043 | 1421 | $data['format_source'] = 'aircraftjson'; |
1044 | 1422 | $data['id_source'] = $id_source; |
1045 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1423 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1424 | + $data['noarchive'] = true; |
|
1425 | + } |
|
1046 | 1426 | $SI->add($data); |
1047 | 1427 | unset($data); |
1048 | 1428 | } |
@@ -1059,7 +1439,9 @@ discard block |
||
1059 | 1439 | //$buffer = $Common->getData($hosts[$id]); |
1060 | 1440 | $buffer = $Common->getData($value['host']); |
1061 | 1441 | $all_data = json_decode($buffer,true); |
1062 | - if (!empty($all_data)) $reset = 0; |
|
1442 | + if (!empty($all_data)) { |
|
1443 | + $reset = 0; |
|
1444 | + } |
|
1063 | 1445 | foreach ($all_data as $key => $line) { |
1064 | 1446 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1065 | 1447 | $data = array(); |
@@ -1080,8 +1462,12 @@ discard block |
||
1080 | 1462 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
1081 | 1463 | $data['format_source'] = 'fr24json'; |
1082 | 1464 | $data['id_source'] = $id_source; |
1083 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1084 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1465 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1466 | + $data['noarchive'] = true; |
|
1467 | + } |
|
1468 | + if (isset($value['name']) && $value['name'] != '') { |
|
1469 | + $data['source_name'] = $value['name']; |
|
1470 | + } |
|
1085 | 1471 | $SI->add($data); |
1086 | 1472 | unset($data); |
1087 | 1473 | } |
@@ -1110,24 +1496,42 @@ discard block |
||
1110 | 1496 | if (isset($line['inf'])) { |
1111 | 1497 | $data = array(); |
1112 | 1498 | $data['hex'] = $line['inf']['ia']; |
1113 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1499 | + if (isset($line['inf']['cs'])) { |
|
1500 | + $data['ident'] = $line['inf']['cs']; |
|
1501 | + } |
|
1502 | + //$line[13] |
|
1114 | 1503 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
1115 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1116 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1504 | + if (isset($line['inf']['gs'])) { |
|
1505 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1506 | + } |
|
1507 | + // speed |
|
1508 | + if (isset($line['inf']['tr'])) { |
|
1509 | + $data['heading'] = $line['inf']['tr']; |
|
1510 | + } |
|
1511 | + // heading |
|
1117 | 1512 | $data['latitude'] = $line['pt'][0]; // lat |
1118 | 1513 | $data['longitude'] = $line['pt'][1]; // long |
1119 | 1514 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
1120 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1515 | + if (isset($line['inf']['sq'])) { |
|
1516 | + $data['squawk'] = $line['inf']['sq']; |
|
1517 | + } |
|
1518 | + // squawk |
|
1121 | 1519 | //$data['aircraft_icao'] = $line[8]; |
1122 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1520 | + if (isset($line['inf']['rc'])) { |
|
1521 | + $data['registration'] = $line['inf']['rc']; |
|
1522 | + } |
|
1123 | 1523 | //$data['departure_airport_iata'] = $line[11]; |
1124 | 1524 | //$data['arrival_airport_iata'] = $line[12]; |
1125 | 1525 | //$data['emergency'] = ''; // emergency |
1126 | 1526 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1127 | 1527 | $data['format_source'] = 'radarvirtueljson'; |
1128 | 1528 | $data['id_source'] = $id_source; |
1129 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1130 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1529 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1530 | + $data['noarchive'] = true; |
|
1531 | + } |
|
1532 | + if (isset($value['name']) && $value['name'] != '') { |
|
1533 | + $data['source_name'] = $value['name']; |
|
1534 | + } |
|
1131 | 1535 | $SI->add($data); |
1132 | 1536 | unset($data); |
1133 | 1537 | } |
@@ -1153,30 +1557,65 @@ discard block |
||
1153 | 1557 | $data['id'] = $line['id']; |
1154 | 1558 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
1155 | 1559 | $data['ident'] = $line['callsign']; // ident |
1156 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1157 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1158 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1159 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1160 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1161 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1560 | + if (isset($line['pilotid'])) { |
|
1561 | + $data['pilot_id'] = $line['pilotid']; |
|
1562 | + } |
|
1563 | + // pilot id |
|
1564 | + if (isset($line['name'])) { |
|
1565 | + $data['pilot_name'] = $line['name']; |
|
1566 | + } |
|
1567 | + // pilot name |
|
1568 | + if (isset($line['alt'])) { |
|
1569 | + $data['altitude'] = $line['alt']; |
|
1570 | + } |
|
1571 | + // altitude |
|
1572 | + if (isset($line['gs'])) { |
|
1573 | + $data['speed'] = $line['gs']; |
|
1574 | + } |
|
1575 | + // speed |
|
1576 | + if (isset($line['heading'])) { |
|
1577 | + $data['heading'] = $line['heading']; |
|
1578 | + } |
|
1579 | + // heading |
|
1580 | + if (isset($line['route'])) { |
|
1581 | + $data['waypoints'] = $line['route']; |
|
1582 | + } |
|
1583 | + // route |
|
1162 | 1584 | $data['latitude'] = $line['lat']; // lat |
1163 | 1585 | $data['longitude'] = $line['lon']; // long |
1164 | 1586 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
1165 | 1587 | //$data['squawk'] = $line['squawk']; // squawk |
1166 | 1588 | //$data['emergency'] = ''; // emergency |
1167 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1168 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1169 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1589 | + if (isset($line['depicao'])) { |
|
1590 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1591 | + } |
|
1592 | + if (isset($line['deptime'])) { |
|
1593 | + $data['departure_airport_time'] = $line['deptime']; |
|
1594 | + } |
|
1595 | + if (isset($line['arricao'])) { |
|
1596 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1597 | + } |
|
1170 | 1598 | //$data['arrival_airport_time'] = $line['arrtime']; |
1171 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1172 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1173 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1174 | - else $data['info'] = ''; |
|
1599 | + if (isset($line['aircraft'])) { |
|
1600 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1601 | + } |
|
1602 | + if (isset($line['transponder'])) { |
|
1603 | + $data['squawk'] = $line['transponder']; |
|
1604 | + } |
|
1605 | + if (isset($line['atis'])) { |
|
1606 | + $data['info'] = $line['atis']; |
|
1607 | + } else { |
|
1608 | + $data['info'] = ''; |
|
1609 | + } |
|
1175 | 1610 | $data['format_source'] = 'pireps'; |
1176 | 1611 | $data['id_source'] = $id_source; |
1177 | 1612 | $data['datetime'] = date('Y-m-d H:i:s'); |
1178 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1179 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1613 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1614 | + $data['noarchive'] = true; |
|
1615 | + } |
|
1616 | + if (isset($value['name']) && $value['name'] != '') { |
|
1617 | + $data['source_name'] = $value['name']; |
|
1618 | + } |
|
1180 | 1619 | if ($line['icon'] === 'plane') { |
1181 | 1620 | $SI->add($data); |
1182 | 1621 | // print_r($data); |
@@ -1185,16 +1624,28 @@ discard block |
||
1185 | 1624 | $data['info'] = str_replace('&sect;','',$data['info']); |
1186 | 1625 | $typec = substr($data['ident'],-3); |
1187 | 1626 | $data['type'] = ''; |
1188 | - if ($typec === 'APP') $data['type'] = 'Approach'; |
|
1189 | - elseif ($typec === 'TWR') $data['type'] = 'Tower'; |
|
1190 | - elseif ($typec === 'OBS') $data['type'] = 'Observer'; |
|
1191 | - elseif ($typec === 'GND') $data['type'] = 'Ground'; |
|
1192 | - elseif ($typec === 'DEL') $data['type'] = 'Delivery'; |
|
1193 | - elseif ($typec === 'DEP') $data['type'] = 'Departure'; |
|
1194 | - elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station'; |
|
1195 | - elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
1196 | - else $data['type'] = 'Observer'; |
|
1197 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
1627 | + if ($typec === 'APP') { |
|
1628 | + $data['type'] = 'Approach'; |
|
1629 | + } elseif ($typec === 'TWR') { |
|
1630 | + $data['type'] = 'Tower'; |
|
1631 | + } elseif ($typec === 'OBS') { |
|
1632 | + $data['type'] = 'Observer'; |
|
1633 | + } elseif ($typec === 'GND') { |
|
1634 | + $data['type'] = 'Ground'; |
|
1635 | + } elseif ($typec === 'DEL') { |
|
1636 | + $data['type'] = 'Delivery'; |
|
1637 | + } elseif ($typec === 'DEP') { |
|
1638 | + $data['type'] = 'Departure'; |
|
1639 | + } elseif ($typec === 'FSS') { |
|
1640 | + $data['type'] = 'Flight Service Station'; |
|
1641 | + } elseif ($typec === 'CTR') { |
|
1642 | + $data['type'] = 'Control Radar or Centre'; |
|
1643 | + } else { |
|
1644 | + $data['type'] = 'Observer'; |
|
1645 | + } |
|
1646 | + if (isset($ATC)) { |
|
1647 | + echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
1648 | + } |
|
1198 | 1649 | } |
1199 | 1650 | unset($data); |
1200 | 1651 | } |
@@ -1209,7 +1660,9 @@ discard block |
||
1209 | 1660 | ) |
1210 | 1661 | ) { |
1211 | 1662 | //$buffer = $Common->getData($hosts[$id]); |
1212 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1663 | + if ($globalDebug) { |
|
1664 | + echo 'Get Data...'."\n"; |
|
1665 | + } |
|
1213 | 1666 | $buffer = $Common->getData($value['host']); |
1214 | 1667 | $all_data = json_decode($buffer,true); |
1215 | 1668 | if ($buffer != '' && is_array($all_data)) { |
@@ -1217,10 +1670,16 @@ discard block |
||
1217 | 1670 | foreach ($all_data as $line) { |
1218 | 1671 | $data = array(); |
1219 | 1672 | //$data['id'] = $line['id']; // id not usable |
1220 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1673 | + if (isset($line['pilotid'])) { |
|
1674 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1675 | + } |
|
1221 | 1676 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1222 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1223 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1677 | + if (isset($line['pilotname'])) { |
|
1678 | + $data['pilot_name'] = $line['pilotname']; |
|
1679 | + } |
|
1680 | + if (isset($line['pilotid'])) { |
|
1681 | + $data['pilot_id'] = $line['pilotid']; |
|
1682 | + } |
|
1224 | 1683 | $data['ident'] = $line['flightnum']; // ident |
1225 | 1684 | $data['altitude'] = $line['alt']; // altitude |
1226 | 1685 | $data['speed'] = $line['gs']; // speed |
@@ -1236,7 +1695,9 @@ discard block |
||
1236 | 1695 | $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
1237 | 1696 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1238 | 1697 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1239 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1698 | + } else { |
|
1699 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1700 | + } |
|
1240 | 1701 | $data['departure_airport_icao'] = $line['depicao']; |
1241 | 1702 | $data['departure_airport_time'] = $line['deptime']; |
1242 | 1703 | $data['arrival_airport_icao'] = $line['arricao']; |
@@ -1244,29 +1705,47 @@ discard block |
||
1244 | 1705 | if (isset($line['registration'])) { |
1245 | 1706 | $data['registration'] = $line['registration']; |
1246 | 1707 | //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
1247 | - } else $data['registration'] = $line['aircraft']; |
|
1248 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1249 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1708 | + } else { |
|
1709 | + $data['registration'] = $line['aircraft']; |
|
1710 | + } |
|
1711 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1712 | + $data['noarchive'] = true; |
|
1713 | + } |
|
1714 | + if (isset($line['route'])) { |
|
1715 | + $data['waypoints'] = $line['route']; |
|
1716 | + } |
|
1717 | + // route |
|
1250 | 1718 | if (isset($line['aircraftname'])) { |
1251 | 1719 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1252 | 1720 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1253 | 1721 | $aircraft_data = explode('-',$line['aircraftname']); |
1254 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1255 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1256 | - else { |
|
1722 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1723 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1724 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1725 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1726 | + } else { |
|
1257 | 1727 | $aircraft_data = explode(' ',$line['aircraftname']); |
1258 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1259 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1728 | + if (isset($aircraft_data[1])) { |
|
1729 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1730 | + } else { |
|
1731 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1732 | + } |
|
1260 | 1733 | } |
1261 | 1734 | } |
1262 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1735 | + if (isset($line['route'])) { |
|
1736 | + $data['waypoints'] = $line['route']; |
|
1737 | + } |
|
1263 | 1738 | $data['id_source'] = $id_source; |
1264 | 1739 | $data['format_source'] = 'phpvmacars'; |
1265 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1740 | + if (isset($value['name']) && $value['name'] != '') { |
|
1741 | + $data['source_name'] = $value['name']; |
|
1742 | + } |
|
1266 | 1743 | $SI->add($data); |
1267 | 1744 | unset($data); |
1268 | 1745 | } |
1269 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1746 | + if ($globalDebug) { |
|
1747 | + echo 'No more data...'."\n"; |
|
1748 | + } |
|
1270 | 1749 | unset($buffer); |
1271 | 1750 | unset($all_data); |
1272 | 1751 | } |
@@ -1279,7 +1758,9 @@ discard block |
||
1279 | 1758 | ) |
1280 | 1759 | ) { |
1281 | 1760 | //$buffer = $Common->getData($hosts[$id]); |
1282 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1761 | + if ($globalDebug) { |
|
1762 | + echo 'Get Data...'."\n"; |
|
1763 | + } |
|
1283 | 1764 | $buffer = $Common->getData($value['host']); |
1284 | 1765 | $all_data = json_decode($buffer,true); |
1285 | 1766 | if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
@@ -1290,10 +1771,16 @@ discard block |
||
1290 | 1771 | //$data['id'] = $line['id']; // id not usable |
1291 | 1772 | $data['id'] = $line['id']; |
1292 | 1773 | //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
1293 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1294 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1774 | + if (isset($line['user']['username'])) { |
|
1775 | + $data['pilot_name'] = $line['user']['username']; |
|
1776 | + } |
|
1777 | + if (isset($line['user_id'])) { |
|
1778 | + $data['pilot_id'] = $line['user_id']; |
|
1779 | + } |
|
1295 | 1780 | $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
1296 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1781 | + if (is_numeric($data['ident'])) { |
|
1782 | + $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1783 | + } |
|
1297 | 1784 | $data['altitude'] = $line['altitude']; // altitude |
1298 | 1785 | $data['speed'] = $line['groundspeed']; // speed |
1299 | 1786 | $data['heading'] = $line['heading']; // heading |
@@ -1306,7 +1793,9 @@ discard block |
||
1306 | 1793 | $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
1307 | 1794 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1308 | 1795 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1309 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1796 | + } else { |
|
1797 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1798 | + } |
|
1310 | 1799 | |
1311 | 1800 | $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
1312 | 1801 | $data['departure_airport_time'] = $line['bid']['deptime']; |
@@ -1314,17 +1803,26 @@ discard block |
||
1314 | 1803 | $data['arrival_airport_time'] = $line['bid']['arrtime']; |
1315 | 1804 | $data['registration'] = $line['bid']['aircraft']['registration']; |
1316 | 1805 | |
1317 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1318 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1806 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1807 | + $data['noarchive'] = true; |
|
1808 | + } |
|
1809 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') { |
|
1810 | + $data['waypoints'] = $line['bid']['route']; |
|
1811 | + } |
|
1812 | + // route |
|
1319 | 1813 | $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
1320 | 1814 | |
1321 | 1815 | $data['id_source'] = $id_source; |
1322 | 1816 | $data['format_source'] = 'vaos'; |
1323 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1817 | + if (isset($value['name']) && $value['name'] != '') { |
|
1818 | + $data['source_name'] = $value['name']; |
|
1819 | + } |
|
1324 | 1820 | $SI->add($data); |
1325 | 1821 | unset($data); |
1326 | 1822 | } |
1327 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1823 | + if ($globalDebug) { |
|
1824 | + echo 'No more data...'."\n"; |
|
1825 | + } |
|
1328 | 1826 | unset($buffer); |
1329 | 1827 | unset($all_data); |
1330 | 1828 | } |
@@ -1337,7 +1835,9 @@ discard block |
||
1337 | 1835 | ) |
1338 | 1836 | ) { |
1339 | 1837 | //$buffer = $Common->getData($hosts[$id]); |
1340 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1838 | + if ($globalDebug) { |
|
1839 | + echo 'Get Data...'."\n"; |
|
1840 | + } |
|
1341 | 1841 | $buffer = $Common->getData($value['host']); |
1342 | 1842 | $all_data = json_decode($buffer,true); |
1343 | 1843 | if ($buffer != '' && is_array($all_data)) { |
@@ -1366,16 +1866,25 @@ discard block |
||
1366 | 1866 | $data['arrival_airport_icao'] = $line['arrival']; |
1367 | 1867 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1368 | 1868 | //$data['registration'] = $line['aircraft']; |
1369 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1869 | + if (isset($line['route'])) { |
|
1870 | + $data['waypoints'] = $line['route']; |
|
1871 | + } |
|
1872 | + // route |
|
1370 | 1873 | $data['aircraft_icao'] = $line['plane_type']; |
1371 | 1874 | $data['id_source'] = $id_source; |
1372 | 1875 | $data['format_source'] = 'vam'; |
1373 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1374 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1876 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1877 | + $data['noarchive'] = true; |
|
1878 | + } |
|
1879 | + if (isset($value['name']) && $value['name'] != '') { |
|
1880 | + $data['source_name'] = $value['name']; |
|
1881 | + } |
|
1375 | 1882 | $SI->add($data); |
1376 | 1883 | unset($data); |
1377 | 1884 | } |
1378 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1885 | + if ($globalDebug) { |
|
1886 | + echo 'No more data...'."\n"; |
|
1887 | + } |
|
1379 | 1888 | unset($buffer); |
1380 | 1889 | unset($all_data); |
1381 | 1890 | } |
@@ -1388,7 +1897,9 @@ discard block |
||
1388 | 1897 | ) |
1389 | 1898 | ) { |
1390 | 1899 | //$buffer = $Common->getData($hosts[$id]); |
1391 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1900 | + if ($globalDebug) { |
|
1901 | + echo 'Get Data...'."\n"; |
|
1902 | + } |
|
1392 | 1903 | $buffer = $Common->getData($value['host']); |
1393 | 1904 | $all_data = json_decode($buffer,true); |
1394 | 1905 | if ($buffer != '') { |
@@ -1406,12 +1917,16 @@ discard block |
||
1406 | 1917 | $data['id_source'] = $id_source; |
1407 | 1918 | $data['format_source'] = 'blitzortung'; |
1408 | 1919 | $SI->add($data); |
1409 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
1920 | + if ($globalDebug) { |
|
1921 | + echo '☈ Lightning added'."\n"; |
|
1922 | + } |
|
1410 | 1923 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1411 | 1924 | unset($data); |
1412 | 1925 | } |
1413 | 1926 | } |
1414 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1927 | + if ($globalDebug) { |
|
1928 | + echo 'No more data...'."\n"; |
|
1929 | + } |
|
1415 | 1930 | unset($buffer); |
1416 | 1931 | } |
1417 | 1932 | $last_exec[$id]['last'] = time(); |
@@ -1423,7 +1938,9 @@ discard block |
||
1423 | 1938 | $write = NULL; |
1424 | 1939 | $e = NULL; |
1425 | 1940 | $n = socket_select($read, $write, $e, $timeout); |
1426 | - if ($e != NULL) var_dump($e); |
|
1941 | + if ($e != NULL) { |
|
1942 | + var_dump($e); |
|
1943 | + } |
|
1427 | 1944 | if ($n > 0) { |
1428 | 1945 | $reset = 0; |
1429 | 1946 | foreach ($read as $nb => $r) { |
@@ -1445,13 +1962,17 @@ discard block |
||
1445 | 1962 | if ($buffer !== FALSE) { |
1446 | 1963 | if ($format === 'vrstcp') { |
1447 | 1964 | $buffer = explode('},{',$buffer); |
1448 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1965 | + } else { |
|
1966 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1967 | + } |
|
1449 | 1968 | } |
1450 | 1969 | // SBS format is CSV format |
1451 | 1970 | if ($buffer !== FALSE && $buffer !== '') { |
1452 | 1971 | $tt[$format] = 0; |
1453 | 1972 | if ($format === 'acarssbs3') { |
1454 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1973 | + if ($globalDebug) { |
|
1974 | + echo 'ACARS : '.$buffer."\n"; |
|
1975 | + } |
|
1455 | 1976 | $ACARS->add(trim($buffer)); |
1456 | 1977 | $ACARS->deleteLiveAcarsData(); |
1457 | 1978 | } elseif ($format === 'raw') { |
@@ -1460,30 +1981,70 @@ discard block |
||
1460 | 1981 | if (is_array($data)) { |
1461 | 1982 | $data['datetime'] = date('Y-m-d H:i:s'); |
1462 | 1983 | $data['format_source'] = 'raw'; |
1463 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1464 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1465 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1466 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1984 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1985 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1986 | + } |
|
1987 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1988 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1989 | + } |
|
1990 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1991 | + $data['noarchive'] = true; |
|
1992 | + } |
|
1993 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1994 | + $SI->add($data); |
|
1995 | + } |
|
1467 | 1996 | } |
1468 | 1997 | } elseif ($format === 'ais') { |
1469 | 1998 | $ais_data = $AIS->parse_line(trim($buffer)); |
1470 | 1999 | $data = array(); |
1471 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1472 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1473 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1474 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1475 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1476 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1477 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1478 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1479 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1480 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1481 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1482 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1483 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1484 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1485 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1486 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2000 | + if (isset($ais_data['ident'])) { |
|
2001 | + $data['ident'] = $ais_data['ident']; |
|
2002 | + } |
|
2003 | + if (isset($ais_data['mmsi'])) { |
|
2004 | + $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
2005 | + } |
|
2006 | + if (isset($ais_data['speed'])) { |
|
2007 | + $data['speed'] = $ais_data['speed']; |
|
2008 | + } |
|
2009 | + if (isset($ais_data['heading'])) { |
|
2010 | + $data['heading'] = $ais_data['heading']; |
|
2011 | + } |
|
2012 | + if (isset($ais_data['latitude'])) { |
|
2013 | + $data['latitude'] = $ais_data['latitude']; |
|
2014 | + } |
|
2015 | + if (isset($ais_data['longitude'])) { |
|
2016 | + $data['longitude'] = $ais_data['longitude']; |
|
2017 | + } |
|
2018 | + if (isset($ais_data['status'])) { |
|
2019 | + $data['status'] = $ais_data['status']; |
|
2020 | + } |
|
2021 | + if (isset($ais_data['statusid'])) { |
|
2022 | + $data['status_id'] = $ais_data['statusid']; |
|
2023 | + } |
|
2024 | + if (isset($ais_data['type'])) { |
|
2025 | + $data['type'] = $ais_data['type']; |
|
2026 | + } |
|
2027 | + if (isset($ais_data['imo'])) { |
|
2028 | + $data['imo'] = $ais_data['imo']; |
|
2029 | + } |
|
2030 | + if (isset($ais_data['callsign'])) { |
|
2031 | + $data['callsign'] = $ais_data['callsign']; |
|
2032 | + } |
|
2033 | + if (isset($ais_data['destination'])) { |
|
2034 | + $data['arrival_code'] = $ais_data['destination']; |
|
2035 | + } |
|
2036 | + if (isset($ais_data['eta_ts'])) { |
|
2037 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
2038 | + } |
|
2039 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2040 | + $data['noarchive'] = true; |
|
2041 | + } |
|
2042 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2043 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2044 | + } |
|
2045 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2046 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2047 | + } |
|
1487 | 2048 | |
1488 | 2049 | if (isset($ais_data['timestamp'])) { |
1489 | 2050 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1492,7 +2053,9 @@ discard block |
||
1492 | 2053 | } |
1493 | 2054 | $data['format_source'] = 'aisnmea'; |
1494 | 2055 | $data['id_source'] = $id_source; |
1495 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
2056 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') { |
|
2057 | + $MI->add($data); |
|
2058 | + } |
|
1496 | 2059 | unset($data); |
1497 | 2060 | } elseif ($format === 'flightgearsp') { |
1498 | 2061 | //echo $buffer."\n"; |
@@ -1510,12 +2073,18 @@ discard block |
||
1510 | 2073 | $data['speed'] = round($line[5]*1.94384); |
1511 | 2074 | $data['datetime'] = date('Y-m-d H:i:s'); |
1512 | 2075 | $data['format_source'] = 'flightgearsp'; |
1513 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1514 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2076 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2077 | + $data['noarchive'] = true; |
|
2078 | + } |
|
2079 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2080 | + $SI->add($data); |
|
2081 | + } |
|
1515 | 2082 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1516 | 2083 | } |
1517 | 2084 | } elseif ($format === 'acars') { |
1518 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
2085 | + if ($globalDebug) { |
|
2086 | + echo 'ACARS : '.$buffer."\n"; |
|
2087 | + } |
|
1519 | 2088 | $ACARS->add(trim($buffer)); |
1520 | 2089 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1521 | 2090 | $ACARS->deleteLiveAcarsData(); |
@@ -1536,8 +2105,12 @@ discard block |
||
1536 | 2105 | $aircraft_type = $line[10]; |
1537 | 2106 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1538 | 2107 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1539 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1540 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2108 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2109 | + $data['noarchive'] = true; |
|
2110 | + } |
|
2111 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2112 | + $SI->add($data); |
|
2113 | + } |
|
1541 | 2114 | } |
1542 | 2115 | } |
1543 | 2116 | } elseif ($format === 'beast') { |
@@ -1547,28 +2120,62 @@ discard block |
||
1547 | 2120 | foreach($buffer as $all_data) { |
1548 | 2121 | $line = json_decode('{'.$all_data.'}',true); |
1549 | 2122 | $data = array(); |
1550 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1551 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1552 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1553 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1554 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1555 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1556 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
2123 | + if (isset($line['Icao'])) { |
|
2124 | + $data['hex'] = $line['Icao']; |
|
2125 | + } |
|
2126 | + // hex |
|
2127 | + if (isset($line['Call'])) { |
|
2128 | + $data['ident'] = $line['Call']; |
|
2129 | + } |
|
2130 | + // ident |
|
2131 | + if (isset($line['Alt'])) { |
|
2132 | + $data['altitude'] = $line['Alt']; |
|
2133 | + } |
|
2134 | + // altitude |
|
2135 | + if (isset($line['Spd'])) { |
|
2136 | + $data['speed'] = $line['Spd']; |
|
2137 | + } |
|
2138 | + // speed |
|
2139 | + if (isset($line['Trak'])) { |
|
2140 | + $data['heading'] = $line['Trak']; |
|
2141 | + } |
|
2142 | + // heading |
|
2143 | + if (isset($line['Lat'])) { |
|
2144 | + $data['latitude'] = $line['Lat']; |
|
2145 | + } |
|
2146 | + // lat |
|
2147 | + if (isset($line['Long'])) { |
|
2148 | + $data['longitude'] = $line['Long']; |
|
2149 | + } |
|
2150 | + // long |
|
1557 | 2151 | //$data['verticalrate'] = $line['']; // verticale rate |
1558 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
2152 | + if (isset($line['Sqk'])) { |
|
2153 | + $data['squawk'] = $line['Sqk']; |
|
2154 | + } |
|
2155 | + // squawk |
|
1559 | 2156 | $data['emergency'] = ''; // emergency |
1560 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
2157 | + if (isset($line['Reg'])) { |
|
2158 | + $data['registration'] = $line['Reg']; |
|
2159 | + } |
|
1561 | 2160 | /* |
1562 | 2161 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1563 | 2162 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1564 | 2163 | */ |
1565 | 2164 | $data['datetime'] = date('Y-m-d H:i:s'); |
1566 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
2165 | + if (isset($line['Type'])) { |
|
2166 | + $data['aircraft_icao'] = $line['Type']; |
|
2167 | + } |
|
1567 | 2168 | $data['format_source'] = 'vrstcp'; |
1568 | 2169 | $data['id_source'] = $id_source; |
1569 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1570 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1571 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
2170 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2171 | + $data['noarchive'] = true; |
|
2172 | + } |
|
2173 | + if (isset($value['name']) && $value['name'] != '') { |
|
2174 | + $data['source_name'] = $value['name']; |
|
2175 | + } |
|
2176 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
2177 | + $SI->add($data); |
|
2178 | + } |
|
1572 | 2179 | unset($data); |
1573 | 2180 | } |
1574 | 2181 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
@@ -1581,22 +2188,46 @@ discard block |
||
1581 | 2188 | $data['hex'] = $lined['hexid']; |
1582 | 2189 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1583 | 2190 | $data['datetime'] = date('Y-m-d H:i:s');; |
1584 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1585 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1586 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1587 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1588 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1589 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1590 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
2191 | + if (isset($lined['ident'])) { |
|
2192 | + $data['ident'] = $lined['ident']; |
|
2193 | + } |
|
2194 | + if (isset($lined['lat'])) { |
|
2195 | + $data['latitude'] = $lined['lat']; |
|
2196 | + } |
|
2197 | + if (isset($lined['lon'])) { |
|
2198 | + $data['longitude'] = $lined['lon']; |
|
2199 | + } |
|
2200 | + if (isset($lined['speed'])) { |
|
2201 | + $data['speed'] = $lined['speed']; |
|
2202 | + } |
|
2203 | + if (isset($lined['squawk'])) { |
|
2204 | + $data['squawk'] = $lined['squawk']; |
|
2205 | + } |
|
2206 | + if (isset($lined['alt'])) { |
|
2207 | + $data['altitude'] = $lined['alt']; |
|
2208 | + } |
|
2209 | + if (isset($lined['heading'])) { |
|
2210 | + $data['heading'] = $lined['heading']; |
|
2211 | + } |
|
1591 | 2212 | $data['id_source'] = $id_source; |
1592 | 2213 | $data['format_source'] = 'tsv'; |
1593 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1594 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1595 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1596 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
2214 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2215 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2216 | + } |
|
2217 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2218 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2219 | + } |
|
2220 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2221 | + $data['noarchive'] = true; |
|
2222 | + } |
|
2223 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2224 | + $SI->add($data); |
|
2225 | + } |
|
1597 | 2226 | unset($lined); |
1598 | 2227 | unset($data); |
1599 | - } else $error = true; |
|
2228 | + } else { |
|
2229 | + $error = true; |
|
2230 | + } |
|
1600 | 2231 | } elseif ($format === 'aprs' && $use_aprs) { |
1601 | 2232 | if ($aprs_connect === 0) { |
1602 | 2233 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1622,63 +2253,121 @@ discard block |
||
1622 | 2253 | $aprs_last_tx = time(); |
1623 | 2254 | $data = array(); |
1624 | 2255 | //print_r($line); |
1625 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1626 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1627 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1628 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1629 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1630 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1631 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1632 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1633 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1634 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
2256 | + if (isset($line['address'])) { |
|
2257 | + $data['hex'] = $line['address']; |
|
2258 | + } |
|
2259 | + if (isset($line['mmsi'])) { |
|
2260 | + $data['mmsi'] = $line['mmsi']; |
|
2261 | + } |
|
2262 | + if (isset($line['imo'])) { |
|
2263 | + $data['imo'] = $line['imo']; |
|
2264 | + } |
|
2265 | + if (isset($line['squawk'])) { |
|
2266 | + $data['squawk'] = $line['squawk']; |
|
2267 | + } |
|
2268 | + if (isset($line['arrival_code'])) { |
|
2269 | + $data['arrival_code'] = $line['arrival_code']; |
|
2270 | + } |
|
2271 | + if (isset($line['arrival_date'])) { |
|
2272 | + $data['arrival_date'] = $line['arrival_date']; |
|
2273 | + } |
|
2274 | + if (isset($line['typeid'])) { |
|
2275 | + $data['type_id'] = $line['typeid']; |
|
2276 | + } |
|
2277 | + if (isset($line['statusid'])) { |
|
2278 | + $data['status_id'] = $line['statusid']; |
|
2279 | + } |
|
2280 | + if (isset($line['timestamp'])) { |
|
2281 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
2282 | + } else { |
|
2283 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
2284 | + } |
|
1635 | 2285 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1636 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
2286 | + if (isset($line['ident'])) { |
|
2287 | + $data['ident'] = $line['ident']; |
|
2288 | + } |
|
1637 | 2289 | $data['latitude'] = $line['latitude']; |
1638 | 2290 | $data['longitude'] = $line['longitude']; |
1639 | 2291 | //$data['verticalrate'] = $line[16]; |
1640 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
2292 | + if (isset($line['speed'])) { |
|
2293 | + $data['speed'] = $line['speed']; |
|
2294 | + } |
|
1641 | 2295 | //else $data['speed'] = 0; |
1642 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1643 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1644 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
2296 | + if (isset($line['altitude'])) { |
|
2297 | + $data['altitude'] = $line['altitude']; |
|
2298 | + } |
|
2299 | + if (isset($line['comment'])) { |
|
2300 | + $data['comment'] = $line['comment']; |
|
2301 | + } |
|
2302 | + if (isset($line['symbol'])) { |
|
2303 | + $data['type'] = $line['symbol']; |
|
2304 | + } |
|
1645 | 2305 | //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
1646 | 2306 | |
1647 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
2307 | + if (isset($line['heading']) && isset($line['format_source'])) { |
|
2308 | + $data['heading'] = $line['heading']; |
|
2309 | + } |
|
1648 | 2310 | //else echo 'No heading...'."\n"; |
1649 | 2311 | //else $data['heading'] = 0; |
1650 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
2312 | + if (isset($line['stealth'])) { |
|
2313 | + $data['aircraft_type'] = $line['stealth']; |
|
2314 | + } |
|
1651 | 2315 | //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
1652 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1653 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1654 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1655 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
2316 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) { |
|
2317 | + $data['noarchive'] = true; |
|
2318 | + } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) { |
|
2319 | + $data['noarchive'] = false; |
|
2320 | + } |
|
2321 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2322 | + $data['noarchive'] = true; |
|
2323 | + } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { |
|
2324 | + $data['noarchive'] = false; |
|
2325 | + } |
|
1656 | 2326 | $data['id_source'] = $id_source; |
1657 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1658 | - else $data['format_source'] = 'aprs'; |
|
2327 | + if (isset($line['format_source'])) { |
|
2328 | + $data['format_source'] = $line['format_source']; |
|
2329 | + } else { |
|
2330 | + $data['format_source'] = 'aprs'; |
|
2331 | + } |
|
1659 | 2332 | $data['source_name'] = $line['source']; |
1660 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1661 | - else $data['source_type'] = 'flarm'; |
|
1662 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2333 | + if (isset($line['source_type'])) { |
|
2334 | + $data['source_type'] = $line['source_type']; |
|
2335 | + } else { |
|
2336 | + $data['source_type'] = 'flarm'; |
|
2337 | + } |
|
2338 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2339 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2340 | + } |
|
1663 | 2341 | $currentdate = date('Y-m-d H:i:s'); |
1664 | 2342 | $aprsdate = strtotime($data['datetime']); |
1665 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
2343 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') { |
|
2344 | + $data['altitude_relative'] = 'AMSL'; |
|
2345 | + } |
|
1666 | 2346 | // Accept data if time <= system time + 20s |
1667 | 2347 | //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1668 | 2348 | if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
1669 | 2349 | $send = $SI->add($data); |
1670 | 2350 | } elseif ($data['source_type'] === 'ais') { |
1671 | 2351 | $data['type'] = ''; |
1672 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
|
2352 | + if (isset($globalMarine) && $globalMarine) { |
|
2353 | + $send = $MI->add($data); |
|
2354 | + } |
|
1673 | 2355 | } elseif (isset($line['stealth'])) { |
1674 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1675 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2356 | + if ($line['stealth'] != 0) { |
|
2357 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
2358 | + } else { |
|
2359 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
2360 | + } |
|
1676 | 2361 | } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1677 | 2362 | //$line['symbol'] === 'Balloon' || |
1678 | 2363 | $line['symbol'] === 'Glider' || |
1679 | 2364 | $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
1680 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1681 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2365 | + if ($line['symbol'] === 'Ballon') { |
|
2366 | + $data['aircraft_icao'] = 'BALL'; |
|
2367 | + } |
|
2368 | + if ($line['symbol'] === 'Glider') { |
|
2369 | + $data['aircraft_icao'] = 'PARAGLIDER'; |
|
2370 | + } |
|
1682 | 2371 | $send = $SI->add($data); |
1683 | 2372 | } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
1684 | 2373 | $line['symbol'] === 'Yacht (Sail)' || |
@@ -1709,9 +2398,13 @@ discard block |
||
1709 | 2398 | //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
1710 | 2399 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
1711 | 2400 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1712 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
2401 | + if (isset($globalTracker) && $globalTracker) { |
|
2402 | + $send = $TI->add($data); |
|
2403 | + } |
|
1713 | 2404 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1714 | - if (!isset($data['altitude'])) $data['altitude'] = 0; |
|
2405 | + if (!isset($data['altitude'])) { |
|
2406 | + $data['altitude'] = 0; |
|
2407 | + } |
|
1715 | 2408 | $Source->deleteOldLocationByType('gs'); |
1716 | 2409 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
1717 | 2410 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
@@ -1720,7 +2413,9 @@ discard block |
||
1720 | 2413 | } |
1721 | 2414 | } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
1722 | 2415 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1723 | - if ($globalDebug) echo '# Weather Station added'."\n"; |
|
2416 | + if ($globalDebug) { |
|
2417 | + echo '# Weather Station added'."\n"; |
|
2418 | + } |
|
1724 | 2419 | $Source->deleteOldLocationByType('wx'); |
1725 | 2420 | $weather_data = json_encode($line); |
1726 | 2421 | if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
@@ -1730,7 +2425,9 @@ discard block |
||
1730 | 2425 | } |
1731 | 2426 | } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
1732 | 2427 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1733 | - if ($globalDebug) echo '☈ Lightning added'."\n"; |
|
2428 | + if ($globalDebug) { |
|
2429 | + echo '☈ Lightning added'."\n"; |
|
2430 | + } |
|
1734 | 2431 | $Source->deleteOldLocationByType('lightning'); |
1735 | 2432 | if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
1736 | 2433 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
@@ -1742,8 +2439,7 @@ discard block |
||
1742 | 2439 | print_r($line); |
1743 | 2440 | } |
1744 | 2441 | unset($data); |
1745 | - } |
|
1746 | - elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
2442 | + } elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
|
1747 | 2443 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
1748 | 2444 | } |
1749 | 2445 | /* |
@@ -1752,7 +2448,9 @@ discard block |
||
1752 | 2448 | } |
1753 | 2449 | */ |
1754 | 2450 | //elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1755 | - elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
2451 | + elseif ($line === true && $globalDebug) { |
|
2452 | + echo '!! Failed : '.$buffer."!!\n"; |
|
2453 | + } |
|
1756 | 2454 | if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
1757 | 2455 | $Source->deleteOldLocationByType('lightning'); |
1758 | 2456 | $Source->deleteOldLocationByType('wx'); |
@@ -1788,26 +2486,45 @@ discard block |
||
1788 | 2486 | $data['ground'] = $line[21]; |
1789 | 2487 | $data['emergency'] = $line[19]; |
1790 | 2488 | $data['format_source'] = 'sbs'; |
1791 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1792 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1793 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
2489 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
2490 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
2491 | + } |
|
2492 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
2493 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
2494 | + } |
|
2495 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
2496 | + $data['noarchive'] = true; |
|
2497 | + } |
|
1794 | 2498 | $data['id_source'] = $id_source; |
1795 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1796 | - else $error = true; |
|
2499 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
2500 | + $send = $SI->add($data); |
|
2501 | + } else { |
|
2502 | + $error = true; |
|
2503 | + } |
|
1797 | 2504 | unset($data); |
1798 | - } else $error = true; |
|
2505 | + } else { |
|
2506 | + $error = true; |
|
2507 | + } |
|
1799 | 2508 | if ($error) { |
1800 | 2509 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
1801 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
2510 | + if ($globalDebug) { |
|
2511 | + echo "Not a message. Ignoring... \n"; |
|
2512 | + } |
|
1802 | 2513 | } else { |
1803 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
2514 | + if ($globalDebug) { |
|
2515 | + echo "Wrong line format. Ignoring... \n"; |
|
2516 | + } |
|
1804 | 2517 | if ($globalDebug) { |
1805 | 2518 | echo $buffer; |
1806 | 2519 | //print_r($line); |
1807 | 2520 | } |
1808 | 2521 | //socket_close($r); |
1809 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1810 | - if ($format === 'aprs') $aprs_connect = 0; |
|
2522 | + if ($globalDebug) { |
|
2523 | + echo "Reconnect after an error...\n"; |
|
2524 | + } |
|
2525 | + if ($format === 'aprs') { |
|
2526 | + $aprs_connect = 0; |
|
2527 | + } |
|
1811 | 2528 | $sourceer[$nb] = $globalSources[$nb]; |
1812 | 2529 | connect_all($sourceer); |
1813 | 2530 | $sourceer = array(); |
@@ -1815,10 +2532,14 @@ discard block |
||
1815 | 2532 | } |
1816 | 2533 | } |
1817 | 2534 | // Sleep for xxx microseconds |
1818 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
2535 | + if (isset($globalSBSSleep)) { |
|
2536 | + usleep($globalSBSSleep); |
|
2537 | + } |
|
1819 | 2538 | } else { |
1820 | 2539 | if ($format === 'flightgearmp') { |
1821 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
2540 | + if ($globalDebug) { |
|
2541 | + echo "Reconnect FlightGear MP..."; |
|
2542 | + } |
|
1822 | 2543 | //@socket_close($r); |
1823 | 2544 | sleep($globalMinFetch); |
1824 | 2545 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1827,10 +2548,15 @@ discard block |
||
1827 | 2548 | break; |
1828 | 2549 | |
1829 | 2550 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1830 | - if (isset($tt[$format])) $tt[$format]++; |
|
1831 | - else $tt[$format] = 0; |
|
2551 | + if (isset($tt[$format])) { |
|
2552 | + $tt[$format]++; |
|
2553 | + } else { |
|
2554 | + $tt[$format] = 0; |
|
2555 | + } |
|
1832 | 2556 | if ($tt[$format] > 30 || $buffer === FALSE) { |
1833 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
2557 | + if ($globalDebug) { |
|
2558 | + echo "ERROR : Reconnect ".$format."..."; |
|
2559 | + } |
|
1834 | 2560 | //@socket_close($r); |
1835 | 2561 | sleep(2); |
1836 | 2562 | $aprs_connect = 0; |
@@ -1848,11 +2574,17 @@ discard block |
||
1848 | 2574 | } else { |
1849 | 2575 | $error = socket_strerror(socket_last_error()); |
1850 | 2576 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1851 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1852 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
2577 | + if ($globalDebug) { |
|
2578 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
2579 | + } |
|
2580 | + if (isset($globalDebug)) { |
|
2581 | + echo "Restarting...\n"; |
|
2582 | + } |
|
1853 | 2583 | // Restart the script if possible |
1854 | 2584 | if (is_array($sockets)) { |
1855 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
2585 | + if ($globalDebug) { |
|
2586 | + echo "Shutdown all sockets..."; |
|
2587 | + } |
|
1856 | 2588 | |
1857 | 2589 | foreach ($sockets as $sock) { |
1858 | 2590 | @socket_shutdown($sock,2); |
@@ -1860,25 +2592,45 @@ discard block |
||
1860 | 2592 | } |
1861 | 2593 | |
1862 | 2594 | } |
1863 | - if ($globalDebug) echo "Waiting..."; |
|
2595 | + if ($globalDebug) { |
|
2596 | + echo "Waiting..."; |
|
2597 | + } |
|
1864 | 2598 | sleep(2); |
1865 | 2599 | $time = time(); |
1866 | 2600 | //connect_all($hosts); |
1867 | 2601 | $aprs_connect = 0; |
1868 | - if ($reset%5 === 0) sleep(20); |
|
1869 | - if ($reset%10 === 0) sleep(100); |
|
1870 | - if ($reset%20 === 0) sleep(200); |
|
1871 | - if ($reset > 100) exit('Too many attempts...'); |
|
1872 | - if ($globalDebug) echo "Restart all connections..."; |
|
2602 | + if ($reset%5 === 0) { |
|
2603 | + sleep(20); |
|
2604 | + } |
|
2605 | + if ($reset%10 === 0) { |
|
2606 | + sleep(100); |
|
2607 | + } |
|
2608 | + if ($reset%20 === 0) { |
|
2609 | + sleep(200); |
|
2610 | + } |
|
2611 | + if ($reset > 100) { |
|
2612 | + exit('Too many attempts...'); |
|
2613 | + } |
|
2614 | + if ($globalDebug) { |
|
2615 | + echo "Restart all connections..."; |
|
2616 | + } |
|
1873 | 2617 | connect_all($globalSources); |
1874 | 2618 | } |
1875 | 2619 | } |
1876 | 2620 | } |
1877 | 2621 | if ($globalDaemon === false) { |
1878 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1879 | - if (isset($SI)) $SI->checkAll(); |
|
1880 | - if (isset($TI)) $TI->checkAll(); |
|
1881 | - if (isset($MI)) $MI->checkAll(); |
|
2622 | + if ($globalDebug) { |
|
2623 | + echo 'Check all...'."\n"; |
|
2624 | + } |
|
2625 | + if (isset($SI)) { |
|
2626 | + $SI->checkAll(); |
|
2627 | + } |
|
2628 | + if (isset($TI)) { |
|
2629 | + $TI->checkAll(); |
|
2630 | + } |
|
2631 | + if (isset($MI)) { |
|
2632 | + $MI->checkAll(); |
|
2633 | + } |
|
1882 | 2634 | } |
1883 | 2635 | } |
1884 | 2636 | } |