@@ -29,7 +29,9 @@ discard block |
||
29 | 29 | if (isset($filter[0]['source'])) { |
30 | 30 | $filters = array_merge($filters,$filter); |
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
33 | 35 | $filter_query_join = ''; |
34 | 36 | $filter_query_where = ''; |
35 | 37 | foreach($filters as $flt) { |
@@ -118,8 +120,11 @@ discard block |
||
118 | 120 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
119 | 121 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
120 | 122 | } |
121 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
122 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
123 | + if ($filter_query_where == '' && $where) { |
|
124 | + $filter_query_where = ' WHERE'; |
|
125 | + } elseif ($filter_query_where != '' && $and) { |
|
126 | + $filter_query_where .= ' AND'; |
|
127 | + } |
|
123 | 128 | if ($filter_query_where != '') { |
124 | 129 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
125 | 130 | } |
@@ -161,7 +166,9 @@ discard block |
||
161 | 166 | } |
162 | 167 | } |
163 | 168 | |
164 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
169 | + if (!isset($globalLiveInterval)) { |
|
170 | + $globalLiveInterval = '200'; |
|
171 | + } |
|
165 | 172 | if ($globalDBdriver == 'mysql') { |
166 | 173 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
167 | 174 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -186,7 +193,9 @@ discard block |
||
186 | 193 | |
187 | 194 | $filter_query = $this->getFilter($filter,true,true); |
188 | 195 | |
189 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
196 | + if (!isset($globalLiveInterval)) { |
|
197 | + $globalLiveInterval = '200'; |
|
198 | + } |
|
190 | 199 | if ($globalDBdriver == 'mysql') { |
191 | 200 | // $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query"; |
192 | 201 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao'; |
@@ -243,7 +252,9 @@ discard block |
||
243 | 252 | |
244 | 253 | $filter_query = $this->getFilter($filter,true,true); |
245 | 254 | |
246 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
255 | + if (!isset($globalLiveInterval)) { |
|
256 | + $globalLiveInterval = '200'; |
|
257 | + } |
|
247 | 258 | if ($globalDBdriver == 'mysql') { |
248 | 259 | /* |
249 | 260 | $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
@@ -287,7 +298,9 @@ discard block |
||
287 | 298 | global $globalDBdriver, $globalLiveInterval; |
288 | 299 | $filter_query = $this->getFilter($filter,true,true); |
289 | 300 | |
290 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
301 | + if (!isset($globalLiveInterval)) { |
|
302 | + $globalLiveInterval = '200'; |
|
303 | + } |
|
291 | 304 | if ($globalDBdriver == 'mysql') { |
292 | 305 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
293 | 306 | $query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
@@ -317,7 +330,9 @@ discard block |
||
317 | 330 | { |
318 | 331 | global $globalDBdriver, $globalLiveInterval; |
319 | 332 | $Spotter = new Spotter($this->db); |
320 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
333 | + if (!isset($globalLiveInterval)) { |
|
334 | + $globalLiveInterval = '200'; |
|
335 | + } |
|
321 | 336 | $filter_query = $this->getFilter($filter); |
322 | 337 | |
323 | 338 | if (is_array($coord)) { |
@@ -325,7 +340,9 @@ discard block |
||
325 | 340 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
326 | 341 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
327 | 342 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
328 | - } else return array(); |
|
343 | + } else { |
|
344 | + return array(); |
|
345 | + } |
|
329 | 346 | if ($globalDBdriver == 'mysql') { |
330 | 347 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
331 | 348 | } else { |
@@ -346,7 +363,9 @@ discard block |
||
346 | 363 | { |
347 | 364 | global $globalDBdriver, $globalLiveInterval; |
348 | 365 | $Spotter = new Spotter($this->db); |
349 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
366 | + if (!isset($globalLiveInterval)) { |
|
367 | + $globalLiveInterval = '200'; |
|
368 | + } |
|
350 | 369 | $filter_query = $this->getFilter($filter,true,true); |
351 | 370 | |
352 | 371 | if (is_array($coord)) { |
@@ -354,7 +373,9 @@ discard block |
||
354 | 373 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
355 | 374 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
356 | 375 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
357 | - } else return array(); |
|
376 | + } else { |
|
377 | + return array(); |
|
378 | + } |
|
358 | 379 | if ($globalDBdriver == 'mysql') { |
359 | 380 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
360 | 381 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.' spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.''; |
@@ -561,11 +582,15 @@ discard block |
||
561 | 582 | //$query = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date'; |
562 | 583 | if ($globalDBdriver == 'mysql') { |
563 | 584 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
564 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
585 | + if ($liveinterval) { |
|
586 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
587 | + } |
|
565 | 588 | $query .= ' ORDER BY date'; |
566 | 589 | } else { |
567 | 590 | $query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id'; |
568 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
591 | + if ($liveinterval) { |
|
592 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
593 | + } |
|
569 | 594 | $query .= ' ORDER BY date'; |
570 | 595 | } |
571 | 596 | |
@@ -660,7 +685,9 @@ discard block |
||
660 | 685 | $i++; |
661 | 686 | $j++; |
662 | 687 | if ($j == 30) { |
663 | - if ($globalDebug) echo "."; |
|
688 | + if ($globalDebug) { |
|
689 | + echo "."; |
|
690 | + } |
|
664 | 691 | try { |
665 | 692 | |
666 | 693 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -967,7 +994,9 @@ discard block |
||
967 | 994 | { |
968 | 995 | return false; |
969 | 996 | } |
970 | - } else return ''; |
|
997 | + } else { |
|
998 | + return ''; |
|
999 | + } |
|
971 | 1000 | |
972 | 1001 | if ($longitude != '') |
973 | 1002 | { |
@@ -975,7 +1004,9 @@ discard block |
||
975 | 1004 | { |
976 | 1005 | return false; |
977 | 1006 | } |
978 | - } else return ''; |
|
1007 | + } else { |
|
1008 | + return ''; |
|
1009 | + } |
|
979 | 1010 | |
980 | 1011 | if ($waypoints != '') |
981 | 1012 | { |
@@ -991,7 +1022,9 @@ discard block |
||
991 | 1022 | { |
992 | 1023 | return false; |
993 | 1024 | } |
994 | - } else $altitude = 0; |
|
1025 | + } else { |
|
1026 | + $altitude = 0; |
|
1027 | + } |
|
995 | 1028 | |
996 | 1029 | if ($heading != '') |
997 | 1030 | { |
@@ -999,7 +1032,9 @@ discard block |
||
999 | 1032 | { |
1000 | 1033 | return false; |
1001 | 1034 | } |
1002 | - } else $heading = 0; |
|
1035 | + } else { |
|
1036 | + $heading = 0; |
|
1037 | + } |
|
1003 | 1038 | |
1004 | 1039 | if ($groundspeed != '') |
1005 | 1040 | { |
@@ -1007,9 +1042,13 @@ discard block |
||
1007 | 1042 | { |
1008 | 1043 | return false; |
1009 | 1044 | } |
1010 | - } else $groundspeed = 0; |
|
1045 | + } else { |
|
1046 | + $groundspeed = 0; |
|
1047 | + } |
|
1011 | 1048 | date_default_timezone_set('UTC'); |
1012 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
1049 | + if ($date == '') { |
|
1050 | + $date = date("Y-m-d H:i:s", time()); |
|
1051 | + } |
|
1013 | 1052 | |
1014 | 1053 | |
1015 | 1054 | $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
@@ -1053,10 +1092,18 @@ discard block |
||
1053 | 1092 | $arrival_airport_country = ''; |
1054 | 1093 | |
1055 | 1094 | |
1056 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1057 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1058 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1059 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1095 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) { |
|
1096 | + $squawk = NULL; |
|
1097 | + } |
|
1098 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) { |
|
1099 | + $verticalrate = NULL; |
|
1100 | + } |
|
1101 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1102 | + $groundspeed = 0; |
|
1103 | + } |
|
1104 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1105 | + $heading = 0; |
|
1106 | + } |
|
1060 | 1107 | |
1061 | 1108 | $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
1062 | 1109 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -1070,10 +1117,14 @@ discard block |
||
1070 | 1117 | return "error : ".$e->getMessage(); |
1071 | 1118 | } |
1072 | 1119 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1073 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1120 | + if ($globalDebug) { |
|
1121 | + echo '(Add to SBS archive : '; |
|
1122 | + } |
|
1074 | 1123 | $SpotterArchive = new SpotterArchive($this->db); |
1075 | 1124 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
1076 | - if ($globalDebug) echo $result.')'; |
|
1125 | + if ($globalDebug) { |
|
1126 | + echo $result.')'; |
|
1127 | + } |
|
1077 | 1128 | } |
1078 | 1129 | return "success"; |
1079 | 1130 |
@@ -63,7 +63,9 @@ discard block |
||
63 | 63 | $dbc = $this->db; |
64 | 64 | $this->all_flights[$id]['schedule_check'] = true; |
65 | 65 | if ($globalSchedulesFetch) { |
66 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
66 | + if ($globalDebug) { |
|
67 | + echo 'Getting schedule info...'."\n"; |
|
68 | + } |
|
67 | 69 | $Spotter = new Spotter($dbc); |
68 | 70 | $Schedule = new Schedule($dbc); |
69 | 71 | $Translation = new Translation($dbc); |
@@ -74,7 +76,9 @@ discard block |
||
74 | 76 | if ($Schedule->checkSchedule($operator) == 0) { |
75 | 77 | $schedule = $Schedule->fetchSchedule($operator); |
76 | 78 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
77 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
79 | + if ($globalDebug) { |
|
80 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
81 | + } |
|
78 | 82 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
79 | 83 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
80 | 84 | // Should also check if route schedule = route from DB |
@@ -83,7 +87,9 @@ discard block |
||
83 | 87 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
84 | 88 | if (trim($airport_icao) != '') { |
85 | 89 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
86 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
90 | + if ($globalDebug) { |
|
91 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
92 | + } |
|
87 | 93 | } |
88 | 94 | } |
89 | 95 | } |
@@ -92,17 +98,25 @@ discard block |
||
92 | 98 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
93 | 99 | if (trim($airport_icao) != '') { |
94 | 100 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
95 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
101 | + if ($globalDebug) { |
|
102 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
103 | + } |
|
96 | 104 | } |
97 | 105 | } |
98 | 106 | } |
99 | 107 | $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']); |
100 | 108 | } |
101 | - } else $scheduleexist = true; |
|
102 | - } else $scheduleexist = true; |
|
109 | + } else { |
|
110 | + $scheduleexist = true; |
|
111 | + } |
|
112 | + } else { |
|
113 | + $scheduleexist = true; |
|
114 | + } |
|
103 | 115 | // close connection, at least one way will work ? |
104 | 116 | if ($scheduleexist) { |
105 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
117 | + if ($globalDebug) { |
|
118 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
119 | + } |
|
106 | 120 | $sch = $Schedule->getSchedule($operator); |
107 | 121 | $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'])); |
108 | 122 | } |
@@ -124,14 +138,18 @@ discard block |
||
124 | 138 | |
125 | 139 | public function checkAll() { |
126 | 140 | global $globalDebug, $globalNoImport; |
127 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
141 | + if ($globalDebug) { |
|
142 | + echo "Update last seen flights data...\n"; |
|
143 | + } |
|
128 | 144 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
129 | 145 | foreach ($this->all_flights as $key => $flight) { |
130 | 146 | if (isset($this->all_flights[$key]['id'])) { |
131 | 147 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
132 | 148 | $Spotter = new Spotter($this->db); |
133 | 149 | $real_arrival = $this->arrival($key); |
134 | - if (isset($this->all_flights[$key]['altitude'])) $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']); |
|
150 | + if (isset($this->all_flights[$key]['altitude'])) { |
|
151 | + $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']); |
|
152 | + } |
|
135 | 153 | } |
136 | 154 | } |
137 | 155 | } |
@@ -139,24 +157,32 @@ discard block |
||
139 | 157 | |
140 | 158 | public function arrival($key) { |
141 | 159 | global $globalClosestMinDist, $globalDebug; |
142 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
160 | + if ($globalDebug) { |
|
161 | + echo 'Update arrival...'."\n"; |
|
162 | + } |
|
143 | 163 | $Spotter = new Spotter($this->db); |
144 | 164 | $airport_icao = ''; |
145 | 165 | $airport_time = ''; |
146 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
166 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
167 | + $globalClosestMinDist = 50; |
|
168 | + } |
|
147 | 169 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
148 | 170 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
149 | 171 | if (isset($closestAirports[0])) { |
150 | 172 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
151 | 173 | $airport_icao = $closestAirports[0]['icao']; |
152 | 174 | $airport_time = $this->all_flights[$key]['datetime']; |
153 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
175 | + if ($globalDebug) { |
|
176 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
177 | + } |
|
154 | 178 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
155 | 179 | foreach ($closestAirports as $airport) { |
156 | 180 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
157 | 181 | $airport_icao = $airport['icao']; |
158 | 182 | $airport_time = $this->all_flights[$key]['datetime']; |
159 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
183 | + if ($globalDebug) { |
|
184 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
185 | + } |
|
160 | 186 | break; |
161 | 187 | } |
162 | 188 | } |
@@ -164,14 +190,20 @@ discard block |
||
164 | 190 | $airport_icao = $closestAirports[0]['icao']; |
165 | 191 | $airport_time = $this->all_flights[$key]['datetime']; |
166 | 192 | } else { |
167 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
193 | + if ($globalDebug) { |
|
194 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
195 | + } |
|
168 | 196 | } |
169 | 197 | } else { |
170 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
198 | + if ($globalDebug) { |
|
199 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
200 | + } |
|
171 | 201 | } |
172 | 202 | |
173 | 203 | } else { |
174 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
204 | + if ($globalDebug) { |
|
205 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
206 | + } |
|
175 | 207 | } |
176 | 208 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
177 | 209 | } |
@@ -181,12 +213,16 @@ discard block |
||
181 | 213 | public function del() { |
182 | 214 | global $globalDebug, $globalNoImport, $globalNoDB; |
183 | 215 | // Delete old infos |
184 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
216 | + if ($globalDebug) { |
|
217 | + echo 'Delete old values and update latest data...'."\n"; |
|
218 | + } |
|
185 | 219 | foreach ($this->all_flights as $key => $flight) { |
186 | 220 | if (isset($flight['lastupdate'])) { |
187 | 221 | if ($flight['lastupdate'] < (time()-3000)) { |
188 | 222 | if (isset($this->all_flights[$key]['id'])) { |
189 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
223 | + if ($globalDebug) { |
|
224 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
225 | + } |
|
190 | 226 | /* |
191 | 227 | $SpotterLive = new SpotterLive(); |
192 | 228 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
@@ -197,7 +233,9 @@ discard block |
||
197 | 233 | $Spotter = new Spotter($this->db); |
198 | 234 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
199 | 235 | $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']); |
200 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
236 | + if ($globalDebug && $result != 'success') { |
|
237 | + echo '!!! ERROR : '.$result."\n"; |
|
238 | + } |
|
201 | 239 | } |
202 | 240 | // Put in archive |
203 | 241 | // $Spotter->db = null; |
@@ -212,8 +250,10 @@ discard block |
||
212 | 250 | public function add($line) { |
213 | 251 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB; |
214 | 252 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
215 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
216 | -/* |
|
253 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
254 | + $globalCoordMinChange = '0.02'; |
|
255 | + } |
|
256 | + /* |
|
217 | 257 | $Spotter = new Spotter(); |
218 | 258 | $dbc = $Spotter->db; |
219 | 259 | $SpotterLive = new SpotterLive($dbc); |
@@ -241,11 +281,15 @@ discard block |
||
241 | 281 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
242 | 282 | $current_date = date('Y-m-d'); |
243 | 283 | $source = $line['source_name']; |
244 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
284 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
285 | + $source = $line['format_source']; |
|
286 | + } |
|
245 | 287 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
246 | 288 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
247 | 289 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
248 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
290 | + } else { |
|
291 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
292 | + } |
|
249 | 293 | } |
250 | 294 | |
251 | 295 | /* |
@@ -261,22 +305,35 @@ discard block |
||
261 | 305 | //$this->db = $dbc; |
262 | 306 | |
263 | 307 | //$hex = trim($line['hex']); |
264 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
265 | - else $id = trim($line['id']); |
|
308 | + if (!isset($line['id'])) { |
|
309 | + $id = trim($line['hex']); |
|
310 | + } else { |
|
311 | + $id = trim($line['id']); |
|
312 | + } |
|
266 | 313 | |
267 | 314 | if (!isset($this->all_flights[$id])) { |
268 | 315 | $this->all_flights[$id] = array(); |
269 | 316 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
270 | 317 | $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,'source_type' => '')); |
271 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
318 | + if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
319 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
320 | + } |
|
272 | 321 | if (!isset($line['id'])) { |
273 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
274 | -// 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'))); |
|
322 | + if (!isset($globalDaemon)) { |
|
323 | + $globalDaemon = TRUE; |
|
324 | + } |
|
325 | + // 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'))); |
|
275 | 326 | // 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'))); |
276 | - 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' => $id.'-'.date('YmdHi'))); |
|
327 | + 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')) { |
|
328 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
329 | + } |
|
277 | 330 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
278 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
279 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
331 | + } else { |
|
332 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
333 | + } |
|
334 | + if ($globalAllFlights !== FALSE) { |
|
335 | + $dataFound = true; |
|
336 | + } |
|
280 | 337 | } |
281 | 338 | if (isset($line['source_type']) && $line['source_type'] != '') { |
282 | 339 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
@@ -298,17 +355,27 @@ discard block |
||
298 | 355 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
299 | 356 | } |
300 | 357 | $Spotter->db = null; |
301 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
302 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
358 | + if ($globalDebugTimeElapsed) { |
|
359 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
360 | + } |
|
361 | + if ($aircraft_icao != '') { |
|
362 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
363 | + } |
|
303 | 364 | } |
304 | 365 | } |
305 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
306 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
366 | + if ($globalAllFlights !== FALSE) { |
|
367 | + $dataFound = true; |
|
368 | + } |
|
369 | + if ($globalDebug) { |
|
370 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
371 | + } |
|
307 | 372 | } |
308 | 373 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
309 | 374 | $icao = $line['aircraft_icao']; |
310 | 375 | $Spotter = new Spotter($this->db); |
311 | - if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
376 | + if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
377 | + $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
378 | + } |
|
312 | 379 | $Spotter->db = null; |
313 | 380 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
314 | 381 | } |
@@ -318,15 +385,24 @@ discard block |
||
318 | 385 | $Spotter = new Spotter($this->db); |
319 | 386 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
320 | 387 | $Spotter->db = null; |
321 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
388 | + if ($aircraft_icao != '') { |
|
389 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
390 | + } |
|
322 | 391 | } |
323 | 392 | } |
324 | 393 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
325 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
326 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
327 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
328 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
329 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
394 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
395 | + $aircraft_icao = 'GLID'; |
|
396 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
397 | + $aircraft_icao = 'UHEL'; |
|
398 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
399 | + $aircraft_icao = 'TOWPLANE'; |
|
400 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
401 | + $aircraft_icao = 'POWAIRC'; |
|
402 | + } |
|
403 | + if (isset($aircraft_icao)) { |
|
404 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
405 | + } |
|
330 | 406 | } |
331 | 407 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
332 | 408 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -336,8 +412,11 @@ discard block |
||
336 | 412 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
337 | 413 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
338 | 414 | } else { |
339 | - 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"; |
|
340 | - 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"; |
|
415 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
416 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
417 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
418 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
419 | + } |
|
341 | 420 | /* |
342 | 421 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
343 | 422 | print_r($this->all_flights[$id]); |
@@ -370,15 +449,25 @@ discard block |
||
370 | 449 | $timeelapsed = microtime(true); |
371 | 450 | $Spotter = new Spotter($this->db); |
372 | 451 | $fromsource = NULL; |
373 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
374 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
375 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
376 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
377 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
452 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
453 | + $fromsource = $globalAirlinesSource; |
|
454 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
455 | + $fromsource = 'vatsim'; |
|
456 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
457 | + $fromsource = 'ivao'; |
|
458 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
459 | + $fromsource = 'vatsim'; |
|
460 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
461 | + $fromsource = 'ivao'; |
|
462 | + } |
|
378 | 463 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
379 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
464 | + if ($globalDebug && $result != 'success') { |
|
465 | + echo '!!! ERROR : '.$result."\n"; |
|
466 | + } |
|
380 | 467 | $Spotter->db = null; |
381 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
468 | + if ($globalDebugTimeElapsed) { |
|
469 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
470 | + } |
|
382 | 471 | } |
383 | 472 | } |
384 | 473 | |
@@ -390,7 +479,9 @@ discard block |
||
390 | 479 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
391 | 480 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
392 | 481 | */ |
393 | - 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'])); |
|
482 | + if (!isset($this->all_flights[$id]['id'])) { |
|
483 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
484 | + } |
|
394 | 485 | |
395 | 486 | //$putinarchive = true; |
396 | 487 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -408,7 +499,9 @@ discard block |
||
408 | 499 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
409 | 500 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
410 | 501 | $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' => '')); |
411 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
502 | + if ($globalDebugTimeElapsed) { |
|
503 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
504 | + } |
|
412 | 505 | } |
413 | 506 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
414 | 507 | $timeelapsed = microtime(true); |
@@ -422,7 +515,9 @@ discard block |
||
422 | 515 | $Translation->db = null; |
423 | 516 | } |
424 | 517 | $Spotter->db = null; |
425 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
518 | + if ($globalDebugTimeElapsed) { |
|
519 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
520 | + } |
|
426 | 521 | } |
427 | 522 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
428 | 523 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -431,9 +526,13 @@ discard block |
||
431 | 526 | $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'])); |
432 | 527 | } |
433 | 528 | } |
434 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
529 | + if (!isset($globalFork)) { |
|
530 | + $globalFork = TRUE; |
|
531 | + } |
|
435 | 532 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
436 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
533 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
534 | + $this->get_Schedule($id,trim($line['ident'])); |
|
535 | + } |
|
437 | 536 | } |
438 | 537 | } |
439 | 538 | } |
@@ -449,16 +548,23 @@ discard block |
||
449 | 548 | // use datetime |
450 | 549 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
451 | 550 | $speed = $speed*3.6; |
452 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
453 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
551 | + if ($speed < 1000) { |
|
552 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
553 | + } |
|
554 | + if ($globalDebug) { |
|
555 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
556 | + } |
|
454 | 557 | } |
455 | 558 | } |
456 | 559 | |
457 | 560 | |
458 | 561 | |
459 | 562 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
460 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
461 | - else unset($timediff); |
|
563 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
564 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
565 | + } else { |
|
566 | + unset($timediff); |
|
567 | + } |
|
462 | 568 | if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && 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')))) { |
463 | 569 | 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'])) { |
464 | 570 | 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'])) { |
@@ -467,15 +573,23 @@ discard block |
||
467 | 573 | $this->all_flights[$id]['putinarchive'] = true; |
468 | 574 | $this->tmd = 0; |
469 | 575 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
470 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
576 | + if ($globalDebug) { |
|
577 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
578 | + } |
|
471 | 579 | $timeelapsed = microtime(true); |
472 | 580 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
473 | 581 | $Spotter = new Spotter($this->db); |
474 | 582 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
475 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
583 | + if (!empty($all_country)) { |
|
584 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
585 | + } |
|
476 | 586 | $Spotter->db = null; |
477 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
478 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
587 | + if ($globalDebugTimeElapsed) { |
|
588 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
589 | + } |
|
590 | + if ($globalDebug) { |
|
591 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
592 | + } |
|
479 | 593 | } |
480 | 594 | } |
481 | 595 | } |
@@ -483,7 +597,9 @@ discard block |
||
483 | 597 | |
484 | 598 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
485 | 599 | //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) { |
486 | - if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
600 | + if (!isset($this->all_flights[$id]['archive_latitude'])) { |
|
601 | + $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
602 | + } |
|
487 | 603 | 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') { |
488 | 604 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
489 | 605 | $dataFound = true; |
@@ -505,9 +621,13 @@ discard block |
||
505 | 621 | */ |
506 | 622 | } |
507 | 623 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
508 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
624 | + if ($line['longitude'] > 180) { |
|
625 | + $line['longitude'] = $line['longitude'] - 360; |
|
626 | + } |
|
509 | 627 | //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) { |
510 | - if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
628 | + if (!isset($this->all_flights[$id]['archive_longitude'])) { |
|
629 | + $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
630 | + } |
|
511 | 631 | 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') { |
512 | 632 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
513 | 633 | $dataFound = true; |
@@ -538,7 +658,9 @@ discard block |
||
538 | 658 | } |
539 | 659 | } |
540 | 660 | if (isset($line['last_update']) && $line['last_update'] != '') { |
541 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
661 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
662 | + $dataFound = true; |
|
663 | + } |
|
542 | 664 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
543 | 665 | } |
544 | 666 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -560,41 +682,61 @@ discard block |
||
560 | 682 | // Here we force archive of flight because after ground it's a new one (or should be) |
561 | 683 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
562 | 684 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
563 | - 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'))); |
|
564 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
565 | - 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'])); |
|
685 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) { |
|
686 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
687 | + } elseif (isset($line['id'])) { |
|
688 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
689 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
690 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
691 | + } |
|
692 | + } |
|
693 | + if ($line['ground'] != 1) { |
|
694 | + $line['ground'] = 0; |
|
566 | 695 | } |
567 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
568 | 696 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
569 | 697 | //$dataFound = true; |
570 | 698 | } |
571 | 699 | if (isset($line['squawk']) && $line['squawk'] != '') { |
572 | 700 | 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'])) { |
573 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
701 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
702 | + $this->all_flights[$id]['putinarchive'] = true; |
|
703 | + } |
|
574 | 704 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
575 | 705 | $highlight = ''; |
576 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
577 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
578 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
706 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
707 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
708 | + } |
|
709 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
710 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
711 | + } |
|
712 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
713 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
714 | + } |
|
579 | 715 | if ($highlight != '') { |
580 | 716 | $timeelapsed = microtime(true); |
581 | 717 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
582 | 718 | $Spotter = new Spotter($this->db); |
583 | 719 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
584 | 720 | $Spotter->db = null; |
585 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
721 | + if ($globalDebugTimeElapsed) { |
|
722 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
723 | + } |
|
586 | 724 | } |
587 | 725 | //$putinarchive = true; |
588 | 726 | //$highlight = ''; |
589 | 727 | } |
590 | 728 | |
591 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
729 | + } else { |
|
730 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
731 | + } |
|
592 | 732 | //$dataFound = true; |
593 | 733 | } |
594 | 734 | |
595 | 735 | if (isset($line['altitude']) && $line['altitude'] != '') { |
596 | 736 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
597 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
737 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
738 | + $this->all_flights[$id]['putinarchive'] = true; |
|
739 | + } |
|
598 | 740 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
599 | 741 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
600 | 742 | //$dataFound = true; |
@@ -606,21 +748,30 @@ discard block |
||
606 | 748 | } |
607 | 749 | |
608 | 750 | if (isset($line['heading']) && $line['heading'] != '') { |
609 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
751 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
752 | + $this->all_flights[$id]['putinarchive'] = true; |
|
753 | + } |
|
610 | 754 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
611 | 755 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
612 | 756 | //$dataFound = true; |
613 | 757 | } 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']) { |
614 | 758 | $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']); |
615 | 759 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
616 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
617 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
760 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
761 | + $this->all_flights[$id]['putinarchive'] = true; |
|
762 | + } |
|
763 | + if ($globalDebug) { |
|
764 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
765 | + } |
|
618 | 766 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
619 | 767 | // If not enough messages and ACARS set heading to 0 |
620 | 768 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
621 | 769 | } |
622 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
623 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
770 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
771 | + $dataFound = false; |
|
772 | + } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
773 | + $dataFound = false; |
|
774 | + } |
|
624 | 775 | |
625 | 776 | // print_r($this->all_flights[$id]); |
626 | 777 | //gets the callsign from the last hour |
@@ -636,23 +787,38 @@ discard block |
||
636 | 787 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
637 | 788 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
638 | 789 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
639 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
790 | + if ($globalDebug) { |
|
791 | + echo "Check if aircraft is already in DB..."; |
|
792 | + } |
|
640 | 793 | $timeelapsed = microtime(true); |
641 | 794 | $SpotterLive = new SpotterLive($this->db); |
642 | 795 | 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')) { |
643 | 796 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
644 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
797 | + if ($globalDebugTimeElapsed) { |
|
798 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
799 | + } |
|
645 | 800 | } elseif (isset($line['id'])) { |
646 | 801 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
647 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
802 | + if ($globalDebugTimeElapsed) { |
|
803 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
804 | + } |
|
648 | 805 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
649 | 806 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
650 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
651 | - } else $recent_ident = ''; |
|
807 | + if ($globalDebugTimeElapsed) { |
|
808 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
809 | + } |
|
810 | + } else { |
|
811 | + $recent_ident = ''; |
|
812 | + } |
|
652 | 813 | $SpotterLive->db=null; |
653 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
654 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
655 | - } else $recent_ident = ''; |
|
814 | + if ($globalDebug && $recent_ident == '') { |
|
815 | + echo " Not in DB.\n"; |
|
816 | + } elseif ($globalDebug && $recent_ident != '') { |
|
817 | + echo " Already in DB.\n"; |
|
818 | + } |
|
819 | + } else { |
|
820 | + $recent_ident = ''; |
|
821 | + } |
|
656 | 822 | } else { |
657 | 823 | $recent_ident = ''; |
658 | 824 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -660,7 +826,9 @@ discard block |
||
660 | 826 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
661 | 827 | if($recent_ident == "") |
662 | 828 | { |
663 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
829 | + if ($globalDebug) { |
|
830 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
831 | + } |
|
664 | 832 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
665 | 833 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
666 | 834 | //adds the spotter data for the archive |
@@ -704,31 +872,49 @@ discard block |
||
704 | 872 | |
705 | 873 | if (!$ignoreImport) { |
706 | 874 | $highlight = ''; |
707 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
708 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
709 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
710 | - 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'))); |
|
875 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
876 | + $highlight = 'Squawk 7500 : Hijack'; |
|
877 | + } |
|
878 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
879 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
880 | + } |
|
881 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
882 | + $highlight = 'Squawk 7700 : Emergency'; |
|
883 | + } |
|
884 | + if (!isset($this->all_flights[$id]['id'])) { |
|
885 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
886 | + } |
|
711 | 887 | $timeelapsed = microtime(true); |
712 | 888 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
713 | 889 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
714 | 890 | $Spotter = new Spotter($this->db); |
715 | 891 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
716 | 892 | $Spotter->db = null; |
717 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
893 | + if ($globalDebug && isset($result)) { |
|
894 | + echo $result."\n"; |
|
895 | + } |
|
718 | 896 | } |
719 | 897 | } |
720 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
898 | + if ($globalDebugTimeElapsed) { |
|
899 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
900 | + } |
|
721 | 901 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
722 | 902 | |
723 | 903 | // Add source stat in DB |
724 | 904 | $Stats = new Stats($this->db); |
725 | 905 | if (!empty($this->stats)) { |
726 | - if ($globalDebug) echo 'Add source stats : '; |
|
906 | + if ($globalDebug) { |
|
907 | + echo 'Add source stats : '; |
|
908 | + } |
|
727 | 909 | foreach($this->stats as $date => $data) { |
728 | 910 | foreach($data as $source => $sourced) { |
729 | 911 | //print_r($sourced); |
730 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
731 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
912 | + if (isset($sourced['polar'])) { |
|
913 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
914 | + } |
|
915 | + if (isset($sourced['hist'])) { |
|
916 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
917 | + } |
|
732 | 918 | if (isset($sourced['msg'])) { |
733 | 919 | if (time() - $sourced['msg']['date'] > 10) { |
734 | 920 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -741,13 +927,17 @@ discard block |
||
741 | 927 | unset($this->stats[$date]); |
742 | 928 | } |
743 | 929 | } |
744 | - if ($globalDebug) echo 'Done'."\n"; |
|
930 | + if ($globalDebug) { |
|
931 | + echo 'Done'."\n"; |
|
932 | + } |
|
745 | 933 | |
746 | 934 | } |
747 | 935 | $Stats->db = null; |
748 | 936 | } |
749 | 937 | $this->del(); |
750 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
938 | + } elseif ($globalDebug) { |
|
939 | + echo 'Ignore data'."\n"; |
|
940 | + } |
|
751 | 941 | //$ignoreImport = false; |
752 | 942 | $this->all_flights[$id]['addedSpotter'] = 1; |
753 | 943 | //print_r($this->all_flights[$id]); |
@@ -764,7 +954,9 @@ discard block |
||
764 | 954 | */ |
765 | 955 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
766 | 956 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
767 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
957 | + if ($globalDebug) { |
|
958 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
959 | + } |
|
768 | 960 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
769 | 961 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
770 | 962 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -773,7 +965,9 @@ discard block |
||
773 | 965 | $SpotterLive->db=null; |
774 | 966 | } |
775 | 967 | } |
776 | - if ($globalDebug) echo " Done\n"; |
|
968 | + if ($globalDebug) { |
|
969 | + echo " Done\n"; |
|
970 | + } |
|
777 | 971 | $this->last_delete = time(); |
778 | 972 | } |
779 | 973 | } else { |
@@ -800,11 +994,17 @@ discard block |
||
800 | 994 | //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"; |
801 | 995 | if ($globalDebug) { |
802 | 996 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
803 | - 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"; |
|
804 | - 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"; |
|
997 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
998 | + 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"; |
|
999 | + } else { |
|
1000 | + 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"; |
|
1001 | + } |
|
805 | 1002 | } else { |
806 | - 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"; |
|
807 | - 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"; |
|
1003 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
1004 | + 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"; |
|
1005 | + } else { |
|
1006 | + 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"; |
|
1007 | + } |
|
808 | 1008 | } |
809 | 1009 | } |
810 | 1010 | $ignoreImport = false; |
@@ -850,22 +1050,30 @@ discard block |
||
850 | 1050 | |
851 | 1051 | if (!$ignoreImport) { |
852 | 1052 | 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'])) { |
853 | - 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'))); |
|
1053 | + if (!isset($this->all_flights[$id]['id'])) { |
|
1054 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
1055 | + } |
|
854 | 1056 | $timeelapsed = microtime(true); |
855 | 1057 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
856 | 1058 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
857 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1059 | + if ($globalDebug) { |
|
1060 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
1061 | + } |
|
858 | 1062 | $SpotterLive = new SpotterLive($this->db); |
859 | 1063 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
860 | 1064 | $SpotterLive->db = null; |
861 | - if ($globalDebug) echo $result."\n"; |
|
1065 | + if ($globalDebug) { |
|
1066 | + echo $result."\n"; |
|
1067 | + } |
|
862 | 1068 | } |
863 | 1069 | } |
864 | 1070 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
865 | 1071 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
866 | 1072 | } |
867 | 1073 | $this->all_flights[$id]['putinarchive'] = false; |
868 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1074 | + if ($globalDebugTimeElapsed) { |
|
1075 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
1076 | + } |
|
869 | 1077 | |
870 | 1078 | // Put statistics in $this->stats variable |
871 | 1079 | //if ($line['format_source'] != 'aprs') { |
@@ -873,7 +1081,9 @@ discard block |
||
873 | 1081 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
874 | 1082 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
875 | 1083 | $source = $this->all_flights[$id]['source_name']; |
876 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
1084 | + if ($source == '') { |
|
1085 | + $source = $this->all_flights[$id]['format_source']; |
|
1086 | + } |
|
877 | 1087 | if (!isset($this->source_location[$source])) { |
878 | 1088 | $Location = new Source(); |
879 | 1089 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -894,7 +1104,9 @@ discard block |
||
894 | 1104 | $stats_heading = round($stats_heading/22.5); |
895 | 1105 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
896 | 1106 | $current_date = date('Y-m-d'); |
897 | - if ($stats_heading == 16) $stats_heading = 0; |
|
1107 | + if ($stats_heading == 16) { |
|
1108 | + $stats_heading = 0; |
|
1109 | + } |
|
898 | 1110 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
899 | 1111 | for ($i=0;$i<=15;$i++) { |
900 | 1112 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -912,7 +1124,9 @@ discard block |
||
912 | 1124 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
913 | 1125 | end($this->stats[$current_date][$source]['hist']); |
914 | 1126 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
915 | - } else $mini = 0; |
|
1127 | + } else { |
|
1128 | + $mini = 0; |
|
1129 | + } |
|
916 | 1130 | for ($i=$mini;$i<=$distance;$i+=10) { |
917 | 1131 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
918 | 1132 | } |
@@ -924,19 +1138,27 @@ discard block |
||
924 | 1138 | } |
925 | 1139 | |
926 | 1140 | $this->all_flights[$id]['lastupdate'] = time(); |
927 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
1141 | + if ($this->all_flights[$id]['putinarchive']) { |
|
1142 | + $send = true; |
|
1143 | + } |
|
928 | 1144 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
929 | - } 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"; |
|
1145 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
1146 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1147 | + } |
|
930 | 1148 | //$this->del(); |
931 | 1149 | |
932 | 1150 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
933 | 1151 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
934 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1152 | + if ($globalDebug) { |
|
1153 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
1154 | + } |
|
935 | 1155 | $SpotterLive = new SpotterLive($this->db); |
936 | 1156 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
937 | 1157 | $SpotterLive->db = null; |
938 | 1158 | //SpotterLive->deleteLiveSpotterData(); |
939 | - if ($globalDebug) echo " Done\n"; |
|
1159 | + if ($globalDebug) { |
|
1160 | + echo " Done\n"; |
|
1161 | + } |
|
940 | 1162 | $this->last_delete_hourly = time(); |
941 | 1163 | } else { |
942 | 1164 | $this->del(); |
@@ -948,7 +1170,9 @@ discard block |
||
948 | 1170 | //$ignoreImport = false; |
949 | 1171 | } |
950 | 1172 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
951 | - if ($send) return $this->all_flights[$id]; |
|
1173 | + if ($send) { |
|
1174 | + return $this->all_flights[$id]; |
|
1175 | + } |
|
952 | 1176 | } |
953 | 1177 | } |
954 | 1178 | } |
@@ -55,7 +55,9 @@ discard block |
||
55 | 55 | { |
56 | 56 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
57 | 57 | $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
58 | - } else $image = $spotter_item['image_thumbnail']; |
|
58 | + } else { |
|
59 | + $image = $spotter_item['image_thumbnail']; |
|
60 | + } |
|
59 | 61 | |
60 | 62 | } |
61 | 63 | /* else { |
@@ -67,7 +69,9 @@ discard block |
||
67 | 69 | print '<div class="left"><img src="'.$image.'" alt="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].'" title="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].' Image © '.$spotter_item['image_copyright'].'"/><br />Image © '.$spotter_item['image_copyright'].'</div>'; |
68 | 70 | } |
69 | 71 | print '<div class="right"><div class="callsign-details"><div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>'; |
70 | -if (isset($spotter_item['airline_name'])) print '<div class="airline">'.$spotter_item['airline_name'].'</div>'; |
|
72 | +if (isset($spotter_item['airline_name'])) { |
|
73 | + print '<div class="airline">'.$spotter_item['airline_name'].'</div>'; |
|
74 | +} |
|
71 | 75 | print '</div>'; |
72 | 76 | print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country']; |
73 | 77 | if (isset($spotter_item['departure_airport_time'])) { |
@@ -95,9 +99,14 @@ discard block |
||
95 | 99 | print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country']; |
96 | 100 | print '</div></div><div id="aircraft">'; |
97 | 101 | print '<span>'._("Aircraft").'</span>'; |
98 | -if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>'; |
|
99 | -if (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>'; |
|
100 | -else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name']; |
|
102 | +if (isset($spotter_item['aircraft_wiki'])) { |
|
103 | + print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>'; |
|
104 | +} |
|
105 | +if (isset($spotter_item['aircraft_type'])) { |
|
106 | + print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>'; |
|
107 | +} else { |
|
108 | + print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name']; |
|
109 | +} |
|
101 | 110 | print '</div>'; |
102 | 111 | print '<div id ="altitude"><span>'._("Altitude").'</span>'; |
103 | 112 | if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
@@ -106,7 +115,9 @@ discard block |
||
106 | 115 | print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')'; |
107 | 116 | } |
108 | 117 | print '</div>'; |
109 | -if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>'; |
|
118 | +if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') { |
|
119 | + print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>'; |
|
120 | +} |
|
110 | 121 | print '<div id="speed"><span>'._("Speed").'</span>'; |
111 | 122 | if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) { |
112 | 123 | print round($spotter_item['ground_speed']*1.15078).' mph'; |
@@ -120,8 +131,11 @@ discard block |
||
120 | 131 | print '<div id="heading"><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>'; |
121 | 132 | if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') { |
122 | 133 | print '<div id="pilot"><span>'._("Pilot").'</span>'; |
123 | - if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
124 | - else print $spotter_item['pilot_name']; |
|
134 | + if (isset($spotter_item['pilot_id'])) { |
|
135 | + print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
136 | + } else { |
|
137 | + print $spotter_item['pilot_name']; |
|
138 | + } |
|
125 | 139 | print '</div>'; |
126 | 140 | } |
127 | 141 | |
@@ -149,10 +163,18 @@ discard block |
||
149 | 163 | print '</div>'; |
150 | 164 | print '</div>'; |
151 | 165 | |
152 | -if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
|
153 | -if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
|
154 | -if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
155 | -if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
|
166 | +if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') { |
|
167 | + print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
|
168 | +} |
|
169 | +if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') { |
|
170 | + print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
|
171 | +} |
|
172 | +if (isset($spotter_item['acars']['message'])) { |
|
173 | + print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
174 | +} |
|
175 | +if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) { |
|
176 | + print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
|
177 | +} |
|
156 | 178 | print '</div>'; |
157 | 179 | ?> |
158 | 180 | </div> |
159 | 181 | \ No newline at end of file |
@@ -35,7 +35,9 @@ discard block |
||
35 | 35 | $temp += 1; |
36 | 36 | $flat = (float)($temp / (60.0 * 10000.0)); |
37 | 37 | $flat *= -1.0; |
38 | - } else $flat = (float)($temp / (60.0 * 10000.0)); |
|
38 | + } else { |
|
39 | + $flat = (float)($temp / (60.0 * 10000.0)); |
|
40 | + } |
|
39 | 41 | return $flat; // float |
40 | 42 | } |
41 | 43 | |
@@ -47,7 +49,9 @@ discard block |
||
47 | 49 | $temp += 1; |
48 | 50 | $flon = (float)($temp / (60.0 * 10000.0)); |
49 | 51 | $flon *= -1.0; |
50 | - } else $flon = (float)($temp / (60.0 * 10000.0)); |
|
52 | + } else { |
|
53 | + $flon = (float)($temp / (60.0 * 10000.0)); |
|
54 | + } |
|
51 | 55 | return $flon; |
52 | 56 | } |
53 | 57 | |
@@ -70,10 +74,8 @@ discard block |
||
70 | 74 | */ |
71 | 75 | private function asciidec_2_8bit($ascii) { |
72 | 76 | //only process in the following range: 48-87, 96-119 |
73 | - if ($ascii < 48) { } |
|
74 | - else { |
|
75 | - if($ascii>119) { } |
|
76 | - else { |
|
77 | + if ($ascii < 48) { } else { |
|
78 | + if($ascii>119) { } else { |
|
77 | 79 | if ($ascii>87 && $ascii<96) ; |
78 | 80 | else { |
79 | 81 | $ascii=$ascii+40; |
@@ -175,7 +177,9 @@ discard block |
||
175 | 177 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28))); |
176 | 178 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27))); |
177 | 179 | $ro->heading = bindec(substr($_aisdata,124,9)); |
178 | - if ($ro->heading == 511) $ro->heading = ''; |
|
180 | + if ($ro->heading == 511) { |
|
181 | + $ro->heading = ''; |
|
182 | + } |
|
179 | 183 | $ro->cls = 2; // class B |
180 | 184 | } else if ($ro->id == 19) { |
181 | 185 | $ro->cog = bindec(substr($_aisdata,112,12))/10; |
@@ -185,7 +189,9 @@ discard block |
||
185 | 189 | $ro->name = $this->binchar($_aisdata,143,120); |
186 | 190 | $ro->cls = 2; // class B |
187 | 191 | $ro->heading = bindec(substr($_aisdata,124,9)); |
188 | - if ($ro->heading == 511) $ro->heading = ''; |
|
192 | + if ($ro->heading == 511) { |
|
193 | + $ro->heading = ''; |
|
194 | + } |
|
189 | 195 | $ro->typeid = bindec(substr($_aisdata,263,8)); |
190 | 196 | $ro->type = $this->getShipType($ro->typeid); |
191 | 197 | //$ro->to_bow = bindec(substr($_aisdata,271,9)); |
@@ -216,9 +222,13 @@ discard block |
||
216 | 222 | $ro->cls = 2; // class B |
217 | 223 | } else if ($ro->id == 27) { |
218 | 224 | $ro->cog = bindec(substr($_aisdata,85,9)); |
219 | - if ($ro->cog == 511) $ro->cog = 0.0; |
|
225 | + if ($ro->cog == 511) { |
|
226 | + $ro->cog = 0.0; |
|
227 | + } |
|
220 | 228 | $ro->sog = bindec(substr($_aisdata,79,6)); |
221 | - if ($ro->sog == 63) $ro->sog = 0.0; |
|
229 | + if ($ro->sog == 63) { |
|
230 | + $ro->sog = 0.0; |
|
231 | + } |
|
222 | 232 | $ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10); |
223 | 233 | $ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10); |
224 | 234 | $ro->cls = 1; // class A |
@@ -267,88 +277,171 @@ discard block |
||
267 | 277 | } |
268 | 278 | |
269 | 279 | public function getShipType($code) { |
270 | - if ($code == 0) return 'Not available (default)'; |
|
271 | - elseif ($code >= 1 && $code <= 19) return 'Reserved for future use'; |
|
272 | - elseif ($code == 20) return 'Wing in ground (WIG), all ships of this type'; |
|
273 | - elseif ($code == 21) return 'Wing in ground (WIG), Hazardous category A'; |
|
274 | - elseif ($code == 22) return 'Wing in ground (WIG), Hazardous category B'; |
|
275 | - elseif ($code == 23) return 'Wing in ground (WIG), Hazardous category C'; |
|
276 | - elseif ($code == 24) return 'Wing in ground (WIG), Hazardous category D'; |
|
277 | - elseif ($code == 25) return 'Wing in ground (WIG), Reserved for future use'; |
|
278 | - elseif ($code == 26) return 'Wing in ground (WIG), Reserved for future use'; |
|
279 | - elseif ($code == 27) return 'Wing in ground (WIG), Reserved for future use'; |
|
280 | - elseif ($code == 28) return 'Wing in ground (WIG), Reserved for future use'; |
|
281 | - elseif ($code == 29) return 'Wing in ground (WIG), Reserved for future use'; |
|
282 | - elseif ($code == 30) return 'Fishing'; |
|
283 | - elseif ($code == 31) return 'Towing'; |
|
284 | - elseif ($code == 32) return 'Towing: length exceeds 200m or breadth exceeds 25m'; |
|
285 | - elseif ($code == 33) return 'Dredging or underwater ops'; |
|
286 | - elseif ($code == 34) return 'Diving ops'; |
|
287 | - elseif ($code == 35) return 'Military ops'; |
|
288 | - elseif ($code == 36) return 'Sailing'; |
|
289 | - elseif ($code == 37) return 'Pleasure Craft'; |
|
290 | - elseif ($code == 38) return 'Reserved'; |
|
291 | - elseif ($code == 39) return 'Reserved'; |
|
292 | - elseif ($code == 40) return 'High speed craft (HSC), all ships of this type'; |
|
293 | - elseif ($code == 41) return 'High speed craft (HSC), Hazardous category A'; |
|
294 | - elseif ($code == 42) return 'High speed craft (HSC), Hazardous category B'; |
|
295 | - elseif ($code == 43) return 'High speed craft (HSC), Hazardous category C'; |
|
296 | - elseif ($code == 44) return 'High speed craft (HSC), Hazardous category D'; |
|
297 | - elseif ($code == 45) return 'High speed craft (HSC), Reserved for future use'; |
|
298 | - elseif ($code == 46) return 'High speed craft (HSC), Reserved for future use'; |
|
299 | - elseif ($code == 47) return 'High speed craft (HSC), Reserved for future use'; |
|
300 | - elseif ($code == 48) return 'High speed craft (HSC), Reserved for future use'; |
|
301 | - elseif ($code == 49) return 'High speed craft (HSC), No additional information'; |
|
302 | - elseif ($code == 50) return 'Pilot Vessel'; |
|
303 | - elseif ($code == 51) return 'Search and Rescue vessel'; |
|
304 | - elseif ($code == 52) return 'Tug'; |
|
305 | - elseif ($code == 53) return 'Port Tender'; |
|
306 | - elseif ($code == 54) return 'Anti-pollution equipment'; |
|
307 | - elseif ($code == 55) return 'Law Enforcement'; |
|
308 | - elseif ($code == 56) return 'Spare - Local Vessel'; |
|
309 | - elseif ($code == 57) return 'Spare - Local Vessel'; |
|
310 | - elseif ($code == 58) return 'Medical Transport'; |
|
311 | - elseif ($code == 59) return 'Noncombatant ship according to RR Resolution No. 18'; |
|
312 | - elseif ($code == 60) return 'Passenger, all ships of this type'; |
|
313 | - elseif ($code == 61) return 'Passenger, Hazardous category A'; |
|
314 | - elseif ($code == 62) return 'Passenger, Hazardous category B'; |
|
315 | - elseif ($code == 63) return 'Passenger, Hazardous category C'; |
|
316 | - elseif ($code == 64) return 'Passenger, Hazardous category D'; |
|
317 | - elseif ($code == 65) return 'Passenger, Reserved for future use'; |
|
318 | - elseif ($code == 66) return 'Passenger, Reserved for future use'; |
|
319 | - elseif ($code == 67) return 'Passenger, Reserved for future use'; |
|
320 | - elseif ($code == 68) return 'Passenger, Reserved for future use'; |
|
321 | - elseif ($code == 69) return 'Passenger, No additional information'; |
|
322 | - elseif ($code == 70) return 'Cargo, all ships of this type'; |
|
323 | - elseif ($code == 71) return 'Cargo, Hazardous category A'; |
|
324 | - elseif ($code == 72) return 'Cargo, Hazardous category B'; |
|
325 | - elseif ($code == 73) return 'Cargo, Hazardous category C'; |
|
326 | - elseif ($code == 74) return 'Cargo, Hazardous category D'; |
|
327 | - elseif ($code == 75) return 'Cargo, Reserved for future use'; |
|
328 | - elseif ($code == 76) return 'Cargo, Reserved for future use'; |
|
329 | - elseif ($code == 77) return 'Cargo, Reserved for future use'; |
|
330 | - elseif ($code == 78) return 'Cargo, Reserved for future use'; |
|
331 | - elseif ($code == 79) return 'Cargo, No additional information'; |
|
332 | - elseif ($code == 80) return 'Tanker, all ships of this type'; |
|
333 | - elseif ($code == 81) return 'Tanker, Hazardous category A'; |
|
334 | - elseif ($code == 82) return 'Tanker, Hazardous category B'; |
|
335 | - elseif ($code == 83) return 'Tanker, Hazardous category C'; |
|
336 | - elseif ($code == 84) return 'Tanker, Hazardous category D'; |
|
337 | - elseif ($code == 85) return 'Tanker, Reserved for future use'; |
|
338 | - elseif ($code == 86) return 'Tanker, Reserved for future use'; |
|
339 | - elseif ($code == 87) return 'Tanker, Reserved for future use'; |
|
340 | - elseif ($code == 88) return 'Tanker, Reserved for future use'; |
|
341 | - elseif ($code == 89) return 'Tanker, No additional information'; |
|
342 | - elseif ($code == 90) return 'Other Type, all ships of this type'; |
|
343 | - elseif ($code == 91) return 'Other Type, Hazardous category A'; |
|
344 | - elseif ($code == 92) return 'Other Type, Hazardous category B'; |
|
345 | - elseif ($code == 93) return 'Other Type, Hazardous category C'; |
|
346 | - elseif ($code == 94) return 'Other Type, Hazardous category D'; |
|
347 | - elseif ($code == 95) return 'Other Type, Reserved for future use'; |
|
348 | - elseif ($code == 96) return 'Other Type, Reserved for future use'; |
|
349 | - elseif ($code == 97) return 'Other Type, Reserved for future use'; |
|
350 | - elseif ($code == 98) return 'Other Type, Reserved for future use'; |
|
351 | - elseif ($code == 99) return 'Other Type, no additional information'; |
|
280 | + if ($code == 0) { |
|
281 | + return 'Not available (default)'; |
|
282 | + } elseif ($code >= 1 && $code <= 19) { |
|
283 | + return 'Reserved for future use'; |
|
284 | + } elseif ($code == 20) { |
|
285 | + return 'Wing in ground (WIG), all ships of this type'; |
|
286 | + } elseif ($code == 21) { |
|
287 | + return 'Wing in ground (WIG), Hazardous category A'; |
|
288 | + } elseif ($code == 22) { |
|
289 | + return 'Wing in ground (WIG), Hazardous category B'; |
|
290 | + } elseif ($code == 23) { |
|
291 | + return 'Wing in ground (WIG), Hazardous category C'; |
|
292 | + } elseif ($code == 24) { |
|
293 | + return 'Wing in ground (WIG), Hazardous category D'; |
|
294 | + } elseif ($code == 25) { |
|
295 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
296 | + } elseif ($code == 26) { |
|
297 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
298 | + } elseif ($code == 27) { |
|
299 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
300 | + } elseif ($code == 28) { |
|
301 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
302 | + } elseif ($code == 29) { |
|
303 | + return 'Wing in ground (WIG), Reserved for future use'; |
|
304 | + } elseif ($code == 30) { |
|
305 | + return 'Fishing'; |
|
306 | + } elseif ($code == 31) { |
|
307 | + return 'Towing'; |
|
308 | + } elseif ($code == 32) { |
|
309 | + return 'Towing: length exceeds 200m or breadth exceeds 25m'; |
|
310 | + } elseif ($code == 33) { |
|
311 | + return 'Dredging or underwater ops'; |
|
312 | + } elseif ($code == 34) { |
|
313 | + return 'Diving ops'; |
|
314 | + } elseif ($code == 35) { |
|
315 | + return 'Military ops'; |
|
316 | + } elseif ($code == 36) { |
|
317 | + return 'Sailing'; |
|
318 | + } elseif ($code == 37) { |
|
319 | + return 'Pleasure Craft'; |
|
320 | + } elseif ($code == 38) { |
|
321 | + return 'Reserved'; |
|
322 | + } elseif ($code == 39) { |
|
323 | + return 'Reserved'; |
|
324 | + } elseif ($code == 40) { |
|
325 | + return 'High speed craft (HSC), all ships of this type'; |
|
326 | + } elseif ($code == 41) { |
|
327 | + return 'High speed craft (HSC), Hazardous category A'; |
|
328 | + } elseif ($code == 42) { |
|
329 | + return 'High speed craft (HSC), Hazardous category B'; |
|
330 | + } elseif ($code == 43) { |
|
331 | + return 'High speed craft (HSC), Hazardous category C'; |
|
332 | + } elseif ($code == 44) { |
|
333 | + return 'High speed craft (HSC), Hazardous category D'; |
|
334 | + } elseif ($code == 45) { |
|
335 | + return 'High speed craft (HSC), Reserved for future use'; |
|
336 | + } elseif ($code == 46) { |
|
337 | + return 'High speed craft (HSC), Reserved for future use'; |
|
338 | + } elseif ($code == 47) { |
|
339 | + return 'High speed craft (HSC), Reserved for future use'; |
|
340 | + } elseif ($code == 48) { |
|
341 | + return 'High speed craft (HSC), Reserved for future use'; |
|
342 | + } elseif ($code == 49) { |
|
343 | + return 'High speed craft (HSC), No additional information'; |
|
344 | + } elseif ($code == 50) { |
|
345 | + return 'Pilot Vessel'; |
|
346 | + } elseif ($code == 51) { |
|
347 | + return 'Search and Rescue vessel'; |
|
348 | + } elseif ($code == 52) { |
|
349 | + return 'Tug'; |
|
350 | + } elseif ($code == 53) { |
|
351 | + return 'Port Tender'; |
|
352 | + } elseif ($code == 54) { |
|
353 | + return 'Anti-pollution equipment'; |
|
354 | + } elseif ($code == 55) { |
|
355 | + return 'Law Enforcement'; |
|
356 | + } elseif ($code == 56) { |
|
357 | + return 'Spare - Local Vessel'; |
|
358 | + } elseif ($code == 57) { |
|
359 | + return 'Spare - Local Vessel'; |
|
360 | + } elseif ($code == 58) { |
|
361 | + return 'Medical Transport'; |
|
362 | + } elseif ($code == 59) { |
|
363 | + return 'Noncombatant ship according to RR Resolution No. 18'; |
|
364 | + } elseif ($code == 60) { |
|
365 | + return 'Passenger, all ships of this type'; |
|
366 | + } elseif ($code == 61) { |
|
367 | + return 'Passenger, Hazardous category A'; |
|
368 | + } elseif ($code == 62) { |
|
369 | + return 'Passenger, Hazardous category B'; |
|
370 | + } elseif ($code == 63) { |
|
371 | + return 'Passenger, Hazardous category C'; |
|
372 | + } elseif ($code == 64) { |
|
373 | + return 'Passenger, Hazardous category D'; |
|
374 | + } elseif ($code == 65) { |
|
375 | + return 'Passenger, Reserved for future use'; |
|
376 | + } elseif ($code == 66) { |
|
377 | + return 'Passenger, Reserved for future use'; |
|
378 | + } elseif ($code == 67) { |
|
379 | + return 'Passenger, Reserved for future use'; |
|
380 | + } elseif ($code == 68) { |
|
381 | + return 'Passenger, Reserved for future use'; |
|
382 | + } elseif ($code == 69) { |
|
383 | + return 'Passenger, No additional information'; |
|
384 | + } elseif ($code == 70) { |
|
385 | + return 'Cargo, all ships of this type'; |
|
386 | + } elseif ($code == 71) { |
|
387 | + return 'Cargo, Hazardous category A'; |
|
388 | + } elseif ($code == 72) { |
|
389 | + return 'Cargo, Hazardous category B'; |
|
390 | + } elseif ($code == 73) { |
|
391 | + return 'Cargo, Hazardous category C'; |
|
392 | + } elseif ($code == 74) { |
|
393 | + return 'Cargo, Hazardous category D'; |
|
394 | + } elseif ($code == 75) { |
|
395 | + return 'Cargo, Reserved for future use'; |
|
396 | + } elseif ($code == 76) { |
|
397 | + return 'Cargo, Reserved for future use'; |
|
398 | + } elseif ($code == 77) { |
|
399 | + return 'Cargo, Reserved for future use'; |
|
400 | + } elseif ($code == 78) { |
|
401 | + return 'Cargo, Reserved for future use'; |
|
402 | + } elseif ($code == 79) { |
|
403 | + return 'Cargo, No additional information'; |
|
404 | + } elseif ($code == 80) { |
|
405 | + return 'Tanker, all ships of this type'; |
|
406 | + } elseif ($code == 81) { |
|
407 | + return 'Tanker, Hazardous category A'; |
|
408 | + } elseif ($code == 82) { |
|
409 | + return 'Tanker, Hazardous category B'; |
|
410 | + } elseif ($code == 83) { |
|
411 | + return 'Tanker, Hazardous category C'; |
|
412 | + } elseif ($code == 84) { |
|
413 | + return 'Tanker, Hazardous category D'; |
|
414 | + } elseif ($code == 85) { |
|
415 | + return 'Tanker, Reserved for future use'; |
|
416 | + } elseif ($code == 86) { |
|
417 | + return 'Tanker, Reserved for future use'; |
|
418 | + } elseif ($code == 87) { |
|
419 | + return 'Tanker, Reserved for future use'; |
|
420 | + } elseif ($code == 88) { |
|
421 | + return 'Tanker, Reserved for future use'; |
|
422 | + } elseif ($code == 89) { |
|
423 | + return 'Tanker, No additional information'; |
|
424 | + } elseif ($code == 90) { |
|
425 | + return 'Other Type, all ships of this type'; |
|
426 | + } elseif ($code == 91) { |
|
427 | + return 'Other Type, Hazardous category A'; |
|
428 | + } elseif ($code == 92) { |
|
429 | + return 'Other Type, Hazardous category B'; |
|
430 | + } elseif ($code == 93) { |
|
431 | + return 'Other Type, Hazardous category C'; |
|
432 | + } elseif ($code == 94) { |
|
433 | + return 'Other Type, Hazardous category D'; |
|
434 | + } elseif ($code == 95) { |
|
435 | + return 'Other Type, Reserved for future use'; |
|
436 | + } elseif ($code == 96) { |
|
437 | + return 'Other Type, Reserved for future use'; |
|
438 | + } elseif ($code == 97) { |
|
439 | + return 'Other Type, Reserved for future use'; |
|
440 | + } elseif ($code == 98) { |
|
441 | + return 'Other Type, Reserved for future use'; |
|
442 | + } elseif ($code == 99) { |
|
443 | + return 'Other Type, no additional information'; |
|
444 | + } |
|
352 | 445 | } |
353 | 446 | |
354 | 447 | public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) { |
@@ -386,19 +479,34 @@ discard block |
||
386 | 479 | // assume 1st ! is valid |
387 | 480 | // find * ensure that it is at correct position |
388 | 481 | $end = strrpos ( $rawdata , '*' ); |
389 | - if ($end === FALSE) return -1; // check for NULLS!!! |
|
482 | + if ($end === FALSE) { |
|
483 | + return -1; |
|
484 | + } |
|
485 | + // check for NULLS!!! |
|
390 | 486 | $cs = substr( $rawdata, $end + 1 ); |
391 | - if ( strlen($cs) != 2 ) return -1; // correct cs length |
|
487 | + if ( strlen($cs) != 2 ) { |
|
488 | + return -1; |
|
489 | + } |
|
490 | + // correct cs length |
|
392 | 491 | $dcs = (int)hexdec( $cs ); |
393 | - for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum |
|
492 | + for ( $alias=1; $alias<$end; $alias++) { |
|
493 | + $chksum ^= ord( $rawdata[$alias] ); |
|
494 | + } |
|
495 | + // perform XOR for NMEA checksum |
|
394 | 496 | if ( $chksum == $dcs ) { // NMEA checksum pass |
395 | 497 | $pcs = explode(',', $rawdata); |
396 | 498 | // !AI??? identifier |
397 | 499 | $num_seq = (int)$pcs[1]; // number of sequences |
398 | 500 | $seq = (int)$pcs[2]; // get sequence |
399 | 501 | // get msg sequence id |
400 | - if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1 |
|
401 | - else $msg_sid = (int)$pcs[3]; // multipart message |
|
502 | + if ($pcs[3] == '') { |
|
503 | + $msg_sid = -1; |
|
504 | + } |
|
505 | + // non-multipart message, set to -1 |
|
506 | + else { |
|
507 | + $msg_sid = (int)$pcs[3]; |
|
508 | + } |
|
509 | + // multipart message |
|
402 | 510 | $ais_ch = $pcs[4]; // get AIS channel |
403 | 511 | // message sequence checking |
404 | 512 | if ($num_seq < 1 || $num_seq > 9) { |
@@ -459,10 +567,18 @@ discard block |
||
459 | 567 | //DEBUG echo "[$start $end $tst]\n"; |
460 | 568 | $result = $this->process_ais_raw( $tst, "" ); |
461 | 569 | $last_pos = $end + 1; |
462 | - } else break; |
|
570 | + } else { |
|
571 | + break; |
|
572 | + } |
|
573 | + } |
|
574 | + if ($last_pos > 0) { |
|
575 | + $cbuf = substr($cbuf, $last_pos); |
|
463 | 576 | } |
464 | - if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move... |
|
465 | - if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode... |
|
577 | + // move... |
|
578 | + if (strlen($cbuf) > 1024) { |
|
579 | + $cbuf = ""; |
|
580 | + } |
|
581 | + // prevent overflow simple mode... |
|
466 | 582 | return $result; |
467 | 583 | } |
468 | 584 | |
@@ -482,7 +598,9 @@ discard block |
||
482 | 598 | if ($lat<0.0) { |
483 | 599 | $lat = -$lat; |
484 | 600 | $neg=true; |
485 | - } else $neg=false; |
|
601 | + } else { |
|
602 | + $neg=false; |
|
603 | + } |
|
486 | 604 | $latd = 0x00000000; |
487 | 605 | $latd = intval ($lat * 600000.0); |
488 | 606 | if ($neg==true) { |
@@ -498,7 +616,9 @@ discard block |
||
498 | 616 | if ($lon<0.0) { |
499 | 617 | $lon = -$lon; |
500 | 618 | $neg=true; |
501 | - } else $neg=false; |
|
619 | + } else { |
|
620 | + $neg=false; |
|
621 | + } |
|
502 | 622 | $lond = 0x00000000; |
503 | 623 | $lond = intval ($lon * 600000.0); |
504 | 624 | if ($neg==true) { |
@@ -511,9 +631,14 @@ discard block |
||
511 | 631 | |
512 | 632 | private function char2bin($name, $max_len) { |
513 | 633 | $len = strlen($name); |
514 | - if ($len > $max_len) $name = substr($name,0,$max_len); |
|
515 | - if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6); |
|
516 | - else $pad = ''; |
|
634 | + if ($len > $max_len) { |
|
635 | + $name = substr($name,0,$max_len); |
|
636 | + } |
|
637 | + if ($len < $max_len) { |
|
638 | + $pad = str_repeat('0', ($max_len - $len) * 6); |
|
639 | + } else { |
|
640 | + $pad = ''; |
|
641 | + } |
|
517 | 642 | $rv = ''; |
518 | 643 | $ais_chars = array( |
519 | 644 | '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9, |
@@ -526,9 +651,12 @@ discard block |
||
526 | 651 | ); |
527 | 652 | // " |
528 | 653 | $_a = str_split($name); |
529 | - if ($_a) foreach ($_a as $_1) { |
|
654 | + if ($_a) { |
|
655 | + foreach ($_a as $_1) { |
|
530 | 656 | if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1]; |
531 | - else $dec = 0; |
|
657 | + } else { |
|
658 | + $dec = 0; |
|
659 | + } |
|
532 | 660 | $bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT); |
533 | 661 | $rv .= $bin; |
534 | 662 | //echo "$_1 $dec ($bin)<br/>"; |
@@ -540,7 +668,9 @@ discard block |
||
540 | 668 | $len_bit = strlen($_enc); |
541 | 669 | $rem6 = $len_bit % 6; |
542 | 670 | $pad6_len = 0; |
543 | - if ($rem6) $pad6_len = 6 - $rem6; |
|
671 | + if ($rem6) { |
|
672 | + $pad6_len = 6 - $rem6; |
|
673 | + } |
|
544 | 674 | //echo $pad6_len.'<br>'; |
545 | 675 | $_enc .= str_repeat("0", $pad6_len); // pad the text... |
546 | 676 | $len_enc = strlen($_enc) / 6; |
@@ -549,8 +679,11 @@ discard block |
||
549 | 679 | for ($i=0; $i<$len_enc; $i++) { |
550 | 680 | $offset = $i * 6; |
551 | 681 | $dec = bindec(substr($_enc,$offset,6)); |
552 | - if ($dec < 40) $dec += 48; |
|
553 | - else $dec += 56; |
|
682 | + if ($dec < 40) { |
|
683 | + $dec += 48; |
|
684 | + } else { |
|
685 | + $dec += 56; |
|
686 | + } |
|
554 | 687 | //echo chr($dec)." $dec<br/>"; |
555 | 688 | $itu .= chr($dec); |
556 | 689 | } |
@@ -563,25 +696,41 @@ discard block |
||
563 | 696 | } |
564 | 697 | $hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
565 | 698 | $lsb = $chksum & 0x0F; |
566 | - if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb]; |
|
567 | - else $lsbc = '0'; |
|
699 | + if ($lsb >=0 && $lsb <= 15 ) { |
|
700 | + $lsbc = $hex_arr[$lsb]; |
|
701 | + } else { |
|
702 | + $lsbc = '0'; |
|
703 | + } |
|
568 | 704 | $msb = (($chksum & 0xF0) >> 4) & 0x0F; |
569 | - if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb]; |
|
570 | - else $msbc = '0'; |
|
705 | + if ($msb >=0 && $msb <= 15 ) { |
|
706 | + $msbc = $hex_arr[$msb]; |
|
707 | + } else { |
|
708 | + $msbc = '0'; |
|
709 | + } |
|
571 | 710 | $itu = '!'.$itu."*{$msbc}{$lsbc}\r\n"; |
572 | 711 | return $itu; |
573 | 712 | } |
574 | 713 | |
575 | 714 | public function parse($buffer) { |
576 | 715 | $data = $this->process_ais_buf($buffer); |
577 | - if (!is_object($data)) return array(); |
|
578 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
579 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
716 | + if (!is_object($data)) { |
|
717 | + return array(); |
|
718 | + } |
|
719 | + if ($data->lon != 0) { |
|
720 | + $result['longitude'] = $data->lon; |
|
721 | + } |
|
722 | + if ($data->lat != 0) { |
|
723 | + $result['latitude'] = $data->lat; |
|
724 | + } |
|
580 | 725 | $result['ident'] = trim($data->name); |
581 | 726 | $result['timestamp'] = $data->ts; |
582 | 727 | $result['mmsi'] = $data->mmsi; |
583 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
584 | - if ($data->cog != 0) $result['heading'] = $data->cog; |
|
728 | + if ($data->sog != -1.0) { |
|
729 | + $result['speed'] = $data->sog; |
|
730 | + } |
|
731 | + if ($data->cog != 0) { |
|
732 | + $result['heading'] = $data->cog; |
|
733 | + } |
|
585 | 734 | /* |
586 | 735 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
587 | 736 | $ro->id = bindec(substr($_aisdata,0,6)); |
@@ -591,15 +740,25 @@ discard block |
||
591 | 740 | |
592 | 741 | public function mmsitype($mmsi) { |
593 | 742 | if (strlen($mmsi) == 9) { |
594 | - if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
595 | - elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device'; |
|
596 | - elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)'; |
|
597 | - elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft'; |
|
598 | - elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship'; |
|
599 | - elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation'; |
|
600 | - elseif (substr($mmsi,0,2) == '00') return 'Coastal stations'; |
|
601 | - elseif (substr($mmsi,0,1) == '0') return 'Group of ships'; |
|
602 | - else return 'Ship'; |
|
743 | + if (substr($mmsi,0,3) == '974') { |
|
744 | + return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS'; |
|
745 | + } elseif (substr($mmsi,0,3) == '972') { |
|
746 | + return 'MOB (Man Overboard) device'; |
|
747 | + } elseif (substr($mmsi,0,3) == '970') { |
|
748 | + return 'AIS SART (Search and Rescue Transmitter)'; |
|
749 | + } elseif (substr($mmsi,0,3) == '111') { |
|
750 | + return 'SAR (Search and Rescue) aircraft'; |
|
751 | + } elseif (substr($mmsi,0,2) == '98') { |
|
752 | + return 'Auxiliary craft associated with a parent ship'; |
|
753 | + } elseif (substr($mmsi,0,2) == '99') { |
|
754 | + return 'Aids to Navigation'; |
|
755 | + } elseif (substr($mmsi,0,2) == '00') { |
|
756 | + return 'Coastal stations'; |
|
757 | + } elseif (substr($mmsi,0,1) == '0') { |
|
758 | + return 'Group of ships'; |
|
759 | + } else { |
|
760 | + return 'Ship'; |
|
761 | + } |
|
603 | 762 | } |
604 | 763 | |
605 | 764 | |
@@ -616,25 +775,48 @@ discard block |
||
616 | 775 | //if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n"; |
617 | 776 | return array(); |
618 | 777 | } |
619 | - if ($data->lon != 0) $result['longitude'] = $data->lon; |
|
620 | - if ($data->lat != 0) $result['latitude'] = $data->lat; |
|
778 | + if ($data->lon != 0) { |
|
779 | + $result['longitude'] = $data->lon; |
|
780 | + } |
|
781 | + if ($data->lat != 0) { |
|
782 | + $result['latitude'] = $data->lat; |
|
783 | + } |
|
621 | 784 | $result['ident'] = trim(str_replace('@','',$data->name)); |
622 | 785 | $result['timestamp'] = $data->ts; |
623 | 786 | $result['mmsi'] = $data->mmsi; |
624 | - if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi']; |
|
787 | + if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') { |
|
788 | + $result['mmsi'] = '3'.$result['mmsi']; |
|
789 | + } |
|
625 | 790 | $result['mmsi_type'] = $this->mmsitype($result['mmsi']); |
626 | - if ($data->sog != -1.0) $result['speed'] = $data->sog; |
|
627 | - if ($data->heading != '') $result['heading'] = $data->heading; |
|
628 | - elseif ($data->cog != 0) $result['heading'] = $data->cog; |
|
629 | - if ($data->status != '') $result['status'] = $data->status; |
|
630 | - if ($data->type != '') $result['type'] = $data->type; |
|
631 | - if ($data->typeid != '') $result['typeid'] = $data->typeid; |
|
632 | - if ($data->imo != '') $result['imo'] = $data->imo; |
|
633 | - if ($data->callsign != '') $result['callsign'] = $data->callsign; |
|
791 | + if ($data->sog != -1.0) { |
|
792 | + $result['speed'] = $data->sog; |
|
793 | + } |
|
794 | + if ($data->heading != '') { |
|
795 | + $result['heading'] = $data->heading; |
|
796 | + } elseif ($data->cog != 0) { |
|
797 | + $result['heading'] = $data->cog; |
|
798 | + } |
|
799 | + if ($data->status != '') { |
|
800 | + $result['status'] = $data->status; |
|
801 | + } |
|
802 | + if ($data->type != '') { |
|
803 | + $result['type'] = $data->type; |
|
804 | + } |
|
805 | + if ($data->typeid != '') { |
|
806 | + $result['typeid'] = $data->typeid; |
|
807 | + } |
|
808 | + if ($data->imo != '') { |
|
809 | + $result['imo'] = $data->imo; |
|
810 | + } |
|
811 | + if ($data->callsign != '') { |
|
812 | + $result['callsign'] = $data->callsign; |
|
813 | + } |
|
634 | 814 | if ($data->eta_month != '' && $data->eta_day != '' && $data->eta_hour != '' && $data->eta_minute != '') { |
635 | 815 | $result['eta_ts'] = strtotime(date('Y').'-'.$data->eta_month.'-'.$data->eta_day.' '.$data->eta_hour.':'.$data->eta_minute.':00'); |
636 | 816 | } |
637 | - if ($data->destination != '') $result['destination'] = $data->destination; |
|
817 | + if ($data->destination != '') { |
|
818 | + $result['destination'] = $data->destination; |
|
819 | + } |
|
638 | 820 | $result['all'] = (array) $data; |
639 | 821 | /* |
640 | 822 | $ro->cls = 0; // AIS class undefined, also indicate unparsed msg |
@@ -107,17 +107,23 @@ discard block |
||
107 | 107 | |
108 | 108 | /* Check that end was found and body has at least one byte. */ |
109 | 109 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
110 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
110 | + if ($globalDebug) { |
|
111 | + echo '!!! APRS invalid : '.$input."\n"; |
|
112 | + } |
|
111 | 113 | return false; |
112 | 114 | } |
113 | 115 | |
114 | - if ($debug) echo 'input : '.$input."\n"; |
|
116 | + if ($debug) { |
|
117 | + echo 'input : '.$input."\n"; |
|
118 | + } |
|
115 | 119 | /* Save header and body. */ |
116 | 120 | $body = substr($input,$splitpos+1,$input_len); |
117 | 121 | $body_len = strlen($body); |
118 | 122 | $header = substr($input,0,$splitpos); |
119 | 123 | //$header_len = strlen($header); |
120 | - if ($debug) echo 'header : '.$header."\n"; |
|
124 | + if ($debug) { |
|
125 | + echo 'header : '.$header."\n"; |
|
126 | + } |
|
121 | 127 | |
122 | 128 | /* Parse source, target and path. */ |
123 | 129 | //FLRDF0A52>APRS,qAS,LSTB |
@@ -131,10 +137,14 @@ discard block |
||
131 | 137 | $result['format_source'] = 'famaprs'; |
132 | 138 | $result['source_type'] = 'ais'; |
133 | 139 | } else { |
134 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
140 | + if ($debug) { |
|
141 | + echo 'ident : '.$ident."\n"; |
|
142 | + } |
|
135 | 143 | $result['ident'] = $ident; |
136 | 144 | } |
137 | - } else return false; |
|
145 | + } else { |
|
146 | + return false; |
|
147 | + } |
|
138 | 148 | $elements = explode(',',$all_elements); |
139 | 149 | $source = end($elements); |
140 | 150 | $result['source'] = $source; |
@@ -143,7 +153,9 @@ discard block |
||
143 | 153 | //echo "ok"; |
144 | 154 | //if ($element == 'TCPIP*') return false; |
145 | 155 | } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
146 | - if ($debug) echo 'element : '.$element."\n"; |
|
156 | + if ($debug) { |
|
157 | + echo 'element : '.$element."\n"; |
|
158 | + } |
|
147 | 159 | return false; |
148 | 160 | } |
149 | 161 | /* |
@@ -156,13 +168,17 @@ discard block |
||
156 | 168 | } |
157 | 169 | |
158 | 170 | $type = substr($body,0,1); |
159 | - if ($debug) echo 'type : '.$type."\n"; |
|
171 | + if ($debug) { |
|
172 | + echo 'type : '.$type."\n"; |
|
173 | + } |
|
160 | 174 | if ($type == ';') { |
161 | 175 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
162 | 176 | $result['address'] = trim(substr($body,1,9)); |
163 | 177 | } elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { |
164 | 178 | $result['mmsi'] = trim(substr($body,1,9)); |
165 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
179 | + } else { |
|
180 | + $result['ident'] = trim(substr($body,1,9)); |
|
181 | + } |
|
166 | 182 | } elseif ($type == ',') { |
167 | 183 | // Invalid data or test data |
168 | 184 | return false; |
@@ -230,7 +246,9 @@ discard block |
||
230 | 246 | //$symbol_table = $matches[4]; |
231 | 247 | $lat = intval($lat_deg); |
232 | 248 | $lon = intval($lon_deg); |
233 | - if ($lat > 89 || $lon > 179) return false; |
|
249 | + if ($lat > 89 || $lon > 179) { |
|
250 | + return false; |
|
251 | + } |
|
234 | 252 | |
235 | 253 | /* |
236 | 254 | $tmp_5b = str_replace('.','',$lat_min); |
@@ -240,8 +258,12 @@ discard block |
||
240 | 258 | */ |
241 | 259 | $latitude = $lat + floatval($lat_min)/60; |
242 | 260 | $longitude = $lon + floatval($lon_min)/60; |
243 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
244 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
261 | + if ($sind == 'S') { |
|
262 | + $latitude = 0-$latitude; |
|
263 | + } |
|
264 | + if ($wind == 'W') { |
|
265 | + $longitude = 0-$longitude; |
|
266 | + } |
|
245 | 267 | $result['latitude'] = $latitude; |
246 | 268 | $result['longitude'] = $longitude; |
247 | 269 | $body_parse = substr($body_parse,18); |
@@ -275,7 +297,9 @@ discard block |
||
275 | 297 | $body_parse = substr($body_parse,1); |
276 | 298 | $body_parse_len = strlen($body_parse); |
277 | 299 | $result['symbol_code'] = $symbol_code; |
278 | - if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
|
300 | + if (isset($this->symbols[$symbol_code])) { |
|
301 | + $result['symbol'] = $this->symbols[$symbol_code]; |
|
302 | + } |
|
279 | 303 | if ($symbol_code != '_') { |
280 | 304 | } |
281 | 305 | //$body_parse = substr($body_parse,1); |
@@ -286,7 +310,9 @@ discard block |
||
286 | 310 | if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
287 | 311 | $course = substr($body_parse,0,3); |
288 | 312 | $tmp_s = intval($course); |
289 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
313 | + if ($tmp_s >= 1 && $tmp_s <= 360) { |
|
314 | + $result['heading'] = intval($course); |
|
315 | + } |
|
290 | 316 | $speed = substr($body_parse,4,3); |
291 | 317 | if ($speed != '...') { |
292 | 318 | //$result['speed'] = round($speed*1.852); |
@@ -327,10 +353,16 @@ discard block |
||
327 | 353 | $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
328 | 354 | $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
329 | 355 | |
330 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
|
331 | - else $result['latitude'] += $lat_off; |
|
332 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
|
333 | - else $result['longitude'] += $lon_off; |
|
356 | + if ($result['latitude'] < 0) { |
|
357 | + $result['latitude'] -= $lat_off; |
|
358 | + } else { |
|
359 | + $result['latitude'] += $lat_off; |
|
360 | + } |
|
361 | + if ($result['longitude'] < 0) { |
|
362 | + $result['longitude'] -= $lon_off; |
|
363 | + } else { |
|
364 | + $result['longitude'] += $lon_off; |
|
365 | + } |
|
334 | 366 | } |
335 | 367 | |
336 | 368 | $body_parse = substr($body_parse,6); |
@@ -366,27 +398,48 @@ discard block |
||
366 | 398 | $address = substr($id,2); |
367 | 399 | //print_r($matches); |
368 | 400 | $addressType = (intval(substr($id,0,2),16))&3; |
369 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
|
370 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
|
371 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
|
372 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
|
401 | + if ($addressType == 0) { |
|
402 | + $result['addresstype'] = "RANDOM"; |
|
403 | + } elseif ($addressType == 1) { |
|
404 | + $result['addresstype'] = "ICAO"; |
|
405 | + } elseif ($addressType == 2) { |
|
406 | + $result['addresstype'] = "FLARM"; |
|
407 | + } elseif ($addressType == 3) { |
|
408 | + $result['addresstype'] = "OGN"; |
|
409 | + } |
|
373 | 410 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
374 | 411 | $result['aircrafttype_code'] = $aircraftType; |
375 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
|
376 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
|
377 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; |
|
378 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
379 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; |
|
380 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; |
|
381 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; |
|
382 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; |
|
383 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
384 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
385 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; |
|
386 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; |
|
387 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
|
388 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
|
389 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
|
412 | + if ($aircraftType == 0) { |
|
413 | + $result['aircrafttype'] = "UNKNOWN"; |
|
414 | + } elseif ($aircraftType == 1) { |
|
415 | + $result['aircrafttype'] = "GLIDER"; |
|
416 | + } elseif ($aircraftType == 2) { |
|
417 | + $result['aircrafttype'] = "TOW_PLANE"; |
|
418 | + } elseif ($aircraftType == 3) { |
|
419 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
420 | + } elseif ($aircraftType == 4) { |
|
421 | + $result['aircrafttype'] = "PARACHUTE"; |
|
422 | + } elseif ($aircraftType == 5) { |
|
423 | + $result['aircrafttype'] = "DROP_PLANE"; |
|
424 | + } elseif ($aircraftType == 6) { |
|
425 | + $result['aircrafttype'] = "HANG_GLIDER"; |
|
426 | + } elseif ($aircraftType == 7) { |
|
427 | + $result['aircrafttype'] = "PARA_GLIDER"; |
|
428 | + } elseif ($aircraftType == 8) { |
|
429 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
430 | + } elseif ($aircraftType == 9) { |
|
431 | + $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
432 | + } elseif ($aircraftType == 10) { |
|
433 | + $result['aircrafttype'] = "UFO"; |
|
434 | + } elseif ($aircraftType == 11) { |
|
435 | + $result['aircrafttype'] = "BALLOON"; |
|
436 | + } elseif ($aircraftType == 12) { |
|
437 | + $result['aircrafttype'] = "AIRSHIP"; |
|
438 | + } elseif ($aircraftType == 13) { |
|
439 | + $result['aircrafttype'] = "UAV"; |
|
440 | + } elseif ($aircraftType == 15) { |
|
441 | + $result['aircrafttype'] = "STATIC_OBJECT"; |
|
442 | + } |
|
390 | 443 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
391 | 444 | $result['stealth'] = $stealth; |
392 | 445 | $result['address'] = $address; |
@@ -426,13 +479,21 @@ discard block |
||
426 | 479 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
427 | 480 | } |
428 | 481 | } |
429 | - } else $result['comment'] = trim($body_parse); |
|
482 | + } else { |
|
483 | + $result['comment'] = trim($body_parse); |
|
484 | + } |
|
430 | 485 | |
431 | 486 | } |
432 | 487 | //} |
433 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
434 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
435 | - if ($debug) print_r($result); |
|
488 | + if (isset($result['latitude'])) { |
|
489 | + $result['latitude'] = round($result['latitude'],4); |
|
490 | + } |
|
491 | + if (isset($result['longitude'])) { |
|
492 | + $result['longitude'] = round($result['longitude'],4); |
|
493 | + } |
|
494 | + if ($debug) { |
|
495 | + print_r($result); |
|
496 | + } |
|
436 | 497 | return $result; |
437 | 498 | } |
438 | 499 | |
@@ -441,12 +502,21 @@ discard block |
||
441 | 502 | $aprs_connect = 0; |
442 | 503 | $aprs_keep = 120; |
443 | 504 | $aprs_last_tx = time(); |
444 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
445 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
446 | - if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
|
447 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
448 | - if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
|
449 | - else $aprs_pass = '-1'; |
|
505 | + if (isset($globalAPRSversion)) { |
|
506 | + $aprs_version = $globalAPRSversion; |
|
507 | + } else { |
|
508 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
509 | + } |
|
510 | + if (isset($globalServerAPRSssid)) { |
|
511 | + $aprs_ssid = $globalServerAPRSssid; |
|
512 | + } else { |
|
513 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
514 | + } |
|
515 | + if (isset($globalServerAPRSpass)) { |
|
516 | + $aprs_pass = $globalServerAPRSpass; |
|
517 | + } else { |
|
518 | + $aprs_pass = '-1'; |
|
519 | + } |
|
450 | 520 | |
451 | 521 | $aprs_filter = ''; |
452 | 522 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
@@ -478,7 +548,9 @@ discard block |
||
478 | 548 | } |
479 | 549 | |
480 | 550 | public function send($data) { |
481 | - if ($this->connected === false) $this->connect(); |
|
551 | + if ($this->connected === false) { |
|
552 | + $this->connect(); |
|
553 | + } |
|
482 | 554 | $send = socket_send( $this->socket , $data , strlen($data),0); |
483 | 555 | if ($send === FALSE) { |
484 | 556 | socket_close($this->socket); |
@@ -500,18 +572,26 @@ discard block |
||
500 | 572 | //$w = '00'; |
501 | 573 | $custom = ''; |
502 | 574 | if ($ident != '') { |
503 | - if ($custom != '') $custom .= '/'; |
|
575 | + if ($custom != '') { |
|
576 | + $custom .= '/'; |
|
577 | + } |
|
504 | 578 | $custom .= 'CS='.$ident; |
505 | 579 | } |
506 | 580 | if ($squawk != '') { |
507 | - if ($custom != '') $custom .= '/'; |
|
581 | + if ($custom != '') { |
|
582 | + $custom .= '/'; |
|
583 | + } |
|
508 | 584 | $custom .= 'SQ='.$squawk; |
509 | 585 | } |
510 | 586 | if ($aircraft_icao != '' && $aircraft_icao != 'NA') { |
511 | - if ($custom != '') $custom .= '/'; |
|
587 | + if ($custom != '') { |
|
588 | + $custom .= '/'; |
|
589 | + } |
|
512 | 590 | $custom .= 'AI='.$aircraft_icao; |
513 | 591 | } |
514 | - if ($custom != '') $custom = ' '.$custom; |
|
592 | + if ($custom != '') { |
|
593 | + $custom = ' '.$custom; |
|
594 | + } |
|
515 | 595 | $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
516 | 596 | } |
517 | 597 | } |
@@ -529,26 +609,38 @@ discard block |
||
529 | 609 | //$w = '00'; |
530 | 610 | $custom = ''; |
531 | 611 | if ($ident != '') { |
532 | - if ($custom != '') $custom .= '/'; |
|
612 | + if ($custom != '') { |
|
613 | + $custom .= '/'; |
|
614 | + } |
|
533 | 615 | $custom .= 'CS='.$ident; |
534 | 616 | } |
535 | 617 | if ($typeid != '') { |
536 | - if ($custom != '') $custom .= '/'; |
|
618 | + if ($custom != '') { |
|
619 | + $custom .= '/'; |
|
620 | + } |
|
537 | 621 | $custom .= 'TI='.$typeid; |
538 | 622 | } |
539 | 623 | if ($imo != '') { |
540 | - if ($custom != '') $custom .= '/'; |
|
624 | + if ($custom != '') { |
|
625 | + $custom .= '/'; |
|
626 | + } |
|
541 | 627 | $custom .= 'IMO='.$imo; |
542 | 628 | } |
543 | 629 | if ($arrival_date != '') { |
544 | - if ($custom != '') $custom .= '/'; |
|
630 | + if ($custom != '') { |
|
631 | + $custom .= '/'; |
|
632 | + } |
|
545 | 633 | $custom .= 'AD='.strtotime($arrival_date); |
546 | 634 | } |
547 | 635 | if ($arrival_code != '') { |
548 | - if ($custom != '') $custom .= '/'; |
|
636 | + if ($custom != '') { |
|
637 | + $custom .= '/'; |
|
638 | + } |
|
549 | 639 | $custom .= 'AC='.$arrival_code; |
550 | 640 | } |
551 | - if ($custom != '') $custom = ' '.$custom; |
|
641 | + if ($custom != '') { |
|
642 | + $custom = ' '.$custom; |
|
643 | + } |
|
552 | 644 | $altitude = 0; |
553 | 645 | $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
554 | 646 | } |
@@ -13,13 +13,17 @@ discard block |
||
13 | 13 | require_once(dirname(__FILE__).'/../require/class.SBS.php'); |
14 | 14 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
16 | +if (isset($globalTracker) && $globalTracker) { |
|
17 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
|
18 | +} |
|
17 | 19 | if (isset($globalMarine) && $globalMarine) { |
18 | 20 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
19 | 21 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
20 | 22 | } |
21 | 23 | |
22 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
24 | +if (!isset($globalDebug)) { |
|
25 | + $globalDebug = FALSE; |
|
26 | +} |
|
23 | 27 | |
24 | 28 | // Check if schema is at latest version |
25 | 29 | $Connection = new Connection(); |
@@ -54,35 +58,62 @@ discard block |
||
54 | 58 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 59 | if (isset($options['s'])) { |
56 | 60 | $globalSources = array(); |
57 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | - else $globalSources[] = array('host' => $options['s']); |
|
59 | -} elseif (isset($options['source'])) { |
|
61 | + if (isset($options['format'])) { |
|
62 | + $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | + } else { |
|
64 | + $globalSources[] = array('host' => $options['s']); |
|
65 | + } |
|
66 | + } elseif (isset($options['source'])) { |
|
60 | 67 | $globalSources = array(); |
61 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | - else $globalSources[] = array('host' => $options['source']); |
|
63 | -} |
|
68 | + if (isset($options['format'])) { |
|
69 | + $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
70 | + } else { |
|
71 | + $globalSources[] = array('host' => $options['source']); |
|
72 | + } |
|
73 | + } |
|
64 | 74 | if (isset($options['aprsserverhost'])) { |
65 | 75 | $globalServerAPRS = TRUE; |
66 | 76 | $globalServerAPRShost = $options['aprsserverhost']; |
67 | 77 | } |
68 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; |
|
69 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; |
|
70 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; |
|
71 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; |
|
72 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; |
|
73 | -if (isset($options['server'])) $globalServer = TRUE; |
|
74 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
75 | -else $id_source = 1; |
|
78 | +if (isset($options['aprsserverport'])) { |
|
79 | + $globalServerAPRSport = $options['aprsserverport']; |
|
80 | +} |
|
81 | +if (isset($options['aprsserverssid'])) { |
|
82 | + $globalServerAPRSssid = $options['aprsserverssid']; |
|
83 | +} |
|
84 | +if (isset($options['aprsserverpass'])) { |
|
85 | + $globalServerAPRSpass = $options['aprsserverpass']; |
|
86 | +} |
|
87 | +if (isset($options['noaprsserver'])) { |
|
88 | + $globalServerAPRS = FALSE; |
|
89 | +} |
|
90 | +if (isset($options['nodaemon'])) { |
|
91 | + $globalDaemon = FALSE; |
|
92 | +} |
|
93 | +if (isset($options['server'])) { |
|
94 | + $globalServer = TRUE; |
|
95 | +} |
|
96 | +if (isset($options['idsource'])) { |
|
97 | + $id_source = $options['idsource']; |
|
98 | +} else { |
|
99 | + $id_source = 1; |
|
100 | +} |
|
76 | 101 | if (isset($globalServer) && $globalServer) { |
77 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
102 | + if ($globalDebug) { |
|
103 | + echo "Using Server Mode\n"; |
|
104 | + } |
|
78 | 105 | $SI=new SpotterServer(); |
79 | 106 | /* |
80 | 107 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
81 | 108 | $SI = new adsb2aprs(); |
82 | 109 | $SI->connect(); |
83 | 110 | */ |
84 | -} else $SI=new SpotterImport($Connection->db); |
|
85 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
|
111 | +} else { |
|
112 | + $SI=new SpotterImport($Connection->db); |
|
113 | +} |
|
114 | +if (isset($globalTracker) && $globalTracker) { |
|
115 | + $TI = new TrackerImport($Connection->db); |
|
116 | +} |
|
86 | 117 | if (isset($globalMarine) && $globalMarine) { |
87 | 118 | $AIS = new AIS(); |
88 | 119 | $MI = new MarineImport($Connection->db); |
@@ -104,7 +135,9 @@ discard block |
||
104 | 135 | } |
105 | 136 | |
106 | 137 | // let's try and connect |
107 | -if ($globalDebug) echo "Connecting...\n"; |
|
138 | +if ($globalDebug) { |
|
139 | + echo "Connecting...\n"; |
|
140 | +} |
|
108 | 141 | $use_aprs = false; |
109 | 142 | $aprs_full = false; |
110 | 143 | $reset = 0; |
@@ -113,7 +146,9 @@ discard block |
||
113 | 146 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
114 | 147 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
115 | 148 | $reset++; |
116 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
149 | + if ($globalDebug) { |
|
150 | + echo 'Connect to all...'."\n"; |
|
151 | + } |
|
117 | 152 | foreach ($hosts as $id => $value) { |
118 | 153 | $host = $value['host']; |
119 | 154 | $globalSources[$id]['last_exec'] = 0; |
@@ -123,27 +158,37 @@ discard block |
||
123 | 158 | //$formats[$id] = 'deltadbtxt'; |
124 | 159 | $globalSources[$id]['format'] = 'deltadbtxt'; |
125 | 160 | //$last_exec['deltadbtxt'] = 0; |
126 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
161 | + if ($globalDebug) { |
|
162 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
163 | + } |
|
127 | 164 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
128 | 165 | //$formats[$id] = 'vatsimtxt'; |
129 | 166 | $globalSources[$id]['format'] = 'vatsimtxt'; |
130 | 167 | //$last_exec['vatsimtxt'] = 0; |
131 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
168 | + if ($globalDebug) { |
|
169 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
170 | + } |
|
132 | 171 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
133 | 172 | //$formats[$id] = 'aircraftlistjson'; |
134 | 173 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
135 | 174 | //$last_exec['aircraftlistjson'] = 0; |
136 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
175 | + if ($globalDebug) { |
|
176 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
177 | + } |
|
137 | 178 | } else if (preg_match('/opensky/i',$host)) { |
138 | 179 | //$formats[$id] = 'aircraftlistjson'; |
139 | 180 | $globalSources[$id]['format'] = 'opensky'; |
140 | 181 | //$last_exec['aircraftlistjson'] = 0; |
141 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
182 | + if ($globalDebug) { |
|
183 | + echo "Connect to opensky source (".$host.")...\n"; |
|
184 | + } |
|
142 | 185 | } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
143 | 186 | //$formats[$id] = 'radarvirtueljson'; |
144 | 187 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
145 | 188 | //$last_exec['radarvirtueljson'] = 0; |
146 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
189 | + if ($globalDebug) { |
|
190 | + echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
191 | + } |
|
147 | 192 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
148 | 193 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
149 | 194 | exit(0); |
@@ -152,7 +197,9 @@ discard block |
||
152 | 197 | //$formats[$id] = 'planeupdatefaa'; |
153 | 198 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
154 | 199 | //$last_exec['planeupdatefaa'] = 0; |
155 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
200 | + if ($globalDebug) { |
|
201 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
202 | + } |
|
156 | 203 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
157 | 204 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
158 | 205 | exit(0); |
@@ -161,26 +208,36 @@ discard block |
||
161 | 208 | //$formats[$id] = 'phpvmacars'; |
162 | 209 | $globalSources[$id]['format'] = 'phpvmacars'; |
163 | 210 | //$last_exec['phpvmacars'] = 0; |
164 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
211 | + if ($globalDebug) { |
|
212 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
213 | + } |
|
165 | 214 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
166 | 215 | //$formats[$id] = 'phpvmacars'; |
167 | 216 | $globalSources[$id]['format'] = 'vam'; |
168 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
217 | + if ($globalDebug) { |
|
218 | + echo "Connect to Vam source (".$host.")...\n"; |
|
219 | + } |
|
169 | 220 | } else if (preg_match('/whazzup/i',$host)) { |
170 | 221 | //$formats[$id] = 'whazzup'; |
171 | 222 | $globalSources[$id]['format'] = 'whazzup'; |
172 | 223 | //$last_exec['whazzup'] = 0; |
173 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
224 | + if ($globalDebug) { |
|
225 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
226 | + } |
|
174 | 227 | } else if (preg_match('/recentpireps/i',$host)) { |
175 | 228 | //$formats[$id] = 'pirepsjson'; |
176 | 229 | $globalSources[$id]['format'] = 'pirepsjson'; |
177 | 230 | //$last_exec['pirepsjson'] = 0; |
178 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
231 | + if ($globalDebug) { |
|
232 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
233 | + } |
|
179 | 234 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
180 | 235 | //$formats[$id] = 'fr24json'; |
181 | 236 | $globalSources[$id]['format'] = 'fr24json'; |
182 | 237 | //$last_exec['fr24json'] = 0; |
183 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
238 | + if ($globalDebug) { |
|
239 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
240 | + } |
|
184 | 241 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
185 | 242 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
186 | 243 | exit(0); |
@@ -189,7 +246,9 @@ discard block |
||
189 | 246 | //$formats[$id] = 'fr24json'; |
190 | 247 | $globalSources[$id]['format'] = 'myshiptracking'; |
191 | 248 | //$last_exec['fr24json'] = 0; |
192 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
249 | + if ($globalDebug) { |
|
250 | + echo "Connect to myshiptracking source (".$host.")...\n"; |
|
251 | + } |
|
193 | 252 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
194 | 253 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
195 | 254 | exit(0); |
@@ -198,17 +257,24 @@ discard block |
||
198 | 257 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
199 | 258 | //$formats[$id] = 'tsv'; |
200 | 259 | $globalSources[$id]['format'] = 'tsv'; |
201 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
260 | + if ($globalDebug) { |
|
261 | + echo "Connect to tsv source (".$host.")...\n"; |
|
262 | + } |
|
202 | 263 | } |
203 | 264 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
204 | 265 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
205 | 266 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
206 | 267 | if ($idf !== false) { |
207 | 268 | $httpfeeds[$id] = $idf; |
208 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
269 | + if ($globalDebug) { |
|
270 | + echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
271 | + } |
|
272 | + } elseif ($globalDebug) { |
|
273 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
209 | 274 | } |
210 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
211 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
275 | + } elseif ($globalDebug) { |
|
276 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
277 | + } |
|
212 | 278 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
213 | 279 | $hostport = explode(':',$host); |
214 | 280 | if (isset($hostport[1])) { |
@@ -248,17 +314,25 @@ discard block |
||
248 | 314 | //$formats[$id] = 'beast'; |
249 | 315 | $globalSources[$id]['format'] = 'beast'; |
250 | 316 | //} else $formats[$id] = 'sbs'; |
251 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
317 | + } else { |
|
318 | + $globalSources[$id]['format'] = 'sbs'; |
|
319 | + } |
|
252 | 320 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
253 | 321 | } |
254 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
322 | + if ($globalDebug) { |
|
323 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
324 | + } |
|
255 | 325 | } else { |
256 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
326 | + if ($globalDebug) { |
|
327 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
328 | + } |
|
257 | 329 | } |
258 | 330 | } |
259 | 331 | } |
260 | 332 | } |
261 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
333 | +if (!isset($globalMinFetch)) { |
|
334 | + $globalMinFetch = 15; |
|
335 | +} |
|
262 | 336 | |
263 | 337 | // Initialize all |
264 | 338 | $status = array(); |
@@ -267,13 +341,19 @@ discard block |
||
267 | 341 | $formats = array(); |
268 | 342 | $last_exec = array(); |
269 | 343 | $time = time(); |
270 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
271 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
272 | -else $timeout = 20; |
|
344 | +if (isset($globalSourcesTimeout)) { |
|
345 | + $timeout = $globalSourcesTimeOut; |
|
346 | +} else if (isset($globalSBS1TimeOut)) { |
|
347 | + $timeout = $globalSBS1TimeOut; |
|
348 | +} else { |
|
349 | + $timeout = 20; |
|
350 | +} |
|
273 | 351 | $errno = ''; |
274 | 352 | $errstr=''; |
275 | 353 | |
276 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
354 | +if (!isset($globalDaemon)) { |
|
355 | + $globalDaemon = TRUE; |
|
356 | +} |
|
277 | 357 | /* Initiate connections to all the hosts simultaneously */ |
278 | 358 | //connect_all($hosts); |
279 | 359 | //connect_all($globalSources); |
@@ -299,7 +379,9 @@ discard block |
||
299 | 379 | if (isset($source['format']) && $source['format'] == 'aprs') { |
300 | 380 | $aprs_connect = 0; |
301 | 381 | $use_aprs = true; |
302 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
382 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
383 | + $aprs_full = true; |
|
384 | + } |
|
303 | 385 | break; |
304 | 386 | } |
305 | 387 | } |
@@ -310,25 +392,48 @@ discard block |
||
310 | 392 | $aprs_connect = 0; |
311 | 393 | $aprs_keep = 120; |
312 | 394 | $aprs_last_tx = time(); |
313 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
314 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
315 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
316 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
317 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
318 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
319 | - if ($aprs_full) $aprs_filter = ''; |
|
320 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
|
321 | - else $aprs_pass = '-1'; |
|
395 | + if (isset($globalAPRSversion)) { |
|
396 | + $aprs_version = $globalAPRSversion; |
|
397 | + } else { |
|
398 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
399 | + } |
|
400 | + if (isset($globalAPRSssid)) { |
|
401 | + $aprs_ssid = $globalAPRSssid; |
|
402 | + } else { |
|
403 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
404 | + } |
|
405 | + if (isset($globalAPRSfilter)) { |
|
406 | + $aprs_filter = $globalAPRSfilter; |
|
407 | + } else { |
|
408 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
409 | + } |
|
410 | + if ($aprs_full) { |
|
411 | + $aprs_filter = ''; |
|
412 | + } |
|
413 | + if (isset($globalAPRSpass)) { |
|
414 | + $aprs_pass = $globalAPRSpass; |
|
415 | + } else { |
|
416 | + $aprs_pass = '-1'; |
|
417 | + } |
|
322 | 418 | |
323 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
324 | - else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
325 | -} |
|
419 | + if ($aprs_filter != '') { |
|
420 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; |
|
421 | + } else { |
|
422 | + $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
|
423 | + } |
|
424 | + } |
|
326 | 425 | |
327 | 426 | // connected - lets do some work |
328 | -if ($globalDebug) echo "Connected!\n"; |
|
427 | +if ($globalDebug) { |
|
428 | + echo "Connected!\n"; |
|
429 | +} |
|
329 | 430 | sleep(1); |
330 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
331 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
431 | +if ($globalDebug) { |
|
432 | + echo "SCAN MODE \n\n"; |
|
433 | +} |
|
434 | +if (!isset($globalCronEnd)) { |
|
435 | + $globalCronEnd = 60; |
|
436 | +} |
|
332 | 437 | $endtime = time()+$globalCronEnd; |
333 | 438 | $i = 1; |
334 | 439 | $tt = array(); |
@@ -342,10 +447,14 @@ discard block |
||
342 | 447 | |
343 | 448 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
344 | 449 | while ($i > 0) { |
345 | - if (!$globalDaemon) $i = $endtime-time(); |
|
450 | + if (!$globalDaemon) { |
|
451 | + $i = $endtime-time(); |
|
452 | + } |
|
346 | 453 | // Delete old ATC |
347 | 454 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
348 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
455 | + if ($globalDebug) { |
|
456 | + echo 'Delete old ATC...'."\n"; |
|
457 | + } |
|
349 | 458 | $ATC->deleteOldATC(); |
350 | 459 | } |
351 | 460 | |
@@ -353,10 +462,14 @@ discard block |
||
353 | 462 | if (count($last_exec) == count($globalSources)) { |
354 | 463 | $max = $globalMinFetch; |
355 | 464 | foreach ($last_exec as $last) { |
356 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
465 | + if ((time() - $last['last']) < $max) { |
|
466 | + $max = time() - $last['last']; |
|
467 | + } |
|
357 | 468 | } |
358 | 469 | if ($max != $globalMinFetch) { |
359 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
470 | + if ($globalDebug) { |
|
471 | + echo 'Sleeping...'."\n"; |
|
472 | + } |
|
360 | 473 | sleep($globalMinFetch-$max+2); |
361 | 474 | } |
362 | 475 | } |
@@ -365,11 +478,15 @@ discard block |
||
365 | 478 | //foreach ($formats as $id => $value) { |
366 | 479 | foreach ($globalSources as $id => $value) { |
367 | 480 | date_default_timezone_set('UTC'); |
368 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
481 | + if (!isset($last_exec[$id]['last'])) { |
|
482 | + $last_exec[$id]['last'] = 0; |
|
483 | + } |
|
369 | 484 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
370 | 485 | //$buffer = $Common->getData($hosts[$id]); |
371 | 486 | $buffer = $Common->getData($value['host']); |
372 | - if ($buffer != '') $reset = 0; |
|
487 | + if ($buffer != '') { |
|
488 | + $reset = 0; |
|
489 | + } |
|
373 | 490 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
374 | 491 | $buffer = explode('\n',$buffer); |
375 | 492 | foreach ($buffer as $line) { |
@@ -378,20 +495,41 @@ discard block |
||
378 | 495 | $data = array(); |
379 | 496 | $data['hex'] = $line[1]; // hex |
380 | 497 | $data['ident'] = $line[2]; // ident |
381 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
382 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
383 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
384 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
385 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
498 | + if (isset($line[3])) { |
|
499 | + $data['altitude'] = $line[3]; |
|
500 | + } |
|
501 | + // altitude |
|
502 | + if (isset($line[4])) { |
|
503 | + $data['speed'] = $line[4]; |
|
504 | + } |
|
505 | + // speed |
|
506 | + if (isset($line[5])) { |
|
507 | + $data['heading'] = $line[5]; |
|
508 | + } |
|
509 | + // heading |
|
510 | + if (isset($line[6])) { |
|
511 | + $data['latitude'] = $line[6]; |
|
512 | + } |
|
513 | + // lat |
|
514 | + if (isset($line[7])) { |
|
515 | + $data['longitude'] = $line[7]; |
|
516 | + } |
|
517 | + // long |
|
386 | 518 | $data['verticalrate'] = ''; // vertical rate |
387 | 519 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
388 | 520 | $data['emergency'] = ''; // emergency |
389 | 521 | $data['datetime'] = date('Y-m-d H:i:s'); |
390 | 522 | $data['format_source'] = 'deltadbtxt'; |
391 | 523 | $data['id_source'] = $id_source; |
392 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
393 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
394 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
524 | + if (isset($value['name']) && $value['name'] != '') { |
|
525 | + $data['source_name'] = $value['name']; |
|
526 | + } |
|
527 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
528 | + $data['noarchive'] = true; |
|
529 | + } |
|
530 | + if (isset($value['sourcestats'])) { |
|
531 | + $data['sourcestats'] = $value['sourcestats']; |
|
532 | + } |
|
395 | 533 | $SI->add($data); |
396 | 534 | unset($data); |
397 | 535 | } |
@@ -401,7 +539,9 @@ discard block |
||
401 | 539 | date_default_timezone_set('CET'); |
402 | 540 | $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
403 | 541 | date_default_timezone_set('UTC'); |
404 | - if ($buffer != '') $reset = 0; |
|
542 | + if ($buffer != '') { |
|
543 | + $reset = 0; |
|
544 | + } |
|
405 | 545 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
406 | 546 | $buffer = explode('\n',$buffer); |
407 | 547 | foreach ($buffer as $line) { |
@@ -410,16 +550,36 @@ discard block |
||
410 | 550 | $add = false; |
411 | 551 | $ais_data = $AIS->parse_line(trim($line)); |
412 | 552 | $data = array(); |
413 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
414 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
415 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
416 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
417 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
418 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
419 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
420 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
421 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
422 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
553 | + if (isset($ais_data['ident'])) { |
|
554 | + $data['ident'] = $ais_data['ident']; |
|
555 | + } |
|
556 | + if (isset($ais_data['mmsi'])) { |
|
557 | + $data['mmsi'] = $ais_data['mmsi']; |
|
558 | + } |
|
559 | + if (isset($ais_data['speed'])) { |
|
560 | + $data['speed'] = $ais_data['speed']; |
|
561 | + } |
|
562 | + if (isset($ais_data['heading'])) { |
|
563 | + $data['heading'] = $ais_data['heading']; |
|
564 | + } |
|
565 | + if (isset($ais_data['latitude'])) { |
|
566 | + $data['latitude'] = $ais_data['latitude']; |
|
567 | + } |
|
568 | + if (isset($ais_data['longitude'])) { |
|
569 | + $data['longitude'] = $ais_data['longitude']; |
|
570 | + } |
|
571 | + if (isset($ais_data['status'])) { |
|
572 | + $data['status'] = $ais_data['status']; |
|
573 | + } |
|
574 | + if (isset($ais_data['type'])) { |
|
575 | + $data['type'] = $ais_data['type']; |
|
576 | + } |
|
577 | + if (isset($ais_data['imo'])) { |
|
578 | + $data['imo'] = $ais_data['imo']; |
|
579 | + } |
|
580 | + if (isset($ais_data['callsign'])) { |
|
581 | + $data['callsign'] = $ais_data['callsign']; |
|
582 | + } |
|
423 | 583 | if (isset($ais_data['timestamp'])) { |
424 | 584 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
425 | 585 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
@@ -434,8 +594,12 @@ discard block |
||
434 | 594 | $data['id_source'] = $id_source; |
435 | 595 | //print_r($data); |
436 | 596 | echo 'Add...'."\n"; |
437 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
438 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
597 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
598 | + $data['noarchive'] = true; |
|
599 | + } |
|
600 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
601 | + $MI->add($data); |
|
602 | + } |
|
439 | 603 | unset($data); |
440 | 604 | } |
441 | 605 | } |
@@ -455,18 +619,42 @@ discard block |
||
455 | 619 | if ($line != '') { |
456 | 620 | $ais_data = $AIS->parse_line(trim($line)); |
457 | 621 | $data = array(); |
458 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
459 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
460 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
461 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
462 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
463 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
464 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
465 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
466 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
467 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
468 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
469 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
622 | + if (isset($ais_data['ident'])) { |
|
623 | + $data['ident'] = $ais_data['ident']; |
|
624 | + } |
|
625 | + if (isset($ais_data['mmsi'])) { |
|
626 | + $data['mmsi'] = $ais_data['mmsi']; |
|
627 | + } |
|
628 | + if (isset($ais_data['speed'])) { |
|
629 | + $data['speed'] = $ais_data['speed']; |
|
630 | + } |
|
631 | + if (isset($ais_data['heading'])) { |
|
632 | + $data['heading'] = $ais_data['heading']; |
|
633 | + } |
|
634 | + if (isset($ais_data['latitude'])) { |
|
635 | + $data['latitude'] = $ais_data['latitude']; |
|
636 | + } |
|
637 | + if (isset($ais_data['longitude'])) { |
|
638 | + $data['longitude'] = $ais_data['longitude']; |
|
639 | + } |
|
640 | + if (isset($ais_data['status'])) { |
|
641 | + $data['status'] = $ais_data['status']; |
|
642 | + } |
|
643 | + if (isset($ais_data['type'])) { |
|
644 | + $data['type'] = $ais_data['type']; |
|
645 | + } |
|
646 | + if (isset($ais_data['imo'])) { |
|
647 | + $data['imo'] = $ais_data['imo']; |
|
648 | + } |
|
649 | + if (isset($ais_data['callsign'])) { |
|
650 | + $data['callsign'] = $ais_data['callsign']; |
|
651 | + } |
|
652 | + if (isset($ais_data['destination'])) { |
|
653 | + $data['arrival_code'] = $ais_data['destination']; |
|
654 | + } |
|
655 | + if (isset($ais_data['eta_ts'])) { |
|
656 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
657 | + } |
|
470 | 658 | if (isset($ais_data['timestamp'])) { |
471 | 659 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
472 | 660 | } else { |
@@ -474,8 +662,12 @@ discard block |
||
474 | 662 | } |
475 | 663 | $data['format_source'] = 'aisnmeahttp'; |
476 | 664 | $data['id_source'] = $id_source; |
477 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
478 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
665 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
666 | + $data['noarchive'] = true; |
|
667 | + } |
|
668 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
669 | + $MI->add($data); |
|
670 | + } |
|
479 | 671 | unset($data); |
480 | 672 | } |
481 | 673 | } |
@@ -504,7 +696,9 @@ discard block |
||
504 | 696 | $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
505 | 697 | $data['format_source'] = 'myshiptracking'; |
506 | 698 | $data['id_source'] = $id_source; |
507 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
699 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
700 | + $data['noarchive'] = true; |
|
701 | + } |
|
508 | 702 | $MI->add($data); |
509 | 703 | unset($data); |
510 | 704 | } |
@@ -525,7 +719,9 @@ discard block |
||
525 | 719 | $data['callsign'] = $line['callsign']; |
526 | 720 | $data['mmsi'] = $line['mmsi']; |
527 | 721 | $data['speed'] = $line['sog']; |
528 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
722 | + if ($line['heading'] != '511') { |
|
723 | + $data['heading'] = $line['heading']; |
|
724 | + } |
|
529 | 725 | $data['latitude'] = $line['latitude']; |
530 | 726 | $data['longitude'] = $line['longitude']; |
531 | 727 | $data['type_id'] = $line['shiptype']; |
@@ -533,7 +729,9 @@ discard block |
||
533 | 729 | $data['datetime'] = $line['time']; |
534 | 730 | $data['format_source'] = 'boatbeaconapp'; |
535 | 731 | $data['id_source'] = $id_source; |
536 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
732 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
733 | + $data['noarchive'] = true; |
|
734 | + } |
|
537 | 735 | $MI->add($data); |
538 | 736 | unset($data); |
539 | 737 | } |
@@ -546,7 +744,9 @@ discard block |
||
546 | 744 | echo 'download...'; |
547 | 745 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
548 | 746 | echo 'done !'."\n"; |
549 | - if ($buffer != '') $reset = 0; |
|
747 | + if ($buffer != '') { |
|
748 | + $reset = 0; |
|
749 | + } |
|
550 | 750 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
551 | 751 | $buffer = explode('\n',$buffer); |
552 | 752 | foreach ($buffer as $line) { |
@@ -571,7 +771,9 @@ discard block |
||
571 | 771 | //$data['etaTime'] = substr($line,135,5); |
572 | 772 | $data['format_source'] = 'shipplotter'; |
573 | 773 | $data['id_source'] = $id_source; |
574 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
774 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
775 | + $data['noarchive'] = true; |
|
776 | + } |
|
575 | 777 | //print_r($data); |
576 | 778 | echo 'Add...'."\n"; |
577 | 779 | $MI->add($data); |
@@ -591,16 +793,28 @@ discard block |
||
591 | 793 | $line = explode(':', $line); |
592 | 794 | if (count($line) > 30 && $line[0] != 'callsign') { |
593 | 795 | $data = array(); |
594 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
595 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
796 | + if (isset($line[37]) && $line[37] != '') { |
|
797 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
798 | + } else { |
|
799 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
800 | + } |
|
596 | 801 | $data['pilot_id'] = $line[1]; |
597 | 802 | $data['pilot_name'] = $line[2]; |
598 | 803 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
599 | 804 | $data['ident'] = $line[0]; // ident |
600 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
805 | + if ($line[7] != '' && $line[7] != 0) { |
|
806 | + $data['altitude'] = $line[7]; |
|
807 | + } |
|
808 | + // altitude |
|
601 | 809 | $data['speed'] = $line[8]; // speed |
602 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
603 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
810 | + if (isset($line[45])) { |
|
811 | + $data['heading'] = $line[45]; |
|
812 | + } |
|
813 | + // heading |
|
814 | + elseif (isset($line[38])) { |
|
815 | + $data['heading'] = $line[38]; |
|
816 | + } |
|
817 | + // heading |
|
604 | 818 | $data['latitude'] = $line[5]; // lat |
605 | 819 | $data['longitude'] = $line[6]; // long |
606 | 820 | $data['verticalrate'] = ''; // vertical rate |
@@ -616,7 +830,9 @@ discard block |
||
616 | 830 | $data['frequency'] = $line[4]; |
617 | 831 | $data['type'] = $line[18]; |
618 | 832 | $data['range'] = $line[19]; |
619 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
833 | + if (isset($line[35])) { |
|
834 | + $data['info'] = $line[35]; |
|
835 | + } |
|
620 | 836 | $data['id_source'] = $id_source; |
621 | 837 | //$data['arrival_airport_time'] = ; |
622 | 838 | if ($line[9] != '') { |
@@ -630,25 +846,44 @@ discard block |
||
630 | 846 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
631 | 847 | */ |
632 | 848 | $data['format_source'] = $value['format']; |
633 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
634 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
635 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
636 | - elseif ($line[3] == 'ATC') { |
|
849 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
850 | + $data['noarchive'] = true; |
|
851 | + } |
|
852 | + if (isset($value['name']) && $value['name'] != '') { |
|
853 | + $data['source_name'] = $value['name']; |
|
854 | + } |
|
855 | + if ($line[3] == 'PILOT') { |
|
856 | + $SI->add($data); |
|
857 | + } elseif ($line[3] == 'ATC') { |
|
637 | 858 | //print_r($data); |
638 | 859 | $data['info'] = str_replace('^§','<br />',$data['info']); |
639 | 860 | $data['info'] = str_replace('&sect;','',$data['info']); |
640 | 861 | $typec = substr($data['ident'],-3); |
641 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
642 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
643 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
644 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
645 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
646 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
647 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
648 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
649 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
650 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
651 | - if (isset($ATC)) 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']); |
|
862 | + if ($typec == 'APP') { |
|
863 | + $data['type'] = 'Approach'; |
|
864 | + } elseif ($typec == 'TWR') { |
|
865 | + $data['type'] = 'Tower'; |
|
866 | + } elseif ($typec == 'OBS') { |
|
867 | + $data['type'] = 'Observer'; |
|
868 | + } elseif ($typec == 'GND') { |
|
869 | + $data['type'] = 'Ground'; |
|
870 | + } elseif ($typec == 'DEL') { |
|
871 | + $data['type'] = 'Delivery'; |
|
872 | + } elseif ($typec == 'DEP') { |
|
873 | + $data['type'] = 'Departure'; |
|
874 | + } elseif ($typec == 'FSS') { |
|
875 | + $data['type'] = 'Flight Service Station'; |
|
876 | + } elseif ($typec == 'CTR') { |
|
877 | + $data['type'] = 'Control Radar or Centre'; |
|
878 | + } elseif ($data['type'] == '') { |
|
879 | + $data['type'] = 'Observer'; |
|
880 | + } |
|
881 | + if (!isset($data['source_name'])) { |
|
882 | + $data['source_name'] = ''; |
|
883 | + } |
|
884 | + if (isset($ATC)) { |
|
885 | + 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']); |
|
886 | + } |
|
652 | 887 | } |
653 | 888 | unset($data); |
654 | 889 | } |
@@ -667,27 +902,58 @@ discard block |
||
667 | 902 | foreach ($all_data['acList'] as $line) { |
668 | 903 | $data = array(); |
669 | 904 | $data['hex'] = $line['Icao']; // hex |
670 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
671 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
672 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
673 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
674 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
675 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
905 | + if (isset($line['Call'])) { |
|
906 | + $data['ident'] = $line['Call']; |
|
907 | + } |
|
908 | + // ident |
|
909 | + if (isset($line['Alt'])) { |
|
910 | + $data['altitude'] = $line['Alt']; |
|
911 | + } |
|
912 | + // altitude |
|
913 | + if (isset($line['Spd'])) { |
|
914 | + $data['speed'] = $line['Spd']; |
|
915 | + } |
|
916 | + // speed |
|
917 | + if (isset($line['Trak'])) { |
|
918 | + $data['heading'] = $line['Trak']; |
|
919 | + } |
|
920 | + // heading |
|
921 | + if (isset($line['Lat'])) { |
|
922 | + $data['latitude'] = $line['Lat']; |
|
923 | + } |
|
924 | + // lat |
|
925 | + if (isset($line['Long'])) { |
|
926 | + $data['longitude'] = $line['Long']; |
|
927 | + } |
|
928 | + // long |
|
676 | 929 | //$data['verticalrate'] = $line['']; // verticale rate |
677 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
930 | + if (isset($line['Sqk'])) { |
|
931 | + $data['squawk'] = $line['Sqk']; |
|
932 | + } |
|
933 | + // squawk |
|
678 | 934 | $data['emergency'] = ''; // emergency |
679 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
935 | + if (isset($line['Reg'])) { |
|
936 | + $data['registration'] = $line['Reg']; |
|
937 | + } |
|
680 | 938 | /* |
681 | 939 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
682 | 940 | else $data['datetime'] = date('Y-m-d H:i:s'); |
683 | 941 | */ |
684 | 942 | $data['datetime'] = date('Y-m-d H:i:s'); |
685 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
943 | + if (isset($line['Type'])) { |
|
944 | + $data['aircraft_icao'] = $line['Type']; |
|
945 | + } |
|
686 | 946 | $data['format_source'] = 'aircraftlistjson'; |
687 | 947 | $data['id_source'] = $id_source; |
688 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
689 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
690 | - if (isset($data['latitude'])) $SI->add($data); |
|
948 | + if (isset($value['name']) && $value['name'] != '') { |
|
949 | + $data['source_name'] = $value['name']; |
|
950 | + } |
|
951 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
952 | + $data['noarchive'] = true; |
|
953 | + } |
|
954 | + if (isset($data['latitude'])) { |
|
955 | + $SI->add($data); |
|
956 | + } |
|
691 | 957 | unset($data); |
692 | 958 | } |
693 | 959 | } elseif (is_array($all_data)) { |
@@ -707,8 +973,12 @@ discard block |
||
707 | 973 | $data['datetime'] = date('Y-m-d H:i:s'); |
708 | 974 | $data['format_source'] = 'aircraftlistjson'; |
709 | 975 | $data['id_source'] = $id_source; |
710 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
711 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
976 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
977 | + $data['noarchive'] = true; |
|
978 | + } |
|
979 | + if (isset($value['name']) && $value['name'] != '') { |
|
980 | + $data['source_name'] = $value['name']; |
|
981 | + } |
|
712 | 982 | $SI->add($data); |
713 | 983 | unset($data); |
714 | 984 | } |
@@ -744,8 +1014,12 @@ discard block |
||
744 | 1014 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
745 | 1015 | $data['format_source'] = 'planeupdatefaa'; |
746 | 1016 | $data['id_source'] = $id_source; |
747 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
748 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1017 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1018 | + $data['noarchive'] = true; |
|
1019 | + } |
|
1020 | + if (isset($value['name']) && $value['name'] != '') { |
|
1021 | + $data['source_name'] = $value['name']; |
|
1022 | + } |
|
749 | 1023 | $SI->add($data); |
750 | 1024 | unset($data); |
751 | 1025 | } |
@@ -774,7 +1048,9 @@ discard block |
||
774 | 1048 | $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
775 | 1049 | $data['format_source'] = 'opensky'; |
776 | 1050 | $data['id_source'] = $id_source; |
777 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1051 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1052 | + $data['noarchive'] = true; |
|
1053 | + } |
|
778 | 1054 | $SI->add($data); |
779 | 1055 | unset($data); |
780 | 1056 | } |
@@ -786,7 +1062,9 @@ discard block |
||
786 | 1062 | //$buffer = $Common->getData($hosts[$id]); |
787 | 1063 | $buffer = $Common->getData($value['host']); |
788 | 1064 | $all_data = json_decode($buffer,true); |
789 | - if (!empty($all_data)) $reset = 0; |
|
1065 | + if (!empty($all_data)) { |
|
1066 | + $reset = 0; |
|
1067 | + } |
|
790 | 1068 | foreach ($all_data as $key => $line) { |
791 | 1069 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
792 | 1070 | $data = array(); |
@@ -807,8 +1085,12 @@ discard block |
||
807 | 1085 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
808 | 1086 | $data['format_source'] = 'fr24json'; |
809 | 1087 | $data['id_source'] = $id_source; |
810 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
811 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1088 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1089 | + $data['noarchive'] = true; |
|
1090 | + } |
|
1091 | + if (isset($value['name']) && $value['name'] != '') { |
|
1092 | + $data['source_name'] = $value['name']; |
|
1093 | + } |
|
812 | 1094 | $SI->add($data); |
813 | 1095 | unset($data); |
814 | 1096 | } |
@@ -832,24 +1114,42 @@ discard block |
||
832 | 1114 | if (isset($line['inf'])) { |
833 | 1115 | $data = array(); |
834 | 1116 | $data['hex'] = $line['inf']['ia']; |
835 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
1117 | + if (isset($line['inf']['cs'])) { |
|
1118 | + $data['ident'] = $line['inf']['cs']; |
|
1119 | + } |
|
1120 | + //$line[13] |
|
836 | 1121 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
837 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
838 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1122 | + if (isset($line['inf']['gs'])) { |
|
1123 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
1124 | + } |
|
1125 | + // speed |
|
1126 | + if (isset($line['inf']['tr'])) { |
|
1127 | + $data['heading'] = $line['inf']['tr']; |
|
1128 | + } |
|
1129 | + // heading |
|
839 | 1130 | $data['latitude'] = $line['pt'][0]; // lat |
840 | 1131 | $data['longitude'] = $line['pt'][1]; // long |
841 | 1132 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
842 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1133 | + if (isset($line['inf']['sq'])) { |
|
1134 | + $data['squawk'] = $line['inf']['sq']; |
|
1135 | + } |
|
1136 | + // squawk |
|
843 | 1137 | //$data['aircraft_icao'] = $line[8]; |
844 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1138 | + if (isset($line['inf']['rc'])) { |
|
1139 | + $data['registration'] = $line['inf']['rc']; |
|
1140 | + } |
|
845 | 1141 | //$data['departure_airport_iata'] = $line[11]; |
846 | 1142 | //$data['arrival_airport_iata'] = $line[12]; |
847 | 1143 | //$data['emergency'] = ''; // emergency |
848 | 1144 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
849 | 1145 | $data['format_source'] = 'radarvirtueljson'; |
850 | 1146 | $data['id_source'] = $id_source; |
851 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
852 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1147 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1148 | + $data['noarchive'] = true; |
|
1149 | + } |
|
1150 | + if (isset($value['name']) && $value['name'] != '') { |
|
1151 | + $data['source_name'] = $value['name']; |
|
1152 | + } |
|
853 | 1153 | $SI->add($data); |
854 | 1154 | unset($data); |
855 | 1155 | } |
@@ -870,30 +1170,65 @@ discard block |
||
870 | 1170 | $data['id'] = $line['id']; |
871 | 1171 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
872 | 1172 | $data['ident'] = $line['callsign']; // ident |
873 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
874 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
875 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
876 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
877 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
878 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1173 | + if (isset($line['pilotid'])) { |
|
1174 | + $data['pilot_id'] = $line['pilotid']; |
|
1175 | + } |
|
1176 | + // pilot id |
|
1177 | + if (isset($line['name'])) { |
|
1178 | + $data['pilot_name'] = $line['name']; |
|
1179 | + } |
|
1180 | + // pilot name |
|
1181 | + if (isset($line['alt'])) { |
|
1182 | + $data['altitude'] = $line['alt']; |
|
1183 | + } |
|
1184 | + // altitude |
|
1185 | + if (isset($line['gs'])) { |
|
1186 | + $data['speed'] = $line['gs']; |
|
1187 | + } |
|
1188 | + // speed |
|
1189 | + if (isset($line['heading'])) { |
|
1190 | + $data['heading'] = $line['heading']; |
|
1191 | + } |
|
1192 | + // heading |
|
1193 | + if (isset($line['route'])) { |
|
1194 | + $data['waypoints'] = $line['route']; |
|
1195 | + } |
|
1196 | + // route |
|
879 | 1197 | $data['latitude'] = $line['lat']; // lat |
880 | 1198 | $data['longitude'] = $line['lon']; // long |
881 | 1199 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
882 | 1200 | //$data['squawk'] = $line['squawk']; // squawk |
883 | 1201 | //$data['emergency'] = ''; // emergency |
884 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
885 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
886 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1202 | + if (isset($line['depicao'])) { |
|
1203 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1204 | + } |
|
1205 | + if (isset($line['deptime'])) { |
|
1206 | + $data['departure_airport_time'] = $line['deptime']; |
|
1207 | + } |
|
1208 | + if (isset($line['arricao'])) { |
|
1209 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1210 | + } |
|
887 | 1211 | //$data['arrival_airport_time'] = $line['arrtime']; |
888 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
889 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
890 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
891 | - else $data['info'] = ''; |
|
1212 | + if (isset($line['aircraft'])) { |
|
1213 | + $data['aircraft_icao'] = $line['aircraft']; |
|
1214 | + } |
|
1215 | + if (isset($line['transponder'])) { |
|
1216 | + $data['squawk'] = $line['transponder']; |
|
1217 | + } |
|
1218 | + if (isset($line['atis'])) { |
|
1219 | + $data['info'] = $line['atis']; |
|
1220 | + } else { |
|
1221 | + $data['info'] = ''; |
|
1222 | + } |
|
892 | 1223 | $data['format_source'] = 'pireps'; |
893 | 1224 | $data['id_source'] = $id_source; |
894 | 1225 | $data['datetime'] = date('Y-m-d H:i:s'); |
895 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
896 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1226 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1227 | + $data['noarchive'] = true; |
|
1228 | + } |
|
1229 | + if (isset($value['name']) && $value['name'] != '') { |
|
1230 | + $data['source_name'] = $value['name']; |
|
1231 | + } |
|
897 | 1232 | if ($line['icon'] == 'plane') { |
898 | 1233 | $SI->add($data); |
899 | 1234 | // print_r($data); |
@@ -902,16 +1237,28 @@ discard block |
||
902 | 1237 | $data['info'] = str_replace('&sect;','',$data['info']); |
903 | 1238 | $typec = substr($data['ident'],-3); |
904 | 1239 | $data['type'] = ''; |
905 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
906 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
907 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
908 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
909 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
910 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
911 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
912 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
913 | - else $data['type'] = 'Observer'; |
|
914 | - if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
|
1240 | + if ($typec == 'APP') { |
|
1241 | + $data['type'] = 'Approach'; |
|
1242 | + } elseif ($typec == 'TWR') { |
|
1243 | + $data['type'] = 'Tower'; |
|
1244 | + } elseif ($typec == 'OBS') { |
|
1245 | + $data['type'] = 'Observer'; |
|
1246 | + } elseif ($typec == 'GND') { |
|
1247 | + $data['type'] = 'Ground'; |
|
1248 | + } elseif ($typec == 'DEL') { |
|
1249 | + $data['type'] = 'Delivery'; |
|
1250 | + } elseif ($typec == 'DEP') { |
|
1251 | + $data['type'] = 'Departure'; |
|
1252 | + } elseif ($typec == 'FSS') { |
|
1253 | + $data['type'] = 'Flight Service Station'; |
|
1254 | + } elseif ($typec == 'CTR') { |
|
1255 | + $data['type'] = 'Control Radar or Centre'; |
|
1256 | + } else { |
|
1257 | + $data['type'] = 'Observer'; |
|
1258 | + } |
|
1259 | + if (isset($ATC)) { |
|
1260 | + 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']); |
|
1261 | + } |
|
915 | 1262 | } |
916 | 1263 | unset($data); |
917 | 1264 | } |
@@ -921,7 +1268,9 @@ discard block |
||
921 | 1268 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
922 | 1269 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
923 | 1270 | //$buffer = $Common->getData($hosts[$id]); |
924 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1271 | + if ($globalDebug) { |
|
1272 | + echo 'Get Data...'."\n"; |
|
1273 | + } |
|
925 | 1274 | $buffer = $Common->getData($value['host']); |
926 | 1275 | $all_data = json_decode($buffer,true); |
927 | 1276 | if ($buffer != '' && is_array($all_data)) { |
@@ -929,10 +1278,16 @@ discard block |
||
929 | 1278 | foreach ($all_data as $line) { |
930 | 1279 | $data = array(); |
931 | 1280 | //$data['id'] = $line['id']; // id not usable |
932 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1281 | + if (isset($line['pilotid'])) { |
|
1282 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1283 | + } |
|
933 | 1284 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
934 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
935 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1285 | + if (isset($line['pilotname'])) { |
|
1286 | + $data['pilot_name'] = $line['pilotname']; |
|
1287 | + } |
|
1288 | + if (isset($line['pilotid'])) { |
|
1289 | + $data['pilot_id'] = $line['pilotid']; |
|
1290 | + } |
|
936 | 1291 | $data['ident'] = $line['flightnum']; // ident |
937 | 1292 | $data['altitude'] = $line['alt']; // altitude |
938 | 1293 | $data['speed'] = $line['gs']; // speed |
@@ -950,28 +1305,44 @@ discard block |
||
950 | 1305 | $data['arrival_airport_icao'] = $line['arricao']; |
951 | 1306 | $data['arrival_airport_time'] = $line['arrtime']; |
952 | 1307 | $data['registration'] = $line['aircraft']; |
953 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
954 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1308 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1309 | + $data['noarchive'] = true; |
|
1310 | + } |
|
1311 | + if (isset($line['route'])) { |
|
1312 | + $data['waypoints'] = $line['route']; |
|
1313 | + } |
|
1314 | + // route |
|
955 | 1315 | if (isset($line['aircraftname'])) { |
956 | 1316 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
957 | 1317 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
958 | 1318 | $aircraft_data = explode('-',$line['aircraftname']); |
959 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
960 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
961 | - else { |
|
1319 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { |
|
1320 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
1321 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { |
|
1322 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
1323 | + } else { |
|
962 | 1324 | $aircraft_data = explode(' ',$line['aircraftname']); |
963 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
964 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1325 | + if (isset($aircraft_data[1])) { |
|
1326 | + $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1327 | + } else { |
|
1328 | + $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1329 | + } |
|
965 | 1330 | } |
966 | 1331 | } |
967 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1332 | + if (isset($line['route'])) { |
|
1333 | + $data['waypoints'] = $line['route']; |
|
1334 | + } |
|
968 | 1335 | $data['id_source'] = $id_source; |
969 | 1336 | $data['format_source'] = 'phpvmacars'; |
970 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1337 | + if (isset($value['name']) && $value['name'] != '') { |
|
1338 | + $data['source_name'] = $value['name']; |
|
1339 | + } |
|
971 | 1340 | $SI->add($data); |
972 | 1341 | unset($data); |
973 | 1342 | } |
974 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1343 | + if ($globalDebug) { |
|
1344 | + echo 'No more data...'."\n"; |
|
1345 | + } |
|
975 | 1346 | unset($buffer); |
976 | 1347 | unset($all_data); |
977 | 1348 | } |
@@ -979,7 +1350,9 @@ discard block |
||
979 | 1350 | $last_exec[$id]['last'] = time(); |
980 | 1351 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
981 | 1352 | //$buffer = $Common->getData($hosts[$id]); |
982 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1353 | + if ($globalDebug) { |
|
1354 | + echo 'Get Data...'."\n"; |
|
1355 | + } |
|
983 | 1356 | $buffer = $Common->getData($value['host']); |
984 | 1357 | $all_data = json_decode($buffer,true); |
985 | 1358 | if ($buffer != '' && is_array($all_data)) { |
@@ -1008,16 +1381,25 @@ discard block |
||
1008 | 1381 | $data['arrival_airport_icao'] = $line['arrival']; |
1009 | 1382 | //$data['arrival_airport_time'] = $line['arrival_time']; |
1010 | 1383 | //$data['registration'] = $line['aircraft']; |
1011 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1384 | + if (isset($line['route'])) { |
|
1385 | + $data['waypoints'] = $line['route']; |
|
1386 | + } |
|
1387 | + // route |
|
1012 | 1388 | $data['aircraft_icao'] = $line['plane_type']; |
1013 | 1389 | $data['id_source'] = $id_source; |
1014 | 1390 | $data['format_source'] = 'vam'; |
1015 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1016 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1391 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { |
|
1392 | + $data['noarchive'] = true; |
|
1393 | + } |
|
1394 | + if (isset($value['name']) && $value['name'] != '') { |
|
1395 | + $data['source_name'] = $value['name']; |
|
1396 | + } |
|
1017 | 1397 | $SI->add($data); |
1018 | 1398 | unset($data); |
1019 | 1399 | } |
1020 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
1400 | + if ($globalDebug) { |
|
1401 | + echo 'No more data...'."\n"; |
|
1402 | + } |
|
1021 | 1403 | unset($buffer); |
1022 | 1404 | unset($all_data); |
1023 | 1405 | } |
@@ -1025,7 +1407,9 @@ discard block |
||
1025 | 1407 | $last_exec[$id]['last'] = time(); |
1026 | 1408 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1027 | 1409 | } 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' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1028 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1410 | + if (function_exists('pcntl_fork')) { |
|
1411 | + pcntl_signal_dispatch(); |
|
1412 | + } |
|
1029 | 1413 | //$last_exec[$id]['last'] = time(); |
1030 | 1414 | |
1031 | 1415 | //$read = array( $sockets[$id] ); |
@@ -1033,7 +1417,9 @@ discard block |
||
1033 | 1417 | $write = NULL; |
1034 | 1418 | $e = NULL; |
1035 | 1419 | $n = socket_select($read, $write, $e, $timeout); |
1036 | - if ($e != NULL) var_dump($e); |
|
1420 | + if ($e != NULL) { |
|
1421 | + var_dump($e); |
|
1422 | + } |
|
1037 | 1423 | if ($n > 0) { |
1038 | 1424 | $reset = 0; |
1039 | 1425 | foreach ($read as $nb => $r) { |
@@ -1054,12 +1440,16 @@ discard block |
||
1054 | 1440 | //$SI::del(); |
1055 | 1441 | if ($format == 'vrstcp') { |
1056 | 1442 | $buffer = explode('},{',$buffer); |
1057 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1443 | + } else { |
|
1444 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1445 | + } |
|
1058 | 1446 | // SBS format is CSV format |
1059 | 1447 | if ($buffer !== FALSE && $buffer != '') { |
1060 | 1448 | $tt[$format] = 0; |
1061 | 1449 | if ($format == 'acarssbs3') { |
1062 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1450 | + if ($globalDebug) { |
|
1451 | + echo 'ACARS : '.$buffer."\n"; |
|
1452 | + } |
|
1063 | 1453 | $ACARS->add(trim($buffer)); |
1064 | 1454 | $ACARS->deleteLiveAcarsData(); |
1065 | 1455 | } elseif ($format == 'raw') { |
@@ -1068,27 +1458,61 @@ discard block |
||
1068 | 1458 | if (is_array($data)) { |
1069 | 1459 | $data['datetime'] = date('Y-m-d H:i:s'); |
1070 | 1460 | $data['format_source'] = 'raw'; |
1071 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1072 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1073 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1074 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1461 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1462 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1463 | + } |
|
1464 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1465 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1466 | + } |
|
1467 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1468 | + $data['noarchive'] = true; |
|
1469 | + } |
|
1470 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1471 | + $SI->add($data); |
|
1472 | + } |
|
1075 | 1473 | } |
1076 | 1474 | } elseif ($format == 'ais') { |
1077 | 1475 | $ais_data = $AIS->parse_line(trim($buffer)); |
1078 | 1476 | $data = array(); |
1079 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1080 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1081 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1082 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1083 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1084 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1085 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1086 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1087 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1088 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1089 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1090 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1091 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1477 | + if (isset($ais_data['ident'])) { |
|
1478 | + $data['ident'] = $ais_data['ident']; |
|
1479 | + } |
|
1480 | + if (isset($ais_data['mmsi'])) { |
|
1481 | + $data['mmsi'] = $ais_data['mmsi']; |
|
1482 | + } |
|
1483 | + if (isset($ais_data['speed'])) { |
|
1484 | + $data['speed'] = $ais_data['speed']; |
|
1485 | + } |
|
1486 | + if (isset($ais_data['heading'])) { |
|
1487 | + $data['heading'] = $ais_data['heading']; |
|
1488 | + } |
|
1489 | + if (isset($ais_data['latitude'])) { |
|
1490 | + $data['latitude'] = $ais_data['latitude']; |
|
1491 | + } |
|
1492 | + if (isset($ais_data['longitude'])) { |
|
1493 | + $data['longitude'] = $ais_data['longitude']; |
|
1494 | + } |
|
1495 | + if (isset($ais_data['status'])) { |
|
1496 | + $data['status'] = $ais_data['status']; |
|
1497 | + } |
|
1498 | + if (isset($ais_data['type'])) { |
|
1499 | + $data['type'] = $ais_data['type']; |
|
1500 | + } |
|
1501 | + if (isset($ais_data['imo'])) { |
|
1502 | + $data['imo'] = $ais_data['imo']; |
|
1503 | + } |
|
1504 | + if (isset($ais_data['callsign'])) { |
|
1505 | + $data['callsign'] = $ais_data['callsign']; |
|
1506 | + } |
|
1507 | + if (isset($ais_data['destination'])) { |
|
1508 | + $data['arrival_code'] = $ais_data['destination']; |
|
1509 | + } |
|
1510 | + if (isset($ais_data['eta_ts'])) { |
|
1511 | + $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1512 | + } |
|
1513 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1514 | + $data['noarchive'] = true; |
|
1515 | + } |
|
1092 | 1516 | |
1093 | 1517 | if (isset($ais_data['timestamp'])) { |
1094 | 1518 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
@@ -1097,7 +1521,9 @@ discard block |
||
1097 | 1521 | } |
1098 | 1522 | $data['format_source'] = 'aisnmea'; |
1099 | 1523 | $data['id_source'] = $id_source; |
1100 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1524 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { |
|
1525 | + $MI->add($data); |
|
1526 | + } |
|
1101 | 1527 | unset($data); |
1102 | 1528 | } elseif ($format == 'flightgearsp') { |
1103 | 1529 | //echo $buffer."\n"; |
@@ -1115,12 +1541,18 @@ discard block |
||
1115 | 1541 | $data['speed'] = round($line[5]*1.94384); |
1116 | 1542 | $data['datetime'] = date('Y-m-d H:i:s'); |
1117 | 1543 | $data['format_source'] = 'flightgearsp'; |
1118 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1119 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1544 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1545 | + $data['noarchive'] = true; |
|
1546 | + } |
|
1547 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1548 | + $SI->add($data); |
|
1549 | + } |
|
1120 | 1550 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1121 | 1551 | } |
1122 | 1552 | } elseif ($format == 'acars') { |
1123 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1553 | + if ($globalDebug) { |
|
1554 | + echo 'ACARS : '.$buffer."\n"; |
|
1555 | + } |
|
1124 | 1556 | $ACARS->add(trim($buffer)); |
1125 | 1557 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
1126 | 1558 | $ACARS->deleteLiveAcarsData(); |
@@ -1141,8 +1573,12 @@ discard block |
||
1141 | 1573 | $aircraft_type = $line[10]; |
1142 | 1574 | $aircraft_type = preg_split(':/:',$aircraft_type); |
1143 | 1575 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
1144 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1145 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1576 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1577 | + $data['noarchive'] = true; |
|
1578 | + } |
|
1579 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1580 | + $SI->add($data); |
|
1581 | + } |
|
1146 | 1582 | } |
1147 | 1583 | } |
1148 | 1584 | } elseif ($format == 'beast') { |
@@ -1152,28 +1588,62 @@ discard block |
||
1152 | 1588 | foreach($buffer as $all_data) { |
1153 | 1589 | $line = json_decode('{'.$all_data.'}',true); |
1154 | 1590 | $data = array(); |
1155 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
|
1156 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
1157 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
1158 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
1159 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
1160 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
1161 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
1591 | + if (isset($line['Icao'])) { |
|
1592 | + $data['hex'] = $line['Icao']; |
|
1593 | + } |
|
1594 | + // hex |
|
1595 | + if (isset($line['Call'])) { |
|
1596 | + $data['ident'] = $line['Call']; |
|
1597 | + } |
|
1598 | + // ident |
|
1599 | + if (isset($line['Alt'])) { |
|
1600 | + $data['altitude'] = $line['Alt']; |
|
1601 | + } |
|
1602 | + // altitude |
|
1603 | + if (isset($line['Spd'])) { |
|
1604 | + $data['speed'] = $line['Spd']; |
|
1605 | + } |
|
1606 | + // speed |
|
1607 | + if (isset($line['Trak'])) { |
|
1608 | + $data['heading'] = $line['Trak']; |
|
1609 | + } |
|
1610 | + // heading |
|
1611 | + if (isset($line['Lat'])) { |
|
1612 | + $data['latitude'] = $line['Lat']; |
|
1613 | + } |
|
1614 | + // lat |
|
1615 | + if (isset($line['Long'])) { |
|
1616 | + $data['longitude'] = $line['Long']; |
|
1617 | + } |
|
1618 | + // long |
|
1162 | 1619 | //$data['verticalrate'] = $line['']; // verticale rate |
1163 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
1620 | + if (isset($line['Sqk'])) { |
|
1621 | + $data['squawk'] = $line['Sqk']; |
|
1622 | + } |
|
1623 | + // squawk |
|
1164 | 1624 | $data['emergency'] = ''; // emergency |
1165 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
1625 | + if (isset($line['Reg'])) { |
|
1626 | + $data['registration'] = $line['Reg']; |
|
1627 | + } |
|
1166 | 1628 | /* |
1167 | 1629 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
1168 | 1630 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1169 | 1631 | */ |
1170 | 1632 | $data['datetime'] = date('Y-m-d H:i:s'); |
1171 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
1633 | + if (isset($line['Type'])) { |
|
1634 | + $data['aircraft_icao'] = $line['Type']; |
|
1635 | + } |
|
1172 | 1636 | $data['format_source'] = 'vrstcp'; |
1173 | 1637 | $data['id_source'] = $id_source; |
1174 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1175 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1176 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
|
1638 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1639 | + $data['noarchive'] = true; |
|
1640 | + } |
|
1641 | + if (isset($value['name']) && $value['name'] != '') { |
|
1642 | + $data['source_name'] = $value['name']; |
|
1643 | + } |
|
1644 | + if (isset($data['latitude']) && isset($data['hex'])) { |
|
1645 | + $SI->add($data); |
|
1646 | + } |
|
1177 | 1647 | unset($data); |
1178 | 1648 | } |
1179 | 1649 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
@@ -1186,22 +1656,46 @@ discard block |
||
1186 | 1656 | $data['hex'] = $lined['hexid']; |
1187 | 1657 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1188 | 1658 | $data['datetime'] = date('Y-m-d H:i:s');; |
1189 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1190 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1191 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1192 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1193 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1194 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1195 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1659 | + if (isset($lined['ident'])) { |
|
1660 | + $data['ident'] = $lined['ident']; |
|
1661 | + } |
|
1662 | + if (isset($lined['lat'])) { |
|
1663 | + $data['latitude'] = $lined['lat']; |
|
1664 | + } |
|
1665 | + if (isset($lined['lon'])) { |
|
1666 | + $data['longitude'] = $lined['lon']; |
|
1667 | + } |
|
1668 | + if (isset($lined['speed'])) { |
|
1669 | + $data['speed'] = $lined['speed']; |
|
1670 | + } |
|
1671 | + if (isset($lined['squawk'])) { |
|
1672 | + $data['squawk'] = $lined['squawk']; |
|
1673 | + } |
|
1674 | + if (isset($lined['alt'])) { |
|
1675 | + $data['altitude'] = $lined['alt']; |
|
1676 | + } |
|
1677 | + if (isset($lined['heading'])) { |
|
1678 | + $data['heading'] = $lined['heading']; |
|
1679 | + } |
|
1196 | 1680 | $data['id_source'] = $id_source; |
1197 | 1681 | $data['format_source'] = 'tsv'; |
1198 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1199 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1200 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1201 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1682 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1683 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1684 | + } |
|
1685 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1686 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1687 | + } |
|
1688 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1689 | + $data['noarchive'] = true; |
|
1690 | + } |
|
1691 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1692 | + $SI->add($data); |
|
1693 | + } |
|
1202 | 1694 | unset($lined); |
1203 | 1695 | unset($data); |
1204 | - } else $error = true; |
|
1696 | + } else { |
|
1697 | + $error = true; |
|
1698 | + } |
|
1205 | 1699 | } elseif ($format == 'aprs' && $use_aprs) { |
1206 | 1700 | if ($aprs_connect == 0) { |
1207 | 1701 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -1226,32 +1720,66 @@ discard block |
||
1226 | 1720 | $aprs_last_tx = time(); |
1227 | 1721 | $data = array(); |
1228 | 1722 | //print_r($line); |
1229 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1230 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1231 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1232 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1723 | + if (isset($line['address'])) { |
|
1724 | + $data['hex'] = $line['address']; |
|
1725 | + } |
|
1726 | + if (isset($line['mmsi'])) { |
|
1727 | + $data['mmsi'] = $line['mmsi']; |
|
1728 | + } |
|
1729 | + if (isset($line['timestamp'])) { |
|
1730 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1731 | + } else { |
|
1732 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1733 | + } |
|
1233 | 1734 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1234 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1735 | + if (isset($line['ident'])) { |
|
1736 | + $data['ident'] = $line['ident']; |
|
1737 | + } |
|
1235 | 1738 | $data['latitude'] = $line['latitude']; |
1236 | 1739 | $data['longitude'] = $line['longitude']; |
1237 | 1740 | //$data['verticalrate'] = $line[16]; |
1238 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1239 | - else $data['speed'] = 0; |
|
1240 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1241 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1242 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1243 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1741 | + if (isset($line['speed'])) { |
|
1742 | + $data['speed'] = $line['speed']; |
|
1743 | + } else { |
|
1744 | + $data['speed'] = 0; |
|
1745 | + } |
|
1746 | + if (isset($line['altitude'])) { |
|
1747 | + $data['altitude'] = $line['altitude']; |
|
1748 | + } |
|
1749 | + if (isset($line['comment'])) { |
|
1750 | + $data['comment'] = $line['comment']; |
|
1751 | + } |
|
1752 | + if (isset($line['symbol'])) { |
|
1753 | + $data['type'] = $line['symbol']; |
|
1754 | + } |
|
1755 | + if (isset($line['heading'])) { |
|
1756 | + $data['heading'] = $line['heading']; |
|
1757 | + } |
|
1244 | 1758 | //else $data['heading'] = 0; |
1245 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1246 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE)) $data['noarchive'] = true; |
|
1247 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1759 | + if (isset($line['stealth'])) { |
|
1760 | + $data['aircraft_type'] = $line['stealth']; |
|
1761 | + } |
|
1762 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE)) { |
|
1763 | + $data['noarchive'] = true; |
|
1764 | + } |
|
1765 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1766 | + $data['noarchive'] = true; |
|
1767 | + } |
|
1248 | 1768 | $data['id_source'] = $id_source; |
1249 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1250 | - else $data['format_source'] = 'aprs'; |
|
1769 | + if (isset($line['format_source'])) { |
|
1770 | + $data['format_source'] = $line['format_source']; |
|
1771 | + } else { |
|
1772 | + $data['format_source'] = 'aprs'; |
|
1773 | + } |
|
1251 | 1774 | $data['source_name'] = $line['source']; |
1252 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1253 | - else $data['source_type'] = 'flarm'; |
|
1254 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1775 | + if (isset($line['source_type'])) { |
|
1776 | + $data['source_type'] = $line['source_type']; |
|
1777 | + } else { |
|
1778 | + $data['source_type'] = 'flarm'; |
|
1779 | + } |
|
1780 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1781 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1782 | + } |
|
1255 | 1783 | $currentdate = date('Y-m-d H:i:s'); |
1256 | 1784 | $aprsdate = strtotime($data['datetime']); |
1257 | 1785 | // Accept data if time <= system time + 20s |
@@ -1261,19 +1789,22 @@ discard block |
||
1261 | 1789 | echo 'add...'."\n"; |
1262 | 1790 | $send = $MI->add($data); |
1263 | 1791 | } elseif (isset($line['stealth'])) { |
1264 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1265 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1792 | + if ($line['stealth'] != 0) { |
|
1793 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
1794 | + } else { |
|
1795 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
1796 | + } |
|
1266 | 1797 | //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
1267 | 1798 | } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
1268 | 1799 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1269 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
|
1800 | + if (isset($globalTracker) && $globalTracker) { |
|
1801 | + $send = $TI->add($data); |
|
1802 | + } |
|
1270 | 1803 | } |
1271 | 1804 | unset($data); |
1272 | - } |
|
1273 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1805 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
1274 | 1806 | echo '!! Weather Station not yet supported'."\n"; |
1275 | - } |
|
1276 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
|
1807 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
|
1277 | 1808 | echo '!! Car & Trucks not yet supported'."\n"; |
1278 | 1809 | } |
1279 | 1810 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
@@ -1306,26 +1837,45 @@ discard block |
||
1306 | 1837 | $data['ground'] = $line[21]; |
1307 | 1838 | $data['emergency'] = $line[19]; |
1308 | 1839 | $data['format_source'] = 'sbs'; |
1309 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1310 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1311 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1840 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
1841 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
1842 | + } |
|
1843 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
1844 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1845 | + } |
|
1846 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { |
|
1847 | + $data['noarchive'] = true; |
|
1848 | + } |
|
1312 | 1849 | $data['id_source'] = $id_source; |
1313 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1314 | - else $error = true; |
|
1850 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
1851 | + $send = $SI->add($data); |
|
1852 | + } else { |
|
1853 | + $error = true; |
|
1854 | + } |
|
1315 | 1855 | unset($data); |
1316 | - } else $error = true; |
|
1856 | + } else { |
|
1857 | + $error = true; |
|
1858 | + } |
|
1317 | 1859 | if ($error) { |
1318 | 1860 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1319 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
1861 | + if ($globalDebug) { |
|
1862 | + echo "Not a message. Ignoring... \n"; |
|
1863 | + } |
|
1320 | 1864 | } else { |
1321 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
1865 | + if ($globalDebug) { |
|
1866 | + echo "Wrong line format. Ignoring... \n"; |
|
1867 | + } |
|
1322 | 1868 | if ($globalDebug) { |
1323 | 1869 | echo $buffer; |
1324 | 1870 | //print_r($line); |
1325 | 1871 | } |
1326 | 1872 | //socket_close($r); |
1327 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
1328 | - if ($format == 'aprs') $aprs_connect = 0; |
|
1873 | + if ($globalDebug) { |
|
1874 | + echo "Reconnect after an error...\n"; |
|
1875 | + } |
|
1876 | + if ($format == 'aprs') { |
|
1877 | + $aprs_connect = 0; |
|
1878 | + } |
|
1329 | 1879 | $sourceer[$nb] = $globalSources[$nb]; |
1330 | 1880 | connect_all($sourceer); |
1331 | 1881 | $sourceer = array(); |
@@ -1333,10 +1883,14 @@ discard block |
||
1333 | 1883 | } |
1334 | 1884 | } |
1335 | 1885 | // Sleep for xxx microseconds |
1336 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
1886 | + if (isset($globalSBSSleep)) { |
|
1887 | + usleep($globalSBSSleep); |
|
1888 | + } |
|
1337 | 1889 | } else { |
1338 | 1890 | if ($format == 'flightgearmp') { |
1339 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1891 | + if ($globalDebug) { |
|
1892 | + echo "Reconnect FlightGear MP..."; |
|
1893 | + } |
|
1340 | 1894 | //@socket_close($r); |
1341 | 1895 | sleep($globalMinFetch); |
1342 | 1896 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1345,10 +1899,15 @@ discard block |
||
1345 | 1899 | break; |
1346 | 1900 | |
1347 | 1901 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1348 | - if (isset($tt[$format])) $tt[$format]++; |
|
1349 | - else $tt[$format] = 0; |
|
1902 | + if (isset($tt[$format])) { |
|
1903 | + $tt[$format]++; |
|
1904 | + } else { |
|
1905 | + $tt[$format] = 0; |
|
1906 | + } |
|
1350 | 1907 | if ($tt[$format] > 30) { |
1351 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
1908 | + if ($globalDebug) { |
|
1909 | + echo "ERROR : Reconnect ".$format."..."; |
|
1910 | + } |
|
1352 | 1911 | //@socket_close($r); |
1353 | 1912 | sleep(2); |
1354 | 1913 | $aprs_connect = 0; |
@@ -1365,11 +1924,17 @@ discard block |
||
1365 | 1924 | } else { |
1366 | 1925 | $error = socket_strerror(socket_last_error()); |
1367 | 1926 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1368 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1369 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
1927 | + if ($globalDebug) { |
|
1928 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1929 | + } |
|
1930 | + if (isset($globalDebug)) { |
|
1931 | + echo "Restarting...\n"; |
|
1932 | + } |
|
1370 | 1933 | // Restart the script if possible |
1371 | 1934 | if (is_array($sockets)) { |
1372 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1935 | + if ($globalDebug) { |
|
1936 | + echo "Shutdown all sockets..."; |
|
1937 | + } |
|
1373 | 1938 | |
1374 | 1939 | foreach ($sockets as $sock) { |
1375 | 1940 | @socket_shutdown($sock,2); |
@@ -1377,21 +1942,33 @@ discard block |
||
1377 | 1942 | } |
1378 | 1943 | |
1379 | 1944 | } |
1380 | - if ($globalDebug) echo "Restart all connections..."; |
|
1945 | + if ($globalDebug) { |
|
1946 | + echo "Restart all connections..."; |
|
1947 | + } |
|
1381 | 1948 | sleep(2); |
1382 | 1949 | $time = time(); |
1383 | 1950 | //connect_all($hosts); |
1384 | 1951 | $aprs_connect = 0; |
1385 | - if ($reset%5 == 0) sleep(20); |
|
1386 | - if ($reset%10 == 0) sleep(100); |
|
1387 | - if ($reset%20 == 0) sleep(200); |
|
1388 | - if ($reset > 100) exit('Too many attempts...'); |
|
1952 | + if ($reset%5 == 0) { |
|
1953 | + sleep(20); |
|
1954 | + } |
|
1955 | + if ($reset%10 == 0) { |
|
1956 | + sleep(100); |
|
1957 | + } |
|
1958 | + if ($reset%20 == 0) { |
|
1959 | + sleep(200); |
|
1960 | + } |
|
1961 | + if ($reset > 100) { |
|
1962 | + exit('Too many attempts...'); |
|
1963 | + } |
|
1389 | 1964 | connect_all($globalSources); |
1390 | 1965 | } |
1391 | 1966 | } |
1392 | 1967 | } |
1393 | 1968 | if ($globalDaemon === false) { |
1394 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1969 | + if ($globalDebug) { |
|
1970 | + echo 'Check all...'."\n"; |
|
1971 | + } |
|
1395 | 1972 | $SI->checkAll(); |
1396 | 1973 | } |
1397 | 1974 | } |
@@ -53,7 +53,9 @@ discard block |
||
53 | 53 | |
54 | 54 | public function checkAll() { |
55 | 55 | global $globalDebug; |
56 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
56 | + if ($globalDebug) { |
|
57 | + echo "Update last seen tracked data...\n"; |
|
58 | + } |
|
57 | 59 | foreach ($this->all_tracked as $key => $flight) { |
58 | 60 | if (isset($this->all_tracked[$key]['id'])) { |
59 | 61 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
@@ -66,13 +68,17 @@ discard block |
||
66 | 68 | public function del() { |
67 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
68 | 70 | // Delete old infos |
69 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
71 | + if ($globalDebug) { |
|
72 | + echo 'Delete old values and update latest data...'."\n"; |
|
73 | + } |
|
70 | 74 | foreach ($this->all_tracked as $key => $flight) { |
71 | 75 | if (isset($flight['lastupdate'])) { |
72 | 76 | if ($flight['lastupdate'] < (time()-3000)) { |
73 | 77 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
74 | 78 | if (isset($this->all_tracked[$key]['id'])) { |
75 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
79 | + if ($globalDebug) { |
|
80 | + echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
81 | + } |
|
76 | 82 | /* |
77 | 83 | $MarineLive = new MarineLive(); |
78 | 84 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
@@ -82,7 +88,9 @@ discard block |
||
82 | 88 | $Marine = new Marine($this->db); |
83 | 89 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
84 | 90 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']); |
85 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
91 | + if ($globalDebug && $result != 'success') { |
|
92 | + echo '!!! ERROR : '.$result."\n"; |
|
93 | + } |
|
86 | 94 | } |
87 | 95 | // Put in archive |
88 | 96 | // $Marine->db = null; |
@@ -96,7 +104,9 @@ discard block |
||
96 | 104 | |
97 | 105 | public function add($line) { |
98 | 106 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
99 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
107 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
108 | + $globalCoordMinChange = '0.02'; |
|
109 | + } |
|
100 | 110 | date_default_timezone_set('UTC'); |
101 | 111 | $dataFound = false; |
102 | 112 | $send = false; |
@@ -121,8 +131,11 @@ discard block |
||
121 | 131 | |
122 | 132 | $Common = new Common(); |
123 | 133 | $AIS = new AIS(); |
124 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
125 | - else $id = trim($line['id']); |
|
134 | + if (!isset($line['id'])) { |
|
135 | + $id = trim($line['mmsi']); |
|
136 | + } else { |
|
137 | + $id = trim($line['id']); |
|
138 | + } |
|
126 | 139 | |
127 | 140 | if (!isset($this->all_tracked[$id])) { |
128 | 141 | $this->all_tracked[$id] = array(); |
@@ -130,10 +143,16 @@ discard block |
||
130 | 143 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
131 | 144 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
132 | 145 | if (!isset($line['id'])) { |
133 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
146 | + if (!isset($globalDaemon)) { |
|
147 | + $globalDaemon = TRUE; |
|
148 | + } |
|
134 | 149 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
135 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
136 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
150 | + } else { |
|
151 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
152 | + } |
|
153 | + if ($globalAllTracked !== FALSE) { |
|
154 | + $dataFound = true; |
|
155 | + } |
|
137 | 156 | } |
138 | 157 | |
139 | 158 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
@@ -183,13 +202,19 @@ discard block |
||
183 | 202 | $Marine = new Marine($this->db); |
184 | 203 | $fromsource = NULL; |
185 | 204 | $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
186 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
205 | + if ($globalDebug && $result != 'success') { |
|
206 | + echo '!!! ERROR : '.$result."\n"; |
|
207 | + } |
|
187 | 208 | $Marine->db = null; |
188 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
209 | + if ($globalDebugTimeElapsed) { |
|
210 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
211 | + } |
|
189 | 212 | } |
190 | 213 | } |
191 | 214 | } |
192 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
215 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
216 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
217 | + } |
|
193 | 218 | } |
194 | 219 | |
195 | 220 | if (isset($line['speed']) && $line['speed'] != '') { |
@@ -200,14 +225,21 @@ discard block |
||
200 | 225 | if ($distance > 1000 && $distance < 10000) { |
201 | 226 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
202 | 227 | $speed = $speed*3.6; |
203 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
204 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
228 | + if ($speed < 1000) { |
|
229 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
230 | + } |
|
231 | + if ($globalDebug) { |
|
232 | + echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
233 | + } |
|
205 | 234 | } |
206 | 235 | } |
207 | 236 | |
208 | 237 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
209 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
210 | - else unset($timediff); |
|
238 | + if (isset($this->all_tracked[$id]['time_last_coord'])) { |
|
239 | + $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
240 | + } else { |
|
241 | + unset($timediff); |
|
242 | + } |
|
211 | 243 | if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
212 | 244 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
213 | 245 | if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -215,22 +247,32 @@ discard block |
||
215 | 247 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
216 | 248 | $this->all_tracked[$id]['putinarchive'] = true; |
217 | 249 | |
218 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
250 | + if ($globalDebug) { |
|
251 | + echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
252 | + } |
|
219 | 253 | $timeelapsed = microtime(true); |
220 | 254 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
221 | 255 | $Marine = new Marine($this->db); |
222 | 256 | $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
223 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
257 | + if (!empty($all_country)) { |
|
258 | + $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
259 | + } |
|
224 | 260 | $Marine->db = null; |
225 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
261 | + if ($globalDebugTimeElapsed) { |
|
262 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
263 | + } |
|
226 | 264 | } |
227 | 265 | $this->tmd = 0; |
228 | - if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
266 | + if ($globalDebug) { |
|
267 | + echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
|
268 | + } |
|
229 | 269 | } |
230 | 270 | } |
231 | 271 | |
232 | 272 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
233 | - if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
273 | + if (!isset($this->all_tracked[$id]['archive_latitude'])) { |
|
274 | + $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
|
275 | + } |
|
234 | 276 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
235 | 277 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
236 | 278 | $dataFound = true; |
@@ -239,8 +281,12 @@ discard block |
||
239 | 281 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
240 | 282 | } |
241 | 283 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
242 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
243 | - if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
284 | + if ($line['longitude'] > 180) { |
|
285 | + $line['longitude'] = $line['longitude'] - 360; |
|
286 | + } |
|
287 | + if (!isset($this->all_tracked[$id]['archive_longitude'])) { |
|
288 | + $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
|
289 | + } |
|
244 | 290 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
245 | 291 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
246 | 292 | $dataFound = true; |
@@ -258,7 +304,9 @@ discard block |
||
258 | 304 | } |
259 | 305 | } |
260 | 306 | if (isset($line['last_update']) && $line['last_update'] != '') { |
261 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
307 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) { |
|
308 | + $dataFound = true; |
|
309 | + } |
|
262 | 310 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
263 | 311 | } |
264 | 312 | if (isset($line['format_source']) && $line['format_source'] != '') { |
@@ -276,15 +324,21 @@ discard block |
||
276 | 324 | } |
277 | 325 | |
278 | 326 | if (isset($line['heading']) && $line['heading'] != '') { |
279 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
327 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) { |
|
328 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
329 | + } |
|
280 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
281 | 331 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
282 | 332 | //$dataFound = true; |
283 | 333 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
284 | 334 | $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
285 | 335 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
286 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
287 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
336 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) { |
|
337 | + $this->all_tracked[$id]['putinarchive'] = true; |
|
338 | + } |
|
339 | + if ($globalDebug) { |
|
340 | + echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
341 | + } |
|
288 | 342 | } |
289 | 343 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
290 | 344 | |
@@ -292,8 +346,11 @@ discard block |
||
292 | 346 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
293 | 347 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
294 | 348 | } else { |
295 | - if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
296 | - elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
349 | + if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
350 | + echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
|
351 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) { |
|
352 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
353 | + } |
|
297 | 354 | return ''; |
298 | 355 | } |
299 | 356 | } else { |
@@ -308,23 +365,38 @@ discard block |
||
308 | 365 | if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
309 | 366 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
310 | 367 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
311 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
368 | + if ($globalDebug) { |
|
369 | + echo "Check if aircraft is already in DB..."; |
|
370 | + } |
|
312 | 371 | $timeelapsed = microtime(true); |
313 | 372 | $MarineLive = new MarineLive($this->db); |
314 | 373 | if (isset($line['id'])) { |
315 | 374 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
316 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
375 | + if ($globalDebugTimeElapsed) { |
|
376 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
377 | + } |
|
317 | 378 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
318 | 379 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
319 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
380 | + if ($globalDebugTimeElapsed) { |
|
381 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
382 | + } |
|
320 | 383 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
321 | 384 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
322 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
323 | - } else $recent_ident = ''; |
|
385 | + if ($globalDebugTimeElapsed) { |
|
386 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
387 | + } |
|
388 | + } else { |
|
389 | + $recent_ident = ''; |
|
390 | + } |
|
324 | 391 | $MarineLive->db=null; |
325 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
326 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
327 | - } else $recent_ident = ''; |
|
392 | + if ($globalDebug && $recent_ident == '') { |
|
393 | + echo " Not in DB.\n"; |
|
394 | + } elseif ($globalDebug && $recent_ident != '') { |
|
395 | + echo " Already in DB.\n"; |
|
396 | + } |
|
397 | + } else { |
|
398 | + $recent_ident = ''; |
|
399 | + } |
|
328 | 400 | } else { |
329 | 401 | $recent_ident = ''; |
330 | 402 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
@@ -332,18 +404,26 @@ discard block |
||
332 | 404 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
333 | 405 | if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
334 | 406 | { |
335 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
407 | + if ($globalDebug) { |
|
408 | + echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
|
409 | + } |
|
336 | 410 | //adds the spotter data for the archive |
337 | 411 | $highlight = ''; |
338 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
412 | + if (!isset($this->all_tracked[$id]['id'])) { |
|
413 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
414 | + } |
|
339 | 415 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
340 | 416 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
341 | 417 | $timeelapsed = microtime(true); |
342 | 418 | $Marine = new Marine($this->db); |
343 | 419 | $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
344 | 420 | $Marine->db = null; |
345 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
421 | + if ($globalDebug && isset($result)) { |
|
422 | + echo $result."\n"; |
|
423 | + } |
|
424 | + if ($globalDebugTimeElapsed) { |
|
425 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
426 | + } |
|
347 | 427 | } |
348 | 428 | } |
349 | 429 | /* |
@@ -378,13 +458,17 @@ discard block |
||
378 | 458 | $this->all_tracked[$id]['addedMarine'] = 1; |
379 | 459 | //print_r($this->all_tracked[$id]); |
380 | 460 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
381 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
461 | + if ($globalDebug) { |
|
462 | + echo "---- Deleting Live Marine data older than 9 hours..."; |
|
463 | + } |
|
382 | 464 | //MarineLive->deleteLiveMarineDataNotUpdated(); |
383 | 465 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
384 | 466 | $MarineLive = new MarineLive($this->db); |
385 | 467 | $MarineLive->deleteLiveMarineData(); |
386 | 468 | $MarineLive->db=null; |
387 | - if ($globalDebug) echo " Done\n"; |
|
469 | + if ($globalDebug) { |
|
470 | + echo " Done\n"; |
|
471 | + } |
|
388 | 472 | } |
389 | 473 | $this->last_delete = time(); |
390 | 474 | } |
@@ -410,15 +494,21 @@ discard block |
||
410 | 494 | |
411 | 495 | if (!$ignoreImport) { |
412 | 496 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
413 | - if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
497 | + if ($globalDebug) { |
|
498 | + echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
|
499 | + } |
|
414 | 500 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
415 | 501 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
416 | 502 | $timeelapsed = microtime(true); |
417 | 503 | $MarineLive = new MarineLive($this->db); |
418 | 504 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
419 | 505 | $MarineLive->db = null; |
420 | - if ($globalDebug) echo $result."\n"; |
|
421 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
506 | + if ($globalDebug) { |
|
507 | + echo $result."\n"; |
|
508 | + } |
|
509 | + if ($globalDebugTimeElapsed) { |
|
510 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
511 | + } |
|
422 | 512 | } |
423 | 513 | } |
424 | 514 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
@@ -481,19 +571,27 @@ discard block |
||
481 | 571 | */ |
482 | 572 | |
483 | 573 | $this->all_tracked[$id]['lastupdate'] = time(); |
484 | - if ($this->all_tracked[$id]['putinarchive']) $send = true; |
|
485 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
574 | + if ($this->all_tracked[$id]['putinarchive']) { |
|
575 | + $send = true; |
|
576 | + } |
|
577 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
578 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
579 | + } |
|
486 | 580 | //$this->del(); |
487 | 581 | |
488 | 582 | |
489 | 583 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
490 | 584 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
491 | - if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
585 | + if ($globalDebug) { |
|
586 | + echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
|
587 | + } |
|
492 | 588 | $MarineLive = new MarineLive($this->db); |
493 | 589 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
494 | 590 | $MarineLive->db = null; |
495 | 591 | //MarineLive->deleteLiveMarineData(); |
496 | - if ($globalDebug) echo " Done\n"; |
|
592 | + if ($globalDebug) { |
|
593 | + echo " Done\n"; |
|
594 | + } |
|
497 | 595 | } |
498 | 596 | $this->last_delete_hourly = time(); |
499 | 597 | } |
@@ -502,7 +600,9 @@ discard block |
||
502 | 600 | //$ignoreImport = false; |
503 | 601 | } |
504 | 602 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
505 | - if ($send) return $this->all_tracked[$id]; |
|
603 | + if ($send) { |
|
604 | + return $this->all_tracked[$id]; |
|
605 | + } |
|
506 | 606 | } |
507 | 607 | } |
508 | 608 | } |
@@ -48,27 +48,52 @@ discard block |
||
48 | 48 | } |
49 | 49 | header('Content-Type: text/javascript'); |
50 | 50 | |
51 | -if (!isset($globalJsonCompress)) $compress = true; |
|
52 | -else $compress = $globalJsonCompress; |
|
51 | +if (!isset($globalJsonCompress)) { |
|
52 | + $compress = true; |
|
53 | +} else { |
|
54 | + $compress = $globalJsonCompress; |
|
55 | +} |
|
53 | 56 | |
54 | 57 | $from_archive = false; |
55 | 58 | $min = true; |
56 | 59 | $allhistory = false; |
57 | 60 | $filter['source'] = array(); |
58 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
59 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
60 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
61 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
62 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
63 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
64 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
67 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
61 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
62 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
63 | +} |
|
64 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
65 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
66 | +} |
|
67 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
68 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
69 | +} |
|
70 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
71 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
72 | +} |
|
73 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
74 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
75 | +} |
|
76 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
77 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
78 | +} |
|
79 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
80 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
81 | +} |
|
82 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
83 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
84 | +} |
|
85 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
86 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
87 | +} |
|
88 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
89 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
90 | +} |
|
68 | 91 | |
69 | 92 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
70 | 93 | $min = true; |
71 | -} else $min = false; |
|
94 | +} else { |
|
95 | + $min = false; |
|
96 | +} |
|
72 | 97 | |
73 | 98 | if (isset($_GET['ident'])) { |
74 | 99 | $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
@@ -157,21 +182,33 @@ discard block |
||
157 | 182 | } else { |
158 | 183 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
159 | 184 | } |
160 | - } else $flightcnt = count($spotter_array); |
|
161 | - if ($flightcnt == '') $flightcnt = 0; |
|
162 | -} else $flightcnt = 0; |
|
185 | + } else { |
|
186 | + $flightcnt = count($spotter_array); |
|
187 | + } |
|
188 | + if ($flightcnt == '') { |
|
189 | + $flightcnt = 0; |
|
190 | + } |
|
191 | + } else { |
|
192 | + $flightcnt = 0; |
|
193 | +} |
|
163 | 194 | |
164 | 195 | $sqltime = round(microtime(true)-$begintime,2); |
165 | 196 | |
166 | -if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
|
167 | -else $usenextlatlon = true; |
|
197 | +if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) { |
|
198 | + $usenextlatlon = false; |
|
199 | +} else { |
|
200 | + $usenextlatlon = true; |
|
201 | +} |
|
168 | 202 | $j = 0; |
169 | 203 | $prev_flightaware_id = ''; |
170 | 204 | $aircrafts_shadow = array(); |
171 | 205 | $output = '{'; |
172 | 206 | $output .= '"type": "FeatureCollection",'; |
173 | - if ($min) $output .= '"minimal": "true",'; |
|
174 | - else $output .= '"minimal": "false",'; |
|
207 | + if ($min) { |
|
208 | + $output .= '"minimal": "true",'; |
|
209 | + } else { |
|
210 | + $output .= '"minimal": "false",'; |
|
211 | + } |
|
175 | 212 | $output .= '"fc": "'.$flightcnt.'",'; |
176 | 213 | $output .= '"sqt": "'.$sqltime.'",'; |
177 | 214 | |
@@ -215,18 +252,29 @@ discard block |
||
215 | 252 | } |
216 | 253 | $output .= '"properties": {'; |
217 | 254 | if (isset($spotter_item['flightaware_id'])) { |
218 | - if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
219 | - else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
255 | + if ($compress) { |
|
256 | + $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
257 | + } else { |
|
258 | + $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
259 | + } |
|
220 | 260 | } elseif (isset($spotter_item['famtrackid'])) { |
221 | - if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
222 | - else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
261 | + if ($compress) { |
|
262 | + $output .= '"fti": "'.$spotter_item['famtrackid'].'",'; |
|
263 | + } else { |
|
264 | + $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",'; |
|
265 | + } |
|
223 | 266 | } elseif (isset($spotter_item['fammarine_id'])) { |
224 | - if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
225 | - else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
267 | + if ($compress) { |
|
268 | + $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",'; |
|
269 | + } else { |
|
270 | + $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",'; |
|
271 | + } |
|
226 | 272 | } |
227 | 273 | $output .= '"fc": "'.$flightcnt.'",'; |
228 | 274 | $output .= '"sqt": "'.$sqltime.'",'; |
229 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
275 | + if (isset($begindate)) { |
|
276 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
277 | + } |
|
230 | 278 | |
231 | 279 | /* |
232 | 280 | if ($min) $output .= '"minimal": "true",'; |
@@ -234,13 +282,21 @@ discard block |
||
234 | 282 | */ |
235 | 283 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
236 | 284 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
237 | - if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",'; |
|
238 | - else $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
|
285 | + if ($compress) { |
|
286 | + $output .= '"c": "'.$spotter_item['ident'].'",'; |
|
287 | + } else { |
|
288 | + $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
|
289 | + } |
|
239 | 290 | } else { |
240 | - if ($compress) $output .= '"c": "NA",'; |
|
241 | - else $output .= '"callsign": "NA",'; |
|
291 | + if ($compress) { |
|
292 | + $output .= '"c": "NA",'; |
|
293 | + } else { |
|
294 | + $output .= '"callsign": "NA",'; |
|
295 | + } |
|
296 | + } |
|
297 | + if (isset($spotter_item['registration'])) { |
|
298 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
242 | 299 | } |
243 | - if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
244 | 300 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
245 | 301 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
246 | 302 | $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
@@ -253,15 +309,21 @@ discard block |
||
253 | 309 | $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
254 | 310 | } |
255 | 311 | if (!isset($spotter_item['aircraft_shadow']) && !$tracker) { |
256 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
|
257 | - else { |
|
312 | + if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { |
|
313 | + $spotter_item['aircraft_shadow'] = ''; |
|
314 | + } else { |
|
258 | 315 | $aircraft_icao = $spotter_item['aircraft_icao']; |
259 | - if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
260 | - else { |
|
316 | + if (isset($aircrafts_shadow[$aircraft_icao])) { |
|
317 | + $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao]; |
|
318 | + } else { |
|
261 | 319 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
262 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
263 | - elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
264 | - else $spotter_item['aircraft_shadow'] = ''; |
|
320 | + if (count($aircraft_info) > 0) { |
|
321 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
322 | + } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
|
323 | + $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
324 | + } else { |
|
325 | + $spotter_item['aircraft_shadow'] = ''; |
|
326 | + } |
|
265 | 327 | $aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow']; |
266 | 328 | } |
267 | 329 | } |
@@ -269,73 +331,139 @@ discard block |
||
269 | 331 | if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') { |
270 | 332 | if ($tracker) { |
271 | 333 | if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') { |
272 | - if ($compress) $output .= '"as": "ambulance.png",'; |
|
273 | - else $output .= '"aircraft_shadow": "ambulance.png",'; |
|
334 | + if ($compress) { |
|
335 | + $output .= '"as": "ambulance.png",'; |
|
336 | + } else { |
|
337 | + $output .= '"aircraft_shadow": "ambulance.png",'; |
|
338 | + } |
|
274 | 339 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') { |
275 | - if ($compress) $output .= '"as": "police.png",'; |
|
276 | - else $output .= '"aircraft_shadow": "police.png",'; |
|
340 | + if ($compress) { |
|
341 | + $output .= '"as": "police.png",'; |
|
342 | + } else { |
|
343 | + $output .= '"aircraft_shadow": "police.png",'; |
|
344 | + } |
|
277 | 345 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') { |
278 | - if ($compress) $output .= '"as": "ship.png",'; |
|
279 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
346 | + if ($compress) { |
|
347 | + $output .= '"as": "ship.png",'; |
|
348 | + } else { |
|
349 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
350 | + } |
|
280 | 351 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') { |
281 | - if ($compress) $output .= '"as": "ship.png",'; |
|
282 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
352 | + if ($compress) { |
|
353 | + $output .= '"as": "ship.png",'; |
|
354 | + } else { |
|
355 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
356 | + } |
|
283 | 357 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') { |
284 | - if ($compress) $output .= '"as": "ship.png",'; |
|
285 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
358 | + if ($compress) { |
|
359 | + $output .= '"as": "ship.png",'; |
|
360 | + } else { |
|
361 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
362 | + } |
|
286 | 363 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') { |
287 | - if ($compress) $output .= '"as": "truck.png",'; |
|
288 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
364 | + if ($compress) { |
|
365 | + $output .= '"as": "truck.png",'; |
|
366 | + } else { |
|
367 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
368 | + } |
|
289 | 369 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') { |
290 | - if ($compress) $output .= '"as": "truck.png",'; |
|
291 | - else $output .= '"aircraft_shadow": "truck.png",'; |
|
370 | + if ($compress) { |
|
371 | + $output .= '"as": "truck.png",'; |
|
372 | + } else { |
|
373 | + $output .= '"aircraft_shadow": "truck.png",'; |
|
374 | + } |
|
292 | 375 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') { |
293 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
294 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
376 | + if ($compress) { |
|
377 | + $output .= '"as": "aircraft.png",'; |
|
378 | + } else { |
|
379 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
380 | + } |
|
295 | 381 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') { |
296 | - if ($compress) $output .= '"as": "aircraft.png",'; |
|
297 | - else $output .= '"aircraft_shadow": "aircraft.png",'; |
|
382 | + if ($compress) { |
|
383 | + $output .= '"as": "aircraft.png",'; |
|
384 | + } else { |
|
385 | + $output .= '"aircraft_shadow": "aircraft.png",'; |
|
386 | + } |
|
298 | 387 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') { |
299 | - if ($compress) $output .= '"as": "helico.png",'; |
|
300 | - else $output .= '"aircraft_shadow": "helico.png",'; |
|
388 | + if ($compress) { |
|
389 | + $output .= '"as": "helico.png",'; |
|
390 | + } else { |
|
391 | + $output .= '"aircraft_shadow": "helico.png",'; |
|
392 | + } |
|
301 | 393 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') { |
302 | - if ($compress) $output .= '"as": "rail.png",'; |
|
303 | - else $output .= '"aircraft_shadow": "rail.png",'; |
|
394 | + if ($compress) { |
|
395 | + $output .= '"as": "rail.png",'; |
|
396 | + } else { |
|
397 | + $output .= '"aircraft_shadow": "rail.png",'; |
|
398 | + } |
|
304 | 399 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') { |
305 | - if ($compress) $output .= '"as": "firetruck.png",'; |
|
306 | - else $output .= '"aircraft_shadow": "firetruck.png",'; |
|
400 | + if ($compress) { |
|
401 | + $output .= '"as": "firetruck.png",'; |
|
402 | + } else { |
|
403 | + $output .= '"aircraft_shadow": "firetruck.png",'; |
|
404 | + } |
|
307 | 405 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') { |
308 | - if ($compress) $output .= '"as": "bus.png",'; |
|
309 | - else $output .= '"aircraft_shadow": "bus.png",'; |
|
406 | + if ($compress) { |
|
407 | + $output .= '"as": "bus.png",'; |
|
408 | + } else { |
|
409 | + $output .= '"aircraft_shadow": "bus.png",'; |
|
410 | + } |
|
310 | 411 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') { |
311 | - if ($compress) $output .= '"as": "phone.png",'; |
|
312 | - else $output .= '"aircraft_shadow": "phone.png",'; |
|
412 | + if ($compress) { |
|
413 | + $output .= '"as": "phone.png",'; |
|
414 | + } else { |
|
415 | + $output .= '"aircraft_shadow": "phone.png",'; |
|
416 | + } |
|
313 | 417 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') { |
314 | - if ($compress) $output .= '"as": "jogger.png",'; |
|
315 | - else $output .= '"aircraft_shadow": "jogger.png",'; |
|
418 | + if ($compress) { |
|
419 | + $output .= '"as": "jogger.png",'; |
|
420 | + } else { |
|
421 | + $output .= '"aircraft_shadow": "jogger.png",'; |
|
422 | + } |
|
316 | 423 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') { |
317 | - if ($compress) $output .= '"as": "bike.png",'; |
|
318 | - else $output .= '"aircraft_shadow": "bike.png",'; |
|
424 | + if ($compress) { |
|
425 | + $output .= '"as": "bike.png",'; |
|
426 | + } else { |
|
427 | + $output .= '"aircraft_shadow": "bike.png",'; |
|
428 | + } |
|
319 | 429 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') { |
320 | - if ($compress) $output .= '"as": "motorcycle.png",'; |
|
321 | - else $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
430 | + if ($compress) { |
|
431 | + $output .= '"as": "motorcycle.png",'; |
|
432 | + } else { |
|
433 | + $output .= '"aircraft_shadow": "motorcycle.png",'; |
|
434 | + } |
|
322 | 435 | } elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') { |
323 | - if ($compress) $output .= '"as": "balloon.png",'; |
|
324 | - else $output .= '"aircraft_shadow": "balloon.png",'; |
|
436 | + if ($compress) { |
|
437 | + $output .= '"as": "balloon.png",'; |
|
438 | + } else { |
|
439 | + $output .= '"aircraft_shadow": "balloon.png",'; |
|
440 | + } |
|
325 | 441 | } else { |
326 | - if ($compress) $output .= '"as": "car.png",'; |
|
327 | - else $output .= '"aircraft_shadow": "car.png",'; |
|
442 | + if ($compress) { |
|
443 | + $output .= '"as": "car.png",'; |
|
444 | + } else { |
|
445 | + $output .= '"aircraft_shadow": "car.png",'; |
|
446 | + } |
|
328 | 447 | } |
329 | 448 | } elseif ($marine) { |
330 | - if ($compress) $output .= '"as": "ship.png",'; |
|
331 | - else $output .= '"aircraft_shadow": "ship.png",'; |
|
449 | + if ($compress) { |
|
450 | + $output .= '"as": "ship.png",'; |
|
451 | + } else { |
|
452 | + $output .= '"aircraft_shadow": "ship.png",'; |
|
453 | + } |
|
332 | 454 | } else { |
333 | - if ($compress) $output .= '"as": "default.png",'; |
|
334 | - else $output .= '"aircraft_shadow": "default.png",'; |
|
455 | + if ($compress) { |
|
456 | + $output .= '"as": "default.png",'; |
|
457 | + } else { |
|
458 | + $output .= '"aircraft_shadow": "default.png",'; |
|
459 | + } |
|
335 | 460 | } |
336 | 461 | } else { |
337 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
338 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
462 | + if ($compress) { |
|
463 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
464 | + } else { |
|
465 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
466 | + } |
|
339 | 467 | } |
340 | 468 | if (isset($spotter_item['airline_name'])) { |
341 | 469 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
@@ -343,8 +471,11 @@ discard block |
||
343 | 471 | $output .= '"airline_name": "NA",'; |
344 | 472 | } |
345 | 473 | if (isset($spotter_item['departure_airport'])) { |
346 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
347 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
474 | + if ($compress) { |
|
475 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
476 | + } else { |
|
477 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
478 | + } |
|
348 | 479 | } |
349 | 480 | if (isset($spotter_item['departure_airport_city'])) { |
350 | 481 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
@@ -356,8 +487,11 @@ discard block |
||
356 | 487 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
357 | 488 | } |
358 | 489 | if (isset($spotter_item['arrival_airport'])) { |
359 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
360 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
490 | + if ($compress) { |
|
491 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
492 | + } else { |
|
493 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
494 | + } |
|
361 | 495 | } |
362 | 496 | if (isset($spotter_item['arrival_airport_city'])) { |
363 | 497 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
@@ -376,11 +510,17 @@ discard block |
||
376 | 510 | } |
377 | 511 | |
378 | 512 | if (isset($spotter_item['altitude'])) { |
379 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
380 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
513 | + if ($compress) { |
|
514 | + $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
515 | + } else { |
|
516 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
517 | + } |
|
518 | + } |
|
519 | + if ($compress) { |
|
520 | + $output .= '"h": "'.$spotter_item['heading'].'",'; |
|
521 | + } else { |
|
522 | + $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
381 | 523 | } |
382 | - if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",'; |
|
383 | - else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
384 | 524 | |
385 | 525 | if (isset($archivespeed)) { |
386 | 526 | $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
@@ -390,7 +530,9 @@ discard block |
||
390 | 530 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
391 | 531 | } |
392 | 532 | |
393 | - if (!$min) $output .= '"image": "'.$image.'",'; |
|
533 | + if (!$min) { |
|
534 | + $output .= '"image": "'.$image.'",'; |
|
535 | + } |
|
394 | 536 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
395 | 537 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
396 | 538 | } |
@@ -398,8 +540,11 @@ discard block |
||
398 | 540 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
399 | 541 | } |
400 | 542 | if (isset($spotter_item['squawk'])) { |
401 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
402 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
543 | + if ($compress) { |
|
544 | + $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
545 | + } else { |
|
546 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
547 | + } |
|
403 | 548 | } |
404 | 549 | if (isset($spotter_item['squawk_usage'])) { |
405 | 550 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
@@ -418,14 +563,23 @@ discard block |
||
418 | 563 | } |
419 | 564 | // type when not aircraft ? |
420 | 565 | if (isset($spotter_item['type'])) { |
421 | - if ($compress) $output .= '"t": "'.$spotter_item['type'].'"'; |
|
422 | - else $output .= '"type": "'.$spotter_item['type'].'"'; |
|
566 | + if ($compress) { |
|
567 | + $output .= '"t": "'.$spotter_item['type'].'"'; |
|
568 | + } else { |
|
569 | + $output .= '"type": "'.$spotter_item['type'].'"'; |
|
570 | + } |
|
423 | 571 | } elseif ($marine) { |
424 | - if ($compress) $output .= '"t": "ship"'; |
|
425 | - else $output .= '"type": "ship"'; |
|
572 | + if ($compress) { |
|
573 | + $output .= '"t": "ship"'; |
|
574 | + } else { |
|
575 | + $output .= '"type": "ship"'; |
|
576 | + } |
|
426 | 577 | } else { |
427 | - if ($compress) $output .= '"t": "aircraft"'; |
|
428 | - else $output .= '"type": "aircraft"'; |
|
578 | + if ($compress) { |
|
579 | + $output .= '"t": "aircraft"'; |
|
580 | + } else { |
|
581 | + $output .= '"type": "aircraft"'; |
|
582 | + } |
|
429 | 583 | } |
430 | 584 | $output .= '},'; |
431 | 585 | $output .= '"geometry": {'; |
@@ -493,7 +647,9 @@ discard block |
||
493 | 647 | } |
494 | 648 | */ |
495 | 649 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
496 | - if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
|
650 | + if ($history == '' && isset($_COOKIE['history'])) { |
|
651 | + $history = $_COOKIE['history']; |
|
652 | + } |
|
497 | 653 | |
498 | 654 | if ( |
499 | 655 | (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
@@ -525,8 +681,11 @@ discard block |
||
525 | 681 | $output_history .= ']}},'; |
526 | 682 | $output .= $output_history; |
527 | 683 | } |
528 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
529 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
684 | + if ($compress) { |
|
685 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
686 | + } else { |
|
687 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
688 | + } |
|
530 | 689 | } |
531 | 690 | $output_history .= '['; |
532 | 691 | $output_history .= $spotter_history['longitude'].', '; |
@@ -536,9 +695,14 @@ discard block |
||
536 | 695 | $prev_alt = $alt; |
537 | 696 | } else { |
538 | 697 | if ($d == false) { |
539 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
540 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
541 | - } else $d = true; |
|
698 | + if ($compress) { |
|
699 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
700 | + } else { |
|
701 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
|
702 | + } |
|
703 | + } else { |
|
704 | + $d = true; |
|
705 | + } |
|
542 | 706 | $output_history .= '['; |
543 | 707 | $output_history .= $spotter_history['longitude'].', '; |
544 | 708 | $output_history .= $spotter_history['latitude']; |
@@ -581,7 +745,9 @@ discard block |
||
581 | 745 | $output .= ']'; |
582 | 746 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
583 | 747 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
584 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
748 | + if (isset($begindate)) { |
|
749 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
750 | + } |
|
585 | 751 | $output .= '"fc": "'.$j.'"'; |
586 | 752 | } else { |
587 | 753 | $output .= '"features": '; |
@@ -3,8 +3,12 @@ discard block |
||
3 | 3 | require_once('require/class.Common.php'); |
4 | 4 | $tracker = false; |
5 | 5 | $marine = false; |
6 | -if (isset($_GET['tracker'])) $tracker = true; |
|
7 | -if (isset($_GET['marine'])) $marine = true; |
|
6 | +if (isset($_GET['tracker'])) { |
|
7 | + $tracker = true; |
|
8 | +} |
|
9 | +if (isset($_GET['marine'])) { |
|
10 | + $marine = true; |
|
11 | +} |
|
8 | 12 | if ($tracker) { |
9 | 13 | require_once('require/class.Tracker.php'); |
10 | 14 | require_once('require/class.TrackerLive.php'); |
@@ -61,23 +65,46 @@ discard block |
||
61 | 65 | } |
62 | 66 | header('Content-Type: text/javascript'); |
63 | 67 | |
64 | -if (!isset($globalJsonCompress)) $compress = true; |
|
65 | -else $compress = $globalJsonCompress; |
|
68 | +if (!isset($globalJsonCompress)) { |
|
69 | + $compress = true; |
|
70 | +} else { |
|
71 | + $compress = $globalJsonCompress; |
|
72 | +} |
|
66 | 73 | |
67 | 74 | $from_archive = false; |
68 | 75 | $min = false; |
69 | 76 | $allhistory = false; |
70 | 77 | $filter['source'] = array(); |
71 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
72 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
73 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
74 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
75 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
76 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
77 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
78 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
79 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
80 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
78 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') { |
|
79 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
80 | +} |
|
81 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') { |
|
82 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
83 | +} |
|
84 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') { |
|
85 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
86 | +} |
|
87 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') { |
|
88 | + $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
89 | +} |
|
90 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') { |
|
91 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
92 | +} |
|
93 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') { |
|
94 | + $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
95 | +} |
|
96 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') { |
|
97 | + $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
98 | +} |
|
99 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') { |
|
100 | + $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
101 | +} |
|
102 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') { |
|
103 | + $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
104 | +} |
|
105 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') { |
|
106 | + $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
107 | +} |
|
81 | 108 | /* |
82 | 109 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
83 | 110 | $min = true; |
@@ -162,8 +189,12 @@ discard block |
||
162 | 189 | } else { |
163 | 190 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
164 | 191 | } |
165 | - if ($flightcnt == '') $flightcnt = 0; |
|
166 | -} else $flightcnt = 0; |
|
192 | + if ($flightcnt == '') { |
|
193 | + $flightcnt = 0; |
|
194 | + } |
|
195 | + } else { |
|
196 | + $flightcnt = 0; |
|
197 | +} |
|
167 | 198 | |
168 | 199 | $sqltime = round(microtime(true)-$begintime,2); |
169 | 200 | $minitime = time(); |
@@ -186,7 +217,9 @@ discard block |
||
186 | 217 | $j = 0; |
187 | 218 | $prev_flightaware_id = ''; |
188 | 219 | $speed = 1; |
189 | -if (isset($archivespeed)) $speed = $archivespeed; |
|
220 | +if (isset($archivespeed)) { |
|
221 | + $speed = $archivespeed; |
|
222 | +} |
|
190 | 223 | $output = '['; |
191 | 224 | if ($tracker) { |
192 | 225 | $output .= '{"id" : "document", "name" : "tracker","version" : "1.0"'; |
@@ -220,9 +253,13 @@ discard block |
||
220 | 253 | $image = "images/placeholder_thumb.png"; |
221 | 254 | } |
222 | 255 | |
223 | - if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id']; |
|
224 | - elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid']; |
|
225 | - elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id']; |
|
256 | + if (isset($spotter_item['flightaware_id'])) { |
|
257 | + $id = $spotter_item['flightaware_id']; |
|
258 | + } elseif (isset($spotter_item['famtrackid'])) { |
|
259 | + $id = $spotter_item['famtrackid']; |
|
260 | + } elseif (isset($spotter_item['fammarine_id'])) { |
|
261 | + $id = $spotter_item['fammarine_id']; |
|
262 | + } |
|
226 | 263 | if ($prev_flightaware_id != $id) { |
227 | 264 | if ($prev_flightaware_id != '') { |
228 | 265 | $output .= ']'; |
@@ -268,7 +305,9 @@ discard block |
||
268 | 305 | $spotter_item['engine_type'] = $aircraft_info[0]['engine_type']; |
269 | 306 | $spotter_item['wake_category'] = $aircraft_info[0]['wake_category']; |
270 | 307 | $spotter_item['engine_count'] = $aircraft_info[0]['engine_count']; |
271 | - } else $aircraft_shadow = ''; |
|
308 | + } else { |
|
309 | + $aircraft_shadow = ''; |
|
310 | + } |
|
272 | 311 | if ($aircraft_shadow != '') { |
273 | 312 | if (isset($modelsdb[$aircraft_shadow])) { |
274 | 313 | $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20'; |
@@ -405,7 +444,9 @@ discard block |
||
405 | 444 | } |
406 | 445 | $output .= '},'; |
407 | 446 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
408 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
447 | + if ($spotter_item['aircraft_icao'] != '') { |
|
448 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
449 | + } |
|
409 | 450 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
410 | 451 | } |
411 | 452 | } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
@@ -427,7 +468,9 @@ discard block |
||
427 | 468 | } |
428 | 469 | $output .= '},'; |
429 | 470 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
430 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
471 | + if ($spotter_item['aircraft_icao'] != '') { |
|
472 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
473 | + } |
|
431 | 474 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
432 | 475 | } |
433 | 476 | } else { |
@@ -440,7 +483,9 @@ discard block |
||
440 | 483 | } |
441 | 484 | $output .= '},'; |
442 | 485 | //if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
443 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
486 | + if ($spotter_item['aircraft_icao'] != '') { |
|
487 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
488 | + } |
|
444 | 489 | $modelsdb[$aircraft_icao] = 'Cesium_Air.glb'; |
445 | 490 | } |
446 | 491 | } elseif ($tracker && isset($spotter_item['type'])) { |
@@ -495,8 +540,12 @@ discard block |
||
495 | 540 | // $output .= '"interpolationDegree" : 5,'; |
496 | 541 | // $output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", '; |
497 | 542 | $output .= '"cartographicDegrees": ['; |
498 | - if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
|
499 | - if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
|
543 | + if ($minitime > strtotime($spotter_item['date'])) { |
|
544 | + $minitime = strtotime($spotter_item['date']); |
|
545 | + } |
|
546 | + if ($maxitime < strtotime($spotter_item['date'])) { |
|
547 | + $maxitime = strtotime($spotter_item['date']); |
|
548 | + } |
|
500 | 549 | $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
501 | 550 | $output .= $spotter_item['longitude'].', '; |
502 | 551 | $output .= $spotter_item['latitude']; |
@@ -505,19 +554,26 @@ discard block |
||
505 | 554 | if (!$tracker && !$marine) { |
506 | 555 | $output .= ', '.round($spotter_item['altitude']*30.48); |
507 | 556 | $prevalt = round($spotter_item['altitude']*30.48); |
508 | - } else $output .= ', 0'; |
|
557 | + } else { |
|
558 | + $output .= ', 0'; |
|
559 | + } |
|
509 | 560 | //$orientation = '"orientation" : { '; |
510 | 561 | //$orientation .= '"unitQuaternion": ['; |
511 | 562 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
512 | 563 | //$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |
513 | 564 | } else { |
514 | 565 | $output .= ',"'.date("c",strtotime($spotter_item['date'])).'", '; |
515 | - if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']); |
|
566 | + if ($maxitime < strtotime($spotter_item['date'])) { |
|
567 | + $maxitime = strtotime($spotter_item['date']); |
|
568 | + } |
|
516 | 569 | if ($spotter_item['ground_speed'] == 0) { |
517 | 570 | $output .= $prevlong.', '; |
518 | 571 | $output .= $prevlat; |
519 | - if (!$tracker && !$marine) $output .= ', '.$prevalt; |
|
520 | - else $output .= ', 0'; |
|
572 | + if (!$tracker && !$marine) { |
|
573 | + $output .= ', '.$prevalt; |
|
574 | + } else { |
|
575 | + $output .= ', 0'; |
|
576 | + } |
|
521 | 577 | } else { |
522 | 578 | $output .= $spotter_item['longitude'].', '; |
523 | 579 | $output .= $spotter_item['latitude']; |
@@ -531,7 +587,9 @@ discard block |
||
531 | 587 | } else { |
532 | 588 | $output .= ', '.round($spotter_item['altitude']*30.48); |
533 | 589 | } |
534 | - } else $output .= ', 0'; |
|
590 | + } else { |
|
591 | + $output .= ', 0'; |
|
592 | + } |
|
535 | 593 | } |
536 | 594 | //$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0)); |
537 | 595 | //$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w']; |