|
@@ -52,7 +52,9 @@ discard block |
|
|
block discarded – undo |
|
52
|
52
|
try { |
|
53
|
53
|
$GeoidClass = new GeoidHeight(); |
|
54
|
54
|
} catch(Exception $e) { |
|
55
|
|
- if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
|
55
|
+ if ($globalDebug) { |
|
|
56
|
+ echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n"; |
|
|
57
|
+ } |
|
56
|
58
|
$GeoidClass = FALSE; |
|
57
|
59
|
} |
|
58
|
60
|
} |
|
@@ -71,7 +73,9 @@ discard block |
|
|
block discarded – undo |
|
71
|
73
|
$dbc = $this->db; |
|
72
|
74
|
$this->all_flights[$id]['schedule_check'] = true; |
|
73
|
75
|
if ($globalSchedulesFetch) { |
|
74
|
|
- if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
|
76
|
+ if ($globalDebug) { |
|
|
77
|
+ echo 'Getting schedule info...'."\n"; |
|
|
78
|
+ } |
|
75
|
79
|
$Spotter = new Spotter($dbc); |
|
76
|
80
|
$Schedule = new Schedule($dbc); |
|
77
|
81
|
$Translation = new Translation($dbc); |
|
@@ -82,7 +86,9 @@ discard block |
|
|
block discarded – undo |
|
82
|
86
|
if ($Schedule->checkSchedule($operator) == 0) { |
|
83
|
87
|
$schedule = $Schedule->fetchSchedule($operator); |
|
84
|
88
|
if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
|
85
|
|
- if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
|
89
|
+ if ($globalDebug) { |
|
|
90
|
+ echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
|
91
|
+ } |
|
86
|
92
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87
|
93
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88
|
94
|
// Should also check if route schedule = route from DB |
|
@@ -91,7 +97,9 @@ discard block |
|
|
block discarded – undo |
|
91
|
97
|
$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
92
|
98
|
if (trim($airport_icao) != '') { |
|
93
|
99
|
$this->all_flights[$id]['departure_airport'] = $airport_icao; |
|
94
|
|
- if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
|
100
|
+ if ($globalDebug) { |
|
|
101
|
+ echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
|
102
|
+ } |
|
95
|
103
|
} |
|
96
|
104
|
} |
|
97
|
105
|
} |
|
@@ -100,17 +108,25 @@ discard block |
|
|
block discarded – undo |
|
100
|
108
|
$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
101
|
109
|
if (trim($airport_icao) != '') { |
|
102
|
110
|
$this->all_flights[$id]['arrival_airport'] = $airport_icao; |
|
103
|
|
- if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
|
111
|
+ if ($globalDebug) { |
|
|
112
|
+ echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
|
113
|
+ } |
|
104
|
114
|
} |
|
105
|
115
|
} |
|
106
|
116
|
} |
|
107
|
117
|
$Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
108
|
118
|
} |
|
109
|
|
- } else $scheduleexist = true; |
|
110
|
|
- } else $scheduleexist = true; |
|
|
119
|
+ } else { |
|
|
120
|
+ $scheduleexist = true; |
|
|
121
|
+ } |
|
|
122
|
+ } else { |
|
|
123
|
+ $scheduleexist = true; |
|
|
124
|
+ } |
|
111
|
125
|
// close connection, at least one way will work ? |
|
112
|
126
|
if ($scheduleexist) { |
|
113
|
|
- if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
|
127
|
+ if ($globalDebug) { |
|
|
128
|
+ echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
|
129
|
+ } |
|
114
|
130
|
$sch = $Schedule->getSchedule($operator); |
|
115
|
131
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
116
|
132
|
} |
|
@@ -132,14 +148,18 @@ discard block |
|
|
block discarded – undo |
|
132
|
148
|
|
|
133
|
149
|
public function checkAll() { |
|
134
|
150
|
global $globalDebug, $globalNoImport; |
|
135
|
|
- if ($globalDebug) echo "Update last seen flights data...\n"; |
|
|
151
|
+ if ($globalDebug) { |
|
|
152
|
+ echo "Update last seen flights data...\n"; |
|
|
153
|
+ } |
|
136
|
154
|
if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
137
|
155
|
foreach ($this->all_flights as $key => $flight) { |
|
138
|
156
|
if (isset($this->all_flights[$key]['id'])) { |
|
139
|
157
|
//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
140
|
158
|
$Spotter = new Spotter($this->db); |
|
141
|
159
|
$real_arrival = $this->arrival($key); |
|
142
|
|
- if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
|
160
|
+ if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) { |
|
|
161
|
+ $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
|
162
|
+ } |
|
143
|
163
|
} |
|
144
|
164
|
} |
|
145
|
165
|
} |
|
@@ -147,24 +167,32 @@ discard block |
|
|
block discarded – undo |
|
147
|
167
|
|
|
148
|
168
|
public function arrival($key) { |
|
149
|
169
|
global $globalClosestMinDist, $globalDebug; |
|
150
|
|
- if ($globalDebug) echo 'Update arrival...'."\n"; |
|
|
170
|
+ if ($globalDebug) { |
|
|
171
|
+ echo 'Update arrival...'."\n"; |
|
|
172
|
+ } |
|
151
|
173
|
$Spotter = new Spotter($this->db); |
|
152
|
174
|
$airport_icao = ''; |
|
153
|
175
|
$airport_time = ''; |
|
154
|
|
- if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
|
176
|
+ if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
|
177
|
+ $globalClosestMinDist = 50; |
|
|
178
|
+ } |
|
155
|
179
|
if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
156
|
180
|
$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
157
|
181
|
if (isset($closestAirports[0])) { |
|
158
|
182
|
if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
159
|
183
|
$airport_icao = $closestAirports[0]['icao']; |
|
160
|
184
|
$airport_time = $this->all_flights[$key]['datetime']; |
|
161
|
|
- if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
|
185
|
+ if ($globalDebug) { |
|
|
186
|
+ echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
|
187
|
+ } |
|
162
|
188
|
} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
163
|
189
|
foreach ($closestAirports as $airport) { |
|
164
|
190
|
if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
165
|
191
|
$airport_icao = $airport['icao']; |
|
166
|
192
|
$airport_time = $this->all_flights[$key]['datetime']; |
|
167
|
|
- if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
|
193
|
+ if ($globalDebug) { |
|
|
194
|
+ echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
|
195
|
+ } |
|
168
|
196
|
break; |
|
169
|
197
|
} |
|
170
|
198
|
} |
|
@@ -172,14 +200,20 @@ discard block |
|
|
block discarded – undo |
|
172
|
200
|
$airport_icao = $closestAirports[0]['icao']; |
|
173
|
201
|
$airport_time = $this->all_flights[$key]['datetime']; |
|
174
|
202
|
} else { |
|
175
|
|
- if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
|
203
|
+ if ($globalDebug) { |
|
|
204
|
+ echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
|
205
|
+ } |
|
176
|
206
|
} |
|
177
|
207
|
} else { |
|
178
|
|
- if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
|
208
|
+ if ($globalDebug) { |
|
|
209
|
+ echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
|
210
|
+ } |
|
179
|
211
|
} |
|
180
|
212
|
|
|
181
|
213
|
} else { |
|
182
|
|
- if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
|
214
|
+ if ($globalDebug) { |
|
|
215
|
+ echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
|
216
|
+ } |
|
183
|
217
|
} |
|
184
|
218
|
return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
185
|
219
|
} |
|
@@ -189,7 +223,9 @@ discard block |
|
|
block discarded – undo |
|
189
|
223
|
public function del() { |
|
190
|
224
|
global $globalDebug, $globalNoImport, $globalNoDB; |
|
191
|
225
|
// Delete old infos |
|
192
|
|
- if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
|
226
|
+ if ($globalDebug) { |
|
|
227
|
+ echo 'Delete old values and update latest data...'."\n"; |
|
|
228
|
+ } |
|
193
|
229
|
foreach ($this->all_flights as $key => $flight) { |
|
194
|
230
|
if (isset($flight['lastupdate'])) { |
|
195
|
231
|
if ($flight['lastupdate'] < (time()-5900)) { |
|
@@ -203,13 +239,17 @@ discard block |
|
|
block discarded – undo |
|
203
|
239
|
global $globalDebug, $globalNoImport, $globalNoDB; |
|
204
|
240
|
// Delete old infos |
|
205
|
241
|
if (isset($this->all_flights[$key]['id'])) { |
|
206
|
|
- if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
|
242
|
+ if ($globalDebug) { |
|
|
243
|
+ echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
|
244
|
+ } |
|
207
|
245
|
if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
208
|
246
|
$real_arrival = $this->arrival($key); |
|
209
|
247
|
$Spotter = new Spotter($this->db); |
|
210
|
248
|
if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
211
|
249
|
$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
212
|
|
- if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
|
250
|
+ if ($globalDebug && $result != 'success') { |
|
|
251
|
+ echo '!!! ERROR : '.$result."\n"; |
|
|
252
|
+ } |
|
213
|
253
|
} |
|
214
|
254
|
} |
|
215
|
255
|
} |
|
@@ -219,9 +259,13 @@ discard block |
|
|
block discarded – undo |
|
219
|
259
|
public function add($line) { |
|
220
|
260
|
global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass; |
|
221
|
261
|
//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
|
222
|
|
- if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
|
223
|
|
- if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000; |
|
224
|
|
-/* |
|
|
262
|
+ if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
|
263
|
+ $globalCoordMinChange = '0.01'; |
|
|
264
|
+ } |
|
|
265
|
+ if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') { |
|
|
266
|
+ $globalAircraftMaxUpdate = 3000; |
|
|
267
|
+ } |
|
|
268
|
+ /* |
|
225
|
269
|
$Spotter = new Spotter(); |
|
226
|
270
|
$dbc = $Spotter->db; |
|
227
|
271
|
$SpotterLive = new SpotterLive($dbc); |
|
@@ -243,19 +287,28 @@ discard block |
|
|
block discarded – undo |
|
243
|
287
|
// SBS format is CSV format |
|
244
|
288
|
if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
245
|
289
|
//print_r($line); |
|
246
|
|
- if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
|
290
|
+ if (isset($line['hex'])) { |
|
|
291
|
+ $line['hex'] = strtoupper($line['hex']); |
|
|
292
|
+ } |
|
247
|
293
|
if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
248
|
294
|
|
|
249
|
295
|
// Increment message number |
|
250
|
296
|
if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
|
251
|
297
|
$current_date = date('Y-m-d'); |
|
252
|
|
- if (isset($line['source_name'])) $source = $line['source_name']; |
|
253
|
|
- else $source = ''; |
|
254
|
|
- if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
|
298
|
+ if (isset($line['source_name'])) { |
|
|
299
|
+ $source = $line['source_name']; |
|
|
300
|
+ } else { |
|
|
301
|
+ $source = ''; |
|
|
302
|
+ } |
|
|
303
|
+ if ($source == '' || $line['format_source'] == 'aprs') { |
|
|
304
|
+ $source = $line['format_source']; |
|
|
305
|
+ } |
|
255
|
306
|
if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
256
|
307
|
$this->stats[$current_date][$source]['msg']['date'] = time(); |
|
257
|
308
|
$this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
258
|
|
- } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
|
309
|
+ } else { |
|
|
310
|
+ $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
|
311
|
+ } |
|
259
|
312
|
} |
|
260
|
313
|
|
|
261
|
314
|
/* |
|
@@ -271,23 +324,38 @@ discard block |
|
|
block discarded – undo |
|
271
|
324
|
//$this->db = $dbc; |
|
272
|
325
|
|
|
273
|
326
|
//$hex = trim($line['hex']); |
|
274
|
|
- if (!isset($line['id'])) $id = trim($line['hex']); |
|
275
|
|
- else $id = trim($line['id']); |
|
|
327
|
+ if (!isset($line['id'])) { |
|
|
328
|
+ $id = trim($line['hex']); |
|
|
329
|
+ } else { |
|
|
330
|
+ $id = trim($line['id']); |
|
|
331
|
+ } |
|
276
|
332
|
|
|
277
|
333
|
if (!isset($this->all_flights[$id])) { |
|
278
|
|
- if ($globalDebug) echo 'New flight...'."\n"; |
|
|
334
|
+ if ($globalDebug) { |
|
|
335
|
+ echo 'New flight...'."\n"; |
|
|
336
|
+ } |
|
279
|
337
|
$this->all_flights[$id] = array(); |
|
280
|
338
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281
|
339
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
282
|
|
- if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
|
340
|
+ if (isset($globalDaemon) && $globalDaemon === FALSE) { |
|
|
341
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
|
342
|
+ } |
|
283
|
343
|
if (!isset($line['id'])) { |
|
284
|
|
- if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
285
|
|
-// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
|
344
|
+ if (!isset($globalDaemon)) { |
|
|
345
|
+ $globalDaemon = TRUE; |
|
|
346
|
+ } |
|
|
347
|
+ // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
286
|
348
|
// if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
287
|
|
- if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
|
349
|
+ if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
|
350
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
|
351
|
+ } |
|
288
|
352
|
//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
289
|
|
- } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290
|
|
- if ($globalAllFlights !== FALSE) $dataFound = true; |
|
|
353
|
+ } else { |
|
|
354
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
|
355
|
+ } |
|
|
356
|
+ if ($globalAllFlights !== FALSE) { |
|
|
357
|
+ $dataFound = true; |
|
|
358
|
+ } |
|
291
|
359
|
} |
|
292
|
360
|
if (isset($line['source_type']) && $line['source_type'] != '') { |
|
293
|
361
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
@@ -309,12 +377,20 @@ discard block |
|
|
block discarded – undo |
|
309
|
377
|
$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
|
310
|
378
|
} |
|
311
|
379
|
$Spotter->db = null; |
|
312
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313
|
|
- if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
|
380
|
+ if ($globalDebugTimeElapsed) { |
|
|
381
|
+ echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
382
|
+ } |
|
|
383
|
+ if ($aircraft_icao != '') { |
|
|
384
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
|
385
|
+ } |
|
314
|
386
|
} |
|
315
|
387
|
} |
|
316
|
|
- if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317
|
|
- if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
|
388
|
+ if ($globalAllFlights !== FALSE) { |
|
|
389
|
+ $dataFound = true; |
|
|
390
|
+ } |
|
|
391
|
+ if ($globalDebug) { |
|
|
392
|
+ echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
|
393
|
+ } |
|
318
|
394
|
} |
|
319
|
395
|
if (isset($line['id']) && !isset($line['hex'])) { |
|
320
|
396
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
@@ -323,7 +399,9 @@ discard block |
|
|
block discarded – undo |
|
323
|
399
|
$icao = $line['aircraft_icao']; |
|
324
|
400
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
325
|
401
|
$Spotter = new Spotter($this->db); |
|
326
|
|
- if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
|
402
|
+ if (isset($Spotter->aircraft_correct_icaotype[$icao])) { |
|
|
403
|
+ $icao = $Spotter->aircraft_correct_icaotype[$icao]; |
|
|
404
|
+ } |
|
327
|
405
|
$Spotter->db = null; |
|
328
|
406
|
} |
|
329
|
407
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao)); |
|
@@ -334,15 +412,24 @@ discard block |
|
|
block discarded – undo |
|
334
|
412
|
$Spotter = new Spotter($this->db); |
|
335
|
413
|
$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
|
336
|
414
|
$Spotter->db = null; |
|
337
|
|
- if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
|
415
|
+ if ($aircraft_icao != '') { |
|
|
416
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
|
417
|
+ } |
|
338
|
418
|
} |
|
339
|
419
|
} |
|
340
|
420
|
if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
|
341
|
|
- if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
342
|
|
- elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
343
|
|
- elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
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)); |
|
|
421
|
+ if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
|
422
|
+ $aircraft_icao = 'GLID'; |
|
|
423
|
+ } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
|
424
|
+ $aircraft_icao = 'UHEL'; |
|
|
425
|
+ } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
|
426
|
+ $aircraft_icao = 'TOWPLANE'; |
|
|
427
|
+ } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
|
428
|
+ $aircraft_icao = 'POWAIRC'; |
|
|
429
|
+ } |
|
|
430
|
+ if (isset($aircraft_icao)) { |
|
|
431
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
|
432
|
+ } |
|
346
|
433
|
} |
|
347
|
434
|
if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
|
348
|
435
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
@@ -352,8 +439,11 @@ discard block |
|
|
block discarded – undo |
|
352
|
439
|
if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
353
|
440
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
354
|
441
|
} else { |
|
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
|
|
- 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"; |
|
|
442
|
+ if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
|
443
|
+ echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
|
444
|
+ } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
|
445
|
+ echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
|
446
|
+ } |
|
357
|
447
|
/* |
|
358
|
448
|
echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
|
359
|
449
|
print_r($this->all_flights[$id]); |
|
@@ -362,16 +452,22 @@ discard block |
|
|
block discarded – undo |
|
362
|
452
|
return ''; |
|
363
|
453
|
} |
|
364
|
454
|
} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
365
|
|
- if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
|
455
|
+ if ($globalDebug) { |
|
|
456
|
+ echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
|
457
|
+ } |
|
366
|
458
|
return ''; |
|
367
|
459
|
} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
368
|
|
- if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
|
460
|
+ if ($globalDebug) { |
|
|
461
|
+ echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
|
|
462
|
+ } |
|
369
|
463
|
return ''; |
|
370
|
464
|
} elseif (!isset($line['datetime'])) { |
|
371
|
465
|
date_default_timezone_set('UTC'); |
|
372
|
466
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
373
|
467
|
} else { |
|
374
|
|
- if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
|
468
|
+ if ($globalDebug) { |
|
|
469
|
+ echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!"; |
|
|
470
|
+ } |
|
375
|
471
|
return ''; |
|
376
|
472
|
} |
|
377
|
473
|
|
|
@@ -392,30 +488,48 @@ discard block |
|
|
block discarded – undo |
|
392
|
488
|
|
|
393
|
489
|
if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
394
|
490
|
if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
|
395
|
|
- if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
|
491
|
+ if ($globalDebug) { |
|
|
492
|
+ echo '---!!!! New ident, reset aircraft data...'."\n"; |
|
|
493
|
+ } |
|
396
|
494
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
397
|
495
|
$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'])); |
|
|
496
|
+ 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')) { |
|
|
497
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
|
498
|
+ } elseif (isset($line['id'])) { |
|
|
499
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
|
500
|
+ } elseif (isset($this->all_flights[$id]['ident'])) { |
|
|
501
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
|
502
|
+ } |
|
401
|
503
|
} else { |
|
402
|
504
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
403
|
505
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
404
|
506
|
$timeelapsed = microtime(true); |
|
405
|
507
|
$Spotter = new Spotter($this->db); |
|
406
|
508
|
$fromsource = NULL; |
|
407
|
|
- if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
408
|
|
- elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
409
|
|
- elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
410
|
|
- elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
411
|
|
- elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
|
509
|
+ if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
|
510
|
+ $fromsource = $globalAirlinesSource; |
|
|
511
|
+ } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
|
512
|
+ $fromsource = 'vatsim'; |
|
|
513
|
+ } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
|
514
|
+ $fromsource = 'ivao'; |
|
|
515
|
+ } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
|
516
|
+ $fromsource = 'vatsim'; |
|
|
517
|
+ } elseif (isset($globalIVAO) && $globalIVAO) { |
|
|
518
|
+ $fromsource = 'ivao'; |
|
|
519
|
+ } |
|
412
|
520
|
$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
413
|
|
- if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
|
521
|
+ if ($globalDebug && $result != 'success') { |
|
|
522
|
+ echo '!!! ERROR : '.$result."\n"; |
|
|
523
|
+ } |
|
414
|
524
|
$Spotter->db = null; |
|
415
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
525
|
+ if ($globalDebugTimeElapsed) { |
|
|
526
|
+ echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
527
|
+ } |
|
416
|
528
|
} |
|
417
|
529
|
} |
|
418
|
|
- } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
|
530
|
+ } else { |
|
|
531
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
|
532
|
+ } |
|
419
|
533
|
|
|
420
|
534
|
/* |
|
421
|
535
|
if (!isset($line['id'])) { |
|
@@ -425,7 +539,9 @@ discard block |
|
|
block discarded – undo |
|
425
|
539
|
else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
426
|
540
|
} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
427
|
541
|
*/ |
|
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'])); |
|
|
542
|
+ if (!isset($this->all_flights[$id]['id'])) { |
|
|
543
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
|
544
|
+ } |
|
429
|
545
|
|
|
430
|
546
|
//$putinarchive = true; |
|
431
|
547
|
if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
@@ -443,7 +559,9 @@ discard block |
|
|
block discarded – undo |
|
443
|
559
|
$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
|
444
|
560
|
$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
|
445
|
561
|
$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"; |
|
|
562
|
+ if ($globalDebugTimeElapsed) { |
|
|
563
|
+ echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
564
|
+ } |
|
447
|
565
|
} |
|
448
|
566
|
} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
449
|
567
|
$timeelapsed = microtime(true); |
|
@@ -457,7 +575,9 @@ discard block |
|
|
block discarded – undo |
|
457
|
575
|
$Translation->db = null; |
|
458
|
576
|
} |
|
459
|
577
|
$Spotter->db = null; |
|
460
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
578
|
+ if ($globalDebugTimeElapsed) { |
|
|
579
|
+ echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
580
|
+ } |
|
461
|
581
|
} |
|
462
|
582
|
if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
|
463
|
583
|
//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
@@ -466,9 +586,13 @@ discard block |
|
|
block discarded – undo |
|
466
|
586
|
$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
|
587
|
} |
|
468
|
588
|
} |
|
469
|
|
- if (!isset($globalFork)) $globalFork = TRUE; |
|
|
589
|
+ if (!isset($globalFork)) { |
|
|
590
|
+ $globalFork = TRUE; |
|
|
591
|
+ } |
|
470
|
592
|
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'])); |
|
|
593
|
+ if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
|
594
|
+ $this->get_Schedule($id,trim($line['ident'])); |
|
|
595
|
+ } |
|
472
|
596
|
} |
|
473
|
597
|
} |
|
474
|
598
|
} |
|
@@ -486,9 +610,13 @@ discard block |
|
|
block discarded – undo |
|
486
|
610
|
$speed = $speed*3.6; |
|
487
|
611
|
if ($speed < 1000) { |
|
488
|
612
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
489
|
|
- if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
|
613
|
+ if ($globalDebug) { |
|
|
614
|
+ echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
|
615
|
+ } |
|
490
|
616
|
} else { |
|
491
|
|
- if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
|
617
|
+ if ($globalDebug) { |
|
|
618
|
+ echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
|
|
619
|
+ } |
|
492
|
620
|
} |
|
493
|
621
|
} |
|
494
|
622
|
} |
|
@@ -497,13 +625,21 @@ discard block |
|
|
block discarded – undo |
|
497
|
625
|
|
|
498
|
626
|
if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
499
|
627
|
if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
500
|
|
- if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
|
628
|
+ if ($globalDebug) { |
|
|
629
|
+ echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
|
630
|
+ } |
|
501
|
631
|
return false; |
|
502
|
632
|
} |
|
503
|
|
- if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
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']); |
|
506
|
|
- else unset($timediff_archive); |
|
|
633
|
+ if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
|
634
|
+ $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
|
635
|
+ } else { |
|
|
636
|
+ unset($timediff); |
|
|
637
|
+ } |
|
|
638
|
+ if (isset($this->all_flights[$id]['time_last_archive_coord'])) { |
|
|
639
|
+ $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
|
640
|
+ } else { |
|
|
641
|
+ unset($timediff_archive); |
|
|
642
|
+ } |
|
507
|
643
|
if ($this->tmd > 5 |
|
508
|
644
|
|| (isset($line['format_source']) |
|
509
|
645
|
&& $line['format_source'] == 'airwhere' |
|
@@ -539,16 +675,25 @@ discard block |
|
|
block discarded – undo |
|
539
|
675
|
$this->all_flights[$id]['putinarchive'] = true; |
|
540
|
676
|
$this->tmd = 0; |
|
541
|
677
|
if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
542
|
|
- if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
|
678
|
+ if ($globalDebug) { |
|
|
679
|
+ echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
|
680
|
+ } |
|
543
|
681
|
$timeelapsed = microtime(true); |
|
544
|
682
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
545
|
683
|
$Spotter = new Spotter($this->db); |
|
546
|
684
|
$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
547
|
|
- if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
548
|
|
- else $this->all_flights[$id]['over_country'] = ''; |
|
|
685
|
+ if (!empty($all_country)) { |
|
|
686
|
+ $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
|
687
|
+ } else { |
|
|
688
|
+ $this->all_flights[$id]['over_country'] = ''; |
|
|
689
|
+ } |
|
549
|
690
|
$Spotter->db = null; |
|
550
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
551
|
|
- if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
|
691
|
+ if ($globalDebugTimeElapsed) { |
|
|
692
|
+ echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
693
|
+ } |
|
|
694
|
+ if ($globalDebug) { |
|
|
695
|
+ echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
|
696
|
+ } |
|
552
|
697
|
} |
|
553
|
698
|
} |
|
554
|
699
|
$this->all_flights[$id]['time_last_archive_coord'] = time(); |
|
@@ -594,7 +739,9 @@ discard block |
|
|
block discarded – undo |
|
594
|
739
|
*/ |
|
595
|
740
|
} |
|
596
|
741
|
if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
|
597
|
|
- if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
|
742
|
+ if ($line['longitude'] > 180) { |
|
|
743
|
+ $line['longitude'] = $line['longitude'] - 360; |
|
|
744
|
+ } |
|
598
|
745
|
//if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
599
|
746
|
if (!isset($this->all_flights[$id]['archive_longitude'])) { |
|
600
|
747
|
$this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
@@ -631,7 +778,9 @@ discard block |
|
|
block discarded – undo |
|
631
|
778
|
} |
|
632
|
779
|
} |
|
633
|
780
|
if (isset($line['last_update']) && $line['last_update'] != '') { |
|
634
|
|
- if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
|
781
|
+ if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
|
782
|
+ $dataFound = true; |
|
|
783
|
+ } |
|
635
|
784
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
636
|
785
|
} |
|
637
|
786
|
if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
|
@@ -653,35 +802,53 @@ discard block |
|
|
block discarded – undo |
|
653
|
802
|
// Here we force archive of flight because after ground it's a new one (or should be) |
|
654
|
803
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
655
|
804
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
656
|
|
- if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
657
|
|
- elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
658
|
|
- elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
|
805
|
+ if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
|
806
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
|
807
|
+ } elseif (isset($line['id'])) { |
|
|
808
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
|
809
|
+ } elseif (isset($this->all_flights[$id]['ident'])) { |
|
|
810
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
|
811
|
+ } |
|
|
812
|
+ } |
|
|
813
|
+ if ($line['ground'] != 1) { |
|
|
814
|
+ $line['ground'] = 0; |
|
659
|
815
|
} |
|
660
|
|
- if ($line['ground'] != 1) $line['ground'] = 0; |
|
661
|
816
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
662
|
817
|
//$dataFound = true; |
|
663
|
818
|
} |
|
664
|
819
|
if (isset($line['squawk']) && $line['squawk'] != '') { |
|
665
|
820
|
if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
666
|
|
- if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
|
821
|
+ if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
|
822
|
+ $this->all_flights[$id]['putinarchive'] = true; |
|
|
823
|
+ } |
|
667
|
824
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
668
|
825
|
$highlight = ''; |
|
669
|
|
- if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
670
|
|
- if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
671
|
|
- if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
|
826
|
+ if ($this->all_flights[$id]['squawk'] == '7500') { |
|
|
827
|
+ $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
|
828
|
+ } |
|
|
829
|
+ if ($this->all_flights[$id]['squawk'] == '7600') { |
|
|
830
|
+ $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
|
831
|
+ } |
|
|
832
|
+ if ($this->all_flights[$id]['squawk'] == '7700') { |
|
|
833
|
+ $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
|
834
|
+ } |
|
672
|
835
|
if ($highlight != '') { |
|
673
|
836
|
$timeelapsed = microtime(true); |
|
674
|
837
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
675
|
838
|
$Spotter = new Spotter($this->db); |
|
676
|
839
|
$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
677
|
840
|
$Spotter->db = null; |
|
678
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
841
|
+ if ($globalDebugTimeElapsed) { |
|
|
842
|
+ echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
843
|
+ } |
|
679
|
844
|
} |
|
680
|
845
|
//$putinarchive = true; |
|
681
|
846
|
//$highlight = ''; |
|
682
|
847
|
} |
|
683
|
848
|
|
|
684
|
|
- } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
|
849
|
+ } else { |
|
|
850
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
|
851
|
+ } |
|
685
|
852
|
//$dataFound = true; |
|
686
|
853
|
} |
|
687
|
854
|
|
|
@@ -694,19 +861,27 @@ discard block |
|
|
block discarded – undo |
|
694
|
861
|
} |
|
695
|
862
|
} |
|
696
|
863
|
//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
697
|
|
- if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
|
864
|
+ if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
|
865
|
+ $this->all_flights[$id]['putinarchive'] = true; |
|
|
866
|
+ } |
|
698
|
867
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
699
|
868
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
700
|
869
|
//$dataFound = true; |
|
701
|
870
|
//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
702
|
871
|
if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
703
|
872
|
if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
|
704
|
|
- if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
|
|
873
|
+ if ($globalDebug) { |
|
|
874
|
+ echo '--- Reset because of altitude'."\n"; |
|
|
875
|
+ } |
|
705
|
876
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
706
|
877
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
707
|
|
- if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
708
|
|
- elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
709
|
|
- elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
|
878
|
+ if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
|
879
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
|
880
|
+ } elseif (isset($line['id'])) { |
|
|
881
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
|
882
|
+ } elseif (isset($this->all_flights[$id]['ident'])) { |
|
|
883
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
|
884
|
+ } |
|
710
|
885
|
} |
|
711
|
886
|
} |
|
712
|
887
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
@@ -717,22 +892,32 @@ discard block |
|
|
block discarded – undo |
|
717
|
892
|
} |
|
718
|
893
|
|
|
719
|
894
|
if (isset($line['heading']) && $line['heading'] != '') { |
|
720
|
|
- if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
|
895
|
+ if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
|
896
|
+ $this->all_flights[$id]['putinarchive'] = true; |
|
|
897
|
+ } |
|
721
|
898
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
722
|
899
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
723
|
900
|
//$dataFound = true; |
|
724
|
901
|
} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
|
725
|
902
|
$heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
726
|
903
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
727
|
|
- if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
728
|
|
- if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
|
904
|
+ if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
|
905
|
+ $this->all_flights[$id]['putinarchive'] = true; |
|
|
906
|
+ } |
|
|
907
|
+ if ($globalDebug) { |
|
|
908
|
+ echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n"; |
|
|
909
|
+ } |
|
729
|
910
|
} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
|
730
|
911
|
// If not enough messages and ACARS set heading to 0 |
|
731
|
912
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
732
|
913
|
} |
|
733
|
|
- if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
734
|
|
- elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
735
|
|
- elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false; |
|
|
914
|
+ if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
|
915
|
+ $dataFound = false; |
|
|
916
|
+ } elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
|
917
|
+ $dataFound = false; |
|
|
918
|
+ } elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) { |
|
|
919
|
+ $dataFound = false; |
|
|
920
|
+ } |
|
736
|
921
|
|
|
737
|
922
|
// print_r($this->all_flights[$id]); |
|
738
|
923
|
//gets the callsign from the last hour |
|
@@ -749,23 +934,38 @@ discard block |
|
|
block discarded – undo |
|
749
|
934
|
//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
750
|
935
|
if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
751
|
936
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
752
|
|
- if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
|
937
|
+ if ($globalDebug) { |
|
|
938
|
+ echo "Check if aircraft is already in DB..."; |
|
|
939
|
+ } |
|
753
|
940
|
$timeelapsed = microtime(true); |
|
754
|
941
|
$SpotterLive = new SpotterLive($this->db); |
|
755
|
942
|
if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
756
|
943
|
$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
|
757
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
944
|
+ if ($globalDebugTimeElapsed) { |
|
|
945
|
+ echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
946
|
+ } |
|
758
|
947
|
} elseif (isset($line['id'])) { |
|
759
|
948
|
$recent_ident = $SpotterLive->checkIdRecent($line['id']); |
|
760
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
949
|
+ if ($globalDebugTimeElapsed) { |
|
|
950
|
+ echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
951
|
+ } |
|
761
|
952
|
} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
762
|
953
|
$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
|
763
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
764
|
|
- } else $recent_ident = ''; |
|
|
954
|
+ if ($globalDebugTimeElapsed) { |
|
|
955
|
+ echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
956
|
+ } |
|
|
957
|
+ } else { |
|
|
958
|
+ $recent_ident = ''; |
|
|
959
|
+ } |
|
765
|
960
|
$SpotterLive->db=null; |
|
766
|
|
- if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
767
|
|
- elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
768
|
|
- } else $recent_ident = ''; |
|
|
961
|
+ if ($globalDebug && $recent_ident == '') { |
|
|
962
|
+ echo " Not in DB.\n"; |
|
|
963
|
+ } elseif ($globalDebug && $recent_ident != '') { |
|
|
964
|
+ echo " Already in DB.\n"; |
|
|
965
|
+ } |
|
|
966
|
+ } else { |
|
|
967
|
+ $recent_ident = ''; |
|
|
968
|
+ } |
|
769
|
969
|
} else { |
|
770
|
970
|
$recent_ident = ''; |
|
771
|
971
|
$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
@@ -773,7 +973,9 @@ discard block |
|
|
block discarded – undo |
|
773
|
973
|
//if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
774
|
974
|
if($recent_ident == "") |
|
775
|
975
|
{ |
|
776
|
|
- if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
|
976
|
+ if ($globalDebug) { |
|
|
977
|
+ echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
|
978
|
+ } |
|
777
|
979
|
if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
778
|
980
|
if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
779
|
981
|
//adds the spotter data for the archive |
|
@@ -817,31 +1019,49 @@ discard block |
|
|
block discarded – undo |
|
817
|
1019
|
|
|
818
|
1020
|
if (!$ignoreImport) { |
|
819
|
1021
|
$highlight = ''; |
|
820
|
|
- if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
821
|
|
- if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
822
|
|
- if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
823
|
|
- if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
|
1022
|
+ if ($this->all_flights[$id]['squawk'] == '7500') { |
|
|
1023
|
+ $highlight = 'Squawk 7500 : Hijack'; |
|
|
1024
|
+ } |
|
|
1025
|
+ if ($this->all_flights[$id]['squawk'] == '7600') { |
|
|
1026
|
+ $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
|
1027
|
+ } |
|
|
1028
|
+ if ($this->all_flights[$id]['squawk'] == '7700') { |
|
|
1029
|
+ $highlight = 'Squawk 7700 : Emergency'; |
|
|
1030
|
+ } |
|
|
1031
|
+ if (!isset($this->all_flights[$id]['id'])) { |
|
|
1032
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
|
1033
|
+ } |
|
824
|
1034
|
$timeelapsed = microtime(true); |
|
825
|
1035
|
if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
826
|
1036
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
827
|
1037
|
$Spotter = new Spotter($this->db); |
|
828
|
1038
|
$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
829
|
1039
|
$Spotter->db = null; |
|
830
|
|
- if ($globalDebug && isset($result)) echo $result."\n"; |
|
|
1040
|
+ if ($globalDebug && isset($result)) { |
|
|
1041
|
+ echo $result."\n"; |
|
|
1042
|
+ } |
|
831
|
1043
|
} |
|
832
|
1044
|
} |
|
833
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
1045
|
+ if ($globalDebugTimeElapsed) { |
|
|
1046
|
+ echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
1047
|
+ } |
|
834
|
1048
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
835
|
1049
|
|
|
836
|
1050
|
// Add source stat in DB |
|
837
|
1051
|
$Stats = new Stats($this->db); |
|
838
|
1052
|
if (!empty($this->stats)) { |
|
839
|
|
- if ($globalDebug) echo 'Add source stats : '; |
|
|
1053
|
+ if ($globalDebug) { |
|
|
1054
|
+ echo 'Add source stats : '; |
|
|
1055
|
+ } |
|
840
|
1056
|
foreach($this->stats as $date => $data) { |
|
841
|
1057
|
foreach($data as $source => $sourced) { |
|
842
|
1058
|
//print_r($sourced); |
|
843
|
|
- if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
844
|
|
- if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
|
1059
|
+ if (isset($sourced['polar'])) { |
|
|
1060
|
+ echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
|
1061
|
+ } |
|
|
1062
|
+ if (isset($sourced['hist'])) { |
|
|
1063
|
+ echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
|
1064
|
+ } |
|
845
|
1065
|
if (isset($sourced['msg'])) { |
|
846
|
1066
|
if (time() - $sourced['msg']['date'] > 10) { |
|
847
|
1067
|
$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
@@ -854,13 +1074,17 @@ discard block |
|
|
block discarded – undo |
|
854
|
1074
|
unset($this->stats[$date]); |
|
855
|
1075
|
} |
|
856
|
1076
|
} |
|
857
|
|
- if ($globalDebug) echo 'Done'."\n"; |
|
|
1077
|
+ if ($globalDebug) { |
|
|
1078
|
+ echo 'Done'."\n"; |
|
|
1079
|
+ } |
|
858
|
1080
|
|
|
859
|
1081
|
} |
|
860
|
1082
|
$Stats->db = null; |
|
861
|
1083
|
} |
|
862
|
1084
|
$this->del(); |
|
863
|
|
- } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
|
1085
|
+ } elseif ($globalDebug) { |
|
|
1086
|
+ echo 'Ignore data'."\n"; |
|
|
1087
|
+ } |
|
864
|
1088
|
//$ignoreImport = false; |
|
865
|
1089
|
$this->all_flights[$id]['addedSpotter'] = 1; |
|
866
|
1090
|
//print_r($this->all_flights[$id]); |
|
@@ -877,7 +1101,9 @@ discard block |
|
|
block discarded – undo |
|
877
|
1101
|
*/ |
|
878
|
1102
|
//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
|
879
|
1103
|
if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
|
880
|
|
- if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
|
1104
|
+ if ($globalDebug) { |
|
|
1105
|
+ echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
|
1106
|
+ } |
|
881
|
1107
|
//SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
882
|
1108
|
if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
883
|
1109
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
@@ -886,7 +1112,9 @@ discard block |
|
|
block discarded – undo |
|
886
|
1112
|
$SpotterLive->db=null; |
|
887
|
1113
|
} |
|
888
|
1114
|
} |
|
889
|
|
- if ($globalDebug) echo " Done\n"; |
|
|
1115
|
+ if ($globalDebug) { |
|
|
1116
|
+ echo " Done\n"; |
|
|
1117
|
+ } |
|
890
|
1118
|
$this->last_delete = time(); |
|
891
|
1119
|
} |
|
892
|
1120
|
} else { |
|
@@ -913,11 +1141,17 @@ discard block |
|
|
block discarded – undo |
|
913
|
1141
|
//echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
914
|
1142
|
if ($globalDebug) { |
|
915
|
1143
|
if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
|
916
|
|
- if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
917
|
|
- else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
|
1144
|
+ if (isset($this->all_flights[$id]['source_name'])) { |
|
|
1145
|
+ echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
|
1146
|
+ } else { |
|
|
1147
|
+ echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
|
1148
|
+ } |
|
918
|
1149
|
} else { |
|
919
|
|
- if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
920
|
|
- else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
|
1150
|
+ if (isset($this->all_flights[$id]['source_name'])) { |
|
|
1151
|
+ echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
|
1152
|
+ } else { |
|
|
1153
|
+ echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
|
1154
|
+ } |
|
921
|
1155
|
} |
|
922
|
1156
|
} |
|
923
|
1157
|
$ignoreImport = false; |
|
@@ -963,22 +1197,30 @@ discard block |
|
|
block discarded – undo |
|
963
|
1197
|
|
|
964
|
1198
|
if (!$ignoreImport) { |
|
965
|
1199
|
if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
966
|
|
- if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
|
1200
|
+ if (!isset($this->all_flights[$id]['id'])) { |
|
|
1201
|
+ $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
|
1202
|
+ } |
|
967
|
1203
|
$timeelapsed = microtime(true); |
|
968
|
1204
|
if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
969
|
1205
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
970
|
|
- if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
|
1206
|
+ if ($globalDebug) { |
|
|
1207
|
+ echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
|
1208
|
+ } |
|
971
|
1209
|
$SpotterLive = new SpotterLive($this->db); |
|
972
|
1210
|
$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
973
|
1211
|
$SpotterLive->db = null; |
|
974
|
|
- if ($globalDebug) echo $result."\n"; |
|
|
1212
|
+ if ($globalDebug) { |
|
|
1213
|
+ echo $result."\n"; |
|
|
1214
|
+ } |
|
975
|
1215
|
} |
|
976
|
1216
|
} |
|
977
|
1217
|
if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
|
978
|
1218
|
$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
979
|
1219
|
} |
|
980
|
1220
|
$this->all_flights[$id]['putinarchive'] = false; |
|
981
|
|
- if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
1221
|
+ if ($globalDebugTimeElapsed) { |
|
|
1222
|
+ echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
|
1223
|
+ } |
|
982
|
1224
|
|
|
983
|
1225
|
// Put statistics in $this->stats variable |
|
984
|
1226
|
//if ($line['format_source'] != 'aprs') { |
|
@@ -986,7 +1228,9 @@ discard block |
|
|
block discarded – undo |
|
986
|
1228
|
if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
987
|
1229
|
if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
988
|
1230
|
$source = $this->all_flights[$id]['source_name']; |
|
989
|
|
- if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
|
1231
|
+ if ($source == '') { |
|
|
1232
|
+ $source = $this->all_flights[$id]['format_source']; |
|
|
1233
|
+ } |
|
990
|
1234
|
if (!isset($this->source_location[$source])) { |
|
991
|
1235
|
$Location = new Source($this->db); |
|
992
|
1236
|
$coord = $Location->getLocationInfobySourceName($source); |
|
@@ -1007,7 +1251,9 @@ discard block |
|
|
block discarded – undo |
|
1007
|
1251
|
$stats_heading = round($stats_heading/22.5); |
|
1008
|
1252
|
$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
1009
|
1253
|
$current_date = date('Y-m-d'); |
|
1010
|
|
- if ($stats_heading == 16) $stats_heading = 0; |
|
|
1254
|
+ if ($stats_heading == 16) { |
|
|
1255
|
+ $stats_heading = 0; |
|
|
1256
|
+ } |
|
1011
|
1257
|
if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
|
1012
|
1258
|
for ($i=0;$i<=15;$i++) { |
|
1013
|
1259
|
$this->stats[$current_date][$source]['polar'][$i] = 0; |
|
@@ -1025,7 +1271,9 @@ discard block |
|
|
block discarded – undo |
|
1025
|
1271
|
if (isset($this->stats[$current_date][$source]['hist'][0])) { |
|
1026
|
1272
|
end($this->stats[$current_date][$source]['hist']); |
|
1027
|
1273
|
$mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1028
|
|
- } else $mini = 0; |
|
|
1274
|
+ } else { |
|
|
1275
|
+ $mini = 0; |
|
|
1276
|
+ } |
|
1029
|
1277
|
for ($i=$mini;$i<=$distance;$i+=10) { |
|
1030
|
1278
|
$this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1031
|
1279
|
} |
|
@@ -1037,19 +1285,27 @@ discard block |
|
|
block discarded – undo |
|
1037
|
1285
|
} |
|
1038
|
1286
|
|
|
1039
|
1287
|
$this->all_flights[$id]['lastupdate'] = time(); |
|
1040
|
|
- if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
|
1288
|
+ if ($this->all_flights[$id]['putinarchive']) { |
|
|
1289
|
+ $send = true; |
|
|
1290
|
+ } |
|
1041
|
1291
|
//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
1042
|
|
- } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
|
1292
|
+ } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
|
1293
|
+ echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
|
1294
|
+ } |
|
1043
|
1295
|
//$this->del(); |
|
1044
|
1296
|
|
|
1045
|
1297
|
if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
|
1046
|
1298
|
if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1047
|
|
- if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
|
1299
|
+ if ($globalDebug) { |
|
|
1300
|
+ echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
|
1301
|
+ } |
|
1048
|
1302
|
$SpotterLive = new SpotterLive($this->db); |
|
1049
|
1303
|
$SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
1050
|
1304
|
$SpotterLive->db = null; |
|
1051
|
1305
|
//SpotterLive->deleteLiveSpotterData(); |
|
1052
|
|
- if ($globalDebug) echo " Done\n"; |
|
|
1306
|
+ if ($globalDebug) { |
|
|
1307
|
+ echo " Done\n"; |
|
|
1308
|
+ } |
|
1053
|
1309
|
$this->last_delete_hourly = time(); |
|
1054
|
1310
|
} else { |
|
1055
|
1311
|
$this->del(); |
|
@@ -1061,7 +1317,9 @@ discard block |
|
|
block discarded – undo |
|
1061
|
1317
|
//$ignoreImport = false; |
|
1062
|
1318
|
} |
|
1063
|
1319
|
//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
|
1064
|
|
- if ($send) return $this->all_flights[$id]; |
|
|
1320
|
+ if ($send) { |
|
|
1321
|
+ return $this->all_flights[$id]; |
|
|
1322
|
+ } |
|
1065
|
1323
|
} |
|
1066
|
1324
|
} |
|
1067
|
1325
|
} |