@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | $currentdate = date('Y-m-d'); |
35 | 35 | $sourcestat = $Stats->getStatsSource($currentdate); |
36 | 36 | if (!empty($sourcestat)) { |
37 | - foreach($sourcestat as $srcst) { |
|
37 | + foreach ($sourcestat as $srcst) { |
|
38 | 38 | $type = $srcst['stats_type']; |
39 | 39 | if ($type == 'polar' || $type == 'hist') { |
40 | 40 | $source = $srcst['source_name']; |
41 | 41 | $data = $srcst['source_data']; |
42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
42 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | if (isset($globalGeoid) && $globalGeoid) { |
52 | 52 | try { |
53 | 53 | $GeoidClass = new GeoidHeight(); |
54 | - } catch(Exception $e) { |
|
54 | + } catch (Exception $e) { |
|
55 | 55 | if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
56 | 56 | $GeoidClass = FALSE; |
57 | 57 | } |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - public function get_Schedule($id,$ident) { |
|
61 | + public function get_Schedule($id, $ident) { |
|
62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
63 | 63 | // Get schedule here, so it's done only one time |
64 | 64 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | 85 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | 88 | // Should also check if route schedule = route from DB |
89 | 89 | if ($schedule['DepartureAirportIATA'] != '') { |
90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
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']); |
|
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']); |
|
108 | 108 | } |
109 | 109 | } else $scheduleexist = true; |
110 | 110 | } else $scheduleexist = true; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if ($scheduleexist) { |
113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
114 | 114 | $sch = $Schedule->getSchedule($operator); |
115 | - $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'])); |
|
115 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
116 | 116 | } |
117 | 117 | $Spotter->db = null; |
118 | 118 | $Schedule->db = null; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
140 | 140 | $Spotter = new Spotter($this->db); |
141 | 141 | $real_arrival = $this->arrival($key); |
142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
142 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $airport_time = ''; |
154 | 154 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
155 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
156 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
157 | 157 | if (isset($closestAirports[0])) { |
158 | 158 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
159 | 159 | $airport_icao = $closestAirports[0]['icao']; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | break; |
169 | 169 | } |
170 | 170 | } |
171 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
171 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
172 | 172 | $airport_icao = $closestAirports[0]['icao']; |
173 | 173 | $airport_time = $this->all_flights[$key]['datetime']; |
174 | 174 | } else { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } else { |
182 | 182 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
183 | 183 | } |
184 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
184 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
193 | 193 | foreach ($this->all_flights as $key => $flight) { |
194 | 194 | if (isset($flight['lastupdate'])) { |
195 | - if ($flight['lastupdate'] < (time()-5900)) { |
|
195 | + if ($flight['lastupdate'] < (time() - 5900)) { |
|
196 | 196 | $this->delKey($key); |
197 | 197 | } |
198 | 198 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $real_arrival = $this->arrival($key); |
209 | 209 | $Spotter = new Spotter($this->db); |
210 | 210 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
211 | - $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']); |
|
211 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
212 | 212 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
213 | 213 | } |
214 | 214 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $send = false; |
242 | 242 | |
243 | 243 | // SBS format is CSV format |
244 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
244 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
245 | 245 | //print_r($line); |
246 | 246 | if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
247 | 247 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
@@ -277,25 +277,25 @@ discard block |
||
277 | 277 | if (!isset($this->all_flights[$id])) { |
278 | 278 | if ($globalDebug) echo 'New flight...'."\n"; |
279 | 279 | $this->all_flights[$id] = array(); |
280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
281 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '')); |
|
282 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
283 | 283 | if (!isset($line['id'])) { |
284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
285 | 285 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
286 | 286 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
287 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
287 | + 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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
288 | 288 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
289 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
290 | 290 | if ($globalAllFlights !== FALSE) $dataFound = true; |
291 | 291 | } |
292 | 292 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
293 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | //print_r($this->all_flights); |
297 | 297 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
298 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
298 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
299 | 299 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
300 | 300 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
301 | 301 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -304,20 +304,20 @@ discard block |
||
304 | 304 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
305 | 305 | $Spotter = new Spotter($this->db); |
306 | 306 | if (isset($this->all_flights[$id]['source_type'])) { |
307 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
307 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
308 | 308 | } else { |
309 | 309 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | 310 | } |
311 | 311 | $Spotter->db = null; |
312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
312 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
313 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | if ($globalAllFlights !== FALSE) $dataFound = true; |
317 | 317 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
318 | 318 | } |
319 | 319 | if (isset($line['id']) && !isset($line['hex'])) { |
320 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
320 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => '')); |
|
321 | 321 | } |
322 | 322 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
323 | 323 | $icao = $line['aircraft_icao']; |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
327 | 327 | $Spotter->db = null; |
328 | 328 | } |
329 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
329 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao)); |
|
330 | 330 | } |
331 | 331 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
332 | 332 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $Spotter = new Spotter($this->db); |
335 | 335 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
336 | 336 | $Spotter->db = null; |
337 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
337 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -342,15 +342,15 @@ discard block |
||
342 | 342 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
343 | 343 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
344 | 344 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
345 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
345 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
346 | 346 | } |
347 | 347 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
348 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
348 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
349 | 349 | } |
350 | 350 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
351 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
351 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
352 | 352 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
353 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
353 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
354 | 354 | } else { |
355 | 355 | 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"; |
356 | 356 | 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"; |
@@ -361,31 +361,31 @@ discard block |
||
361 | 361 | */ |
362 | 362 | return ''; |
363 | 363 | } |
364 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
364 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
365 | 365 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
366 | 366 | return ''; |
367 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
367 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
368 | 368 | if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
369 | 369 | return ''; |
370 | 370 | } elseif (!isset($line['datetime'])) { |
371 | 371 | date_default_timezone_set('UTC'); |
372 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
372 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
373 | 373 | } else { |
374 | 374 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
375 | 375 | return ''; |
376 | 376 | } |
377 | 377 | |
378 | 378 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
379 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
379 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
380 | 380 | } |
381 | 381 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
382 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
382 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
383 | 383 | } |
384 | 384 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
385 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
385 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id']))); |
|
386 | 386 | } |
387 | 387 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
388 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
388 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name']))); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
@@ -393,13 +393,13 @@ discard block |
||
393 | 393 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
394 | 394 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
395 | 395 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
396 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
397 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
398 | - 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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
399 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
400 | - 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'])); |
|
396 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
397 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
398 | + 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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
399 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
400 | + 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'])); |
|
401 | 401 | } else { |
402 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
402 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
403 | 403 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
404 | 404 | $timeelapsed = microtime(true); |
405 | 405 | $Spotter = new Spotter($this->db); |
@@ -409,13 +409,13 @@ discard block |
||
409 | 409 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
410 | 410 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
411 | 411 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
412 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
412 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
413 | 413 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
414 | 414 | $Spotter->db = null; |
415 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
415 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
416 | 416 | } |
417 | 417 | } |
418 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
418 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
419 | 419 | |
420 | 420 | /* |
421 | 421 | if (!isset($line['id'])) { |
@@ -425,25 +425,25 @@ discard block |
||
425 | 425 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
426 | 426 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
427 | 427 | */ |
428 | - 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'])); |
|
428 | + 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'])); |
|
429 | 429 | |
430 | 430 | //$putinarchive = true; |
431 | 431 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
432 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
432 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
433 | 433 | } |
434 | 434 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
435 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
435 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
436 | 436 | } |
437 | 437 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
438 | - $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' => '')); |
|
438 | + $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' => '')); |
|
439 | 439 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
440 | 440 | $timeelapsed = microtime(true); |
441 | 441 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
442 | 442 | $Spotter = new Spotter($this->db); |
443 | 443 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
444 | 444 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
445 | - $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' => '')); |
|
446 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
445 | + $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' => '')); |
|
446 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
447 | 447 | } |
448 | 448 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
449 | 449 | $timeelapsed = microtime(true); |
@@ -457,35 +457,35 @@ discard block |
||
457 | 457 | $Translation->db = null; |
458 | 458 | } |
459 | 459 | $Spotter->db = null; |
460 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
460 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
461 | 461 | } |
462 | 462 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
463 | 463 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
464 | 464 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
465 | 465 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
466 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
466 | + $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'])); |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | if (!isset($globalFork)) $globalFork = TRUE; |
470 | 470 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
471 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
471 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
472 | 472 | } |
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
476 | 476 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
477 | 477 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
478 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
479 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
478 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
479 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
480 | 480 | //$dataFound = true; |
481 | 481 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
482 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
482 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
483 | 483 | if ($distance > 1000 && $distance < 10000) { |
484 | 484 | // use datetime |
485 | 485 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
486 | 486 | $speed = $speed*3.6; |
487 | 487 | if ($speed < 1000) { |
488 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
488 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
489 | 489 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
490 | 490 | } else { |
491 | 491 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
@@ -500,9 +500,9 @@ discard block |
||
500 | 500 | if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
501 | 501 | return false; |
502 | 502 | } |
503 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
503 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
504 | 504 | else unset($timediff); |
505 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
505 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']); |
|
506 | 506 | else unset($timediff_archive); |
507 | 507 | if ($this->tmd > 5 |
508 | 508 | || (isset($line['format_source']) |
@@ -526,14 +526,14 @@ discard block |
||
526 | 526 | || ($timediff > 30 |
527 | 527 | && isset($this->all_flights[$id]['latitude']) |
528 | 528 | && isset($this->all_flights[$id]['longitude']) |
529 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
529 | + && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')) |
|
530 | 530 | ) |
531 | 531 | ) { |
532 | 532 | |
533 | 533 | if ((isset($timediff) && !isset($timediff_archive)) || (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']))) { |
534 | 534 | if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
535 | 535 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
536 | - || !$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'])) { |
|
536 | + || !$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'])) { |
|
537 | 537 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
538 | 538 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
539 | 539 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -543,11 +543,11 @@ discard block |
||
543 | 543 | $timeelapsed = microtime(true); |
544 | 544 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
545 | 545 | $Spotter = new Spotter($this->db); |
546 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
546 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
547 | 547 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
548 | 548 | else $this->all_flights[$id]['over_country'] = ''; |
549 | 549 | $Spotter->db = null; |
550 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
550 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
551 | 551 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
552 | 552 | } |
553 | 553 | } |
@@ -573,13 +573,13 @@ discard block |
||
573 | 573 | $this->all_flights[$id]['time_last_coord'] = time(); |
574 | 574 | } |
575 | 575 | //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' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
576 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
|
576 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) { |
|
577 | 577 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
578 | 578 | $dataFound = true; |
579 | 579 | $this->all_flights[$id]['time_last_coord'] = time(); |
580 | 580 | } |
581 | 581 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
582 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
582 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
583 | 583 | /* |
584 | 584 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
585 | 585 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -601,13 +601,13 @@ discard block |
||
601 | 601 | $this->all_flights[$id]['time_last_coord'] = time(); |
602 | 602 | } |
603 | 603 | //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' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
604 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
|
604 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) { |
|
605 | 605 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
606 | 606 | $dataFound = true; |
607 | 607 | $this->all_flights[$id]['time_last_coord'] = time(); |
608 | 608 | } |
609 | 609 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
610 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
610 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
611 | 611 | /* |
612 | 612 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
613 | 613 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -625,46 +625,46 @@ discard block |
||
625 | 625 | } else if ($globalDebug && $timediff > 30) { |
626 | 626 | $this->tmd = $this->tmd + 1; |
627 | 627 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
628 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
629 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
628 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
629 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
630 | 630 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
631 | 631 | } |
632 | 632 | } |
633 | 633 | if (isset($line['last_update']) && $line['last_update'] != '') { |
634 | 634 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
635 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
635 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
636 | 636 | } |
637 | 637 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
638 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
638 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
639 | 639 | //$dataFound = true; |
640 | 640 | } |
641 | 641 | if (isset($line['format_source']) && $line['format_source'] != '') { |
642 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
642 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
643 | 643 | } |
644 | 644 | if (isset($line['source_name']) && $line['source_name'] != '') { |
645 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
645 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
646 | 646 | } |
647 | 647 | if (isset($line['emergency']) && $line['emergency'] != '') { |
648 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
648 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
649 | 649 | //$dataFound = true; |
650 | 650 | } |
651 | 651 | if (isset($line['ground']) && $line['ground'] != '') { |
652 | 652 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
653 | 653 | // Here we force archive of flight because after ground it's a new one (or should be) |
654 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
655 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
656 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
657 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
658 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
654 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
655 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
656 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
657 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
658 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
659 | 659 | } |
660 | 660 | if ($line['ground'] != 1) $line['ground'] = 0; |
661 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
661 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
662 | 662 | //$dataFound = true; |
663 | 663 | } |
664 | 664 | if (isset($line['squawk']) && $line['squawk'] != '') { |
665 | 665 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
666 | 666 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
667 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
667 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
668 | 668 | $highlight = ''; |
669 | 669 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
670 | 670 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -673,66 +673,66 @@ discard block |
||
673 | 673 | $timeelapsed = microtime(true); |
674 | 674 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
675 | 675 | $Spotter = new Spotter($this->db); |
676 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
676 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
677 | 677 | $Spotter->db = null; |
678 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
678 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
679 | 679 | } |
680 | 680 | //$putinarchive = true; |
681 | 681 | //$highlight = ''; |
682 | 682 | } |
683 | 683 | |
684 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
684 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
685 | 685 | //$dataFound = true; |
686 | 686 | } |
687 | 687 | |
688 | 688 | if (isset($line['altitude']) && $line['altitude'] != '') { |
689 | 689 | if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) { |
690 | 690 | if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') { |
691 | - $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2); |
|
691 | + $geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2); |
|
692 | 692 | //if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n"; |
693 | 693 | $line['altitude'] = $line['altitude'] - $geoid; |
694 | 694 | } |
695 | 695 | } |
696 | 696 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
697 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
698 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
699 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
697 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
698 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
699 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
700 | 700 | //$dataFound = true; |
701 | 701 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
702 | 702 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
703 | 703 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
704 | 704 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
705 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
706 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
707 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
708 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
709 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
705 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
706 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
707 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
708 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
709 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
710 | 710 | } |
711 | 711 | } |
712 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
712 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude'])); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
716 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
716 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | if (isset($line['heading']) && $line['heading'] != '') { |
720 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
721 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
722 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
720 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
721 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
722 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
723 | 723 | //$dataFound = true; |
724 | 724 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
725 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
726 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
727 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
725 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
726 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
727 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
728 | 728 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
729 | 729 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
730 | 730 | // If not enough messages and ACARS set heading to 0 |
731 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
731 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
732 | 732 | } |
733 | - if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
734 | - elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
735 | - elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
733 | + if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
734 | + elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
735 | + elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
736 | 736 | |
737 | 737 | // print_r($this->all_flights[$id]); |
738 | 738 | //gets the callsign from the last hour |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
744 | 744 | $this->all_flights[$id]['lastupdate'] = time(); |
745 | 745 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
746 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
746 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
747 | 747 | //print_r($this->all_flights); |
748 | 748 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
749 | 749 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -754,61 +754,61 @@ discard block |
||
754 | 754 | $SpotterLive = new SpotterLive($this->db); |
755 | 755 | 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' || $line['format_source'] === 'famaprs')) { |
756 | 756 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
757 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
757 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
758 | 758 | } elseif (isset($line['id'])) { |
759 | 759 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
760 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
760 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
761 | 761 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
762 | 762 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
763 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
763 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
764 | 764 | } else $recent_ident = ''; |
765 | - $SpotterLive->db=null; |
|
765 | + $SpotterLive->db = null; |
|
766 | 766 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
767 | 767 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
768 | 768 | } else $recent_ident = ''; |
769 | 769 | } else { |
770 | 770 | $recent_ident = ''; |
771 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
771 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
772 | 772 | } |
773 | 773 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
774 | - if($recent_ident == "") |
|
774 | + if ($recent_ident == "") |
|
775 | 775 | { |
776 | 776 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
777 | 777 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
778 | 778 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
779 | 779 | //adds the spotter data for the archive |
780 | 780 | $ignoreImport = false; |
781 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
781 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
782 | 782 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
783 | 783 | $ignoreImport = true; |
784 | 784 | } |
785 | 785 | } |
786 | 786 | if (count($globalAirportAccept) > 0) { |
787 | 787 | $ignoreImport = true; |
788 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
788 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
789 | 789 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
790 | 790 | $ignoreImport = false; |
791 | 791 | } |
792 | 792 | } |
793 | 793 | } |
794 | 794 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
795 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
796 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
795 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
796 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
797 | 797 | $ignoreImport = true; |
798 | 798 | } |
799 | 799 | } |
800 | 800 | } |
801 | 801 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
802 | 802 | $ignoreImport = true; |
803 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
804 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
803 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
804 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
805 | 805 | $ignoreImport = false; |
806 | 806 | } |
807 | 807 | } |
808 | 808 | } |
809 | 809 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
810 | 810 | $ignoreImport = true; |
811 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
811 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
812 | 812 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
813 | 813 | $ignoreImport = false; |
814 | 814 | } |
@@ -820,32 +820,32 @@ discard block |
||
820 | 820 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
821 | 821 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
822 | 822 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
823 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
823 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
824 | 824 | $timeelapsed = microtime(true); |
825 | 825 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
826 | 826 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
827 | 827 | $Spotter = new Spotter($this->db); |
828 | - $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']); |
|
828 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']); |
|
829 | 829 | $Spotter->db = null; |
830 | 830 | if ($globalDebug && isset($result)) echo $result."\n"; |
831 | 831 | } |
832 | 832 | } |
833 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
833 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
834 | 834 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
835 | 835 | |
836 | 836 | // Add source stat in DB |
837 | 837 | $Stats = new Stats($this->db); |
838 | 838 | if (!empty($this->stats)) { |
839 | 839 | if ($globalDebug) echo 'Add source stats : '; |
840 | - foreach($this->stats as $date => $data) { |
|
841 | - foreach($data as $source => $sourced) { |
|
840 | + foreach ($this->stats as $date => $data) { |
|
841 | + foreach ($data as $source => $sourced) { |
|
842 | 842 | //print_r($sourced); |
843 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
844 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
843 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
844 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
845 | 845 | if (isset($sourced['msg'])) { |
846 | 846 | if (time() - $sourced['msg']['date'] > 10) { |
847 | 847 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
848 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
848 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
849 | 849 | unset($this->stats[$date][$source]['msg']); |
850 | 850 | } |
851 | 851 | } |
@@ -883,14 +883,14 @@ discard block |
||
883 | 883 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
884 | 884 | $SpotterLive = new SpotterLive($this->db); |
885 | 885 | $SpotterLive->deleteLiveSpotterData(); |
886 | - $SpotterLive->db=null; |
|
886 | + $SpotterLive->db = null; |
|
887 | 887 | } |
888 | 888 | } |
889 | 889 | if ($globalDebug) echo " Done\n"; |
890 | 890 | $this->last_delete = time(); |
891 | 891 | } |
892 | 892 | } else { |
893 | - 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'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
893 | + 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'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
|
894 | 894 | $this->all_flights[$id]['id'] = $recent_ident; |
895 | 895 | $this->all_flights[$id]['addedSpotter'] = 1; |
896 | 896 | } |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
899 | 899 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
900 | 900 | $Spotter = new Spotter($this->db); |
901 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
901 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
902 | 902 | $Spotter->db = null; |
903 | 903 | } |
904 | 904 | } |
@@ -924,37 +924,37 @@ discard block |
||
924 | 924 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
925 | 925 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
926 | 926 | |
927 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
927 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
928 | 928 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
929 | 929 | $ignoreImport = true; |
930 | 930 | } |
931 | 931 | } |
932 | 932 | if (count($globalAirportAccept) > 0) { |
933 | 933 | $ignoreImport = true; |
934 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
934 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
935 | 935 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
936 | 936 | $ignoreImport = false; |
937 | 937 | } |
938 | 938 | } |
939 | 939 | } |
940 | 940 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
941 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
942 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
941 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
942 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
943 | 943 | $ignoreImport = true; |
944 | 944 | } |
945 | 945 | } |
946 | 946 | } |
947 | 947 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
948 | 948 | $ignoreImport = true; |
949 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
950 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
949 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
950 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
951 | 951 | $ignoreImport = false; |
952 | 952 | } |
953 | 953 | } |
954 | 954 | } |
955 | 955 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
956 | 956 | $ignoreImport = true; |
957 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
957 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
958 | 958 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
959 | 959 | $ignoreImport = false; |
960 | 960 | } |
@@ -962,23 +962,23 @@ discard block |
||
962 | 962 | } |
963 | 963 | |
964 | 964 | if (!$ignoreImport) { |
965 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
966 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
965 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
966 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
967 | 967 | $timeelapsed = microtime(true); |
968 | 968 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
969 | 969 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
970 | 970 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
971 | 971 | $SpotterLive = new SpotterLive($this->db); |
972 | - $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']); |
|
972 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
973 | 973 | $SpotterLive->db = null; |
974 | 974 | if ($globalDebug) echo $result."\n"; |
975 | 975 | } |
976 | 976 | } |
977 | 977 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
978 | - $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']); |
|
978 | + $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
979 | 979 | } |
980 | 980 | $this->all_flights[$id]['putinarchive'] = false; |
981 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
981 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
982 | 982 | |
983 | 983 | // Put statistics in $this->stats variable |
984 | 984 | //if ($line['format_source'] != 'aprs') { |
@@ -997,19 +997,19 @@ discard block |
||
997 | 997 | $latitude = $globalCenterLatitude; |
998 | 998 | $longitude = $globalCenterLongitude; |
999 | 999 | } |
1000 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
1000 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
1001 | 1001 | } else { |
1002 | 1002 | $latitude = $this->source_location[$source]['latitude']; |
1003 | 1003 | $longitude = $this->source_location[$source]['longitude']; |
1004 | 1004 | } |
1005 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1005 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1006 | 1006 | //$stats_heading = $stats_heading%22.5; |
1007 | 1007 | $stats_heading = round($stats_heading/22.5); |
1008 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1008 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
1009 | 1009 | $current_date = date('Y-m-d'); |
1010 | 1010 | if ($stats_heading == 16) $stats_heading = 0; |
1011 | 1011 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1012 | - for ($i=0;$i<=15;$i++) { |
|
1012 | + for ($i = 0; $i <= 15; $i++) { |
|
1013 | 1013 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
1014 | 1014 | } |
1015 | 1015 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -1024,9 +1024,9 @@ discard block |
||
1024 | 1024 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1025 | 1025 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1026 | 1026 | end($this->stats[$current_date][$source]['hist']); |
1027 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1027 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
1028 | 1028 | } else $mini = 0; |
1029 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
1029 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
1030 | 1030 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
1031 | 1031 | } |
1032 | 1032 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | $this->all_flights[$id]['lastupdate'] = time(); |
1040 | 1040 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
1041 | 1041 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
1042 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1042 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
1043 | 1043 | //$this->del(); |
1044 | 1044 | |
1045 | 1045 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | 60 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
61 | 61 | $Marine = new Marine($this->db); |
62 | - $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'],$this->all_tracked[$key]['datetime']); |
|
62 | + $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'], $this->all_tracked[$key]['datetime']); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | 73 | if (isset($flight['lastupdate'])) { |
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
74 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
75 | 75 | if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
76 | 76 | if (isset($this->all_tracked[$key]['id'])) { |
77 | 77 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | //$real_arrival = $this->arrival($key); |
84 | 84 | $Marine = new Marine($this->db); |
85 | 85 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
86 | - $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'],$this->all_tracked[$key]['datetime']); |
|
86 | + $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'], $this->all_tracked[$key]['datetime']); |
|
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | 88 | } |
89 | 89 | // Put in archive |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | public function add($line) { |
100 | - global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
|
100 | + global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine; |
|
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
103 | 103 | $dataFound = false; |
104 | 104 | $send = false; |
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | - if(is_array($line) && isset($line['mmsi'])) { |
|
107 | + if (is_array($line) && isset($line['mmsi'])) { |
|
108 | 108 | //print_r($line); |
109 | 109 | if (isset($line['mmsi'])) { |
110 | 110 | |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | 131 | $this->all_tracked[$id] = array(); |
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0)); |
|
133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'status_id' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => '')); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
135 | 135 | if (!isset($line['id'])) { |
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
137 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
139 | 139 | if ($globalAllTracked !== FALSE) $dataFound = true; |
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi'])); |
|
144 | 144 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
@@ -154,64 +154,64 @@ discard block |
||
154 | 154 | } |
155 | 155 | } |
156 | 156 | if (isset($line['type_id'])) { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | 158 | } |
159 | 159 | if (isset($line['type']) && $line['type'] != '') { |
160 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
160 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
161 | 161 | } |
162 | 162 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type'])); |
|
164 | 164 | } |
165 | 165 | if (isset($line['imo']) && $line['imo'] != '') { |
166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo'])); |
|
167 | 167 | } |
168 | 168 | if (isset($line['callsign']) && $line['callsign'] != '') { |
169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign'])); |
|
170 | 170 | } |
171 | 171 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
172 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
172 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code'])); |
|
173 | 173 | } |
174 | 174 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
175 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
175 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date'])); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
179 | 179 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
180 | 180 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
181 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
181 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
182 | 182 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
183 | 183 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
184 | 184 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
185 | 185 | $timeelapsed = microtime(true); |
186 | 186 | $Marine = new Marine($this->db); |
187 | 187 | $fromsource = NULL; |
188 | - $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
188 | + $result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
189 | 189 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
190 | 190 | $Marine->db = null; |
191 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
191 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
195 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
196 | 196 | } |
197 | 197 | |
198 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
|
198 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
199 | 199 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
200 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
200 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
201 | 201 | } else { |
202 | 202 | 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"; |
203 | 203 | 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"; |
204 | 204 | return ''; |
205 | 205 | } |
206 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
|
206 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) { |
|
207 | 207 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
208 | 208 | return ''; |
209 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) { |
|
209 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) { |
|
210 | 210 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
211 | 211 | return ''; |
212 | 212 | } elseif (!isset($line['datetime'])) { |
213 | 213 | date_default_timezone_set('UTC'); |
214 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
214 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
215 | 215 | } else { |
216 | 216 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!"; |
217 | 217 | return ''; |
@@ -219,24 +219,24 @@ discard block |
||
219 | 219 | |
220 | 220 | |
221 | 221 | if (isset($line['speed'])) { |
222 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
223 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
222 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
223 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
224 | 224 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
225 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
225 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
226 | 226 | if ($distance > 1000 && $distance < 10000) { |
227 | 227 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
228 | 228 | $speed = $speed*3.6; |
229 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
229 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
230 | 230 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
234 | 234 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
235 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
235 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
236 | 236 | else unset($timediff); |
237 | - 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')))) { |
|
237 | + 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')))) { |
|
238 | 238 | 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'])) { |
239 | - 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'])) { |
|
239 | + 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'])) { |
|
240 | 240 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
241 | 241 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
242 | 242 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | $timeelapsed = microtime(true); |
246 | 246 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
247 | 247 | $Marine = new Marine($this->db); |
248 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
248 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
249 | 249 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
250 | 250 | $Marine->db = null; |
251 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
251 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
252 | 252 | } |
253 | 253 | $this->tmd = 0; |
254 | 254 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
@@ -257,52 +257,52 @@ discard block |
||
257 | 257 | |
258 | 258 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
259 | 259 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
260 | - 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') { |
|
260 | + 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') { |
|
261 | 261 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
262 | 262 | $dataFound = true; |
263 | 263 | $this->all_tracked[$id]['time_last_coord'] = time(); |
264 | 264 | } |
265 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
265 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
266 | 266 | } |
267 | 267 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
268 | 268 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
269 | 269 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
270 | - 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') { |
|
270 | + 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') { |
|
271 | 271 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
272 | 272 | $dataFound = true; |
273 | 273 | $this->all_tracked[$id]['time_last_coord'] = time(); |
274 | 274 | } |
275 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
275 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | } else if ($globalDebug && $timediff > 20) { |
279 | 279 | $this->tmd = $this->tmd + 1; |
280 | 280 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
281 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
282 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
281 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
282 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
283 | 283 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
284 | 284 | } |
285 | 285 | } |
286 | 286 | if (isset($line['last_update']) && $line['last_update'] != '') { |
287 | 287 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
288 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
288 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
289 | 289 | } |
290 | 290 | if (isset($line['format_source']) && $line['format_source'] != '') { |
291 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
291 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
292 | 292 | } |
293 | 293 | if (isset($line['source_name']) && $line['source_name'] != '') { |
294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
295 | 295 | } |
296 | 296 | if (isset($line['status']) && $line['status'] != '') { |
297 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
297 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status'])); |
|
298 | 298 | } |
299 | 299 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
300 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
300 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id'])); |
|
301 | 301 | if ($this->all_tracked[$id]['addedMarine'] == 1) { |
302 | 302 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
303 | 303 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
304 | 304 | $Marine = new Marine($this->db); |
305 | - $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
|
305 | + $Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']); |
|
306 | 306 | unset($Marine); |
307 | 307 | } |
308 | 308 | } |
@@ -310,18 +310,18 @@ discard block |
||
310 | 310 | } |
311 | 311 | |
312 | 312 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
313 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
313 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | if (isset($line['heading']) && $line['heading'] != '') { |
317 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
318 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
319 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
317 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
318 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
319 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
320 | 320 | //$dataFound = true; |
321 | 321 | } 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']) { |
322 | - $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']); |
|
323 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
324 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
322 | + $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']); |
|
323 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
324 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
325 | 325 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
326 | 326 | } |
327 | 327 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
332 | 332 | $this->all_tracked[$id]['lastupdate'] = time(); |
333 | 333 | if ($this->all_tracked[$id]['addedMarine'] == 0) { |
334 | - 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'])) { |
|
334 | + 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'])) { |
|
335 | 335 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
336 | 336 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
337 | 337 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
@@ -339,37 +339,37 @@ discard block |
||
339 | 339 | $MarineLive = new MarineLive($this->db); |
340 | 340 | if (isset($line['id'])) { |
341 | 341 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
342 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
342 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
343 | 343 | } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
344 | 344 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
345 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
345 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
346 | 346 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
347 | 347 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
348 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
348 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
349 | 349 | } else $recent_ident = ''; |
350 | - $MarineLive->db=null; |
|
350 | + $MarineLive->db = null; |
|
351 | 351 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
352 | 352 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
353 | 353 | } else $recent_ident = ''; |
354 | 354 | } else { |
355 | 355 | $recent_ident = ''; |
356 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
356 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
357 | 357 | } |
358 | 358 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
359 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
359 | + if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
360 | 360 | { |
361 | 361 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
362 | 362 | //adds the spotter data for the archive |
363 | 363 | $highlight = ''; |
364 | - 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'))); |
|
364 | + 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'))); |
|
365 | 365 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
366 | 366 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
367 | 367 | $timeelapsed = microtime(true); |
368 | 368 | $Marine = new Marine($this->db); |
369 | - $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]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
369 | + $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]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
370 | 370 | $Marine->db = null; |
371 | 371 | if ($globalDebug && isset($result)) echo $result."\n"; |
372 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
372 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
@@ -377,15 +377,15 @@ discard block |
||
377 | 377 | $Stats = new Stats($this->db); |
378 | 378 | if (!empty($this->stats)) { |
379 | 379 | if ($globalDebug) echo 'Add source stats : '; |
380 | - foreach($this->stats as $date => $data) { |
|
381 | - foreach($data as $source => $sourced) { |
|
380 | + foreach ($this->stats as $date => $data) { |
|
381 | + foreach ($data as $source => $sourced) { |
|
382 | 382 | //print_r($sourced); |
383 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
384 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
383 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date); |
|
384 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date); |
|
385 | 385 | if (isset($sourced['msg'])) { |
386 | 386 | if (time() - $sourced['msg']['date'] > 10) { |
387 | 387 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
388 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
388 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date); |
|
389 | 389 | unset($this->stats[$date][$source]['msg']); |
390 | 390 | } |
391 | 391 | } |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
410 | 410 | $MarineLive = new MarineLive($this->db); |
411 | 411 | $MarineLive->deleteLiveMarineData(); |
412 | - $MarineLive->db=null; |
|
412 | + $MarineLive->db = null; |
|
413 | 413 | if ($globalDebug) echo " Done\n"; |
414 | 414 | } |
415 | 415 | $this->last_delete = time(); |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
421 | 421 | if (isset($globalDaemon) && !$globalDaemon) { |
422 | 422 | $Marine = new Marine($this->db); |
423 | - $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
423 | + $Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
424 | 424 | $Marine->db = null; |
425 | 425 | } |
426 | 426 | } |
@@ -435,20 +435,20 @@ discard block |
||
435 | 435 | $ignoreImport = false; |
436 | 436 | |
437 | 437 | if (!$ignoreImport) { |
438 | - 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'])) { |
|
438 | + 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'])) { |
|
439 | 439 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
440 | 440 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
441 | 441 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
442 | 442 | $timeelapsed = microtime(true); |
443 | 443 | $MarineLive = new MarineLive($this->db); |
444 | - $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]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
444 | + $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]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
445 | 445 | $MarineLive->db = null; |
446 | 446 | if ($globalDebug) echo $result."\n"; |
447 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
447 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
451 | - $APRSMarine->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]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
451 | + $APRSMarine->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]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
452 | 452 | } |
453 | 453 | $this->all_tracked[$id]['putinarchive'] = false; |
454 | 454 | |
@@ -467,19 +467,19 @@ discard block |
||
467 | 467 | $latitude = $globalCenterLatitude; |
468 | 468 | $longitude = $globalCenterLongitude; |
469 | 469 | } |
470 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
470 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
471 | 471 | } else { |
472 | 472 | $latitude = $this->source_location[$source]['latitude']; |
473 | 473 | $longitude = $this->source_location[$source]['longitude']; |
474 | 474 | } |
475 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
475 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
476 | 476 | //$stats_heading = $stats_heading%22.5; |
477 | 477 | $stats_heading = round($stats_heading/22.5); |
478 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
478 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
479 | 479 | $current_date = date('Y-m-d'); |
480 | 480 | if ($stats_heading == 16) $stats_heading = 0; |
481 | 481 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
482 | - for ($i=0;$i<=15;$i++) { |
|
482 | + for ($i = 0; $i <= 15; $i++) { |
|
483 | 483 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
484 | 484 | } |
485 | 485 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -494,9 +494,9 @@ discard block |
||
494 | 494 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
495 | 495 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
496 | 496 | end($this->stats[$current_date][$source]['hist']); |
497 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
497 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
498 | 498 | } else $mini = 0; |
499 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
499 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
500 | 500 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
501 | 501 | } |
502 | 502 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | |
509 | 509 | $this->all_tracked[$id]['lastupdate'] = time(); |
510 | 510 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
511 | - } 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"; |
|
511 | + } 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"; |
|
512 | 512 | //$this->del(); |
513 | 513 | |
514 | 514 |
@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | die; |
51 | 51 | } |
52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
53 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
53 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
|
57 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine')); |
|
58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 60 | if (isset($options['s'])) { |
61 | 61 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
63 | 63 | else $globalSources[] = array('host' => $options['s']); |
64 | 64 | } elseif (isset($options['source'])) { |
65 | 65 | $globalSources = array(); |
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
67 | 67 | else $globalSources[] = array('host' => $options['source']); |
68 | 68 | } |
69 | 69 | if (isset($options['aprsserverhost'])) { |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | else $id_source = 1; |
105 | 105 | if (isset($globalServer) && $globalServer) { |
106 | 106 | if ($globalDebug) echo "Using Server Mode\n"; |
107 | - $SI=new SpotterServer(); |
|
107 | + $SI = new SpotterServer(); |
|
108 | 108 | /* |
109 | 109 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 110 | $SI = new adsb2aprs(); |
111 | 111 | $SI->connect(); |
112 | 112 | */ |
113 | -} else $SI=new SpotterImport($Connection->db); |
|
113 | +} else $SI = new SpotterImport($Connection->db); |
|
114 | 114 | |
115 | 115 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
116 | 116 | if (isset($globalMarine) && $globalMarine) { |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | $MI = new MarineImport($Connection->db); |
125 | 125 | } |
126 | 126 | //$APRS=new APRS($Connection->db); |
127 | -$SBS=new SBS(); |
|
127 | +$SBS = new SBS(); |
|
128 | 128 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
129 | - $ACARS=new ACARS($Connection->db,true); |
|
130 | - $Source=new Source($Connection->db); |
|
129 | + $ACARS = new ACARS($Connection->db, true); |
|
130 | + $Source = new Source($Connection->db); |
|
131 | 131 | } |
132 | -$Common=new Common(); |
|
132 | +$Common = new Common(); |
|
133 | 133 | date_default_timezone_set('UTC'); |
134 | 134 | //$servertz = system('date +%Z'); |
135 | 135 | // signal handler - playing nice with sockets and dump1090 |
136 | 136 | if (function_exists('pcntl_fork')) { |
137 | - pcntl_signal(SIGINT, function() { |
|
137 | + pcntl_signal(SIGINT, function() { |
|
138 | 138 | global $sockets; |
139 | 139 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
140 | 140 | die("Bye!\n"); |
@@ -150,30 +150,30 @@ discard block |
||
150 | 150 | |
151 | 151 | function connect_all($hosts) { |
152 | 152 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
153 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
153 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
154 | 154 | $reset++; |
155 | 155 | if ($globalDebug) echo 'Connect to all...'."\n"; |
156 | 156 | foreach ($hosts as $id => $value) { |
157 | 157 | $host = $value['host']; |
158 | 158 | $globalSources[$id]['last_exec'] = 0; |
159 | 159 | // Here we check type of source(s) |
160 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
161 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
160 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
161 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
162 | 162 | //$formats[$id] = 'deltadbtxt'; |
163 | 163 | $globalSources[$id]['format'] = 'deltadbtxt'; |
164 | 164 | //$last_exec['deltadbtxt'] = 0; |
165 | 165 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
166 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
166 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
167 | 167 | //$formats[$id] = 'vatsimtxt'; |
168 | 168 | $globalSources[$id]['format'] = 'vatsimtxt'; |
169 | 169 | //$last_exec['vatsimtxt'] = 0; |
170 | 170 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
171 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
171 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
172 | 172 | //$formats[$id] = 'aircraftlistjson'; |
173 | 173 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
174 | 174 | //$last_exec['aircraftlistjson'] = 0; |
175 | 175 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
176 | - } else if (preg_match('/opensky/i',$host)) { |
|
176 | + } else if (preg_match('/opensky/i', $host)) { |
|
177 | 177 | //$formats[$id] = 'aircraftlistjson'; |
178 | 178 | $globalSources[$id]['format'] = 'opensky'; |
179 | 179 | //$last_exec['aircraftlistjson'] = 0; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | exit(0); |
191 | 191 | } |
192 | 192 | */ |
193 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
193 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
194 | 194 | //$formats[$id] = 'planeupdatefaa'; |
195 | 195 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
196 | 196 | //$last_exec['planeupdatefaa'] = 0; |
@@ -199,32 +199,32 @@ discard block |
||
199 | 199 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
200 | 200 | exit(0); |
201 | 201 | } |
202 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
202 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
203 | 203 | //$formats[$id] = 'phpvmacars'; |
204 | 204 | $globalSources[$id]['format'] = 'phpvmacars'; |
205 | 205 | //$last_exec['phpvmacars'] = 0; |
206 | 206 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
207 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
207 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
208 | 208 | //$formats[$id] = 'phpvmacars'; |
209 | 209 | $globalSources[$id]['format'] = 'vam'; |
210 | 210 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
211 | - } else if (preg_match('/whazzup/i',$host)) { |
|
211 | + } else if (preg_match('/whazzup/i', $host)) { |
|
212 | 212 | //$formats[$id] = 'whazzup'; |
213 | 213 | $globalSources[$id]['format'] = 'whazzup'; |
214 | 214 | //$last_exec['whazzup'] = 0; |
215 | 215 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
216 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
216 | + } else if (preg_match('/blitzortung/i', $host)) { |
|
217 | 217 | $globalSources[$id]['format'] = 'blitzortung'; |
218 | 218 | if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
219 | - } else if (preg_match('/airwhere/i',$host)) { |
|
219 | + } else if (preg_match('/airwhere/i', $host)) { |
|
220 | 220 | $globalSources[$id]['format'] = 'airwhere'; |
221 | 221 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
222 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
222 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
223 | 223 | //$formats[$id] = 'pirepsjson'; |
224 | 224 | $globalSources[$id]['format'] = 'pirepsjson'; |
225 | 225 | //$last_exec['pirepsjson'] = 0; |
226 | 226 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
227 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
227 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
228 | 228 | //$formats[$id] = 'fr24json'; |
229 | 229 | $globalSources[$id]['format'] = 'fr24json'; |
230 | 230 | //$last_exec['fr24json'] = 0; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
234 | 234 | exit(0); |
235 | 235 | } |
236 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
236 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
237 | 237 | //$formats[$id] = 'fr24json'; |
238 | 238 | $globalSources[$id]['format'] = 'myshiptracking'; |
239 | 239 | //$last_exec['fr24json'] = 0; |
@@ -243,22 +243,22 @@ discard block |
||
243 | 243 | exit(0); |
244 | 244 | } |
245 | 245 | //} else if (preg_match('/10001/',$host)) { |
246 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
246 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
247 | 247 | //$formats[$id] = 'tsv'; |
248 | 248 | $globalSources[$id]['format'] = 'tsv'; |
249 | 249 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
250 | 250 | } |
251 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
251 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
252 | 252 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
253 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
253 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
254 | 254 | if ($idf !== false) { |
255 | 255 | $httpfeeds[$id] = $idf; |
256 | 256 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
257 | 257 | } |
258 | 258 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
259 | 259 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
260 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
261 | - $hostport = explode(':',$host); |
|
260 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
261 | + $hostport = explode(':', $host); |
|
262 | 262 | if (isset($hostport[1])) { |
263 | 263 | $port = $hostport[1]; |
264 | 264 | $hostn = $hostport[0]; |
@@ -268,19 +268,19 @@ discard block |
||
268 | 268 | } |
269 | 269 | $Common = new Common(); |
270 | 270 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
271 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
271 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
272 | 272 | } else { |
273 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
273 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
274 | 274 | } |
275 | 275 | if ($s) { |
276 | 276 | $sockets[$id] = $s; |
277 | 277 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
278 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
278 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
279 | 279 | //$formats[$id] = 'aprs'; |
280 | 280 | $globalSources[$id]['format'] = 'aprs'; |
281 | 281 | //$aprs_connect = 0; |
282 | 282 | //$use_aprs = true; |
283 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
283 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
284 | 284 | $globalSources[$id]['format'] = 'vrstcp'; |
285 | 285 | } elseif ($port == '10001') { |
286 | 286 | //$formats[$id] = 'tsv'; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
320 | 320 | else $timeout = 20; |
321 | 321 | $errno = ''; |
322 | -$errstr=''; |
|
322 | +$errstr = ''; |
|
323 | 323 | |
324 | 324 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
325 | 325 | /* Initiate connections to all the hosts simultaneously */ |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | //connect_all($globalSources); |
328 | 328 | |
329 | 329 | if (isset($globalProxy) && $globalProxy) { |
330 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
330 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
331 | 331 | } else { |
332 | 332 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
333 | 333 | } |
@@ -357,16 +357,16 @@ discard block |
||
357 | 357 | |
358 | 358 | if ($use_aprs) { |
359 | 359 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
360 | - $APRS=new APRS(); |
|
360 | + $APRS = new APRS(); |
|
361 | 361 | $aprs_connect = 0; |
362 | 362 | $aprs_keep = 120; |
363 | 363 | $aprs_last_tx = time(); |
364 | 364 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
365 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
365 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
366 | 366 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
367 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
367 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
368 | 368 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
369 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
369 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
370 | 370 | if ($aprs_full) $aprs_filter = ''; |
371 | 371 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
372 | 372 | else $aprs_pass = '-1'; |
@@ -380,12 +380,12 @@ discard block |
||
380 | 380 | sleep(1); |
381 | 381 | if ($globalDebug) echo "SCAN MODE \n\n"; |
382 | 382 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
383 | -$endtime = time()+$globalCronEnd; |
|
383 | +$endtime = time() + $globalCronEnd; |
|
384 | 384 | $i = 1; |
385 | 385 | $tt = array(); |
386 | 386 | // Delete all ATC |
387 | 387 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
388 | - $ATC=new ATC($Connection->db); |
|
388 | + $ATC = new ATC($Connection->db); |
|
389 | 389 | } |
390 | 390 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
391 | 391 | $ATC->deleteAll(); |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
395 | 395 | while ($i > 0) { |
396 | - if (!$globalDaemon) $i = $endtime-time(); |
|
396 | + if (!$globalDaemon) $i = $endtime - time(); |
|
397 | 397 | // Delete old ATC |
398 | 398 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
399 | 399 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | } |
408 | 408 | if ($max != $globalMinFetch) { |
409 | 409 | if ($globalDebug) echo 'Sleeping...'."\n"; |
410 | - sleep($globalMinFetch-$max+2); |
|
410 | + sleep($globalMinFetch - $max + 2); |
|
411 | 411 | } |
412 | 412 | } |
413 | 413 | |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | //$buffer = $Common->getData($hosts[$id]); |
427 | 427 | $buffer = $Common->getData($value['host']); |
428 | 428 | if ($buffer != '') $reset = 0; |
429 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
430 | - $buffer = explode('\n',$buffer); |
|
429 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
430 | + $buffer = explode('\n', $buffer); |
|
431 | 431 | foreach ($buffer as $line) { |
432 | 432 | if ($line != '' && count($line) > 7) { |
433 | 433 | $line = explode(',', $line); |
@@ -460,11 +460,11 @@ discard block |
||
460 | 460 | ) |
461 | 461 | ) { |
462 | 462 | date_default_timezone_set('CET'); |
463 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
463 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
464 | 464 | date_default_timezone_set('UTC'); |
465 | 465 | if ($buffer != '') $reset = 0; |
466 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
467 | - $buffer = explode('\n',$buffer); |
|
466 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
467 | + $buffer = explode('\n', $buffer); |
|
468 | 468 | foreach ($buffer as $line) { |
469 | 469 | if ($line != '') { |
470 | 470 | //echo "'".$line."'\n"; |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
483 | 483 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
484 | 484 | if (isset($ais_data['timestamp'])) { |
485 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
485 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
486 | 486 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
487 | 487 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
488 | 488 | $add = true; |
@@ -505,15 +505,15 @@ discard block |
||
505 | 505 | $w = $e = null; |
506 | 506 | |
507 | 507 | if (isset($arr[$id])) { |
508 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
508 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
509 | 509 | if ($nn > 0) { |
510 | 510 | foreach ($httpfeeds as $feed) { |
511 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
511 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
512 | 512 | if ($buffer === FALSE) { |
513 | 513 | connect_all($globalSources); |
514 | 514 | } |
515 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
516 | - $buffer = explode('\n',$buffer); |
|
515 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
516 | + $buffer = explode('\n', $buffer); |
|
517 | 517 | foreach ($buffer as $line) { |
518 | 518 | if ($line != '') { |
519 | 519 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -531,9 +531,9 @@ discard block |
||
531 | 531 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
532 | 532 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
533 | 533 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
534 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
534 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
535 | 535 | if (isset($ais_data['timestamp'])) { |
536 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
536 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
537 | 537 | } else { |
538 | 538 | $data['datetime'] = date('Y-m-d H:i:s'); |
539 | 539 | } |
@@ -565,10 +565,10 @@ discard block |
||
565 | 565 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
566 | 566 | ) |
567 | 567 | ) { |
568 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
568 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
569 | 569 | if ($buffer != '') { |
570 | 570 | //echo $buffer; |
571 | - $all_data = json_decode($buffer,true); |
|
571 | + $all_data = json_decode($buffer, true); |
|
572 | 572 | //print_r($all_data); |
573 | 573 | if (isset($all_data[0]['DATA'])) { |
574 | 574 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | $data['ident'] = $line['NAME']; |
578 | 578 | $data['mmsi'] = $line['MMSI']; |
579 | 579 | if (strlen($data['mmsi']) > 9) { |
580 | - $data['mmsi'] = substr($data['mmsi'],-9); |
|
580 | + $data['mmsi'] = substr($data['mmsi'], -9); |
|
581 | 581 | } |
582 | 582 | $data['speed'] = $line['SOG']; |
583 | 583 | $data['heading'] = $line['COG']; |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
587 | 587 | $data['imo'] = $line['IMO']; |
588 | 588 | //$data['arrival_code'] = $ais_data['destination']; |
589 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
589 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
590 | 590 | $data['format_source'] = 'myshiptracking'; |
591 | 591 | $data['id_source'] = $id_source; |
592 | 592 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -603,9 +603,9 @@ discard block |
||
603 | 603 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
604 | 604 | ) |
605 | 605 | ) { |
606 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
606 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
607 | 607 | if ($buffer != '') { |
608 | - $all_data = json_decode($buffer,true); |
|
608 | + $all_data = json_decode($buffer, true); |
|
609 | 609 | if (isset($all_data[0]['mmsi'])) { |
610 | 610 | foreach ($all_data as $line) { |
611 | 611 | if ($line != '') { |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | ) { |
640 | 640 | $buffer = $Common->getData($value['host']); |
641 | 641 | if ($buffer != '') { |
642 | - $all_data = json_decode($buffer,true); |
|
642 | + $all_data = json_decode($buffer, true); |
|
643 | 643 | if (isset($all_data['features'][0]['id'])) { |
644 | 644 | foreach ($all_data['features'] as $line) { |
645 | 645 | $data = array(); |
@@ -672,27 +672,27 @@ discard block |
||
672 | 672 | ) |
673 | 673 | ) { |
674 | 674 | echo 'download...'; |
675 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
675 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
676 | 676 | echo 'done !'."\n"; |
677 | 677 | if ($buffer != '') $reset = 0; |
678 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
679 | - $buffer = explode('\n',$buffer); |
|
678 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
679 | + $buffer = explode('\n', $buffer); |
|
680 | 680 | foreach ($buffer as $line) { |
681 | 681 | if ($line != '') { |
682 | 682 | $data = array(); |
683 | - $data['mmsi'] = (int)substr($line,0,9); |
|
684 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
683 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
684 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
685 | 685 | //$data['status'] = substr($line,21,2); |
686 | 686 | //$data['type'] = substr($line,24,3); |
687 | - $data['latitude'] = substr($line,29,9); |
|
688 | - $data['longitude'] = substr($line,41,9); |
|
689 | - $data['speed'] = round(substr($line,51,5)); |
|
687 | + $data['latitude'] = substr($line, 29, 9); |
|
688 | + $data['longitude'] = substr($line, 41, 9); |
|
689 | + $data['speed'] = round(substr($line, 51, 5)); |
|
690 | 690 | //$data['course'] = substr($line,57,5); |
691 | - $data['heading'] = round(substr($line,63,3)); |
|
691 | + $data['heading'] = round(substr($line, 63, 3)); |
|
692 | 692 | //$data['draft'] = substr($line,67,4); |
693 | 693 | //$data['length'] = substr($line,72,3); |
694 | 694 | //$data['beam'] = substr($line,76,2); |
695 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
695 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
696 | 696 | //$data['callsign'] = trim(substr($line,100,7); |
697 | 697 | //$data['dest'] = substr($line,108,20); |
698 | 698 | //$data['etaDate'] = substr($line,129,5); |
@@ -725,8 +725,8 @@ discard block |
||
725 | 725 | ) { |
726 | 726 | //$buffer = $Common->getData($hosts[$id]); |
727 | 727 | $buffer = $Common->getData($value['host']); |
728 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
729 | - $buffer = explode('\n',$buffer); |
|
728 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
729 | + $buffer = explode('\n', $buffer); |
|
730 | 730 | $reset = 0; |
731 | 731 | foreach ($buffer as $line) { |
732 | 732 | if ($line != '') { |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
738 | 738 | $data['pilot_id'] = $line[1]; |
739 | 739 | $data['pilot_name'] = $line[2]; |
740 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
740 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
741 | 741 | $data['ident'] = $line[0]; // ident |
742 | 742 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
743 | 743 | $data['speed'] = $line[8]; // speed |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
754 | 754 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
755 | 755 | $data['departure_airport_icao'] = $line[11]; |
756 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
756 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
757 | 757 | $data['arrival_airport_icao'] = $line[13]; |
758 | 758 | $data['frequency'] = $line[4]; |
759 | 759 | $data['type'] = $line[18]; |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | $data['id_source'] = $id_source; |
763 | 763 | //$data['arrival_airport_time'] = ; |
764 | 764 | if ($line[9] != '') { |
765 | - $aircraft_data = explode('/',$line[9]); |
|
765 | + $aircraft_data = explode('/', $line[9]); |
|
766 | 766 | if (isset($aircraft_data[1])) { |
767 | 767 | $data['aircraft_icao'] = $aircraft_data[1]; |
768 | 768 | } |
@@ -777,9 +777,9 @@ discard block |
||
777 | 777 | if ($line[3] == 'PILOT') $SI->add($data); |
778 | 778 | elseif ($line[3] == 'ATC') { |
779 | 779 | //print_r($data); |
780 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
781 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
782 | - $typec = substr($data['ident'],-3); |
|
780 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
781 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
782 | + $typec = substr($data['ident'], -3); |
|
783 | 783 | if ($typec == 'APP') $data['type'] = 'Approach'; |
784 | 784 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
785 | 785 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -791,8 +791,8 @@ discard block |
||
791 | 791 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
792 | 792 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
793 | 793 | if (isset($ATC)) { |
794 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
795 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
794 | + if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
795 | + else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
796 | 796 | } |
797 | 797 | } |
798 | 798 | unset($data); |
@@ -808,24 +808,24 @@ discard block |
||
808 | 808 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
809 | 809 | ) |
810 | 810 | ) { |
811 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
811 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
812 | 812 | if ($buffer != '') { |
813 | 813 | $all_data = simplexml_load_string($buffer); |
814 | - foreach($all_data->children() as $childdata) { |
|
814 | + foreach ($all_data->children() as $childdata) { |
|
815 | 815 | $data = array(); |
816 | 816 | $line = $childdata; |
817 | 817 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
818 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
819 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
820 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
821 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
822 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
823 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
824 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
818 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
819 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
820 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
821 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
822 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
823 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
824 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
825 | 825 | $data['altitude_relative'] = 'AMSL'; |
826 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
826 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
827 | 827 | $data['aircraft_icao'] = 'PARAGLIDER'; |
828 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
828 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
829 | 829 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
830 | 830 | $data['format_source'] = $value['format']; |
831 | 831 | $SI->add($data); |
@@ -833,22 +833,22 @@ discard block |
||
833 | 833 | } |
834 | 834 | } |
835 | 835 | $Source->deleteOldLocationByType('gs'); |
836 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
836 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
837 | 837 | if ($buffer != '') { |
838 | 838 | $all_data = simplexml_load_string($buffer); |
839 | - foreach($all_data->children() as $childdata) { |
|
839 | + foreach ($all_data->children() as $childdata) { |
|
840 | 840 | $data = array(); |
841 | 841 | $line = $childdata; |
842 | - $data['id'] = (int)$line['gsID']; |
|
843 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
844 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
845 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
842 | + $data['id'] = (int) $line['gsID']; |
|
843 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
844 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
845 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
846 | 846 | $data['altitude_relative'] = 'AMSL'; |
847 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
847 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
848 | 848 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
849 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
849 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
850 | 850 | } else { |
851 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
851 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
852 | 852 | } |
853 | 853 | unset($data); |
854 | 854 | } |
@@ -866,9 +866,9 @@ discard block |
||
866 | 866 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
867 | 867 | ) |
868 | 868 | ) { |
869 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
869 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
870 | 870 | if ($buffer != '') { |
871 | - $all_data = json_decode($buffer,true); |
|
871 | + $all_data = json_decode($buffer, true); |
|
872 | 872 | if (isset($all_data['acList'])) { |
873 | 873 | $reset = 0; |
874 | 874 | foreach ($all_data['acList'] as $line) { |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
885 | 885 | $data['emergency'] = ''; // emergency |
886 | 886 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
887 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
887 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
888 | 888 | else $data['datetime'] = date('Y-m-d H:i:s'); |
889 | 889 | //$data['datetime'] = date('Y-m-d H:i:s'); |
890 | 890 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | $data['verticalrate'] = $line['vrt']; // verticale rate |
910 | 910 | $data['squawk'] = $line['squawk']; // squawk |
911 | 911 | $data['emergency'] = ''; // emergency |
912 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
912 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
913 | 913 | else $data['datetime'] = date('Y-m-d H:i:s'); |
914 | 914 | $data['format_source'] = 'aircraftlistjson'; |
915 | 915 | $data['id_source'] = $id_source; |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | ) |
931 | 931 | ) { |
932 | 932 | $buffer = $Common->getData($value['host']); |
933 | - $all_data = json_decode($buffer,true); |
|
933 | + $all_data = json_decode($buffer, true); |
|
934 | 934 | if (isset($all_data['planes'])) { |
935 | 935 | $reset = 0; |
936 | 936 | foreach ($all_data['planes'] as $key => $line) { |
@@ -947,12 +947,12 @@ discard block |
||
947 | 947 | $data['emergency'] = ''; // emergency |
948 | 948 | $data['registration'] = $line[2]; |
949 | 949 | $data['aircraft_icao'] = $line[0]; |
950 | - $deparr = explode('-',$line[1]); |
|
950 | + $deparr = explode('-', $line[1]); |
|
951 | 951 | if (count($deparr) == 2) { |
952 | 952 | $data['departure_airport_icao'] = $deparr[0]; |
953 | 953 | $data['arrival_airport_icao'] = $deparr[1]; |
954 | 954 | } |
955 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
955 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
956 | 956 | $data['format_source'] = 'planeupdatefaa'; |
957 | 957 | $data['id_source'] = $id_source; |
958 | 958 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | ) |
971 | 971 | ) { |
972 | 972 | $buffer = $Common->getData($value['host']); |
973 | - $all_data = json_decode($buffer,true); |
|
973 | + $all_data = json_decode($buffer, true); |
|
974 | 974 | if (isset($all_data['states'])) { |
975 | 975 | $reset = 0; |
976 | 976 | foreach ($all_data['states'] as $key => $line) { |
@@ -987,7 +987,7 @@ discard block |
||
987 | 987 | //$data['emergency'] = ''; // emergency |
988 | 988 | //$data['registration'] = $line[2]; |
989 | 989 | //$data['aircraft_icao'] = $line[0]; |
990 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
990 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
991 | 991 | $data['format_source'] = 'opensky'; |
992 | 992 | $data['id_source'] = $id_source; |
993 | 993 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | ) { |
1007 | 1007 | //$buffer = $Common->getData($hosts[$id]); |
1008 | 1008 | $buffer = $Common->getData($value['host']); |
1009 | - $all_data = json_decode($buffer,true); |
|
1009 | + $all_data = json_decode($buffer, true); |
|
1010 | 1010 | if (!empty($all_data)) $reset = 0; |
1011 | 1011 | foreach ($all_data as $key => $line) { |
1012 | 1012 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -1044,11 +1044,11 @@ discard block |
||
1044 | 1044 | ) |
1045 | 1045 | ) { |
1046 | 1046 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
1047 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1047 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
1048 | 1048 | //echo $buffer; |
1049 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1050 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1051 | - $all_data = json_decode($buffer,true); |
|
1049 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
1050 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
1051 | + $all_data = json_decode($buffer, true); |
|
1052 | 1052 | if (json_last_error() != JSON_ERROR_NONE) { |
1053 | 1053 | die(json_last_error_msg()); |
1054 | 1054 | } |
@@ -1071,7 +1071,7 @@ discard block |
||
1071 | 1071 | //$data['departure_airport_iata'] = $line[11]; |
1072 | 1072 | //$data['arrival_airport_iata'] = $line[12]; |
1073 | 1073 | //$data['emergency'] = ''; // emergency |
1074 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
1074 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
1075 | 1075 | $data['format_source'] = 'radarvirtueljson'; |
1076 | 1076 | $data['id_source'] = $id_source; |
1077 | 1077 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -1092,14 +1092,14 @@ discard block |
||
1092 | 1092 | ) { |
1093 | 1093 | //$buffer = $Common->getData($hosts[$id]); |
1094 | 1094 | $buffer = $Common->getData($value['host'].'?'.time()); |
1095 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1095 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
1096 | 1096 | |
1097 | 1097 | if (isset($all_data['pireps'])) { |
1098 | 1098 | $reset = 0; |
1099 | 1099 | foreach ($all_data['pireps'] as $line) { |
1100 | 1100 | $data = array(); |
1101 | 1101 | $data['id'] = $line['id']; |
1102 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1102 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1103 | 1103 | $data['ident'] = $line['callsign']; // ident |
1104 | 1104 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
1105 | 1105 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -1129,9 +1129,9 @@ discard block |
||
1129 | 1129 | $SI->add($data); |
1130 | 1130 | // print_r($data); |
1131 | 1131 | } elseif ($line['icon'] == 'ct') { |
1132 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
1133 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
1134 | - $typec = substr($data['ident'],-3); |
|
1132 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
1133 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
1134 | + $typec = substr($data['ident'], -3); |
|
1135 | 1135 | $data['type'] = ''; |
1136 | 1136 | if ($typec == 'APP') $data['type'] = 'Approach'; |
1137 | 1137 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -1142,7 +1142,7 @@ discard block |
||
1142 | 1142 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
1143 | 1143 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1144 | 1144 | else $data['type'] = 'Observer'; |
1145 | - 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']); |
|
1145 | + 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']); |
|
1146 | 1146 | } |
1147 | 1147 | unset($data); |
1148 | 1148 | } |
@@ -1159,14 +1159,14 @@ discard block |
||
1159 | 1159 | //$buffer = $Common->getData($hosts[$id]); |
1160 | 1160 | if ($globalDebug) echo 'Get Data...'."\n"; |
1161 | 1161 | $buffer = $Common->getData($value['host']); |
1162 | - $all_data = json_decode($buffer,true); |
|
1162 | + $all_data = json_decode($buffer, true); |
|
1163 | 1163 | if ($buffer != '' && is_array($all_data)) { |
1164 | 1164 | $reset = 0; |
1165 | 1165 | foreach ($all_data as $line) { |
1166 | 1166 | $data = array(); |
1167 | 1167 | //$data['id'] = $line['id']; // id not usable |
1168 | 1168 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
1169 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1169 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1170 | 1170 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
1171 | 1171 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
1172 | 1172 | $data['ident'] = $line['flightnum']; // ident |
@@ -1181,7 +1181,7 @@ discard block |
||
1181 | 1181 | //$data['datetime'] = $line['lastupdate']; |
1182 | 1182 | //$data['last_update'] = $line['lastupdate']; |
1183 | 1183 | if (isset($value['timezone'])) { |
1184 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1184 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1185 | 1185 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1186 | 1186 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1187 | 1187 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1194,14 +1194,14 @@ discard block |
||
1194 | 1194 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1195 | 1195 | if (isset($line['aircraftname'])) { |
1196 | 1196 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1197 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1198 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1197 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1198 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1199 | 1199 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1200 | 1200 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1201 | 1201 | else { |
1202 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1203 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1204 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1202 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
1203 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
1204 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1205 | 1205 | } |
1206 | 1206 | } |
1207 | 1207 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1226,14 +1226,14 @@ discard block |
||
1226 | 1226 | //$buffer = $Common->getData($hosts[$id]); |
1227 | 1227 | if ($globalDebug) echo 'Get Data...'."\n"; |
1228 | 1228 | $buffer = $Common->getData($value['host']); |
1229 | - $all_data = json_decode($buffer,true); |
|
1229 | + $all_data = json_decode($buffer, true); |
|
1230 | 1230 | if ($buffer != '' && is_array($all_data)) { |
1231 | 1231 | $reset = 0; |
1232 | 1232 | foreach ($all_data as $line) { |
1233 | 1233 | $data = array(); |
1234 | 1234 | //$data['id'] = $line['id']; // id not usable |
1235 | 1235 | $data['id'] = trim($line['flight_id']); |
1236 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1236 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1237 | 1237 | $data['pilot_name'] = $line['pilot_name']; |
1238 | 1238 | $data['pilot_id'] = $line['pilot_id']; |
1239 | 1239 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1277,24 +1277,24 @@ discard block |
||
1277 | 1277 | //$buffer = $Common->getData($hosts[$id]); |
1278 | 1278 | if ($globalDebug) echo 'Get Data...'."\n"; |
1279 | 1279 | $buffer = $Common->getData($value['host']); |
1280 | - $all_data = json_decode($buffer,true); |
|
1280 | + $all_data = json_decode($buffer, true); |
|
1281 | 1281 | if ($buffer != '') { |
1282 | 1282 | $Source->deleteLocationBySource('blitzortung'); |
1283 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
1284 | - $buffer = explode('\n',$buffer); |
|
1283 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
1284 | + $buffer = explode('\n', $buffer); |
|
1285 | 1285 | foreach ($buffer as $buffer_line) { |
1286 | - $line = json_decode($buffer_line,true); |
|
1286 | + $line = json_decode($buffer_line, true); |
|
1287 | 1287 | if (isset($line['time'])) { |
1288 | 1288 | $data = array(); |
1289 | 1289 | $data['altitude'] = $line['alt']; // altitude |
1290 | 1290 | $data['latitude'] = $line['lat']; // lat |
1291 | 1291 | $data['longitude'] = $line['lon']; // long |
1292 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10)); |
|
1292 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10)); |
|
1293 | 1293 | $data['id_source'] = $id_source; |
1294 | 1294 | $data['format_source'] = 'blitzortung'; |
1295 | 1295 | $SI->add($data); |
1296 | 1296 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1297 | - $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
|
1297 | + $Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']); |
|
1298 | 1298 | unset($data); |
1299 | 1299 | } |
1300 | 1300 | } |
@@ -1319,11 +1319,11 @@ discard block |
||
1319 | 1319 | //$value = $formats[$nb]; |
1320 | 1320 | $format = $globalSources[$nb]['format']; |
1321 | 1321 | if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
1322 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
1322 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
1323 | 1323 | } elseif ($format == 'vrstcp') { |
1324 | 1324 | $buffer = socket_read($r, 6000); |
1325 | 1325 | } else { |
1326 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1326 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1327 | 1327 | } |
1328 | 1328 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1329 | 1329 | //echo $buffer."\n"; |
@@ -1333,8 +1333,8 @@ discard block |
||
1333 | 1333 | //$SI::del(); |
1334 | 1334 | if ($buffer !== FALSE) { |
1335 | 1335 | if ($format == 'vrstcp') { |
1336 | - $buffer = explode('},{',$buffer); |
|
1337 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1336 | + $buffer = explode('},{', $buffer); |
|
1337 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1338 | 1338 | } |
1339 | 1339 | // SBS format is CSV format |
1340 | 1340 | if ($buffer !== FALSE && $buffer !== '') { |
@@ -1369,13 +1369,13 @@ discard block |
||
1369 | 1369 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1370 | 1370 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1371 | 1371 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1372 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1372 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1373 | 1373 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1374 | 1374 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1375 | 1375 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1376 | 1376 | |
1377 | 1377 | if (isset($ais_data['timestamp'])) { |
1378 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1378 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1379 | 1379 | } else { |
1380 | 1380 | $data['datetime'] = date('Y-m-d H:i:s'); |
1381 | 1381 | } |
@@ -1386,10 +1386,10 @@ discard block |
||
1386 | 1386 | } elseif ($format == 'flightgearsp') { |
1387 | 1387 | //echo $buffer."\n"; |
1388 | 1388 | if (strlen($buffer) > 5) { |
1389 | - $line = explode(',',$buffer); |
|
1389 | + $line = explode(',', $buffer); |
|
1390 | 1390 | $data = array(); |
1391 | 1391 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1392 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1392 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1393 | 1393 | $data['ident'] = $line[6]; |
1394 | 1394 | $data['aircraft_name'] = $line[7]; |
1395 | 1395 | $data['longitude'] = $line[1]; |
@@ -1406,16 +1406,16 @@ discard block |
||
1406 | 1406 | } elseif ($format == 'acars') { |
1407 | 1407 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1408 | 1408 | $ACARS->add(trim($buffer)); |
1409 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1409 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1410 | 1410 | $ACARS->deleteLiveAcarsData(); |
1411 | 1411 | } elseif ($format == 'flightgearmp') { |
1412 | - if (substr($buffer,0,1) != '#') { |
|
1412 | + if (substr($buffer, 0, 1) != '#') { |
|
1413 | 1413 | $data = array(); |
1414 | 1414 | //echo $buffer."\n"; |
1415 | - $line = explode(' ',$buffer); |
|
1415 | + $line = explode(' ', $buffer); |
|
1416 | 1416 | if (count($line) == 11) { |
1417 | - $userserver = explode('@',$line[0]); |
|
1418 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1417 | + $userserver = explode('@', $line[0]); |
|
1418 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1419 | 1419 | $data['ident'] = $userserver[0]; |
1420 | 1420 | $data['registration'] = $userserver[0]; |
1421 | 1421 | $data['latitude'] = $line[4]; |
@@ -1423,8 +1423,8 @@ discard block |
||
1423 | 1423 | $data['altitude'] = $line[6]; |
1424 | 1424 | $data['datetime'] = date('Y-m-d H:i:s'); |
1425 | 1425 | $aircraft_type = $line[10]; |
1426 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1427 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1426 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1427 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1428 | 1428 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1429 | 1429 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1430 | 1430 | } |
@@ -1433,8 +1433,8 @@ discard block |
||
1433 | 1433 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1434 | 1434 | die; |
1435 | 1435 | } elseif ($format == 'vrstcp') { |
1436 | - foreach($buffer as $all_data) { |
|
1437 | - $line = json_decode('{'.$all_data.'}',true); |
|
1436 | + foreach ($buffer as $all_data) { |
|
1437 | + $line = json_decode('{'.$all_data.'}', true); |
|
1438 | 1438 | $data = array(); |
1439 | 1439 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1440 | 1440 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1460,16 +1460,16 @@ discard block |
||
1460 | 1460 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1461 | 1461 | unset($data); |
1462 | 1462 | } |
1463 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1463 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1464 | 1464 | $line = explode("\t", $buffer); |
1465 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1465 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1466 | 1466 | $key = $line[$k]; |
1467 | - $lined[$key] = $line[$k+1]; |
|
1467 | + $lined[$key] = $line[$k + 1]; |
|
1468 | 1468 | } |
1469 | 1469 | if (count($lined) > 3) { |
1470 | 1470 | $data['hex'] = $lined['hexid']; |
1471 | 1471 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1472 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1472 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1473 | 1473 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1474 | 1474 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1475 | 1475 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1488,23 +1488,23 @@ discard block |
||
1488 | 1488 | } else $error = true; |
1489 | 1489 | } elseif ($format == 'aprs' && $use_aprs) { |
1490 | 1490 | if ($aprs_connect == 0) { |
1491 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1491 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1492 | 1492 | $aprs_connect = 1; |
1493 | 1493 | } |
1494 | 1494 | |
1495 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1495 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1496 | 1496 | $aprs_last_tx = time(); |
1497 | 1497 | $data_aprs = "# Keep alive"; |
1498 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1498 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1499 | 1499 | } |
1500 | 1500 | |
1501 | 1501 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1502 | 1502 | //echo 'APRS data : '.$buffer."\n"; |
1503 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1504 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1503 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1504 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1505 | 1505 | //echo $buffer."\n"; |
1506 | 1506 | date_default_timezone_set('UTC'); |
1507 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1507 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1508 | 1508 | $line = $APRS->parse($buffer); |
1509 | 1509 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1510 | 1510 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1519,7 +1519,7 @@ discard block |
||
1519 | 1519 | if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
1520 | 1520 | if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
1521 | 1521 | if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
1522 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1522 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1523 | 1523 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1524 | 1524 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1525 | 1525 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1601,29 +1601,29 @@ discard block |
||
1601 | 1601 | } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
1602 | 1602 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1603 | 1603 | $Source->deleteOldLocationByType('gs'); |
1604 | - if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
|
1605 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1604 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) { |
|
1605 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1606 | 1606 | } else { |
1607 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1607 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1608 | 1608 | } |
1609 | 1609 | } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1610 | 1610 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1611 | 1611 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1612 | 1612 | $Source->deleteOldLocationByType('wx'); |
1613 | 1613 | $weather_data = json_encode($line); |
1614 | - if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) { |
|
1615 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1614 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) { |
|
1615 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1616 | 1616 | } else { |
1617 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
|
1617 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data); |
|
1618 | 1618 | } |
1619 | 1619 | } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) { |
1620 | 1620 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1621 | 1621 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1622 | 1622 | $Source->deleteOldLocationByType('lightning'); |
1623 | - if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) { |
|
1624 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1623 | + if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) { |
|
1624 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1625 | 1625 | } else { |
1626 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
|
1626 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']); |
|
1627 | 1627 | } |
1628 | 1628 | } elseif ($globalDebug) { |
1629 | 1629 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -1632,7 +1632,7 @@ discard block |
||
1632 | 1632 | unset($data); |
1633 | 1633 | } |
1634 | 1634 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1635 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
1635 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
1636 | 1636 | } |
1637 | 1637 | /* |
1638 | 1638 | 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')) { |
@@ -1641,7 +1641,7 @@ discard block |
||
1641 | 1641 | */ |
1642 | 1642 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1643 | 1643 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1644 | - if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1644 | + if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) { |
|
1645 | 1645 | $Source->deleteOldLocationByType('lightning'); |
1646 | 1646 | $Source->deleteOldLocationByType('wx'); |
1647 | 1647 | $globalSources[$nb]['last_weather_clean'] = time(); |
@@ -1726,7 +1726,7 @@ discard block |
||
1726 | 1726 | connect_all($sourceee); |
1727 | 1727 | $sourceee = array(); |
1728 | 1728 | //connect_all($globalSources); |
1729 | - $tt[$format]=0; |
|
1729 | + $tt[$format] = 0; |
|
1730 | 1730 | break; |
1731 | 1731 | } |
1732 | 1732 | } |
@@ -1735,14 +1735,14 @@ discard block |
||
1735 | 1735 | } else { |
1736 | 1736 | $error = socket_strerror(socket_last_error()); |
1737 | 1737 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1738 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1738 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1739 | 1739 | if (isset($globalDebug)) echo "Restarting...\n"; |
1740 | 1740 | // Restart the script if possible |
1741 | 1741 | if (is_array($sockets)) { |
1742 | 1742 | if ($globalDebug) echo "Shutdown all sockets..."; |
1743 | 1743 | |
1744 | 1744 | foreach ($sockets as $sock) { |
1745 | - @socket_shutdown($sock,2); |
|
1745 | + @socket_shutdown($sock, 2); |
|
1746 | 1746 | @socket_close($sock); |
1747 | 1747 | } |
1748 | 1748 |