@@ -5,11 +5,15 @@ |
||
5 | 5 | $Stats = new Stats(); |
6 | 6 | $title = _("Statistics").' - '._("Most common Pilots"); |
7 | 7 | |
8 | -if (!isset($filter_name)) $filter_name = ''; |
|
8 | +if (!isset($filter_name)) { |
|
9 | + $filter_name = ''; |
|
10 | +} |
|
9 | 11 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
10 | 12 | if ($airline_icao == '' && isset($globalFilter)) { |
11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
12 | -} |
|
13 | + if (isset($globalFilter['airline'])) { |
|
14 | + $airline_icao = $globalFilter['airline'][0]; |
|
15 | + } |
|
16 | + } |
|
13 | 17 | setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/'); |
14 | 18 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
15 | 19 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
@@ -59,8 +59,11 @@ discard block |
||
59 | 59 | } |
60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
61 | 61 | $sth->closeCursor(); |
62 | - if ($row['nb'] > 0) return false; |
|
63 | - else return true; |
|
62 | + if ($row['nb'] > 0) { |
|
63 | + return false; |
|
64 | + } else { |
|
65 | + return true; |
|
66 | + } |
|
64 | 67 | } |
65 | 68 | |
66 | 69 | public static function insert_last_update() { |
@@ -84,9 +87,14 @@ discard block |
||
84 | 87 | //$pieces = explode(' ',$data); |
85 | 88 | $pieces = preg_split('/\s/',$data); |
86 | 89 | $pos = 0; |
87 | - if ($pieces[0] == 'METAR') $pos++; |
|
88 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
89 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
90 | + if ($pieces[0] == 'METAR') { |
|
91 | + $pos++; |
|
92 | + } elseif ($pieces[0] == 'SPECI') { |
|
93 | + $pos++; |
|
94 | + } |
|
95 | + if (strlen($pieces[$pos]) != 4) { |
|
96 | + $pos++; |
|
97 | + } |
|
90 | 98 | $result = array(); |
91 | 99 | $result['location'] = $pieces[$pos]; |
92 | 100 | $pos++; |
@@ -95,16 +103,26 @@ discard block |
||
95 | 103 | $c = count($pieces); |
96 | 104 | for($pos++; $pos < $c; $pos++) { |
97 | 105 | $piece = $pieces[$pos]; |
98 | - if ($piece == 'RMK') break; |
|
99 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
100 | - if ($piece == 'COR') $result['correction'] = true; |
|
106 | + if ($piece == 'RMK') { |
|
107 | + break; |
|
108 | + } |
|
109 | + if ($piece == 'AUTO') { |
|
110 | + $result['auto'] = true; |
|
111 | + } |
|
112 | + if ($piece == 'COR') { |
|
113 | + $result['correction'] = true; |
|
114 | + } |
|
101 | 115 | // Wind Speed |
102 | 116 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
103 | 117 | $result['wind']['direction'] = (float)$matches[1]; |
104 | 118 | $result['wind']['unit'] = $matches[4]; |
105 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
106 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
107 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
119 | + if ($result['wind']['unit'] == 'KT') { |
|
120 | + $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
121 | + } elseif ($result['wind']['unit'] == 'KPH') { |
|
122 | + $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
123 | + } elseif ($result['wind']['unit'] == 'MPS') { |
|
124 | + $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
125 | + } |
|
108 | 126 | $result['wind']['gust'] = (float)$matches[3]; |
109 | 127 | $result['wind']['unit'] = $matches[4]; |
110 | 128 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
@@ -186,14 +204,23 @@ discard block |
||
186 | 204 | //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
187 | 205 | $type = $matches[1]; |
188 | 206 | $cloud = array(); |
189 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
190 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
191 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
192 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
193 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
194 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
195 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
196 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
207 | + if ($type == 'SKC') { |
|
208 | + $cloud['type'] = 'No cloud/Sky clear'; |
|
209 | + } elseif ($type == 'CLR') { |
|
210 | + $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
211 | + } elseif ($type == 'NSC') { |
|
212 | + $cloud['type'] = 'No significant cloud'; |
|
213 | + } elseif ($type == 'FEW') { |
|
214 | + $cloud['type'] = 'Few'; |
|
215 | + } elseif ($type == 'SCT') { |
|
216 | + $cloud['type'] = 'Scattered'; |
|
217 | + } elseif ($type == 'BKN') { |
|
218 | + $cloud['type'] = 'Broken'; |
|
219 | + } elseif ($type == 'OVC') { |
|
220 | + $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
221 | + } elseif ($type == 'VV') { |
|
222 | + $cloud['type'] = 'Vertical visibility'; |
|
223 | + } |
|
197 | 224 | $cloud['type_code'] = $type; |
198 | 225 | $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
199 | 226 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
@@ -223,8 +250,11 @@ discard block |
||
223 | 250 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
224 | 251 | //echo $piece; |
225 | 252 | //print_r($matches); |
226 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
227 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
253 | + if (isset($matches[5])) { |
|
254 | + $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
255 | + } else { |
|
256 | + $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
257 | + } |
|
228 | 258 | if (isset($matches[3])) { |
229 | 259 | $range = Array( |
230 | 260 | 'from' => (float)$matches[2], |
@@ -257,8 +287,11 @@ discard block |
||
257 | 287 | if (isset($matches[3])) { |
258 | 288 | $text[] = $this->texts[$matches[3]]; |
259 | 289 | } |
260 | - if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
|
261 | - else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
290 | + if (!isset($result['weather'])) { |
|
291 | + $result['weather'] = implode(' ', $text); |
|
292 | + } else { |
|
293 | + $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
294 | + } |
|
262 | 295 | } |
263 | 296 | } |
264 | 297 | return $result; |
@@ -270,8 +303,11 @@ discard block |
||
270 | 303 | if (isset($globalMETARcycle) && $globalMETARcycle) { |
271 | 304 | $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
272 | 305 | } else { |
273 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
274 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
306 | + if ($globalDBdriver == 'mysql') { |
|
307 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
308 | + } else { |
|
309 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
310 | + } |
|
275 | 311 | } |
276 | 312 | $query_values = array(':icao' => $icao); |
277 | 313 | try { |
@@ -326,7 +362,9 @@ discard block |
||
326 | 362 | |
327 | 363 | public function addMETARCycle() { |
328 | 364 | global $globalDebug, $globalIVAO, $globalTransaction; |
329 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
365 | + if (isset($globalDebug) && $globalDebug) { |
|
366 | + echo "Downloading METAR cycle..."; |
|
367 | + } |
|
330 | 368 | date_default_timezone_set("UTC"); |
331 | 369 | $Common = new Common(); |
332 | 370 | if (isset($globalIVAO) && $globalIVAO) { |
@@ -339,33 +377,49 @@ discard block |
||
339 | 377 | $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
340 | 378 | } |
341 | 379 | if ($handle) { |
342 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
380 | + if (isset($globalDebug) && $globalDebug) { |
|
381 | + echo "Done - Updating DB..."; |
|
382 | + } |
|
343 | 383 | $date = ''; |
344 | 384 | //foreach(explode("\n",$cycle) as $line) { |
345 | - if ($globalTransaction) $this->db->beginTransaction(); |
|
385 | + if ($globalTransaction) { |
|
386 | + $this->db->beginTransaction(); |
|
387 | + } |
|
346 | 388 | while(($line = fgets($handle,4096)) !== false) { |
347 | 389 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
348 | 390 | $date = $line; |
349 | 391 | } elseif ($line != '') { |
350 | 392 | //$this->parse($line); |
351 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
393 | + if ($date == '') { |
|
394 | + $date = date('Y/m/d H:m'); |
|
395 | + } |
|
352 | 396 | $pos = 0; |
353 | 397 | $pieces = preg_split('/\s/',$line); |
354 | - if ($pieces[0] == 'METAR') $pos++; |
|
355 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
398 | + if ($pieces[0] == 'METAR') { |
|
399 | + $pos++; |
|
400 | + } |
|
401 | + if (strlen($pieces[$pos]) != 4) { |
|
402 | + $pos++; |
|
403 | + } |
|
356 | 404 | $location = $pieces[$pos]; |
357 | 405 | echo $this->addMETAR($location,$line,$date); |
358 | 406 | } |
359 | 407 | } |
360 | 408 | fclose($handle); |
361 | - if ($globalTransaction) $this->db->commit(); |
|
409 | + if ($globalTransaction) { |
|
410 | + $this->db->commit(); |
|
411 | + } |
|
412 | + } |
|
413 | + if (isset($globalDebug) && $globalDebug) { |
|
414 | + echo "Done\n"; |
|
362 | 415 | } |
363 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
364 | 416 | |
365 | 417 | } |
366 | 418 | public function downloadMETAR($icao) { |
367 | 419 | global $globalMETARurl; |
368 | - if ($globalMETARurl == '') return array(); |
|
420 | + if ($globalMETARurl == '') { |
|
421 | + return array(); |
|
422 | + } |
|
369 | 423 | date_default_timezone_set("UTC"); |
370 | 424 | $Common = new Common(); |
371 | 425 | $url = str_replace('{icao}',$icao,$globalMETARurl); |
@@ -379,16 +433,24 @@ discard block |
||
379 | 433 | if ($line != '') { |
380 | 434 | //$this->parse($line); |
381 | 435 | //echo $line; |
382 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
436 | + if ($date == '') { |
|
437 | + $date = date('Y/m/d H:m'); |
|
438 | + } |
|
383 | 439 | $pos = 0; |
384 | 440 | $pieces = preg_split('/\s/',$line); |
385 | - if ($pieces[0] == 'METAR') $pos++; |
|
386 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
441 | + if ($pieces[0] == 'METAR') { |
|
442 | + $pos++; |
|
443 | + } |
|
444 | + if (strlen($pieces[$pos]) != 4) { |
|
445 | + $pos++; |
|
446 | + } |
|
387 | 447 | $location = $pieces[$pos]; |
388 | 448 | if (strlen($location == 4)) { |
389 | 449 | $this->addMETAR($location,$line,$date); |
390 | 450 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
391 | - } else return array(); |
|
451 | + } else { |
|
452 | + return array(); |
|
453 | + } |
|
392 | 454 | } |
393 | 455 | //echo $line."\n"; |
394 | 456 | } |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
24 | 24 | } |
25 | 25 | } |
26 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
26 | + if (is_array($globalFilter)) { |
|
27 | + $filter = array_merge($filter,$globalFilter); |
|
28 | + } |
|
27 | 29 | $filter_query_join = ''; |
28 | 30 | $filter_query_where = ''; |
29 | 31 | foreach($filters as $flt) { |
@@ -74,8 +76,11 @@ discard block |
||
74 | 76 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
75 | 77 | } |
76 | 78 | } |
77 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
78 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
79 | + if ($filter_query_where == '' && $where) { |
|
80 | + $filter_query_where = ' WHERE'; |
|
81 | + } elseif ($filter_query_where != '' && $and) { |
|
82 | + $filter_query_where .= ' AND'; |
|
83 | + } |
|
79 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
80 | 85 | return $filter_query; |
81 | 86 | } |
@@ -86,10 +91,17 @@ discard block |
||
86 | 91 | if ($over_country == '') { |
87 | 92 | $Spotter = new Spotter($this->db); |
88 | 93 | $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
89 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
90 | - else $country = ''; |
|
91 | - } else $country = $over_country; |
|
92 | - if ($airline_type === NULL) $airline_type =''; |
|
94 | + if (!empty($data_country)) { |
|
95 | + $country = $data_country['iso2']; |
|
96 | + } else { |
|
97 | + $country = ''; |
|
98 | + } |
|
99 | + } else { |
|
100 | + $country = $over_country; |
|
101 | + } |
|
102 | + if ($airline_type === NULL) { |
|
103 | + $airline_type =''; |
|
104 | + } |
|
93 | 105 | |
94 | 106 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
95 | 107 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
@@ -592,7 +604,9 @@ discard block |
||
592 | 604 | $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
593 | 605 | $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
594 | 606 | $translate = $Translation->ident2icao($q_item); |
595 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
607 | + if ($translate != $q_item) { |
|
608 | + $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
609 | + } |
|
596 | 610 | $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
597 | 611 | $additional_query .= ")"; |
598 | 612 | } |
@@ -810,7 +824,9 @@ discard block |
||
810 | 824 | date_default_timezone_set($globalTimezone); |
811 | 825 | $datetime = new DateTime(); |
812 | 826 | $offset = $datetime->format('P'); |
813 | - } else $offset = '+00:00'; |
|
827 | + } else { |
|
828 | + $offset = '+00:00'; |
|
829 | + } |
|
814 | 830 | |
815 | 831 | |
816 | 832 | if ($date_array[1] != "") |
@@ -1084,9 +1100,13 @@ discard block |
||
1084 | 1100 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1085 | 1101 | } |
1086 | 1102 | } |
1087 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1103 | + if ($sincedate != '') { |
|
1104 | + $query .= "AND date > '".$sincedate."' "; |
|
1105 | + } |
|
1088 | 1106 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1089 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1107 | + if ($limit) { |
|
1108 | + $query .= " LIMIT 0,10"; |
|
1109 | + } |
|
1090 | 1110 | |
1091 | 1111 | |
1092 | 1112 | $sth = $this->db->prepare($query); |
@@ -1130,9 +1150,13 @@ discard block |
||
1130 | 1150 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1131 | 1151 | } |
1132 | 1152 | } |
1133 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1153 | + if ($sincedate != '') { |
|
1154 | + $query .= "AND s.date > '".$sincedate."' "; |
|
1155 | + } |
|
1134 | 1156 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1135 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1157 | + if ($limit) { |
|
1158 | + $query .= " LIMIT 0,10"; |
|
1159 | + } |
|
1136 | 1160 | |
1137 | 1161 | |
1138 | 1162 | $sth = $this->db->prepare($query); |
@@ -6,11 +6,15 @@ discard block |
||
6 | 6 | $beginpage = microtime(true); |
7 | 7 | $Stats = new Stats(); |
8 | 8 | |
9 | -if (!isset($filter_name)) $filter_name = ''; |
|
9 | +if (!isset($filter_name)) { |
|
10 | + $filter_name = ''; |
|
11 | +} |
|
10 | 12 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
11 | 13 | if ($airline_icao == '' && isset($globalFilter)) { |
12 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
13 | -} |
|
14 | + if (isset($globalFilter['airline'])) { |
|
15 | + $airline_icao = $globalFilter['airline'][0]; |
|
16 | + } |
|
17 | + } |
|
14 | 18 | if ($airline_icao != '' && $airline_icao != 'all') { |
15 | 19 | $Spotter = new Spotter(); |
16 | 20 | $airline_info = $Spotter->getAllAirlineInfo($airline_icao); |
@@ -36,14 +40,21 @@ discard block |
||
36 | 40 | <script type="text/javascript" src="<?php echo $globalURL; ?>/js/justgage.js"></script> |
37 | 41 | <div class="column"> |
38 | 42 | <div class="info"> |
39 | - <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1> |
|
43 | + <h1><?php if (isset($airline_name)) { |
|
44 | + echo _("Statistics for ").$airline_name; |
|
45 | +} else { |
|
46 | + echo _("Statistics"); |
|
47 | +} |
|
48 | +?></h1> |
|
40 | 49 | <?php |
41 | 50 | $last_update = $Stats->getLastStatsUpdate(); |
42 | 51 | //if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->'; |
43 | 52 | if (isset($last_update[0]['value'])) { |
44 | 53 | date_default_timezone_set('UTC'); |
45 | 54 | $lastupdate = strtotime($last_update[0]['value']); |
46 | - if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone); |
|
55 | + if (isset($globalTimezone) && $globalTimezone != '') { |
|
56 | + date_default_timezone_set($globalTimezone); |
|
57 | + } |
|
47 | 58 | print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>'; |
48 | 59 | } |
49 | 60 | ?> |
@@ -95,8 +106,9 @@ discard block |
||
95 | 106 | <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2> |
96 | 107 | <?php |
97 | 108 | $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month); |
98 | - if (count($aircraft_array) == 0) print _("No data available"); |
|
99 | - else { |
|
109 | + if (count($aircraft_array) == 0) { |
|
110 | + print _("No data available"); |
|
111 | + } else { |
|
100 | 112 | |
101 | 113 | print '<div id="chart1" class="chart" width="100%"></div> |
102 | 114 | <script> |
@@ -133,11 +145,17 @@ discard block |
||
133 | 145 | <?php |
134 | 146 | if ($year != '' && $month != '') { |
135 | 147 | ?> |
136 | - <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
148 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
149 | + echo '/'.$airline_icao; |
|
150 | +} |
|
151 | +?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
137 | 152 | <?php |
138 | 153 | } else { |
139 | 154 | ?> |
140 | - <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
155 | + <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
156 | + echo '/'.$airline_icao; |
|
157 | +} |
|
158 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
141 | 159 | <?php |
142 | 160 | } |
143 | 161 | ?> |
@@ -182,11 +200,15 @@ discard block |
||
182 | 200 | </script>'; |
183 | 201 | if ($year != '' && $month != '') { |
184 | 202 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
185 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
203 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
204 | + echo '/'.$airline_icao; |
|
205 | + } |
|
186 | 206 | print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
187 | 207 | } else { |
188 | 208 | print '<div class="more"><a href="'.$globalURL.'/statistics/airline'; |
189 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
209 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
210 | + echo '/'.$airline_icao; |
|
211 | + } |
|
190 | 212 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
191 | 213 | } |
192 | 214 | print '</div>'; |
@@ -210,8 +232,9 @@ discard block |
||
210 | 232 | <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2> |
211 | 233 | <?php |
212 | 234 | $pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month); |
213 | - if (count($pilot_array) == 0) print _("No data available"); |
|
214 | - else { |
|
235 | + if (count($pilot_array) == 0) { |
|
236 | + print _("No data available"); |
|
237 | + } else { |
|
215 | 238 | print '<div id="chart7" class="chart" width="100%"></div> |
216 | 239 | <script> |
217 | 240 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -244,7 +267,9 @@ discard block |
||
244 | 267 | } |
245 | 268 | print '<div class="more">'; |
246 | 269 | print '<a href="'.$globalURL.'/statistics/pilot'; |
247 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
270 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
271 | + echo '/'.$airline_icao; |
|
272 | + } |
|
248 | 273 | print'" class="btn btn-default btn" role="button">'._("See full statistic").'»</a>'; |
249 | 274 | print '</div>'; |
250 | 275 | ?> |
@@ -258,8 +283,9 @@ discard block |
||
258 | 283 | <h2><?php echo _("Top 10 Most Common Owners"); ?></h2> |
259 | 284 | <?php |
260 | 285 | $owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month); |
261 | - if (count($owner_array) == 0) print _("No data available"); |
|
262 | - else { |
|
286 | + if (count($owner_array) == 0) { |
|
287 | + print _("No data available"); |
|
288 | + } else { |
|
263 | 289 | print '<div id="chart7" class="chart" width="100%"></div> |
264 | 290 | <script> |
265 | 291 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -292,7 +318,10 @@ discard block |
||
292 | 318 | } |
293 | 319 | ?> |
294 | 320 | <div class="more"> |
295 | - <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
321 | + <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
322 | + echo '/'.$airline_icao; |
|
323 | +} |
|
324 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
296 | 325 | </div> |
297 | 326 | </div> |
298 | 327 | |
@@ -305,8 +334,9 @@ discard block |
||
305 | 334 | <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2> |
306 | 335 | <?php |
307 | 336 | //$flightover_array = $Stats->countAllFlightOverCountries(); |
308 | - if (count($flightover_array) == 0) print _("No data available"); |
|
309 | - else { |
|
337 | + if (count($flightover_array) == 0) { |
|
338 | + print _("No data available"); |
|
339 | + } else { |
|
310 | 340 | print '<div id="chart10" class="chart" width="100%"></div> |
311 | 341 | <script> |
312 | 342 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -341,7 +371,10 @@ discard block |
||
341 | 371 | } |
342 | 372 | ?> |
343 | 373 | <div class="more"> |
344 | - <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
374 | + <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
375 | + echo '/'.$airline_icao; |
|
376 | +} |
|
377 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
345 | 378 | </div> |
346 | 379 | </div> |
347 | 380 | <?php |
@@ -394,7 +427,9 @@ discard block |
||
394 | 427 | } |
395 | 428 | </script>'; |
396 | 429 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; |
397 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
430 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
431 | + echo '/'.$airline_icao; |
|
432 | + } |
|
398 | 433 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
399 | 434 | } |
400 | 435 | ?> |
@@ -441,7 +476,9 @@ discard block |
||
441 | 476 | } |
442 | 477 | </script>'; |
443 | 478 | print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival'; |
444 | - if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; |
|
479 | + if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
480 | + echo '/'.$airline_icao; |
|
481 | + } |
|
445 | 482 | print '" class="btn btn-default btn" role="button">'._("See full statistic").'»</a></div>'; |
446 | 483 | } |
447 | 484 | ?> |
@@ -456,8 +493,9 @@ discard block |
||
456 | 493 | <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2> |
457 | 494 | <?php |
458 | 495 | $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name); |
459 | - if (count($year_array) == 0) print _("No data available"); |
|
460 | - else { |
|
496 | + if (count($year_array) == 0) { |
|
497 | + print _("No data available"); |
|
498 | + } else { |
|
461 | 499 | print '<div id="chart8" class="chart" width="100%"></div> |
462 | 500 | <script> |
463 | 501 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -493,7 +531,10 @@ discard block |
||
493 | 531 | } |
494 | 532 | ?> |
495 | 533 | <div class="more"> |
496 | - <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
534 | + <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
535 | + echo '/'.$airline_icao; |
|
536 | +} |
|
537 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
497 | 538 | </div> |
498 | 539 | </div> |
499 | 540 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -501,8 +542,9 @@ discard block |
||
501 | 542 | <h2><?php echo _("Busiest Day in the last Month"); ?></h2> |
502 | 543 | <?php |
503 | 544 | $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name); |
504 | - if (count($month_array) == 0) print _("No data available"); |
|
505 | - else { |
|
545 | + if (count($month_array) == 0) { |
|
546 | + print _("No data available"); |
|
547 | + } else { |
|
506 | 548 | print '<div id="chart9" class="chart" width="100%"></div> |
507 | 549 | <script> |
508 | 550 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -538,7 +580,10 @@ discard block |
||
538 | 580 | } |
539 | 581 | ?> |
540 | 582 | <div class="more"> |
541 | - <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
583 | + <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
584 | + echo '/'.$airline_icao; |
|
585 | +} |
|
586 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
542 | 587 | </div> |
543 | 588 | </div> |
544 | 589 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -547,8 +592,9 @@ discard block |
||
547 | 592 | <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2> |
548 | 593 | <?php |
549 | 594 | $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
550 | - if (empty($date_array)) print _("No data available"); |
|
551 | - else { |
|
595 | + if (empty($date_array)) { |
|
596 | + print _("No data available"); |
|
597 | + } else { |
|
552 | 598 | print '<div id="chart5" class="chart" width="100%"></div> |
553 | 599 | <script> |
554 | 600 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -585,7 +631,10 @@ discard block |
||
585 | 631 | } |
586 | 632 | ?> |
587 | 633 | <div class="more"> |
588 | - <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
634 | + <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
635 | + echo '/'.$airline_icao; |
|
636 | +} |
|
637 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
589 | 638 | </div> |
590 | 639 | </div> |
591 | 640 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -593,8 +642,9 @@ discard block |
||
593 | 642 | <h2><?php echo _("Busiest Time of the Day"); ?></h2> |
594 | 643 | <?php |
595 | 644 | $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
596 | - if (empty($hour_array)) print _("No data available"); |
|
597 | - else { |
|
645 | + if (empty($hour_array)) { |
|
646 | + print _("No data available"); |
|
647 | + } else { |
|
598 | 648 | |
599 | 649 | print '<div id="chart6" class="chart" width="100%"></div> |
600 | 650 | <script> |
@@ -631,7 +681,10 @@ discard block |
||
631 | 681 | } |
632 | 682 | ?> |
633 | 683 | <div class="more"> |
634 | - <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
684 | + <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') { |
|
685 | + echo '/'.$airline_icao; |
|
686 | +} |
|
687 | +?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>»</a> |
|
635 | 688 | </div> |
636 | 689 | </div> |
637 | 690 | <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> --> |
@@ -650,8 +703,9 @@ discard block |
||
650 | 703 | require_once('require/class.Accident.php'); |
651 | 704 | $Accident = new Accident(); |
652 | 705 | $year_array = $Accident->countFatalitiesByYear($filter_name); |
653 | - if (count($year_array) == 0) print _("No data available"); |
|
654 | - else { |
|
706 | + if (count($year_array) == 0) { |
|
707 | + print _("No data available"); |
|
708 | + } else { |
|
655 | 709 | print '<div id="chart32" class="chart" width="100%"></div> |
656 | 710 | <script> |
657 | 711 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -699,8 +753,9 @@ discard block |
||
699 | 753 | require_once('require/class.Accident.php'); |
700 | 754 | $Accident = new Accident(); |
701 | 755 | $year_array = $Accident->countFatalitiesLast12Months($filter_name); |
702 | - if (count($year_array) == 0) print _("No data available"); |
|
703 | - else { |
|
756 | + if (count($year_array) == 0) { |
|
757 | + print _("No data available"); |
|
758 | + } else { |
|
704 | 759 | print '<div id="chart33" class="chart" width="100%"></div> |
705 | 760 | <script> |
706 | 761 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -776,8 +831,11 @@ discard block |
||
776 | 831 | $distance = $distance; |
777 | 832 | $unit = 'km'; |
778 | 833 | } |
779 | - if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
780 | - else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
834 | + if (!isset($polar_data)) { |
|
835 | + $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
836 | + } else { |
|
837 | + $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}'; |
|
838 | + } |
|
781 | 839 | } |
782 | 840 | ?> |
783 | 841 | <div class="col-md-6"> |
@@ -829,8 +887,11 @@ discard block |
||
829 | 887 | foreach ($msg as $eachmsg) { |
830 | 888 | //$eachmsg = $msg[0]; |
831 | 889 | $data = $eachmsg['source_data']; |
832 | - if ($data > 500) $max = (round(($data+100)/100))*100; |
|
833 | - else $max = 500; |
|
890 | + if ($data > 500) { |
|
891 | + $max = (round(($data+100)/100))*100; |
|
892 | + } else { |
|
893 | + $max = 500; |
|
894 | + } |
|
834 | 895 | ?> |
835 | 896 | <div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div> |
836 | 897 | <script> |
@@ -53,7 +53,9 @@ discard block |
||
53 | 53 | $dbc = $this->db; |
54 | 54 | $this->all_flights[$id]['schedule_check'] = true; |
55 | 55 | if ($globalSchedulesFetch) { |
56 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
56 | + if ($globalDebug) { |
|
57 | + echo 'Getting schedule info...'."\n"; |
|
58 | + } |
|
57 | 59 | $Spotter = new Spotter($dbc); |
58 | 60 | $Schedule = new Schedule($dbc); |
59 | 61 | $Translation = new Translation($dbc); |
@@ -64,7 +66,9 @@ discard block |
||
64 | 66 | if ($Schedule->checkSchedule($operator) == 0) { |
65 | 67 | $schedule = $Schedule->fetchSchedule($operator); |
66 | 68 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
67 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
69 | + if ($globalDebug) { |
|
70 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
71 | + } |
|
68 | 72 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
69 | 73 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
70 | 74 | // Should also check if route schedule = route from DB |
@@ -73,7 +77,9 @@ discard block |
||
73 | 77 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
74 | 78 | if (trim($airport_icao) != '') { |
75 | 79 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
76 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
80 | + if ($globalDebug) { |
|
81 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
82 | + } |
|
77 | 83 | } |
78 | 84 | } |
79 | 85 | } |
@@ -82,17 +88,25 @@ discard block |
||
82 | 88 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
83 | 89 | if (trim($airport_icao) != '') { |
84 | 90 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
85 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
91 | + if ($globalDebug) { |
|
92 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
93 | + } |
|
86 | 94 | } |
87 | 95 | } |
88 | 96 | } |
89 | 97 | $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']); |
90 | 98 | } |
91 | - } else $scheduleexist = true; |
|
92 | - } else $scheduleexist = true; |
|
99 | + } else { |
|
100 | + $scheduleexist = true; |
|
101 | + } |
|
102 | + } else { |
|
103 | + $scheduleexist = true; |
|
104 | + } |
|
93 | 105 | // close connection, at least one way will work ? |
94 | 106 | if ($scheduleexist) { |
95 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
107 | + if ($globalDebug) { |
|
108 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
109 | + } |
|
96 | 110 | $sch = $Schedule->getSchedule($operator); |
97 | 111 | $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'])); |
98 | 112 | } |
@@ -114,7 +128,9 @@ discard block |
||
114 | 128 | |
115 | 129 | public function checkAll() { |
116 | 130 | global $globalDebug; |
117 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
131 | + if ($globalDebug) { |
|
132 | + echo "Update last seen flights data...\n"; |
|
133 | + } |
|
118 | 134 | foreach ($this->all_flights as $key => $flight) { |
119 | 135 | if (isset($this->all_flights[$key]['id'])) { |
120 | 136 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
@@ -127,24 +143,32 @@ discard block |
||
127 | 143 | |
128 | 144 | public function arrival($key) { |
129 | 145 | global $globalClosestMinDist, $globalDebug; |
130 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
146 | + if ($globalDebug) { |
|
147 | + echo 'Update arrival...'."\n"; |
|
148 | + } |
|
131 | 149 | $Spotter = new Spotter($this->db); |
132 | 150 | $airport_icao = ''; |
133 | 151 | $airport_time = ''; |
134 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
152 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
153 | + $globalClosestMinDist = 50; |
|
154 | + } |
|
135 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
136 | 156 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
137 | 157 | if (isset($closestAirports[0])) { |
138 | 158 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
139 | 159 | $airport_icao = $closestAirports[0]['icao']; |
140 | 160 | $airport_time = $this->all_flights[$key]['datetime']; |
141 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
161 | + if ($globalDebug) { |
|
162 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
163 | + } |
|
142 | 164 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
143 | 165 | foreach ($closestAirports as $airport) { |
144 | 166 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
145 | 167 | $airport_icao = $airport['icao']; |
146 | 168 | $airport_time = $this->all_flights[$key]['datetime']; |
147 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
169 | + if ($globalDebug) { |
|
170 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
171 | + } |
|
148 | 172 | break; |
149 | 173 | } |
150 | 174 | } |
@@ -152,14 +176,20 @@ discard block |
||
152 | 176 | $airport_icao = $closestAirports[0]['icao']; |
153 | 177 | $airport_time = $this->all_flights[$key]['datetime']; |
154 | 178 | } else { |
155 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
179 | + if ($globalDebug) { |
|
180 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
181 | + } |
|
156 | 182 | } |
157 | 183 | } else { |
158 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
184 | + if ($globalDebug) { |
|
185 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
186 | + } |
|
159 | 187 | } |
160 | 188 | |
161 | 189 | } else { |
162 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
190 | + if ($globalDebug) { |
|
191 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
192 | + } |
|
163 | 193 | } |
164 | 194 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
165 | 195 | } |
@@ -169,12 +199,16 @@ discard block |
||
169 | 199 | public function del() { |
170 | 200 | global $globalDebug; |
171 | 201 | // Delete old infos |
172 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
202 | + if ($globalDebug) { |
|
203 | + echo 'Delete old values and update latest data...'."\n"; |
|
204 | + } |
|
173 | 205 | foreach ($this->all_flights as $key => $flight) { |
174 | 206 | if (isset($flight['lastupdate'])) { |
175 | 207 | if ($flight['lastupdate'] < (time()-3000)) { |
176 | 208 | if (isset($this->all_flights[$key]['id'])) { |
177 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
209 | + if ($globalDebug) { |
|
210 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
211 | + } |
|
178 | 212 | /* |
179 | 213 | $SpotterLive = new SpotterLive(); |
180 | 214 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
@@ -184,7 +218,9 @@ discard block |
||
184 | 218 | $Spotter = new Spotter($this->db); |
185 | 219 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
186 | 220 | $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']); |
187 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
221 | + if ($globalDebug && $result != 'success') { |
|
222 | + echo '!!! ERROR : '.$result."\n"; |
|
223 | + } |
|
188 | 224 | } |
189 | 225 | // Put in archive |
190 | 226 | // $Spotter->db = null; |
@@ -198,8 +234,10 @@ discard block |
||
198 | 234 | public function add($line) { |
199 | 235 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights; |
200 | 236 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
201 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
202 | -/* |
|
237 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
238 | + $globalCoordMinChange = '0.02'; |
|
239 | + } |
|
240 | + /* |
|
203 | 241 | $Spotter = new Spotter(); |
204 | 242 | $dbc = $Spotter->db; |
205 | 243 | $SpotterLive = new SpotterLive($dbc); |
@@ -227,11 +265,15 @@ discard block |
||
227 | 265 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
228 | 266 | $current_date = date('Y-m-d'); |
229 | 267 | $source = $line['source_name']; |
230 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
268 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
269 | + $source = $line['format_source']; |
|
270 | + } |
|
231 | 271 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
232 | 272 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
233 | 273 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
234 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
274 | + } else { |
|
275 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
276 | + } |
|
235 | 277 | } |
236 | 278 | |
237 | 279 | /* |
@@ -247,8 +289,11 @@ discard block |
||
247 | 289 | //$this->db = $dbc; |
248 | 290 | |
249 | 291 | $hex = trim($line['hex']); |
250 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
251 | - else $id = trim($line['id']); |
|
292 | + if (!isset($line['id'])) { |
|
293 | + $id = trim($line['hex']); |
|
294 | + } else { |
|
295 | + $id = trim($line['id']); |
|
296 | + } |
|
252 | 297 | |
253 | 298 | //print_r($this->all_flights); |
254 | 299 | if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) { |
@@ -263,13 +308,20 @@ discard block |
||
263 | 308 | $Spotter = new Spotter($this->db); |
264 | 309 | $aircraft_icao = $Spotter->getAllAircraftType($hex); |
265 | 310 | $Spotter->db = null; |
266 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
311 | + if ($globalDebugTimeElapsed) { |
|
312 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | + } |
|
267 | 314 | |
268 | 315 | if ($aircraft_icao == '' && isset($line['aircraft_type'])) { |
269 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
270 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
271 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
272 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
316 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
317 | + $aircraft_icao = 'GLID'; |
|
318 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
319 | + $aircraft_icao = 'UHEL'; |
|
320 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
321 | + $aircraft_icao = 'TOWPLANE'; |
|
322 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
323 | + $aircraft_icao = 'POWAIRC'; |
|
324 | + } |
|
273 | 325 | } |
274 | 326 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
275 | 327 | } else if (isset($line['aircraft_name'])) { |
@@ -277,21 +329,36 @@ discard block |
||
277 | 329 | $Spotter = new Spotter($this->db); |
278 | 330 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
279 | 331 | $Spotter->db = null; |
280 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
281 | - else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
282 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
332 | + if ($aircraft_icao != '') { |
|
333 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
334 | + } else { |
|
335 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
336 | + } |
|
337 | + } else { |
|
338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
339 | + } |
|
283 | 340 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', '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)); |
284 | 341 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
285 | 342 | if (!isset($line['id'])) { |
286 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
287 | -// 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'))); |
|
343 | + if (!isset($globalDaemon)) { |
|
344 | + $globalDaemon = TRUE; |
|
345 | + } |
|
346 | + // 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'))); |
|
288 | 347 | // 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'))); |
289 | - 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' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
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' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
|
349 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
350 | + } |
|
290 | 351 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
291 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
352 | + } else { |
|
353 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
354 | + } |
|
292 | 355 | |
293 | - if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
294 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
356 | + if ($globalDebug) { |
|
357 | + echo "*********** New aircraft hex : ".$hex." ***********\n"; |
|
358 | + } |
|
359 | + if ($globalAllFlights !== FALSE) { |
|
360 | + $dataFound = true; |
|
361 | + } |
|
295 | 362 | } |
296 | 363 | |
297 | 364 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
@@ -299,8 +366,11 @@ discard block |
||
299 | 366 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
300 | 367 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
301 | 368 | } else { |
302 | - 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"; |
|
303 | - 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"; |
|
369 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
370 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
371 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
372 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
373 | + } |
|
304 | 374 | /* |
305 | 375 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
306 | 376 | print_r($this->all_flights[$id]); |
@@ -332,15 +402,25 @@ discard block |
||
332 | 402 | $timeelapsed = microtime(true); |
333 | 403 | $Spotter = new Spotter($this->db); |
334 | 404 | $fromsource = NULL; |
335 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
336 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
337 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
338 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
339 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
405 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
406 | + $fromsource = $globalAirlinesSource; |
|
407 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
408 | + $fromsource = 'vatsim'; |
|
409 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
410 | + $fromsource = 'ivao'; |
|
411 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
412 | + $fromsource = 'vatsim'; |
|
413 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
414 | + $fromsource = 'ivao'; |
|
415 | + } |
|
340 | 416 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
341 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
417 | + if ($globalDebug && $result != 'success') { |
|
418 | + echo '!!! ERROR : '.$result."\n"; |
|
419 | + } |
|
342 | 420 | $Spotter->db = null; |
343 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
421 | + if ($globalDebugTimeElapsed) { |
|
422 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
423 | + } |
|
344 | 424 | } |
345 | 425 | |
346 | 426 | /* |
@@ -351,7 +431,9 @@ discard block |
||
351 | 431 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
352 | 432 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
353 | 433 | */ |
354 | - 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'])); |
|
434 | + if (!isset($this->all_flights[$id]['id'])) { |
|
435 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
436 | + } |
|
355 | 437 | |
356 | 438 | //$putinarchive = true; |
357 | 439 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -368,7 +450,9 @@ discard block |
||
368 | 450 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
369 | 451 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
370 | 452 | $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' => '')); |
371 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
453 | + if ($globalDebugTimeElapsed) { |
|
454 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
455 | + } |
|
372 | 456 | |
373 | 457 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
374 | 458 | $timeelapsed = microtime(true); |
@@ -381,7 +465,9 @@ discard block |
||
381 | 465 | $Translation->db = null; |
382 | 466 | } |
383 | 467 | $Spotter->db = null; |
384 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
468 | + if ($globalDebugTimeElapsed) { |
|
469 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
470 | + } |
|
385 | 471 | |
386 | 472 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
387 | 473 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -390,9 +476,13 @@ discard block |
||
390 | 476 | $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'])); |
391 | 477 | } |
392 | 478 | } |
393 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
479 | + if (!isset($globalFork)) { |
|
480 | + $globalFork = TRUE; |
|
481 | + } |
|
394 | 482 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
395 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
483 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
484 | + $this->get_Schedule($id,trim($line['ident'])); |
|
485 | + } |
|
396 | 486 | } |
397 | 487 | } |
398 | 488 | } |
@@ -408,16 +498,23 @@ discard block |
||
408 | 498 | // use datetime |
409 | 499 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
410 | 500 | $speed = $speed*3.6; |
411 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
412 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
501 | + if ($speed < 1000) { |
|
502 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
503 | + } |
|
504 | + if ($globalDebug) { |
|
505 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
506 | + } |
|
413 | 507 | } |
414 | 508 | } |
415 | 509 | |
416 | 510 | |
417 | 511 | |
418 | 512 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
419 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
420 | - else unset($timediff); |
|
513 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
514 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
515 | + } else { |
|
516 | + unset($timediff); |
|
517 | + } |
|
421 | 518 | if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
422 | 519 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
423 | 520 | if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -425,21 +522,31 @@ discard block |
||
425 | 522 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
426 | 523 | $this->all_flights[$id]['putinarchive'] = true; |
427 | 524 | |
428 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
525 | + if ($globalDebug) { |
|
526 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
527 | + } |
|
429 | 528 | $timeelapsed = microtime(true); |
430 | 529 | $Spotter = new Spotter($this->db); |
431 | 530 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
432 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
531 | + if (!empty($all_country)) { |
|
532 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
533 | + } |
|
433 | 534 | $Spotter->db = null; |
434 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
535 | + if ($globalDebugTimeElapsed) { |
|
536 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
537 | + } |
|
435 | 538 | $this->tmd = 0; |
436 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
539 | + if ($globalDebug) { |
|
540 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
541 | + } |
|
437 | 542 | } |
438 | 543 | } |
439 | 544 | |
440 | 545 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
441 | 546 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
442 | - if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
547 | + if (!isset($this->all_flights[$id]['archive_latitude'])) { |
|
548 | + $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
549 | + } |
|
443 | 550 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
444 | 551 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
445 | 552 | $dataFound = true; |
@@ -461,9 +568,13 @@ discard block |
||
461 | 568 | */ |
462 | 569 | } |
463 | 570 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
464 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
571 | + if ($line['longitude'] > 180) { |
|
572 | + $line['longitude'] = $line['longitude'] - 360; |
|
573 | + } |
|
465 | 574 | //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) { |
466 | - if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
575 | + if (!isset($this->all_flights[$id]['archive_longitude'])) { |
|
576 | + $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
577 | + } |
|
467 | 578 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
468 | 579 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
469 | 580 | $dataFound = true; |
@@ -494,7 +605,9 @@ discard block |
||
494 | 605 | } |
495 | 606 | } |
496 | 607 | if (isset($line['last_update']) && $line['last_update'] != '') { |
497 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
608 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
609 | + $dataFound = true; |
|
610 | + } |
|
498 | 611 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
499 | 612 | } |
500 | 613 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -516,11 +629,17 @@ discard block |
||
516 | 629 | // Here we force archive of flight because after ground it's a new one (or should be) |
517 | 630 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
518 | 631 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
519 | - 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'].'-'.date('YmdGi'))); |
|
520 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
521 | - 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'])); |
|
632 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) { |
|
633 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
634 | + } elseif (isset($line['id'])) { |
|
635 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
636 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
637 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
638 | + } |
|
639 | + } |
|
640 | + if ($line['ground'] != 1) { |
|
641 | + $line['ground'] = 0; |
|
522 | 642 | } |
523 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
524 | 643 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
525 | 644 | //$dataFound = true; |
526 | 645 | } |
@@ -528,28 +647,40 @@ discard block |
||
528 | 647 | 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'])) { |
529 | 648 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
530 | 649 | $highlight = ''; |
531 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
532 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
533 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
650 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
651 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
652 | + } |
|
653 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
654 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
655 | + } |
|
656 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
657 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
658 | + } |
|
534 | 659 | if ($highlight != '') { |
535 | 660 | $timeelapsed = microtime(true); |
536 | 661 | $Spotter = new Spotter($this->db); |
537 | 662 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
538 | 663 | $Spotter->db = null; |
539 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
664 | + if ($globalDebugTimeElapsed) { |
|
665 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
666 | + } |
|
540 | 667 | |
541 | 668 | $this->all_flights[$id]['putinarchive'] = true; |
542 | 669 | //$putinarchive = true; |
543 | 670 | //$highlight = ''; |
544 | 671 | } |
545 | 672 | |
546 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
673 | + } else { |
|
674 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
675 | + } |
|
547 | 676 | //$dataFound = true; |
548 | 677 | } |
549 | 678 | |
550 | 679 | if (isset($line['altitude']) && $line['altitude'] != '') { |
551 | 680 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
552 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
681 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) { |
|
682 | + $this->all_flights[$id]['putinarchive'] = true; |
|
683 | + } |
|
553 | 684 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
554 | 685 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
555 | 686 | //$dataFound = true; |
@@ -561,21 +692,30 @@ discard block |
||
561 | 692 | } |
562 | 693 | |
563 | 694 | if (isset($line['heading']) && $line['heading'] != '') { |
564 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
695 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) { |
|
696 | + $this->all_flights[$id]['putinarchive'] = true; |
|
697 | + } |
|
565 | 698 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
566 | 699 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
567 | 700 | //$dataFound = true; |
568 | 701 | } 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']) { |
569 | 702 | $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']); |
570 | 703 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
571 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true; |
|
572 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
704 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) { |
|
705 | + $this->all_flights[$id]['putinarchive'] = true; |
|
706 | + } |
|
707 | + if ($globalDebug) { |
|
708 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
709 | + } |
|
573 | 710 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
574 | 711 | // If not enough messages and ACARS set heading to 0 |
575 | 712 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
576 | 713 | } |
577 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
578 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
714 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
715 | + $dataFound = false; |
|
716 | + } elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
717 | + $dataFound = false; |
|
718 | + } |
|
579 | 719 | |
580 | 720 | // print_r($this->all_flights[$id]); |
581 | 721 | //gets the callsign from the last hour |
@@ -590,23 +730,36 @@ discard block |
||
590 | 730 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
591 | 731 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
592 | 732 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
593 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
733 | + if ($globalDebug) { |
|
734 | + echo "Check if aircraft is already in DB..."; |
|
735 | + } |
|
594 | 736 | $timeelapsed = microtime(true); |
595 | 737 | $SpotterLive = new SpotterLive($this->db); |
596 | 738 | 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' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
597 | 739 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
598 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
740 | + if ($globalDebugTimeElapsed) { |
|
741 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
742 | + } |
|
599 | 743 | } elseif (isset($line['id'])) { |
600 | 744 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
601 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
745 | + if ($globalDebugTimeElapsed) { |
|
746 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
747 | + } |
|
602 | 748 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
603 | 749 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
604 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
605 | - } else $recent_ident = ''; |
|
750 | + if ($globalDebugTimeElapsed) { |
|
751 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
752 | + } |
|
753 | + } else { |
|
754 | + $recent_ident = ''; |
|
755 | + } |
|
606 | 756 | $SpotterLive->db=null; |
607 | 757 | |
608 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
609 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
758 | + if ($globalDebug && $recent_ident == '') { |
|
759 | + echo " Not in DB.\n"; |
|
760 | + } elseif ($globalDebug && $recent_ident != '') { |
|
761 | + echo " Already in DB.\n"; |
|
762 | + } |
|
610 | 763 | } else { |
611 | 764 | $recent_ident = ''; |
612 | 765 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -614,7 +767,9 @@ discard block |
||
614 | 767 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
615 | 768 | if($recent_ident == "") |
616 | 769 | { |
617 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
770 | + if ($globalDebug) { |
|
771 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
772 | + } |
|
618 | 773 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
619 | 774 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
620 | 775 | //adds the spotter data for the archive |
@@ -658,26 +813,44 @@ discard block |
||
658 | 813 | |
659 | 814 | if (!$ignoreImport) { |
660 | 815 | $highlight = ''; |
661 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
662 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
663 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
664 | - 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'))); |
|
816 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
817 | + $highlight = 'Squawk 7500 : Hijack'; |
|
818 | + } |
|
819 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
820 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
821 | + } |
|
822 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
823 | + $highlight = 'Squawk 7700 : Emergency'; |
|
824 | + } |
|
825 | + if (!isset($this->all_flights[$id]['id'])) { |
|
826 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
827 | + } |
|
665 | 828 | $timeelapsed = microtime(true); |
666 | 829 | $Spotter = new Spotter($this->db); |
667 | 830 | $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]['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']); |
668 | 831 | $Spotter->db = null; |
669 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
670 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
832 | + if ($globalDebug && isset($result)) { |
|
833 | + echo $result."\n"; |
|
834 | + } |
|
835 | + if ($globalDebugTimeElapsed) { |
|
836 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
837 | + } |
|
671 | 838 | |
672 | 839 | // Add source stat in DB |
673 | 840 | $Stats = new Stats($this->db); |
674 | 841 | if (!empty($this->stats)) { |
675 | - if ($globalDebug) echo 'Add source stats : '; |
|
842 | + if ($globalDebug) { |
|
843 | + echo 'Add source stats : '; |
|
844 | + } |
|
676 | 845 | foreach($this->stats as $date => $data) { |
677 | 846 | foreach($data as $source => $sourced) { |
678 | 847 | //print_r($sourced); |
679 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
680 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
848 | + if (isset($sourced['polar'])) { |
|
849 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
850 | + } |
|
851 | + if (isset($sourced['hist'])) { |
|
852 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
853 | + } |
|
681 | 854 | if (isset($sourced['msg'])) { |
682 | 855 | if (time() - $sourced['msg']['date'] > 10) { |
683 | 856 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -690,13 +863,17 @@ discard block |
||
690 | 863 | unset($this->stats[$date]); |
691 | 864 | } |
692 | 865 | } |
693 | - if ($globalDebug) echo 'Done'."\n"; |
|
866 | + if ($globalDebug) { |
|
867 | + echo 'Done'."\n"; |
|
868 | + } |
|
694 | 869 | |
695 | 870 | } |
696 | 871 | $Stats->db = null; |
697 | 872 | |
698 | 873 | $this->del(); |
699 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
874 | + } elseif ($globalDebug) { |
|
875 | + echo 'Ignore data'."\n"; |
|
876 | + } |
|
700 | 877 | //$ignoreImport = false; |
701 | 878 | $this->all_flights[$id]['addedSpotter'] = 1; |
702 | 879 | //print_r($this->all_flights[$id]); |
@@ -713,12 +890,16 @@ discard block |
||
713 | 890 | */ |
714 | 891 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
715 | 892 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
716 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
893 | + if ($globalDebug) { |
|
894 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
895 | + } |
|
717 | 896 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
718 | 897 | $SpotterLive = new SpotterLive($this->db); |
719 | 898 | $SpotterLive->deleteLiveSpotterData(); |
720 | 899 | $SpotterLive->db=null; |
721 | - if ($globalDebug) echo " Done\n"; |
|
900 | + if ($globalDebug) { |
|
901 | + echo " Done\n"; |
|
902 | + } |
|
722 | 903 | $this->last_delete = time(); |
723 | 904 | } |
724 | 905 | } else { |
@@ -741,11 +922,17 @@ discard block |
||
741 | 922 | //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"; |
742 | 923 | if ($globalDebug) { |
743 | 924 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
744 | - 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"; |
|
745 | - 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"; |
|
925 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
926 | + 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"; |
|
927 | + } else { |
|
928 | + 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"; |
|
929 | + } |
|
746 | 930 | } else { |
747 | - 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"; |
|
748 | - 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"; |
|
931 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
932 | + 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"; |
|
933 | + } else { |
|
934 | + 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"; |
|
935 | + } |
|
749 | 936 | } |
750 | 937 | } |
751 | 938 | $ignoreImport = false; |
@@ -791,19 +978,25 @@ discard block |
||
791 | 978 | |
792 | 979 | if (!$ignoreImport) { |
793 | 980 | 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'])) { |
794 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
981 | + if ($globalDebug) { |
|
982 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
983 | + } |
|
795 | 984 | $timeelapsed = microtime(true); |
796 | 985 | $SpotterLive = new SpotterLive($this->db); |
797 | 986 | $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]['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']); |
798 | 987 | $SpotterLive->db = null; |
799 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
988 | + if ($globalDebugTimeElapsed) { |
|
989 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
990 | + } |
|
800 | 991 | |
801 | 992 | // Put statistics in $this->stats variable |
802 | 993 | //if ($line['format_source'] != 'aprs') { |
803 | 994 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
804 | 995 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
805 | 996 | $source = $this->all_flights[$id]['source_name']; |
806 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
997 | + if ($source == '') { |
|
998 | + $source = $this->all_flights[$id]['format_source']; |
|
999 | + } |
|
807 | 1000 | if (!isset($this->source_location[$source])) { |
808 | 1001 | $Location = new Source(); |
809 | 1002 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -824,7 +1017,9 @@ discard block |
||
824 | 1017 | $stats_heading = round($stats_heading/22.5); |
825 | 1018 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
826 | 1019 | $current_date = date('Y-m-d'); |
827 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1020 | + if ($stats_heading == 16) { |
|
1021 | + $stats_heading = 0; |
|
1022 | + } |
|
828 | 1023 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
829 | 1024 | for ($i=0;$i<=15;$i++) { |
830 | 1025 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -842,7 +1037,9 @@ discard block |
||
842 | 1037 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
843 | 1038 | end($this->stats[$current_date][$source]['hist']); |
844 | 1039 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
845 | - } else $mini = 0; |
|
1040 | + } else { |
|
1041 | + $mini = 0; |
|
1042 | + } |
|
846 | 1043 | for ($i=$mini;$i<=$distance;$i+=10) { |
847 | 1044 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
848 | 1045 | } |
@@ -853,20 +1050,30 @@ discard block |
||
853 | 1050 | } |
854 | 1051 | |
855 | 1052 | $this->all_flights[$id]['lastupdate'] = time(); |
856 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1053 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1054 | + $send = true; |
|
1055 | + } |
|
857 | 1056 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
858 | - if ($globalDebug) echo $result."\n"; |
|
859 | - } 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"; |
|
1057 | + if ($globalDebug) { |
|
1058 | + echo $result."\n"; |
|
1059 | + } |
|
1060 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1061 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1062 | + } |
|
860 | 1063 | //$this->del(); |
861 | 1064 | |
862 | 1065 | |
863 | 1066 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
864 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1067 | + if ($globalDebug) { |
|
1068 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1069 | + } |
|
865 | 1070 | $SpotterLive = new SpotterLive($this->db); |
866 | 1071 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
867 | 1072 | $SpotterLive->db = null; |
868 | 1073 | //SpotterLive->deleteLiveSpotterData(); |
869 | - if ($globalDebug) echo " Done\n"; |
|
1074 | + if ($globalDebug) { |
|
1075 | + echo " Done\n"; |
|
1076 | + } |
|
870 | 1077 | $this->last_delete_hourly = time(); |
871 | 1078 | } |
872 | 1079 | |
@@ -874,7 +1081,9 @@ discard block |
||
874 | 1081 | //$ignoreImport = false; |
875 | 1082 | } |
876 | 1083 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
877 | - if ($send) return $this->all_flights[$id]; |
|
1084 | + if ($send) { |
|
1085 | + return $this->all_flights[$id]; |
|
1086 | + } |
|
878 | 1087 | } |
879 | 1088 | } |
880 | 1089 | } |
@@ -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 { |
@@ -804,12 +856,16 @@ discard block |
||
804 | 856 | if ($globalDBdriver == 'mysql') { |
805 | 857 | if (!$Connection->tableExists('tle')) { |
806 | 858 | $error .= create_db::import_file('../db/tle.sql'); |
807 | - if ($error != '') return $error; |
|
859 | + if ($error != '') { |
|
860 | + return $error; |
|
861 | + } |
|
808 | 862 | } |
809 | 863 | } else { |
810 | 864 | if (!$Connection->tableExists('tle')) { |
811 | 865 | $error .= create_db::import_file('../db/pgsql/tle.sql'); |
812 | - if ($error != '') return $error; |
|
866 | + if ($error != '') { |
|
867 | + return $error; |
|
868 | + } |
|
813 | 869 | } |
814 | 870 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; |
815 | 871 | try { |
@@ -849,7 +905,9 @@ discard block |
||
849 | 905 | } else { |
850 | 906 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
851 | 907 | } |
852 | - if ($error != '') return 'Import airlines.sql : '.$error; |
|
908 | + if ($error != '') { |
|
909 | + return 'Import airlines.sql : '.$error; |
|
910 | + } |
|
853 | 911 | if (!$Connection->checkColumnName('airlines','forsource')) { |
854 | 912 | // Add forsource to airlines |
855 | 913 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; |
@@ -1332,20 +1390,28 @@ discard block |
||
1332 | 1390 | } |
1333 | 1391 | if ($globalDBdriver == 'mysql') { |
1334 | 1392 | $error .= create_db::import_file('../db/airlines.sql'); |
1335 | - if ($error != '') return $error; |
|
1393 | + if ($error != '') { |
|
1394 | + return $error; |
|
1395 | + } |
|
1336 | 1396 | } else { |
1337 | 1397 | $error .= create_db::import_file('../db/pgsql/airlines.sql'); |
1338 | - if ($error != '') return $error; |
|
1398 | + if ($error != '') { |
|
1399 | + return $error; |
|
1400 | + } |
|
1339 | 1401 | } |
1340 | 1402 | if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) { |
1341 | 1403 | include_once(dirname(__FILE__).'/class.update_db.php'); |
1342 | 1404 | if (isset($globalVATSIM) && $globalVATSIM) { |
1343 | 1405 | $error .= update_db::update_vatsim(); |
1344 | - if ($error != '') return $error; |
|
1406 | + if ($error != '') { |
|
1407 | + return $error; |
|
1408 | + } |
|
1345 | 1409 | } |
1346 | 1410 | if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) { |
1347 | 1411 | $error .= update_db::update_IVAO(); |
1348 | - if ($error != '') return $error; |
|
1412 | + if ($error != '') { |
|
1413 | + return $error; |
|
1414 | + } |
|
1349 | 1415 | } |
1350 | 1416 | } |
1351 | 1417 | |
@@ -1543,8 +1609,11 @@ discard block |
||
1543 | 1609 | if ($Connection->tableExists('aircraft')) { |
1544 | 1610 | if (!$Connection->tableExists('config')) { |
1545 | 1611 | $version = '1'; |
1546 | - if ($update) return self::update_from_1(); |
|
1547 | - else return $version; |
|
1612 | + if ($update) { |
|
1613 | + return self::update_from_1(); |
|
1614 | + } else { |
|
1615 | + return $version; |
|
1616 | + } |
|
1548 | 1617 | } else { |
1549 | 1618 | $Connection = new Connection(); |
1550 | 1619 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
@@ -1558,142 +1627,246 @@ discard block |
||
1558 | 1627 | if ($update) { |
1559 | 1628 | if ($result['value'] == '2') { |
1560 | 1629 | $error = self::update_from_2(); |
1561 | - if ($error != '') return $error; |
|
1562 | - else return self::check_version(true); |
|
1630 | + if ($error != '') { |
|
1631 | + return $error; |
|
1632 | + } else { |
|
1633 | + return self::check_version(true); |
|
1634 | + } |
|
1563 | 1635 | } elseif ($result['value'] == '3') { |
1564 | 1636 | $error = self::update_from_3(); |
1565 | - if ($error != '') return $error; |
|
1566 | - else return self::check_version(true); |
|
1637 | + if ($error != '') { |
|
1638 | + return $error; |
|
1639 | + } else { |
|
1640 | + return self::check_version(true); |
|
1641 | + } |
|
1567 | 1642 | } elseif ($result['value'] == '4') { |
1568 | 1643 | $error = self::update_from_4(); |
1569 | - if ($error != '') return $error; |
|
1570 | - else return self::check_version(true); |
|
1644 | + if ($error != '') { |
|
1645 | + return $error; |
|
1646 | + } else { |
|
1647 | + return self::check_version(true); |
|
1648 | + } |
|
1571 | 1649 | } elseif ($result['value'] == '5') { |
1572 | 1650 | $error = self::update_from_5(); |
1573 | - if ($error != '') return $error; |
|
1574 | - else return self::check_version(true); |
|
1651 | + if ($error != '') { |
|
1652 | + return $error; |
|
1653 | + } else { |
|
1654 | + return self::check_version(true); |
|
1655 | + } |
|
1575 | 1656 | } elseif ($result['value'] == '6') { |
1576 | 1657 | $error = self::update_from_6(); |
1577 | - if ($error != '') return $error; |
|
1578 | - else return self::check_version(true); |
|
1658 | + if ($error != '') { |
|
1659 | + return $error; |
|
1660 | + } else { |
|
1661 | + return self::check_version(true); |
|
1662 | + } |
|
1579 | 1663 | } elseif ($result['value'] == '7') { |
1580 | 1664 | $error = self::update_from_7(); |
1581 | - if ($error != '') return $error; |
|
1582 | - else return self::check_version(true); |
|
1665 | + if ($error != '') { |
|
1666 | + return $error; |
|
1667 | + } else { |
|
1668 | + return self::check_version(true); |
|
1669 | + } |
|
1583 | 1670 | } elseif ($result['value'] == '8') { |
1584 | 1671 | $error = self::update_from_8(); |
1585 | - if ($error != '') return $error; |
|
1586 | - else return self::check_version(true); |
|
1672 | + if ($error != '') { |
|
1673 | + return $error; |
|
1674 | + } else { |
|
1675 | + return self::check_version(true); |
|
1676 | + } |
|
1587 | 1677 | } elseif ($result['value'] == '9') { |
1588 | 1678 | $error = self::update_from_9(); |
1589 | - if ($error != '') return $error; |
|
1590 | - else return self::check_version(true); |
|
1679 | + if ($error != '') { |
|
1680 | + return $error; |
|
1681 | + } else { |
|
1682 | + return self::check_version(true); |
|
1683 | + } |
|
1591 | 1684 | } elseif ($result['value'] == '10') { |
1592 | 1685 | $error = self::update_from_10(); |
1593 | - if ($error != '') return $error; |
|
1594 | - else return self::check_version(true); |
|
1686 | + if ($error != '') { |
|
1687 | + return $error; |
|
1688 | + } else { |
|
1689 | + return self::check_version(true); |
|
1690 | + } |
|
1595 | 1691 | } elseif ($result['value'] == '11') { |
1596 | 1692 | $error = self::update_from_11(); |
1597 | - if ($error != '') return $error; |
|
1598 | - else return self::check_version(true); |
|
1693 | + if ($error != '') { |
|
1694 | + return $error; |
|
1695 | + } else { |
|
1696 | + return self::check_version(true); |
|
1697 | + } |
|
1599 | 1698 | } elseif ($result['value'] == '12') { |
1600 | 1699 | $error = self::update_from_12(); |
1601 | - if ($error != '') return $error; |
|
1602 | - else return self::check_version(true); |
|
1700 | + if ($error != '') { |
|
1701 | + return $error; |
|
1702 | + } else { |
|
1703 | + return self::check_version(true); |
|
1704 | + } |
|
1603 | 1705 | } elseif ($result['value'] == '13') { |
1604 | 1706 | $error = self::update_from_13(); |
1605 | - if ($error != '') return $error; |
|
1606 | - else return self::check_version(true); |
|
1707 | + if ($error != '') { |
|
1708 | + return $error; |
|
1709 | + } else { |
|
1710 | + return self::check_version(true); |
|
1711 | + } |
|
1607 | 1712 | } elseif ($result['value'] == '14') { |
1608 | 1713 | $error = self::update_from_14(); |
1609 | - if ($error != '') return $error; |
|
1610 | - else return self::check_version(true); |
|
1714 | + if ($error != '') { |
|
1715 | + return $error; |
|
1716 | + } else { |
|
1717 | + return self::check_version(true); |
|
1718 | + } |
|
1611 | 1719 | } elseif ($result['value'] == '15') { |
1612 | 1720 | $error = self::update_from_15(); |
1613 | - if ($error != '') return $error; |
|
1614 | - else return self::check_version(true); |
|
1721 | + if ($error != '') { |
|
1722 | + return $error; |
|
1723 | + } else { |
|
1724 | + return self::check_version(true); |
|
1725 | + } |
|
1615 | 1726 | } elseif ($result['value'] == '16') { |
1616 | 1727 | $error = self::update_from_16(); |
1617 | - if ($error != '') return $error; |
|
1618 | - else return self::check_version(true); |
|
1728 | + if ($error != '') { |
|
1729 | + return $error; |
|
1730 | + } else { |
|
1731 | + return self::check_version(true); |
|
1732 | + } |
|
1619 | 1733 | } elseif ($result['value'] == '17') { |
1620 | 1734 | $error = self::update_from_17(); |
1621 | - if ($error != '') return $error; |
|
1622 | - else return self::check_version(true); |
|
1735 | + if ($error != '') { |
|
1736 | + return $error; |
|
1737 | + } else { |
|
1738 | + return self::check_version(true); |
|
1739 | + } |
|
1623 | 1740 | } elseif ($result['value'] == '18') { |
1624 | 1741 | $error = self::update_from_18(); |
1625 | - if ($error != '') return $error; |
|
1626 | - else return self::check_version(true); |
|
1742 | + if ($error != '') { |
|
1743 | + return $error; |
|
1744 | + } else { |
|
1745 | + return self::check_version(true); |
|
1746 | + } |
|
1627 | 1747 | } elseif ($result['value'] == '19') { |
1628 | 1748 | $error = self::update_from_19(); |
1629 | - if ($error != '') return $error; |
|
1630 | - else return self::check_version(true); |
|
1749 | + if ($error != '') { |
|
1750 | + return $error; |
|
1751 | + } else { |
|
1752 | + return self::check_version(true); |
|
1753 | + } |
|
1631 | 1754 | } elseif ($result['value'] == '20') { |
1632 | 1755 | $error = self::update_from_20(); |
1633 | - if ($error != '') return $error; |
|
1634 | - else return self::check_version(true); |
|
1756 | + if ($error != '') { |
|
1757 | + return $error; |
|
1758 | + } else { |
|
1759 | + return self::check_version(true); |
|
1760 | + } |
|
1635 | 1761 | } elseif ($result['value'] == '21') { |
1636 | 1762 | $error = self::update_from_21(); |
1637 | - if ($error != '') return $error; |
|
1638 | - else return self::check_version(true); |
|
1763 | + if ($error != '') { |
|
1764 | + return $error; |
|
1765 | + } else { |
|
1766 | + return self::check_version(true); |
|
1767 | + } |
|
1639 | 1768 | } elseif ($result['value'] == '22') { |
1640 | 1769 | $error = self::update_from_22(); |
1641 | - if ($error != '') return $error; |
|
1642 | - else return self::check_version(true); |
|
1770 | + if ($error != '') { |
|
1771 | + return $error; |
|
1772 | + } else { |
|
1773 | + return self::check_version(true); |
|
1774 | + } |
|
1643 | 1775 | } elseif ($result['value'] == '23') { |
1644 | 1776 | $error = self::update_from_23(); |
1645 | - if ($error != '') return $error; |
|
1646 | - else return self::check_version(true); |
|
1777 | + if ($error != '') { |
|
1778 | + return $error; |
|
1779 | + } else { |
|
1780 | + return self::check_version(true); |
|
1781 | + } |
|
1647 | 1782 | } elseif ($result['value'] == '24') { |
1648 | 1783 | $error = self::update_from_24(); |
1649 | - if ($error != '') return $error; |
|
1650 | - else return self::check_version(true); |
|
1784 | + if ($error != '') { |
|
1785 | + return $error; |
|
1786 | + } else { |
|
1787 | + return self::check_version(true); |
|
1788 | + } |
|
1651 | 1789 | } elseif ($result['value'] == '25') { |
1652 | 1790 | $error = self::update_from_25(); |
1653 | - if ($error != '') return $error; |
|
1654 | - else return self::check_version(true); |
|
1791 | + if ($error != '') { |
|
1792 | + return $error; |
|
1793 | + } else { |
|
1794 | + return self::check_version(true); |
|
1795 | + } |
|
1655 | 1796 | } elseif ($result['value'] == '26') { |
1656 | 1797 | $error = self::update_from_26(); |
1657 | - if ($error != '') return $error; |
|
1658 | - else return self::check_version(true); |
|
1798 | + if ($error != '') { |
|
1799 | + return $error; |
|
1800 | + } else { |
|
1801 | + return self::check_version(true); |
|
1802 | + } |
|
1659 | 1803 | } elseif ($result['value'] == '27') { |
1660 | 1804 | $error = self::update_from_27(); |
1661 | - if ($error != '') return $error; |
|
1662 | - else return self::check_version(true); |
|
1805 | + if ($error != '') { |
|
1806 | + return $error; |
|
1807 | + } else { |
|
1808 | + return self::check_version(true); |
|
1809 | + } |
|
1663 | 1810 | } elseif ($result['value'] == '28') { |
1664 | 1811 | $error = self::update_from_28(); |
1665 | - if ($error != '') return $error; |
|
1666 | - else return self::check_version(true); |
|
1812 | + if ($error != '') { |
|
1813 | + return $error; |
|
1814 | + } else { |
|
1815 | + return self::check_version(true); |
|
1816 | + } |
|
1667 | 1817 | } elseif ($result['value'] == '29') { |
1668 | 1818 | $error = self::update_from_29(); |
1669 | - if ($error != '') return $error; |
|
1670 | - else return self::check_version(true); |
|
1819 | + if ($error != '') { |
|
1820 | + return $error; |
|
1821 | + } else { |
|
1822 | + return self::check_version(true); |
|
1823 | + } |
|
1671 | 1824 | } elseif ($result['value'] == '30') { |
1672 | 1825 | $error = self::update_from_30(); |
1673 | - if ($error != '') return $error; |
|
1674 | - else return self::check_version(true); |
|
1826 | + if ($error != '') { |
|
1827 | + return $error; |
|
1828 | + } else { |
|
1829 | + return self::check_version(true); |
|
1830 | + } |
|
1675 | 1831 | } elseif ($result['value'] == '31') { |
1676 | 1832 | $error = self::update_from_31(); |
1677 | - if ($error != '') return $error; |
|
1678 | - else return self::check_version(true); |
|
1833 | + if ($error != '') { |
|
1834 | + return $error; |
|
1835 | + } else { |
|
1836 | + return self::check_version(true); |
|
1837 | + } |
|
1679 | 1838 | } elseif ($result['value'] == '32') { |
1680 | 1839 | $error = self::update_from_32(); |
1681 | - if ($error != '') return $error; |
|
1682 | - else return self::check_version(true); |
|
1840 | + if ($error != '') { |
|
1841 | + return $error; |
|
1842 | + } else { |
|
1843 | + return self::check_version(true); |
|
1844 | + } |
|
1683 | 1845 | } elseif ($result['value'] == '33') { |
1684 | 1846 | $error = self::update_from_33(); |
1685 | - if ($error != '') return $error; |
|
1686 | - else return self::check_version(true); |
|
1847 | + if ($error != '') { |
|
1848 | + return $error; |
|
1849 | + } else { |
|
1850 | + return self::check_version(true); |
|
1851 | + } |
|
1687 | 1852 | } elseif ($result['value'] == '34') { |
1688 | 1853 | $error = self::update_from_34(); |
1689 | - if ($error != '') return $error; |
|
1690 | - else return self::check_version(true); |
|
1691 | - } else return ''; |
|
1854 | + if ($error != '') { |
|
1855 | + return $error; |
|
1856 | + } else { |
|
1857 | + return self::check_version(true); |
|
1858 | + } |
|
1859 | + } else { |
|
1860 | + return ''; |
|
1861 | + } |
|
1862 | + } else { |
|
1863 | + return $result['value']; |
|
1692 | 1864 | } |
1693 | - else return $result['value']; |
|
1694 | 1865 | } |
1695 | 1866 | |
1696 | - } else return $version; |
|
1867 | + } else { |
|
1868 | + return $version; |
|
1869 | + } |
|
1697 | 1870 | } |
1698 | 1871 | |
1699 | 1872 | } |
@@ -382,7 +382,9 @@ discard block |
||
382 | 382 | if (isset($globalTimezone)) |
383 | 383 | { |
384 | 384 | date_default_timezone_set($globalTimezone); |
385 | - } else date_default_timezone_set('UTC'); |
|
385 | + } else { |
|
386 | + date_default_timezone_set('UTC'); |
|
387 | + } |
|
386 | 388 | if ($showSpecial === true) |
387 | 389 | { |
388 | 390 | print '<tr class="special">'."\n"; |
@@ -397,7 +399,9 @@ discard block |
||
397 | 399 | print '<tr class="active">'; |
398 | 400 | } elseif (isset($spotter_item['spotted_registration'])) { |
399 | 401 | print '<tr class="info">'; |
400 | - } else print '<tr>'; |
|
402 | + } else { |
|
403 | + print '<tr>'; |
|
404 | + } |
|
401 | 405 | } |
402 | 406 | if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive" || strtolower($current_page) == "currently" || strtolower($current_page) == "accident-latest" || strtolower($current_page) == "incident-latest" || strtolower($current_page) == "accident-detailed" || strtolower($current_page) == "incident-detailed") { |
403 | 407 | if ($spotter_item['image_thumbnail'] != "") |
@@ -405,8 +409,9 @@ discard block |
||
405 | 409 | print '<td class="aircraft_thumbnail">'."\n"; |
406 | 410 | |
407 | 411 | if ($spotter_item['image_source'] == 'planespotters') { |
408 | - if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website']; |
|
409 | - else { |
|
412 | + if ($spotter_item['image_source_website'] != '') { |
|
413 | + $image_src = $spotter_item['image_source_website']; |
|
414 | + } else { |
|
410 | 415 | $planespotter_url_array = explode("_", $spotter_item['image']); |
411 | 416 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
412 | 417 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
@@ -419,7 +424,9 @@ discard block |
||
419 | 424 | } else { |
420 | 425 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
421 | 426 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
422 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
427 | + } else { |
|
428 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
429 | + } |
|
423 | 430 | if (isset($spotter_item['airline_name'])) { |
424 | 431 | print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
425 | 432 | } else { |
@@ -441,8 +448,9 @@ discard block |
||
441 | 448 | print '<td class="aircraft_thumbnail">'."\n"; |
442 | 449 | //print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>'; |
443 | 450 | if ($spotter_item['image_source'] == 'planespotters') { |
444 | - if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website']; |
|
445 | - else { |
|
451 | + if ($spotter_item['image_source_website'] != '') { |
|
452 | + $image_src = $spotter_item['image_source_website']; |
|
453 | + } else { |
|
446 | 454 | $planespotter_url_array = explode("_", $spotter_array[0]['image']); |
447 | 455 | $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]); |
448 | 456 | $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id; |
@@ -459,7 +467,9 @@ discard block |
||
459 | 467 | } else { |
460 | 468 | if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') { |
461 | 469 | $image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
462 | - } else $image_thumbnail = $spotter_item['image_thumbnail']; |
|
470 | + } else { |
|
471 | + $image_thumbnail = $spotter_item['image_thumbnail']; |
|
472 | + } |
|
463 | 473 | if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) { |
464 | 474 | print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">© '.$spotter_item['image_copyright'].'</div>'; |
465 | 475 | } elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) { |
@@ -546,15 +556,21 @@ discard block |
||
546 | 556 | if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) { |
547 | 557 | if ($spotter_item['departure_airport_time'] > 2460) { |
548 | 558 | $departure_airport_time = date('H:m',$spotter_item['departure_airport_time']); |
549 | - } else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
559 | + } else { |
|
560 | + $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2); |
|
561 | + } |
|
550 | 562 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
551 | 563 | $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
552 | - } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
564 | + } else { |
|
565 | + $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
566 | + } |
|
553 | 567 | print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n"; |
554 | 568 | } elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') { |
555 | 569 | if ($spotter_item['real_departure_airport_time'] > 2460) { |
556 | 570 | $real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']); |
557 | - } else $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
571 | + } else { |
|
572 | + $real_departure_airport_time = $spotter_item['real_departure_airport_time']; |
|
573 | + } |
|
558 | 574 | print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n"; |
559 | 575 | } elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') { |
560 | 576 | if ($spotter_item['departure_airport_time'] > 2460) { |
@@ -576,7 +592,9 @@ discard block |
||
576 | 592 | $longitude = $spotter_item['longitude']; |
577 | 593 | } |
578 | 594 | $distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude); |
579 | - } else $distance = ''; |
|
595 | + } else { |
|
596 | + $distance = ''; |
|
597 | + } |
|
580 | 598 | if ($distance != '') { |
581 | 599 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
582 | 600 | echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
@@ -601,7 +619,9 @@ discard block |
||
601 | 619 | } else { |
602 | 620 | if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) { |
603 | 621 | print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n"; |
604 | - if (!isset($Spotter)) $Spotter = new Spotter(); |
|
622 | + if (!isset($Spotter)) { |
|
623 | + $Spotter = new Spotter(); |
|
624 | + } |
|
605 | 625 | $arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']); |
606 | 626 | print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n"; |
607 | 627 | print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n"; |
@@ -617,20 +637,28 @@ discard block |
||
617 | 637 | if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) { |
618 | 638 | if ($spotter_item['arrival_airport_time'] > 2460) { |
619 | 639 | $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
620 | - } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
640 | + } else { |
|
641 | + $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
642 | + } |
|
621 | 643 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
622 | 644 | $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
623 | - } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
645 | + } else { |
|
646 | + $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
647 | + } |
|
624 | 648 | print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n"; |
625 | 649 | } elseif (isset($spotter_item['real_arrival_airport_time'])) { |
626 | 650 | if ($spotter_item['real_arrival_airport_time'] > 2460) { |
627 | 651 | $real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']); |
628 | - } else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
652 | + } else { |
|
653 | + $real_arrival_airport_time = $spotter_item['real_arrival_airport_time']; |
|
654 | + } |
|
629 | 655 | print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n"; |
630 | 656 | } elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') { |
631 | 657 | if ($spotter_item['arrival_airport_time'] > 2460) { |
632 | 658 | $arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']); |
633 | - } else $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
659 | + } else { |
|
660 | + $arrival_airport_time = $spotter_item['arrival_airport_time']; |
|
661 | + } |
|
634 | 662 | print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n"; |
635 | 663 | } |
636 | 664 | if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
@@ -643,7 +671,9 @@ discard block |
||
643 | 671 | $longitude = $spotter_item['longitude']; |
644 | 672 | } |
645 | 673 | $distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude); |
646 | - } else $distance = ''; |
|
674 | + } else { |
|
675 | + $distance = ''; |
|
676 | + } |
|
647 | 677 | if ($distance != '') { |
648 | 678 | if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) { |
649 | 679 | echo '<br/><i>'.round($distance*0.539957).' nm</i>'; |
@@ -14,7 +14,9 @@ discard block |
||
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | 16 | |
17 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
17 | +if (!isset($globalDebug)) { |
|
18 | + $globalDebug = FALSE; |
|
19 | +} |
|
18 | 20 | |
19 | 21 | // Check if schema is at latest version |
20 | 22 | $Connection = new Connection(); |
@@ -54,13 +56,22 @@ discard block |
||
54 | 56 | $globalSources = array(); |
55 | 57 | $globalSources[] = array('host' => $options['source']); |
56 | 58 | } |
57 | -if (isset($options['server'])) $globalServer = TRUE; |
|
58 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
59 | -else $id_source = 1; |
|
59 | +if (isset($options['server'])) { |
|
60 | + $globalServer = TRUE; |
|
61 | +} |
|
62 | +if (isset($options['idsource'])) { |
|
63 | + $id_source = $options['idsource']; |
|
64 | +} else { |
|
65 | + $id_source = 1; |
|
66 | +} |
|
60 | 67 | if (isset($globalServer) && $globalServer) { |
61 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
68 | + if ($globalDebug) { |
|
69 | + echo "Using Server Mode\n"; |
|
70 | + } |
|
62 | 71 | $SI=new SpotterServer(); |
63 | -} else $SI=new SpotterImport($Connection->db); |
|
72 | +} else { |
|
73 | + $SI=new SpotterImport($Connection->db); |
|
74 | +} |
|
64 | 75 | //$APRS=new APRS($Connection->db); |
65 | 76 | $SBS=new SBS(); |
66 | 77 | $ACARS=new ACARS($Connection->db); |
@@ -78,7 +89,9 @@ discard block |
||
78 | 89 | } |
79 | 90 | |
80 | 91 | // let's try and connect |
81 | -if ($globalDebug) echo "Connecting...\n"; |
|
92 | +if ($globalDebug) { |
|
93 | + echo "Connecting...\n"; |
|
94 | +} |
|
82 | 95 | $use_aprs = false; |
83 | 96 | $aprs_full = false; |
84 | 97 | $reset = 0; |
@@ -87,7 +100,9 @@ discard block |
||
87 | 100 | $ip = gethostbyname($host); |
88 | 101 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
89 | 102 | $r = @socket_connect($s, $ip, $port); |
90 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
103 | + if (!socket_set_nonblock($s)) { |
|
104 | + echo "Unable to set nonblock on socket\n"; |
|
105 | + } |
|
91 | 106 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
92 | 107 | return $s; |
93 | 108 | } |
@@ -115,7 +130,9 @@ discard block |
||
115 | 130 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
116 | 131 | global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset; |
117 | 132 | $reset++; |
118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
133 | + if ($globalDebug) { |
|
134 | + echo 'Connect to all...'."\n"; |
|
135 | + } |
|
119 | 136 | foreach ($hosts as $id => $value) { |
120 | 137 | $host = $value['host']; |
121 | 138 | $globalSources[$id]['last_exec'] = 0; |
@@ -125,27 +142,37 @@ discard block |
||
125 | 142 | //$formats[$id] = 'deltadbtxt'; |
126 | 143 | $globalSources[$id]['format'] = 'deltadbtxt'; |
127 | 144 | //$last_exec['deltadbtxt'] = 0; |
128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
145 | + if ($globalDebug) { |
|
146 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
147 | + } |
|
129 | 148 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
130 | 149 | //$formats[$id] = 'vatsimtxt'; |
131 | 150 | $globalSources[$id]['format'] = 'vatsimtxt'; |
132 | 151 | //$last_exec['vatsimtxt'] = 0; |
133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
152 | + if ($globalDebug) { |
|
153 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
154 | + } |
|
134 | 155 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
135 | 156 | //$formats[$id] = 'aircraftlistjson'; |
136 | 157 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
137 | 158 | //$last_exec['aircraftlistjson'] = 0; |
138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
159 | + if ($globalDebug) { |
|
160 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
161 | + } |
|
139 | 162 | } else if (preg_match('/opensky/i',$host)) { |
140 | 163 | //$formats[$id] = 'aircraftlistjson'; |
141 | 164 | $globalSources[$id]['format'] = 'opensky'; |
142 | 165 | //$last_exec['aircraftlistjson'] = 0; |
143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
166 | + if ($globalDebug) { |
|
167 | + echo "Connect to opensky source (".$host.")...\n"; |
|
168 | + } |
|
144 | 169 | } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
145 | 170 | //$formats[$id] = 'radarvirtueljson'; |
146 | 171 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
147 | 172 | //$last_exec['radarvirtueljson'] = 0; |
148 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
173 | + if ($globalDebug) { |
|
174 | + echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
175 | + } |
|
149 | 176 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
150 | 177 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
151 | 178 | exit(0); |
@@ -154,7 +181,9 @@ discard block |
||
154 | 181 | //$formats[$id] = 'planeupdatefaa'; |
155 | 182 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
156 | 183 | //$last_exec['planeupdatefaa'] = 0; |
157 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
184 | + if ($globalDebug) { |
|
185 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
186 | + } |
|
158 | 187 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
159 | 188 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
160 | 189 | exit(0); |
@@ -163,26 +192,36 @@ discard block |
||
163 | 192 | //$formats[$id] = 'phpvmacars'; |
164 | 193 | $globalSources[$id]['format'] = 'phpvmacars'; |
165 | 194 | //$last_exec['phpvmacars'] = 0; |
166 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
195 | + if ($globalDebug) { |
|
196 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
197 | + } |
|
167 | 198 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
168 | 199 | //$formats[$id] = 'phpvmacars'; |
169 | 200 | $globalSources[$id]['format'] = 'vam'; |
170 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
201 | + if ($globalDebug) { |
|
202 | + echo "Connect to Vam source (".$host.")...\n"; |
|
203 | + } |
|
171 | 204 | } else if (preg_match('/whazzup/i',$host)) { |
172 | 205 | //$formats[$id] = 'whazzup'; |
173 | 206 | $globalSources[$id]['format'] = 'whazzup'; |
174 | 207 | //$last_exec['whazzup'] = 0; |
175 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
208 | + if ($globalDebug) { |
|
209 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
210 | + } |
|
176 | 211 | } else if (preg_match('/recentpireps/i',$host)) { |
177 | 212 | //$formats[$id] = 'pirepsjson'; |
178 | 213 | $globalSources[$id]['format'] = 'pirepsjson'; |
179 | 214 | //$last_exec['pirepsjson'] = 0; |
180 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
215 | + if ($globalDebug) { |
|
216 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
217 | + } |
|
181 | 218 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
182 | 219 | //$formats[$id] = 'fr24json'; |
183 | 220 | $globalSources[$id]['format'] = 'fr24json'; |
184 | 221 | //$last_exec['fr24json'] = 0; |
185 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
222 | + if ($globalDebug) { |
|
223 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
224 | + } |
|
186 | 225 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
187 | 226 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
188 | 227 | exit(0); |
@@ -191,10 +230,14 @@ discard block |
||
191 | 230 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
192 | 231 | //$formats[$id] = 'tsv'; |
193 | 232 | $globalSources[$id]['format'] = 'tsv'; |
194 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
233 | + if ($globalDebug) { |
|
234 | + echo "Connect to tsv source (".$host.")...\n"; |
|
235 | + } |
|
195 | 236 | } |
196 | 237 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
197 | - if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
238 | + if ($globalDebug) { |
|
239 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
240 | + } |
|
198 | 241 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
199 | 242 | $hostport = explode(':',$host); |
200 | 243 | if (isset($hostport[1])) { |
@@ -231,17 +274,25 @@ discard block |
||
231 | 274 | //$formats[$id] = 'beast'; |
232 | 275 | $globalSources[$id]['format'] = 'beast'; |
233 | 276 | //} else $formats[$id] = 'sbs'; |
234 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
277 | + } else { |
|
278 | + $globalSources[$id]['format'] = 'sbs'; |
|
279 | + } |
|
235 | 280 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
236 | 281 | } |
237 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
282 | + if ($globalDebug) { |
|
283 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
284 | + } |
|
238 | 285 | } else { |
239 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
286 | + if ($globalDebug) { |
|
287 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
288 | + } |
|
240 | 289 | } |
241 | 290 | } |
242 | 291 | } |
243 | 292 | } |
244 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
293 | +if (!isset($globalMinFetch)) { |
|
294 | + $globalMinFetch = 15; |
|
295 | +} |
|
245 | 296 | |
246 | 297 | // Initialize all |
247 | 298 | $status = array(); |
@@ -249,13 +300,19 @@ discard block |
||
249 | 300 | $formats = array(); |
250 | 301 | $last_exec = array(); |
251 | 302 | $time = time(); |
252 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
253 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
254 | -else $timeout = 20; |
|
303 | +if (isset($globalSourcesTimeout)) { |
|
304 | + $timeout = $globalSourcesTimeOut; |
|
305 | +} else if (isset($globalSBS1TimeOut)) { |
|
306 | + $timeout = $globalSBS1TimeOut; |
|
307 | +} else { |
|
308 | + $timeout = 20; |
|
309 | +} |
|
255 | 310 | $errno = ''; |
256 | 311 | $errstr=''; |
257 | 312 | |
258 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
313 | +if (!isset($globalDaemon)) { |
|
314 | + $globalDaemon = TRUE; |
|
315 | +} |
|
259 | 316 | /* Initiate connections to all the hosts simultaneously */ |
260 | 317 | //connect_all($hosts); |
261 | 318 | //connect_all($globalSources); |
@@ -275,7 +332,9 @@ discard block |
||
275 | 332 | if (isset($source['format']) && $source['format'] == 'aprs') { |
276 | 333 | $aprs_connect = 0; |
277 | 334 | $use_aprs = true; |
278 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
335 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
336 | + $aprs_full = true; |
|
337 | + } |
|
279 | 338 | break; |
280 | 339 | } |
281 | 340 | } |
@@ -286,24 +345,44 @@ discard block |
||
286 | 345 | $aprs_connect = 0; |
287 | 346 | $aprs_keep = 120; |
288 | 347 | $aprs_last_tx = time(); |
289 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
290 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
348 | + if (isset($globalAPRSversion)) { |
|
349 | + $aprs_version = $globalAPRSversion; |
|
350 | + } else { |
|
351 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
352 | + } |
|
291 | 353 | //else $aprs_version = 'Perl Example App'; |
292 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
293 | - else $aprs_ssid = 'FAM-'.str_replace(' ','_',$globalName); |
|
354 | + if (isset($globalAPRSssid)) { |
|
355 | + $aprs_ssid = $globalAPRSssid; |
|
356 | + } else { |
|
357 | + $aprs_ssid = 'FAM-'.str_replace(' ','_',$globalName); |
|
358 | + } |
|
294 | 359 | //else $aprs_ssid = 'PerlEx'; |
295 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
296 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
297 | - if ($aprs_full) $aprs_filter = ''; |
|
298 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
299 | - else $aprs_login = "user {$aprs_ssid} vers {$aprs_version}\n"; |
|
300 | -} |
|
360 | + if (isset($globalAPRSfilter)) { |
|
361 | + $aprs_filter = $globalAPRSfilter; |
|
362 | + } else { |
|
363 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
364 | + } |
|
365 | + if ($aprs_full) { |
|
366 | + $aprs_filter = ''; |
|
367 | + } |
|
368 | + if ($aprs_filter != '') { |
|
369 | + $aprs_login = "user {$aprs_ssid} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
370 | + } else { |
|
371 | + $aprs_login = "user {$aprs_ssid} vers {$aprs_version}\n"; |
|
372 | + } |
|
373 | + } |
|
301 | 374 | |
302 | 375 | // connected - lets do some work |
303 | -if ($globalDebug) echo "Connected!\n"; |
|
376 | +if ($globalDebug) { |
|
377 | + echo "Connected!\n"; |
|
378 | +} |
|
304 | 379 | sleep(1); |
305 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
306 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
380 | +if ($globalDebug) { |
|
381 | + echo "SCAN MODE \n\n"; |
|
382 | +} |
|
383 | +if (!isset($globalCronEnd)) { |
|
384 | + $globalCronEnd = 60; |
|
385 | +} |
|
307 | 386 | $endtime = time()+$globalCronEnd; |
308 | 387 | $i = 1; |
309 | 388 | $tt = array(); |
@@ -317,20 +396,28 @@ discard block |
||
317 | 396 | |
318 | 397 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
319 | 398 | while ($i > 0) { |
320 | - if (!$globalDaemon) $i = $endtime-time(); |
|
399 | + if (!$globalDaemon) { |
|
400 | + $i = $endtime-time(); |
|
401 | + } |
|
321 | 402 | // Delete old ATC |
322 | 403 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
323 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
404 | + if ($globalDebug) { |
|
405 | + echo 'Delete old ATC...'."\n"; |
|
406 | + } |
|
324 | 407 | $ATC->deleteOldATC(); |
325 | 408 | } |
326 | 409 | |
327 | 410 | if (count($last_exec) > 0) { |
328 | 411 | $max = $globalMinFetch; |
329 | 412 | foreach ($last_exec as $last) { |
330 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
413 | + if ((time() - $last['last']) < $max) { |
|
414 | + $max = time() - $last['last']; |
|
415 | + } |
|
331 | 416 | } |
332 | 417 | if ($max != $globalMinFetch) { |
333 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
418 | + if ($globalDebug) { |
|
419 | + echo 'Sleeping...'."\n"; |
|
420 | + } |
|
334 | 421 | sleep($globalMinFetch-$max+2); |
335 | 422 | } |
336 | 423 | } |
@@ -339,11 +426,15 @@ discard block |
||
339 | 426 | //foreach ($formats as $id => $value) { |
340 | 427 | foreach ($globalSources as $id => $value) { |
341 | 428 | date_default_timezone_set('UTC'); |
342 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
429 | + if (!isset($last_exec[$id]['last'])) { |
|
430 | + $last_exec[$id]['last'] = 0; |
|
431 | + } |
|
343 | 432 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
344 | 433 | //$buffer = $Common->getData($hosts[$id]); |
345 | 434 | $buffer = $Common->getData($value['host']); |
346 | - if ($buffer != '') $reset = 0; |
|
435 | + if ($buffer != '') { |
|
436 | + $reset = 0; |
|
437 | + } |
|
347 | 438 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
348 | 439 | $buffer = explode('\n',$buffer); |
349 | 440 | foreach ($buffer as $line) { |
@@ -352,19 +443,38 @@ discard block |
||
352 | 443 | $data = array(); |
353 | 444 | $data['hex'] = $line[1]; // hex |
354 | 445 | $data['ident'] = $line[2]; // ident |
355 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
356 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
357 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
358 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
359 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
446 | + if (isset($line[3])) { |
|
447 | + $data['altitude'] = $line[3]; |
|
448 | + } |
|
449 | + // altitude |
|
450 | + if (isset($line[4])) { |
|
451 | + $data['speed'] = $line[4]; |
|
452 | + } |
|
453 | + // speed |
|
454 | + if (isset($line[5])) { |
|
455 | + $data['heading'] = $line[5]; |
|
456 | + } |
|
457 | + // heading |
|
458 | + if (isset($line[6])) { |
|
459 | + $data['latitude'] = $line[6]; |
|
460 | + } |
|
461 | + // lat |
|
462 | + if (isset($line[7])) { |
|
463 | + $data['longitude'] = $line[7]; |
|
464 | + } |
|
465 | + // long |
|
360 | 466 | $data['verticalrate'] = ''; // vertical rate |
361 | 467 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
362 | 468 | $data['emergency'] = ''; // emergency |
363 | 469 | $data['datetime'] = date('Y-m-d H:i:s'); |
364 | 470 | $data['format_source'] = 'deltadbtxt'; |
365 | 471 | $data['id_source'] = $id_source; |
366 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
367 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
472 | + if (isset($value['name']) && $value['name'] != '') { |
|
473 | + $data['source_name'] = $value['name']; |
|
474 | + } |
|
475 | + if (isset($value['sourcestats'])) { |
|
476 | + $data['sourcestats'] = $value['sourcestats']; |
|
477 | + } |
|
368 | 478 | $SI->add($data); |
369 | 479 | unset($data); |
370 | 480 | } |
@@ -382,16 +492,28 @@ discard block |
||
382 | 492 | $line = explode(':', $line); |
383 | 493 | if (count($line) > 30 && $line[0] != 'callsign') { |
384 | 494 | $data = array(); |
385 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
386 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
495 | + if (isset($line[37]) && $line[37] != '') { |
|
496 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
497 | + } else { |
|
498 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
499 | + } |
|
387 | 500 | $data['pilot_id'] = $line[1]; |
388 | 501 | $data['pilot_name'] = $line[2]; |
389 | 502 | $data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT); |
390 | 503 | $data['ident'] = $line[0]; // ident |
391 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
504 | + if ($line[7] != '' && $line[7] != 0) { |
|
505 | + $data['altitude'] = $line[7]; |
|
506 | + } |
|
507 | + // altitude |
|
392 | 508 | $data['speed'] = $line[8]; // speed |
393 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
394 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
509 | + if (isset($line[45])) { |
|
510 | + $data['heading'] = $line[45]; |
|
511 | + } |
|
512 | + // heading |
|
513 | + elseif (isset($line[38])) { |
|
514 | + $data['heading'] = $line[38]; |
|
515 | + } |
|
516 | + // heading |
|
395 | 517 | $data['latitude'] = $line[5]; // lat |
396 | 518 | $data['longitude'] = $line[6]; // long |
397 | 519 | $data['verticalrate'] = ''; // vertical rate |
@@ -407,7 +529,9 @@ discard block |
||
407 | 529 | $data['frequency'] = $line[4]; |
408 | 530 | $data['type'] = $line[18]; |
409 | 531 | $data['range'] = $line[19]; |
410 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
532 | + if (isset($line[35])) { |
|
533 | + $data['info'] = $line[35]; |
|
534 | + } |
|
411 | 535 | $data['id_source'] = $id_source; |
412 | 536 | //$data['arrival_airport_time'] = ; |
413 | 537 | if ($line[9] != '') { |
@@ -421,23 +545,38 @@ discard block |
||
421 | 545 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
422 | 546 | */ |
423 | 547 | $data['format_source'] = $value['format']; |
424 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
425 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
426 | - elseif ($line[3] == 'ATC') { |
|
548 | + if (isset($value['name']) && $value['name'] != '') { |
|
549 | + $data['source_name'] = $value['name']; |
|
550 | + } |
|
551 | + if ($line[3] == 'PILOT') { |
|
552 | + $SI->add($data); |
|
553 | + } elseif ($line[3] == 'ATC') { |
|
427 | 554 | //print_r($data); |
428 | 555 | $data['info'] = str_replace('^§','<br />',$data['info']); |
429 | 556 | $data['info'] = str_replace('&sect;','',$data['info']); |
430 | 557 | $typec = substr($data['ident'],-3); |
431 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
432 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
433 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
434 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
435 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
436 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
437 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
438 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
439 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
440 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
558 | + if ($typec == 'APP') { |
|
559 | + $data['type'] = 'Approach'; |
|
560 | + } elseif ($typec == 'TWR') { |
|
561 | + $data['type'] = 'Tower'; |
|
562 | + } elseif ($typec == 'OBS') { |
|
563 | + $data['type'] = 'Observer'; |
|
564 | + } elseif ($typec == 'GND') { |
|
565 | + $data['type'] = 'Ground'; |
|
566 | + } elseif ($typec == 'DEL') { |
|
567 | + $data['type'] = 'Delivery'; |
|
568 | + } elseif ($typec == 'DEP') { |
|
569 | + $data['type'] = 'Departure'; |
|
570 | + } elseif ($typec == 'FSS') { |
|
571 | + $data['type'] = 'Flight Service Station'; |
|
572 | + } elseif ($typec == 'CTR') { |
|
573 | + $data['type'] = 'Control Radar or Centre'; |
|
574 | + } elseif ($data['type'] == '') { |
|
575 | + $data['type'] = 'Observer'; |
|
576 | + } |
|
577 | + if (!isset($data['source_name'])) { |
|
578 | + $data['source_name'] = ''; |
|
579 | + } |
|
441 | 580 | 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']); |
442 | 581 | } |
443 | 582 | unset($data); |
@@ -457,26 +596,55 @@ discard block |
||
457 | 596 | foreach ($all_data['acList'] as $line) { |
458 | 597 | $data = array(); |
459 | 598 | $data['hex'] = $line['Icao']; // hex |
460 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
461 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
462 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
463 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
464 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
465 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
599 | + if (isset($line['Call'])) { |
|
600 | + $data['ident'] = $line['Call']; |
|
601 | + } |
|
602 | + // ident |
|
603 | + if (isset($line['Alt'])) { |
|
604 | + $data['altitude'] = $line['Alt']; |
|
605 | + } |
|
606 | + // altitude |
|
607 | + if (isset($line['Spd'])) { |
|
608 | + $data['speed'] = $line['Spd']; |
|
609 | + } |
|
610 | + // speed |
|
611 | + if (isset($line['Trak'])) { |
|
612 | + $data['heading'] = $line['Trak']; |
|
613 | + } |
|
614 | + // heading |
|
615 | + if (isset($line['Lat'])) { |
|
616 | + $data['latitude'] = $line['Lat']; |
|
617 | + } |
|
618 | + // lat |
|
619 | + if (isset($line['Long'])) { |
|
620 | + $data['longitude'] = $line['Long']; |
|
621 | + } |
|
622 | + // long |
|
466 | 623 | //$data['verticalrate'] = $line['']; // verticale rate |
467 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
624 | + if (isset($line['Sqk'])) { |
|
625 | + $data['squawk'] = $line['Sqk']; |
|
626 | + } |
|
627 | + // squawk |
|
468 | 628 | $data['emergency'] = ''; // emergency |
469 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
629 | + if (isset($line['Reg'])) { |
|
630 | + $data['registration'] = $line['Reg']; |
|
631 | + } |
|
470 | 632 | /* |
471 | 633 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
472 | 634 | else $data['datetime'] = date('Y-m-d H:i:s'); |
473 | 635 | */ |
474 | 636 | $data['datetime'] = date('Y-m-d H:i:s'); |
475 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
637 | + if (isset($line['Type'])) { |
|
638 | + $data['aircraft_icao'] = $line['Type']; |
|
639 | + } |
|
476 | 640 | $data['format_source'] = 'aircraftlistjson'; |
477 | 641 | $data['id_source'] = $id_source; |
478 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
479 | - if (isset($data['datetime'])) $SI->add($data); |
|
642 | + if (isset($value['name']) && $value['name'] != '') { |
|
643 | + $data['source_name'] = $value['name']; |
|
644 | + } |
|
645 | + if (isset($data['datetime'])) { |
|
646 | + $SI->add($data); |
|
647 | + } |
|
480 | 648 | unset($data); |
481 | 649 | } |
482 | 650 | } else { |
@@ -496,7 +664,9 @@ discard block |
||
496 | 664 | $data['datetime'] = date('Y-m-d H:i:s'); |
497 | 665 | $data['format_source'] = 'aircraftlistjson'; |
498 | 666 | $data['id_source'] = $id_source; |
499 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
667 | + if (isset($value['name']) && $value['name'] != '') { |
|
668 | + $data['source_name'] = $value['name']; |
|
669 | + } |
|
500 | 670 | $SI->add($data); |
501 | 671 | unset($data); |
502 | 672 | } |
@@ -532,7 +702,9 @@ discard block |
||
532 | 702 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
533 | 703 | $data['format_source'] = 'planeupdatefaa'; |
534 | 704 | $data['id_source'] = $id_source; |
535 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
705 | + if (isset($value['name']) && $value['name'] != '') { |
|
706 | + $data['source_name'] = $value['name']; |
|
707 | + } |
|
536 | 708 | $SI->add($data); |
537 | 709 | unset($data); |
538 | 710 | } |
@@ -572,7 +744,9 @@ discard block |
||
572 | 744 | //$buffer = $Common->getData($hosts[$id]); |
573 | 745 | $buffer = $Common->getData($value['host']); |
574 | 746 | $all_data = json_decode($buffer,true); |
575 | - if (!empty($all_data)) $reset = 0; |
|
747 | + if (!empty($all_data)) { |
|
748 | + $reset = 0; |
|
749 | + } |
|
576 | 750 | foreach ($all_data as $key => $line) { |
577 | 751 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
578 | 752 | $data = array(); |
@@ -593,7 +767,9 @@ discard block |
||
593 | 767 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
594 | 768 | $data['format_source'] = 'fr24json'; |
595 | 769 | $data['id_source'] = $id_source; |
596 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
770 | + if (isset($value['name']) && $value['name'] != '') { |
|
771 | + $data['source_name'] = $value['name']; |
|
772 | + } |
|
597 | 773 | $SI->add($data); |
598 | 774 | unset($data); |
599 | 775 | } |
@@ -617,23 +793,39 @@ discard block |
||
617 | 793 | if (isset($line['inf'])) { |
618 | 794 | $data = array(); |
619 | 795 | $data['hex'] = $line['inf']['ia']; |
620 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
796 | + if (isset($line['inf']['cs'])) { |
|
797 | + $data['ident'] = $line['inf']['cs']; |
|
798 | + } |
|
799 | + //$line[13] |
|
621 | 800 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
622 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
623 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
801 | + if (isset($line['inf']['gs'])) { |
|
802 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
803 | + } |
|
804 | + // speed |
|
805 | + if (isset($line['inf']['tr'])) { |
|
806 | + $data['heading'] = $line['inf']['tr']; |
|
807 | + } |
|
808 | + // heading |
|
624 | 809 | $data['latitude'] = $line['pt'][0]; // lat |
625 | 810 | $data['longitude'] = $line['pt'][1]; // long |
626 | 811 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
627 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
812 | + if (isset($line['inf']['sq'])) { |
|
813 | + $data['squawk'] = $line['inf']['sq']; |
|
814 | + } |
|
815 | + // squawk |
|
628 | 816 | //$data['aircraft_icao'] = $line[8]; |
629 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
817 | + if (isset($line['inf']['rc'])) { |
|
818 | + $data['registration'] = $line['inf']['rc']; |
|
819 | + } |
|
630 | 820 | //$data['departure_airport_iata'] = $line[11]; |
631 | 821 | //$data['arrival_airport_iata'] = $line[12]; |
632 | 822 | //$data['emergency'] = ''; // emergency |
633 | 823 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
634 | 824 | $data['format_source'] = 'radarvirtueljson'; |
635 | 825 | $data['id_source'] = $id_source; |
636 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
826 | + if (isset($value['name']) && $value['name'] != '') { |
|
827 | + $data['source_name'] = $value['name']; |
|
828 | + } |
|
637 | 829 | $SI->add($data); |
638 | 830 | unset($data); |
639 | 831 | } |
@@ -654,29 +846,62 @@ discard block |
||
654 | 846 | $data['id'] = $line['id']; |
655 | 847 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
656 | 848 | $data['ident'] = $line['callsign']; // ident |
657 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
658 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
659 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
660 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
661 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
662 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
849 | + if (isset($line['pilotid'])) { |
|
850 | + $data['pilot_id'] = $line['pilotid']; |
|
851 | + } |
|
852 | + // pilot id |
|
853 | + if (isset($line['name'])) { |
|
854 | + $data['pilot_name'] = $line['name']; |
|
855 | + } |
|
856 | + // pilot name |
|
857 | + if (isset($line['alt'])) { |
|
858 | + $data['altitude'] = $line['alt']; |
|
859 | + } |
|
860 | + // altitude |
|
861 | + if (isset($line['gs'])) { |
|
862 | + $data['speed'] = $line['gs']; |
|
863 | + } |
|
864 | + // speed |
|
865 | + if (isset($line['heading'])) { |
|
866 | + $data['heading'] = $line['heading']; |
|
867 | + } |
|
868 | + // heading |
|
869 | + if (isset($line['route'])) { |
|
870 | + $data['waypoints'] = $line['route']; |
|
871 | + } |
|
872 | + // route |
|
663 | 873 | $data['latitude'] = $line['lat']; // lat |
664 | 874 | $data['longitude'] = $line['lon']; // long |
665 | 875 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
666 | 876 | //$data['squawk'] = $line['squawk']; // squawk |
667 | 877 | //$data['emergency'] = ''; // emergency |
668 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
669 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
670 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
878 | + if (isset($line['depicao'])) { |
|
879 | + $data['departure_airport_icao'] = $line['depicao']; |
|
880 | + } |
|
881 | + if (isset($line['deptime'])) { |
|
882 | + $data['departure_airport_time'] = $line['deptime']; |
|
883 | + } |
|
884 | + if (isset($line['arricao'])) { |
|
885 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
886 | + } |
|
671 | 887 | //$data['arrival_airport_time'] = $line['arrtime']; |
672 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
673 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
674 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
675 | - else $data['info'] = ''; |
|
888 | + if (isset($line['aircraft'])) { |
|
889 | + $data['aircraft_icao'] = $line['aircraft']; |
|
890 | + } |
|
891 | + if (isset($line['transponder'])) { |
|
892 | + $data['squawk'] = $line['transponder']; |
|
893 | + } |
|
894 | + if (isset($line['atis'])) { |
|
895 | + $data['info'] = $line['atis']; |
|
896 | + } else { |
|
897 | + $data['info'] = ''; |
|
898 | + } |
|
676 | 899 | $data['format_source'] = 'pireps'; |
677 | 900 | $data['id_source'] = $id_source; |
678 | 901 | $data['datetime'] = date('Y-m-d H:i:s'); |
679 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
902 | + if (isset($value['name']) && $value['name'] != '') { |
|
903 | + $data['source_name'] = $value['name']; |
|
904 | + } |
|
680 | 905 | if ($line['icon'] == 'plane') { |
681 | 906 | $SI->add($data); |
682 | 907 | // print_r($data); |
@@ -685,15 +910,25 @@ discard block |
||
685 | 910 | $data['info'] = str_replace('&sect;','',$data['info']); |
686 | 911 | $typec = substr($data['ident'],-3); |
687 | 912 | $data['type'] = ''; |
688 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
689 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
690 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
691 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
692 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
693 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
694 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
695 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
696 | - else $data['type'] = 'Observer'; |
|
913 | + if ($typec == 'APP') { |
|
914 | + $data['type'] = 'Approach'; |
|
915 | + } elseif ($typec == 'TWR') { |
|
916 | + $data['type'] = 'Tower'; |
|
917 | + } elseif ($typec == 'OBS') { |
|
918 | + $data['type'] = 'Observer'; |
|
919 | + } elseif ($typec == 'GND') { |
|
920 | + $data['type'] = 'Ground'; |
|
921 | + } elseif ($typec == 'DEL') { |
|
922 | + $data['type'] = 'Delivery'; |
|
923 | + } elseif ($typec == 'DEP') { |
|
924 | + $data['type'] = 'Departure'; |
|
925 | + } elseif ($typec == 'FSS') { |
|
926 | + $data['type'] = 'Flight Service Station'; |
|
927 | + } elseif ($typec == 'CTR') { |
|
928 | + $data['type'] = 'Control Radar or Centre'; |
|
929 | + } else { |
|
930 | + $data['type'] = 'Observer'; |
|
931 | + } |
|
697 | 932 | 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']); |
698 | 933 | } |
699 | 934 | unset($data); |
@@ -704,7 +939,9 @@ discard block |
||
704 | 939 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
705 | 940 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
706 | 941 | //$buffer = $Common->getData($hosts[$id]); |
707 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
942 | + if ($globalDebug) { |
|
943 | + echo 'Get Data...'."\n"; |
|
944 | + } |
|
708 | 945 | $buffer = $Common->getData($value['host']); |
709 | 946 | $all_data = json_decode($buffer,true); |
710 | 947 | if ($buffer != '' && is_array($all_data)) { |
@@ -712,10 +949,16 @@ discard block |
||
712 | 949 | foreach ($all_data as $line) { |
713 | 950 | $data = array(); |
714 | 951 | //$data['id'] = $line['id']; // id not usable |
715 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
952 | + if (isset($line['pilotid'])) { |
|
953 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
954 | + } |
|
716 | 955 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
717 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
718 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
956 | + if (isset($line['pilotname'])) { |
|
957 | + $data['pilot_name'] = $line['pilotname']; |
|
958 | + } |
|
959 | + if (isset($line['pilotid'])) { |
|
960 | + $data['pilot_id'] = $line['pilotid']; |
|
961 | + } |
|
719 | 962 | $data['ident'] = $line['flightnum']; // ident |
720 | 963 | $data['altitude'] = $line['alt']; // altitude |
721 | 964 | $data['speed'] = $line['gs']; // speed |
@@ -733,27 +976,41 @@ discard block |
||
733 | 976 | $data['arrival_airport_icao'] = $line['arricao']; |
734 | 977 | $data['arrival_airport_time'] = $line['arrtime']; |
735 | 978 | $data['registration'] = $line['aircraft']; |
736 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
979 | + if (isset($line['route'])) { |
|
980 | + $data['waypoints'] = $line['route']; |
|
981 | + } |
|
982 | + // route |
|
737 | 983 | if (isset($line['aircraftname'])) { |
738 | 984 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
739 | 985 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
740 | 986 | $aircraft_data = explode('-',$line['aircraftname']); |
741 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
742 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
743 | - else { |
|
987 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) { |
|
988 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
989 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) { |
|
990 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
991 | + } else { |
|
744 | 992 | $aircraft_data = explode(' ',$line['aircraftname']); |
745 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
746 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
993 | + if (isset($aircraft_data[1])) { |
|
994 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
995 | + } else { |
|
996 | + $data['aircraft_icao'] = $line['aircraftname']; |
|
997 | + } |
|
747 | 998 | } |
748 | 999 | } |
749 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1000 | + if (isset($line['route'])) { |
|
1001 | + $data['waypoints'] = $line['route']; |
|
1002 | + } |
|
750 | 1003 | $data['id_source'] = $id_source; |
751 | 1004 | $data['format_source'] = 'phpvmacars'; |
752 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1005 | + if (isset($value['name']) && $value['name'] != '') { |
|
1006 | + $data['source_name'] = $value['name']; |
|
1007 | + } |
|
753 | 1008 | $SI->add($data); |
754 | 1009 | unset($data); |
755 | 1010 | } |
756 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1011 | + if ($globalDebug) { |
|
1012 | + echo 'No more data...'."\n"; |
|
1013 | + } |
|
757 | 1014 | unset($buffer); |
758 | 1015 | unset($all_data); |
759 | 1016 | } |
@@ -761,7 +1018,9 @@ discard block |
||
761 | 1018 | $last_exec[$id]['last'] = time(); |
762 | 1019 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
763 | 1020 | //$buffer = $Common->getData($hosts[$id]); |
764 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1021 | + if ($globalDebug) { |
|
1022 | + echo 'Get Data...'."\n"; |
|
1023 | + } |
|
765 | 1024 | $buffer = $Common->getData($value['host']); |
766 | 1025 | $all_data = json_decode($buffer,true); |
767 | 1026 | if ($buffer != '' && is_array($all_data)) { |
@@ -790,15 +1049,22 @@ discard block |
||
790 | 1049 | $data['arrival_airport_icao'] = $line['arrival']; |
791 | 1050 | //$data['arrival_airport_time'] = $line['arrival_time']; |
792 | 1051 | //$data['registration'] = $line['aircraft']; |
793 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1052 | + if (isset($line['route'])) { |
|
1053 | + $data['waypoints'] = $line['route']; |
|
1054 | + } |
|
1055 | + // route |
|
794 | 1056 | $data['aircraft_icao'] = $line['plane_type']; |
795 | 1057 | $data['id_source'] = $id_source; |
796 | 1058 | $data['format_source'] = 'vam'; |
797 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1059 | + if (isset($value['name']) && $value['name'] != '') { |
|
1060 | + $data['source_name'] = $value['name']; |
|
1061 | + } |
|
798 | 1062 | $SI->add($data); |
799 | 1063 | unset($data); |
800 | 1064 | } |
801 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1065 | + if ($globalDebug) { |
|
1066 | + echo 'No more data...'."\n"; |
|
1067 | + } |
|
802 | 1068 | unset($buffer); |
803 | 1069 | unset($all_data); |
804 | 1070 | } |
@@ -806,7 +1072,9 @@ discard block |
||
806 | 1072 | $last_exec[$id]['last'] = time(); |
807 | 1073 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
808 | 1074 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') { |
809 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1075 | + if (function_exists('pcntl_fork')) { |
|
1076 | + pcntl_signal_dispatch(); |
|
1077 | + } |
|
810 | 1078 | //$last_exec[$id]['last'] = time(); |
811 | 1079 | |
812 | 1080 | //$read = array( $sockets[$id] ); |
@@ -814,7 +1082,9 @@ discard block |
||
814 | 1082 | $write = NULL; |
815 | 1083 | $e = NULL; |
816 | 1084 | $n = socket_select($read, $write, $e, $timeout); |
817 | - if ($e != NULL) var_dump($e); |
|
1085 | + if ($e != NULL) { |
|
1086 | + var_dump($e); |
|
1087 | + } |
|
818 | 1088 | if ($n > 0) { |
819 | 1089 | $reset = 0; |
820 | 1090 | foreach ($read as $nb => $r) { |
@@ -836,7 +1106,9 @@ discard block |
||
836 | 1106 | if ($buffer != '') { |
837 | 1107 | $tt[$format] = 0; |
838 | 1108 | if ($format == 'acarssbs3') { |
839 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1109 | + if ($globalDebug) { |
|
1110 | + echo 'ACARS : '.$buffer."\n"; |
|
1111 | + } |
|
840 | 1112 | $ACARS->add(trim($buffer)); |
841 | 1113 | $ACARS->deleteLiveAcarsData(); |
842 | 1114 | } elseif ($format == 'raw') { |
@@ -845,9 +1117,15 @@ discard block |
||
845 | 1117 | if (is_array($data)) { |
846 | 1118 | $data['datetime'] = date('Y-m-d H:i:s'); |
847 | 1119 | $data['format_source'] = 'raw'; |
848 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
849 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
850 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1120 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1121 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1122 | + } |
|
1123 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1124 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1125 | + } |
|
1126 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1127 | + $SI->add($data); |
|
1128 | + } |
|
851 | 1129 | } |
852 | 1130 | } elseif ($format == 'flightgearsp') { |
853 | 1131 | //echo $buffer."\n"; |
@@ -865,11 +1143,15 @@ discard block |
||
865 | 1143 | $data['speed'] = round($line[5]*1.94384); |
866 | 1144 | $data['datetime'] = date('Y-m-d H:i:s'); |
867 | 1145 | $data['format_source'] = 'flightgearsp'; |
868 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1146 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1147 | + $SI->add($data); |
|
1148 | + } |
|
869 | 1149 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
870 | 1150 | } |
871 | 1151 | } elseif ($format == 'acars') { |
872 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1152 | + if ($globalDebug) { |
|
1153 | + echo 'ACARS : '.$buffer."\n"; |
|
1154 | + } |
|
873 | 1155 | $ACARS->add(trim($buffer)); |
874 | 1156 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
875 | 1157 | $ACARS->deleteLiveAcarsData(); |
@@ -890,7 +1172,9 @@ discard block |
||
890 | 1172 | $aircraft_type = $line[10]; |
891 | 1173 | $aircraft_type = preg_split(':/:',$aircraft_type); |
892 | 1174 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
893 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1175 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1176 | + $SI->add($data); |
|
1177 | + } |
|
894 | 1178 | } |
895 | 1179 | } |
896 | 1180 | } elseif ($format == 'beast') { |
@@ -906,21 +1190,43 @@ discard block |
||
906 | 1190 | $data['hex'] = $lined['hexid']; |
907 | 1191 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
908 | 1192 | $data['datetime'] = date('Y-m-d H:i:s');; |
909 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
910 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
911 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
912 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
913 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
914 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
915 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1193 | + if (isset($lined['ident'])) { |
|
1194 | + $data['ident'] = $lined['ident']; |
|
1195 | + } |
|
1196 | + if (isset($lined['lat'])) { |
|
1197 | + $data['latitude'] = $lined['lat']; |
|
1198 | + } |
|
1199 | + if (isset($lined['lon'])) { |
|
1200 | + $data['longitude'] = $lined['lon']; |
|
1201 | + } |
|
1202 | + if (isset($lined['speed'])) { |
|
1203 | + $data['speed'] = $lined['speed']; |
|
1204 | + } |
|
1205 | + if (isset($lined['squawk'])) { |
|
1206 | + $data['squawk'] = $lined['squawk']; |
|
1207 | + } |
|
1208 | + if (isset($lined['alt'])) { |
|
1209 | + $data['altitude'] = $lined['alt']; |
|
1210 | + } |
|
1211 | + if (isset($lined['heading'])) { |
|
1212 | + $data['heading'] = $lined['heading']; |
|
1213 | + } |
|
916 | 1214 | $data['id_source'] = $id_source; |
917 | 1215 | $data['format_source'] = 'tsv'; |
918 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
919 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
920 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1216 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1217 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1218 | + } |
|
1219 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1220 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1221 | + } |
|
1222 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1223 | + $SI->add($data); |
|
1224 | + } |
|
921 | 1225 | unset($lined); |
922 | 1226 | unset($data); |
923 | - } else $error = true; |
|
1227 | + } else { |
|
1228 | + $error = true; |
|
1229 | + } |
|
924 | 1230 | } elseif ($format == 'aprs' && $use_aprs) { |
925 | 1231 | if ($aprs_connect == 0) { |
926 | 1232 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -949,29 +1255,44 @@ discard block |
||
949 | 1255 | $data['latitude'] = $line['latitude']; |
950 | 1256 | $data['longitude'] = $line['longitude']; |
951 | 1257 | //$data['verticalrate'] = $line[16]; |
952 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
953 | - else $data['speed'] = 0; |
|
1258 | + if (isset($line['speed'])) { |
|
1259 | + $data['speed'] = $line['speed']; |
|
1260 | + } else { |
|
1261 | + $data['speed'] = 0; |
|
1262 | + } |
|
954 | 1263 | $data['altitude'] = $line['altitude']; |
955 | - if (isset($line['course'])) $data['heading'] = $line['course']; |
|
1264 | + if (isset($line['course'])) { |
|
1265 | + $data['heading'] = $line['course']; |
|
1266 | + } |
|
956 | 1267 | //else $data['heading'] = 0; |
957 | 1268 | $data['aircraft_type'] = $line['stealth']; |
958 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
1269 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) { |
|
1270 | + $data['noarchive'] = true; |
|
1271 | + } |
|
959 | 1272 | $data['id_source'] = $id_source; |
960 | 1273 | $data['format_source'] = 'aprs'; |
961 | 1274 | $data['source_name'] = $line['source']; |
962 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1275 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1276 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1277 | + } |
|
963 | 1278 | $currentdate = date('Y-m-d H:i:s'); |
964 | 1279 | $aprsdate = strtotime($data['datetime']); |
965 | 1280 | // Accept data if time <= system time + 20s |
966 | - if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data); |
|
967 | - else { |
|
968 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
969 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1281 | + if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1282 | + $send = $SI->add($data); |
|
1283 | + } else { |
|
1284 | + if ($line['stealth'] != 0) { |
|
1285 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1286 | + } else { |
|
1287 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1288 | + } |
|
970 | 1289 | } |
971 | 1290 | unset($data); |
972 | 1291 | } |
973 | 1292 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
974 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
|
1293 | + elseif ($line == true && $globalDebug) { |
|
1294 | + echo '!! Failed : '.$buffer."!!\n"; |
|
1295 | + } |
|
975 | 1296 | } |
976 | 1297 | } else { |
977 | 1298 | $line = explode(',', $buffer); |
@@ -1000,25 +1321,42 @@ discard block |
||
1000 | 1321 | $data['ground'] = $line[21]; |
1001 | 1322 | $data['emergency'] = $line[19]; |
1002 | 1323 | $data['format_source'] = 'sbs'; |
1003 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1004 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1324 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1325 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1326 | + } |
|
1327 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1328 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1329 | + } |
|
1005 | 1330 | $data['id_source'] = $id_source; |
1006 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1007 | - else $error = true; |
|
1331 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1332 | + $send = $SI->add($data); |
|
1333 | + } else { |
|
1334 | + $error = true; |
|
1335 | + } |
|
1008 | 1336 | unset($data); |
1009 | - } else $error = true; |
|
1337 | + } else { |
|
1338 | + $error = true; |
|
1339 | + } |
|
1010 | 1340 | if ($error) { |
1011 | 1341 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1012 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
1342 | + if ($globalDebug) { |
|
1343 | + echo "Not a message. Ignoring... \n"; |
|
1344 | + } |
|
1013 | 1345 | } else { |
1014 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
1346 | + if ($globalDebug) { |
|
1347 | + echo "Wrong line format. Ignoring... \n"; |
|
1348 | + } |
|
1015 | 1349 | if ($globalDebug) { |
1016 | 1350 | echo $buffer; |
1017 | 1351 | print_r($line); |
1018 | 1352 | } |
1019 | 1353 | //socket_close($r); |
1020 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1021 | - if ($format == 'aprs') $aprs_connect = 0; |
|
1354 | + if ($globalDebug) { |
|
1355 | + echo "Reconnect after an error...\n"; |
|
1356 | + } |
|
1357 | + if ($format == 'aprs') { |
|
1358 | + $aprs_connect = 0; |
|
1359 | + } |
|
1022 | 1360 | $sourceer[$nb] = $globalSources[$nb]; |
1023 | 1361 | connect_all($sourceer); |
1024 | 1362 | $sourceer = array(); |
@@ -1026,10 +1364,14 @@ discard block |
||
1026 | 1364 | } |
1027 | 1365 | } |
1028 | 1366 | // Sleep for xxx microseconds |
1029 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
1367 | + if (isset($globalSBSSleep)) { |
|
1368 | + usleep($globalSBSSleep); |
|
1369 | + } |
|
1030 | 1370 | } else { |
1031 | 1371 | if ($format == 'flightgearmp') { |
1032 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1372 | + if ($globalDebug) { |
|
1373 | + echo "Reconnect FlightGear MP..."; |
|
1374 | + } |
|
1033 | 1375 | //@socket_close($r); |
1034 | 1376 | sleep($globalMinFetch); |
1035 | 1377 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1038,10 +1380,15 @@ discard block |
||
1038 | 1380 | break; |
1039 | 1381 | |
1040 | 1382 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1041 | - if (isset($tt[$format])) $tt[$format]++; |
|
1042 | - else $tt[$format] = 0; |
|
1383 | + if (isset($tt[$format])) { |
|
1384 | + $tt[$format]++; |
|
1385 | + } else { |
|
1386 | + $tt[$format] = 0; |
|
1387 | + } |
|
1043 | 1388 | if ($tt[$format] > 30) { |
1044 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
1389 | + if ($globalDebug) { |
|
1390 | + echo "ERROR : Reconnect ".$format."..."; |
|
1391 | + } |
|
1045 | 1392 | //@socket_close($r); |
1046 | 1393 | sleep(2); |
1047 | 1394 | $aprs_connect = 0; |
@@ -1057,12 +1404,18 @@ discard block |
||
1057 | 1404 | } |
1058 | 1405 | } else { |
1059 | 1406 | $error = socket_strerror(socket_last_error()); |
1060 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1407 | + if ($globalDebug) { |
|
1408 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1409 | + } |
|
1061 | 1410 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) { |
1062 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
1411 | + if (isset($globalDebug)) { |
|
1412 | + echo "Restarting...\n"; |
|
1413 | + } |
|
1063 | 1414 | // Restart the script if possible |
1064 | 1415 | if (is_array($sockets)) { |
1065 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1416 | + if ($globalDebug) { |
|
1417 | + echo "Shutdown all sockets..."; |
|
1418 | + } |
|
1066 | 1419 | |
1067 | 1420 | foreach ($sockets as $sock) { |
1068 | 1421 | @socket_shutdown($sock,2); |
@@ -1070,18 +1423,24 @@ discard block |
||
1070 | 1423 | } |
1071 | 1424 | |
1072 | 1425 | } |
1073 | - if ($globalDebug) echo "Restart all connections..."; |
|
1426 | + if ($globalDebug) { |
|
1427 | + echo "Restart all connections..."; |
|
1428 | + } |
|
1074 | 1429 | sleep(2); |
1075 | 1430 | $time = time(); |
1076 | 1431 | //connect_all($hosts); |
1077 | 1432 | $aprs_connect = 0; |
1078 | - if ($reset > 40) exit('Too many attempts...'); |
|
1433 | + if ($reset > 40) { |
|
1434 | + exit('Too many attempts...'); |
|
1435 | + } |
|
1079 | 1436 | connect_all($globalSources); |
1080 | 1437 | } |
1081 | 1438 | } |
1082 | 1439 | } |
1083 | 1440 | if ($globalDaemon === false) { |
1084 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1441 | + if ($globalDebug) { |
|
1442 | + echo 'Check all...'."\n"; |
|
1443 | + } |
|
1085 | 1444 | $SI->checkAll(); |
1086 | 1445 | } |
1087 | 1446 | } |
@@ -12,8 +12,12 @@ |
||
12 | 12 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
13 | 13 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
14 | 14 | $filter = array(); |
15 | -if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
16 | -if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
15 | +if ($year != '') { |
|
16 | + $filter = array_merge($filter,array('year' => $year)); |
|
17 | +} |
|
18 | +if ($month != '') { |
|
19 | + $filter = array_merge($filter,array('month' => $month)); |
|
20 | +} |
|
17 | 21 | if ($sort != '') { |
18 | 22 | $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter); |
19 | 23 | } else { |