@@ -90,8 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | |
92 | 92 | private function urshift($n, $s) { |
93 | - return ($n >= 0) ? ($n >> $s) : |
|
94 | - (($n & 0x7fffffff) >> $s) | |
|
93 | + return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| |
|
95 | 94 | (0x40000000 >> ($s - 1)); |
96 | 95 | } |
97 | 96 | |
@@ -103,7 +102,7 @@ discard block |
||
103 | 102 | //$split_input = str_split($input); |
104 | 103 | |
105 | 104 | /* Find the end of header checking for NULL bytes while doing it. */ |
106 | - $splitpos = strpos($input,':'); |
|
105 | + $splitpos = strpos($input, ':'); |
|
107 | 106 | |
108 | 107 | /* Check that end was found and body has at least one byte. */ |
109 | 108 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
@@ -113,15 +112,15 @@ discard block |
||
113 | 112 | |
114 | 113 | if ($debug) echo 'input : '.$input."\n"; |
115 | 114 | /* Save header and body. */ |
116 | - $body = substr($input,$splitpos+1,$input_len); |
|
115 | + $body = substr($input, $splitpos + 1, $input_len); |
|
117 | 116 | $body_len = strlen($body); |
118 | - $header = substr($input,0,$splitpos); |
|
117 | + $header = substr($input, 0, $splitpos); |
|
119 | 118 | //$header_len = strlen($header); |
120 | 119 | if ($debug) echo 'header : '.$header."\n"; |
121 | 120 | |
122 | 121 | /* Parse source, target and path. */ |
123 | 122 | //FLRDF0A52>APRS,qAS,LSTB |
124 | - if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
|
123 | + if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) { |
|
125 | 124 | $ident = $matches[1]; |
126 | 125 | $all_elements = $matches[2]; |
127 | 126 | if ($ident == 'AIRCRAFT') { |
@@ -135,14 +134,14 @@ discard block |
||
135 | 134 | $result['ident'] = $ident; |
136 | 135 | } |
137 | 136 | } else return false; |
138 | - $elements = explode(',',$all_elements); |
|
137 | + $elements = explode(',', $all_elements); |
|
139 | 138 | $source = end($elements); |
140 | 139 | $result['source'] = $source; |
141 | 140 | foreach ($elements as $element) { |
142 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
141 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) { |
|
143 | 142 | //echo "ok"; |
144 | 143 | //if ($element == 'TCPIP*') return false; |
145 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
144 | + } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) { |
|
146 | 145 | if ($debug) echo 'element : '.$element."\n"; |
147 | 146 | return false; |
148 | 147 | } |
@@ -155,12 +154,12 @@ discard block |
||
155 | 154 | */ |
156 | 155 | } |
157 | 156 | |
158 | - $type = substr($body,0,1); |
|
157 | + $type = substr($body, 0, 1); |
|
159 | 158 | if ($debug) echo 'type : '.$type."\n"; |
160 | 159 | if ($type == ';') { |
161 | 160 | if (isset($result['source_type']) && $result['source_type'] == 'modes') { |
162 | - $result['address'] = trim(substr($body,1,9)); |
|
163 | - } else $result['ident'] = trim(substr($body,1,9)); |
|
161 | + $result['address'] = trim(substr($body, 1, 9)); |
|
162 | + } else $result['ident'] = trim(substr($body, 1, 9)); |
|
164 | 163 | } elseif ($type == ',') { |
165 | 164 | // Invalid data or test data |
166 | 165 | return false; |
@@ -168,24 +167,24 @@ discard block |
||
168 | 167 | |
169 | 168 | // Check for Timestamp |
170 | 169 | $find = false; |
171 | - $body_parse = substr($body,1); |
|
170 | + $body_parse = substr($body, 1); |
|
172 | 171 | //echo 'Body : '.$body."\n"; |
173 | - if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
|
174 | - $body_parse = substr($body_parse,10); |
|
172 | + if (preg_match('/^;(.){9}\*/', $body, $matches)) { |
|
173 | + $body_parse = substr($body_parse, 10); |
|
175 | 174 | $find = true; |
176 | 175 | //echo $body_parse."\n"; |
177 | 176 | } |
178 | - if (preg_match('/^`(.*)\//',$body,$matches)) { |
|
179 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
177 | + if (preg_match('/^`(.*)\//', $body, $matches)) { |
|
178 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
180 | 179 | $find = true; |
181 | 180 | //echo $body_parse."\n"; |
182 | 181 | } |
183 | - if (preg_match("/^'(.*)\//",$body,$matches)) { |
|
184 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
182 | + if (preg_match("/^'(.*)\//", $body, $matches)) { |
|
183 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); |
|
185 | 184 | $find = true; |
186 | 185 | //echo $body_parse."\n"; |
187 | 186 | } |
188 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
|
187 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) { |
|
189 | 188 | $find = true; |
190 | 189 | //print_r($matches); |
191 | 190 | $timestamp = $matches[0]; |
@@ -200,19 +199,19 @@ discard block |
||
200 | 199 | // This work or not ? |
201 | 200 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
202 | 201 | } |
203 | - $body_parse = substr($body_parse,7); |
|
202 | + $body_parse = substr($body_parse, 7); |
|
204 | 203 | $result['timestamp'] = $timestamp; |
205 | 204 | //echo date('Ymd H:i:s',$timestamp); |
206 | 205 | } |
207 | - if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
|
206 | + if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) { |
|
208 | 207 | $find = true; |
209 | 208 | $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
210 | - $body_parse = substr($body_parse,8); |
|
209 | + $body_parse = substr($body_parse, 8); |
|
211 | 210 | $result['timestamp'] = $timestamp; |
212 | 211 | //echo date('Ymd H:i:s',$timestamp); |
213 | 212 | } |
214 | 213 | //if (strlen($body_parse) > 19) { |
215 | - if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { |
|
214 | + if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) { |
|
216 | 215 | $find = true; |
217 | 216 | // 4658.70N/00707.78Ez |
218 | 217 | //print_r(str_split($body_parse)); |
@@ -238,11 +237,11 @@ discard block |
||
238 | 237 | */ |
239 | 238 | $latitude = $lat + floatval($lat_min)/60; |
240 | 239 | $longitude = $lon + floatval($lon_min)/60; |
241 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
242 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
240 | + if ($sind == 'S') $latitude = 0 - $latitude; |
|
241 | + if ($wind == 'W') $longitude = 0 - $longitude; |
|
243 | 242 | $result['latitude'] = $latitude; |
244 | 243 | $result['longitude'] = $longitude; |
245 | - $body_parse = substr($body_parse,18); |
|
244 | + $body_parse = substr($body_parse, 18); |
|
246 | 245 | $body_parse_len = strlen($body_parse); |
247 | 246 | } |
248 | 247 | $body_parse_len = strlen($body_parse); |
@@ -270,7 +269,7 @@ discard block |
||
270 | 269 | //echo $body_parse; |
271 | 270 | //if ($type != ';' && $type != '>') { |
272 | 271 | if ($type != '') { |
273 | - $body_parse = substr($body_parse,1); |
|
272 | + $body_parse = substr($body_parse, 1); |
|
274 | 273 | $body_parse_len = strlen($body_parse); |
275 | 274 | $result['symbol_code'] = $symbol_code; |
276 | 275 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
@@ -281,16 +280,16 @@ discard block |
||
281 | 280 | //$body_parse_len = strlen($body_parse); |
282 | 281 | if ($body_parse_len >= 7) { |
283 | 282 | |
284 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
285 | - $course = substr($body_parse,0,3); |
|
283 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) { |
|
284 | + $course = substr($body_parse, 0, 3); |
|
286 | 285 | $tmp_s = intval($course); |
287 | 286 | if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
288 | - $speed = substr($body_parse,4,3); |
|
287 | + $speed = substr($body_parse, 4, 3); |
|
289 | 288 | if ($speed != '...') { |
290 | 289 | //$result['speed'] = round($speed*1.852); |
291 | 290 | $result['speed'] = intval($speed); |
292 | 291 | } |
293 | - $body_parse = substr($body_parse,7); |
|
292 | + $body_parse = substr($body_parse, 7); |
|
294 | 293 | } |
295 | 294 | // Check PHGR, PHG, RNG |
296 | 295 | } |
@@ -300,12 +299,12 @@ discard block |
||
300 | 299 | } |
301 | 300 | */ |
302 | 301 | if (strlen($body_parse) > 0) { |
303 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
302 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) { |
|
304 | 303 | $altitude = intval($matches[1]); |
305 | 304 | //$result['altitude'] = round($altitude*0.3048); |
306 | 305 | $result['altitude'] = $altitude; |
307 | 306 | //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
308 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
307 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse)); |
|
309 | 308 | } |
310 | 309 | } |
311 | 310 | |
@@ -316,56 +315,56 @@ discard block |
||
316 | 315 | } |
317 | 316 | */ |
318 | 317 | // DAO |
319 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
318 | + if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) { |
|
320 | 319 | $dao = $matches[1]; |
321 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
320 | + if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) { |
|
322 | 321 | $dao_split = str_split($dao); |
323 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
324 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
322 | + $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0; |
|
323 | + $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0; |
|
325 | 324 | |
326 | 325 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
327 | 326 | else $result['latitude'] += $lat_off; |
328 | 327 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
329 | 328 | else $result['longitude'] += $lon_off; |
330 | 329 | } |
331 | - $body_parse = substr($body_parse,6); |
|
330 | + $body_parse = substr($body_parse, 6); |
|
332 | 331 | } |
333 | 332 | |
334 | - if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
333 | + if (preg_match('/CS=([0-9A-Z]*)/', $body_parse, $matches)) { |
|
335 | 334 | $result['ident'] = $matches[1]; |
336 | 335 | } |
337 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
336 | + if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) { |
|
338 | 337 | $result['squawk'] = $matches[1]; |
339 | 338 | } |
340 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
339 | + if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) { |
|
341 | 340 | $result['aircraft_icao'] = $matches[1]; |
342 | 341 | } |
343 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
342 | + if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) { |
|
344 | 343 | $result['typeid'] = $matches[1]; |
345 | 344 | } |
346 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
345 | + if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) { |
|
347 | 346 | $result['imo'] = $matches[1]; |
348 | 347 | } |
349 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
348 | + if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) { |
|
350 | 349 | $result['arrival_date'] = $matches[1]; |
351 | 350 | } |
352 | - if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
351 | + if (preg_match('/AC=([0-9A-Z]*)/', $body_parse, $matches)) { |
|
353 | 352 | $result['arrival_code'] = $matches[1]; |
354 | 353 | } |
355 | 354 | // OGN comment |
356 | 355 | // echo "Before OGN : ".$body_parse."\n"; |
357 | 356 | //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
358 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
357 | + if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) { |
|
359 | 358 | $id = $matches[1]; |
360 | 359 | //$mode = substr($id,0,2); |
361 | - $address = substr($id,2); |
|
360 | + $address = substr($id, 2); |
|
362 | 361 | //print_r($matches); |
363 | - $addressType = (intval(substr($id,0,2),16))&3; |
|
362 | + $addressType = (intval(substr($id, 0, 2), 16))&3; |
|
364 | 363 | if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
365 | 364 | elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
366 | 365 | elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
367 | 366 | elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
368 | - $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
|
367 | + $aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2); |
|
369 | 368 | $result['aircrafttype_code'] = $aircraftType; |
370 | 369 | if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
371 | 370 | elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
@@ -382,7 +381,7 @@ discard block |
||
382 | 381 | elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
383 | 382 | elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
384 | 383 | elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
385 | - $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
|
384 | + $stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0; |
|
386 | 385 | $result['stealth'] = $stealth; |
387 | 386 | $result['address'] = $address; |
388 | 387 | } |
@@ -394,72 +393,72 @@ discard block |
||
394 | 393 | //$body_parse = substr($body_parse,1); |
395 | 394 | //$body_parse_len = strlen($body_parse); |
396 | 395 | |
397 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
396 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
398 | 397 | $result['wind_dir'] = intval($matches[1]); |
399 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
400 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
401 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
402 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
403 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
398 | + $result['wind_speed'] = round(intval($matches[2])*1.60934, 1); |
|
399 | + $result['wind_gust'] = round(intval($matches[3])*1.60934, 1); |
|
400 | + $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1); |
|
401 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
402 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
404 | 403 | $result['wind_dir'] = intval($matches[1]); |
405 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
406 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
407 | - $result['temp'] = round(5/9*(($matches[4])-32),1); |
|
408 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
409 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
404 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
405 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
406 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); |
|
407 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
408 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { |
|
410 | 409 | $result['wind_dir'] = intval($matches[1]); |
411 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
412 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
413 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
414 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
410 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
411 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
412 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
413 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) { |
|
415 | 414 | $result['wind_dir'] = intval($matches[1]); |
416 | - $result['wind_speed'] = round($matches[2]*1.60934,1); |
|
417 | - $result['wind_gust'] = round($matches[3]*1.60934,1); |
|
418 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
415 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); |
|
416 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); |
|
417 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); |
|
419 | 418 | } |
420 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
421 | - $result['temp'] = round(5/9*(($matches[1])-32),1); |
|
419 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) { |
|
420 | + $result['temp'] = round(5/9*(($matches[1]) - 32), 1); |
|
422 | 421 | } |
423 | 422 | } |
424 | 423 | } else $result['comment'] = trim($body_parse); |
425 | 424 | |
426 | 425 | } |
427 | 426 | //} |
428 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
429 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
427 | + if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4); |
|
428 | + if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4); |
|
430 | 429 | if ($debug) print_r($result); |
431 | 430 | return $result; |
432 | 431 | } |
433 | 432 | |
434 | 433 | function connect() { |
435 | - global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
434 | + global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport; |
|
436 | 435 | $aprs_connect = 0; |
437 | 436 | $aprs_keep = 120; |
438 | 437 | $aprs_last_tx = time(); |
439 | 438 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
440 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
439 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
441 | 440 | if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; |
442 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
441 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
443 | 442 | if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; |
444 | 443 | else $aprs_pass = '-1'; |
445 | 444 | |
446 | - $aprs_filter = ''; |
|
445 | + $aprs_filter = ''; |
|
447 | 446 | $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; |
448 | 447 | $Common = new Common(); |
449 | - $s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr); |
|
448 | + $s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr); |
|
450 | 449 | if ($s !== false) { |
451 | 450 | echo 'Connected to APRS server! '."\n"; |
452 | 451 | $authstart = time(); |
453 | 452 | $this->socket = $s; |
454 | - $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
|
455 | - while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
|
453 | + $send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0); |
|
454 | + while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) { |
|
456 | 455 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
457 | 456 | echo 'APRS user verified !'."\n"; |
458 | 457 | $this->connected = true; |
459 | 458 | return true; |
460 | 459 | break; |
461 | 460 | } |
462 | - if (time()-$authstart > 5) { |
|
461 | + if (time() - $authstart > 5) { |
|
463 | 462 | echo 'APRS timeout'."\n"; |
464 | 463 | break; |
465 | 464 | } |
@@ -469,20 +468,20 @@ discard block |
||
469 | 468 | |
470 | 469 | function send($data) { |
471 | 470 | if ($this->connected === false) $this->connect(); |
472 | - $send = socket_send( $this->socket , $data , strlen($data),0); |
|
471 | + $send = socket_send($this->socket, $data, strlen($data), 0); |
|
473 | 472 | if ($send === FALSE) $this->connect(); |
474 | 473 | } |
475 | 474 | } |
476 | 475 | |
477 | 476 | class APRSSpotter extends APRS { |
478 | - function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) { |
|
477 | + function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) { |
|
479 | 478 | $Common = new Common(); |
480 | 479 | if ($latitude != '' && $longitude != '') { |
481 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
482 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
483 | - $coordinate = str_pad($latitude['deg'].number_format($latitude['min'],2,'.',''),7,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'],2,'.',''),8,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
484 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
485 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
480 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
481 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
482 | + $coordinate = str_pad($latitude['deg'].number_format($latitude['min'], 2, '.', ''), 7, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'], 2, '.', ''), 8, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
483 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
484 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
486 | 485 | $w = $w1.$w2; |
487 | 486 | //$w = '00'; |
488 | 487 | $custom = ''; |
@@ -499,19 +498,19 @@ discard block |
||
499 | 498 | $custom .= 'AI='.$aircraft_icao; |
500 | 499 | } |
501 | 500 | if ($custom != '') $custom = ' '.$custom; |
502 | - $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
501 | + $this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.' *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
503 | 502 | } |
504 | 503 | } |
505 | 504 | } |
506 | 505 | class APRSMarine extends APRS { |
507 | - function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source,$source_name,$over_country) { |
|
506 | + function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country) { |
|
508 | 507 | $Common = new Common(); |
509 | 508 | if ($latitude != '' && $longitude != '') { |
510 | - $latitude = $Common->convertDM($latitude,'latitude'); |
|
511 | - $longitude = $Common->convertDM($longitude,'longitude'); |
|
512 | - $coordinate = str_pad($latitude['deg'].number_format($latitude['min'],2,'.',''),7,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'],2,'.',''),8,'0',STR_PAD_LEFT).$longitude['NSEW']; |
|
513 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); |
|
514 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); |
|
509 | + $latitude = $Common->convertDM($latitude, 'latitude'); |
|
510 | + $longitude = $Common->convertDM($longitude, 'longitude'); |
|
511 | + $coordinate = str_pad($latitude['deg'].number_format($latitude['min'], 2, '.', ''), 7, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.str_pad($longitude['deg'].number_format($longitude['min'], 2, '.', ''), 8, '0', STR_PAD_LEFT).$longitude['NSEW']; |
|
512 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); |
|
513 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); |
|
515 | 514 | $w = $w1.$w2; |
516 | 515 | //$w = '00'; |
517 | 516 | $custom = ''; |
@@ -537,7 +536,7 @@ discard block |
||
537 | 536 | } |
538 | 537 | if ($custom != '') $custom = ' '.$custom; |
539 | 538 | $altitude = 0; |
540 | - $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
539 | + $this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); |
|
541 | 540 | } |
542 | 541 | } |
543 | 542 | } |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | die; |
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
48 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::')); |
|
52 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::')); |
|
53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 55 | if (isset($options['s'])) { |
@@ -67,27 +67,27 @@ discard block |
||
67 | 67 | else $id_source = 1; |
68 | 68 | if (isset($globalServer) && $globalServer) { |
69 | 69 | if ($globalDebug) echo "Using Server Mode\n"; |
70 | - $SI=new SpotterServer(); |
|
70 | + $SI = new SpotterServer(); |
|
71 | 71 | /* |
72 | 72 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
73 | 73 | $SI = new adsb2aprs(); |
74 | 74 | $SI->connect(); |
75 | 75 | */ |
76 | -} else $SI=new SpotterImport($Connection->db); |
|
76 | +} else $SI = new SpotterImport($Connection->db); |
|
77 | 77 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
78 | 78 | if (isset($globalMarine) && $globalMarine) { |
79 | 79 | $AIS = new AIS(); |
80 | 80 | $MI = new MarineImport($Connection->db); |
81 | 81 | } |
82 | 82 | //$APRS=new APRS($Connection->db); |
83 | -$SBS=new SBS(); |
|
84 | -$ACARS=new ACARS($Connection->db); |
|
85 | -$Common=new Common(); |
|
83 | +$SBS = new SBS(); |
|
84 | +$ACARS = new ACARS($Connection->db); |
|
85 | +$Common = new Common(); |
|
86 | 86 | date_default_timezone_set('UTC'); |
87 | 87 | //$servertz = system('date +%Z'); |
88 | 88 | // signal handler - playing nice with sockets and dump1090 |
89 | 89 | if (function_exists('pcntl_fork')) { |
90 | - pcntl_signal(SIGINT, function() { |
|
90 | + pcntl_signal(SIGINT, function() { |
|
91 | 91 | global $sockets; |
92 | 92 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
93 | 93 | die("Bye!\n"); |
@@ -103,35 +103,35 @@ discard block |
||
103 | 103 | |
104 | 104 | function connect_all($hosts) { |
105 | 105 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
106 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
106 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
107 | 107 | $reset++; |
108 | 108 | if ($globalDebug) echo 'Connect to all...'."\n"; |
109 | 109 | foreach ($hosts as $id => $value) { |
110 | 110 | $host = $value['host']; |
111 | 111 | $globalSources[$id]['last_exec'] = 0; |
112 | 112 | // Here we check type of source(s) |
113 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
114 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
113 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
114 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
115 | 115 | //$formats[$id] = 'deltadbtxt'; |
116 | 116 | $globalSources[$id]['format'] = 'deltadbtxt'; |
117 | 117 | //$last_exec['deltadbtxt'] = 0; |
118 | 118 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
119 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
119 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
120 | 120 | //$formats[$id] = 'vatsimtxt'; |
121 | 121 | $globalSources[$id]['format'] = 'vatsimtxt'; |
122 | 122 | //$last_exec['vatsimtxt'] = 0; |
123 | 123 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
124 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
124 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
125 | 125 | //$formats[$id] = 'aircraftlistjson'; |
126 | 126 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
127 | 127 | //$last_exec['aircraftlistjson'] = 0; |
128 | 128 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
129 | - } else if (preg_match('/opensky/i',$host)) { |
|
129 | + } else if (preg_match('/opensky/i', $host)) { |
|
130 | 130 | //$formats[$id] = 'aircraftlistjson'; |
131 | 131 | $globalSources[$id]['format'] = 'opensky'; |
132 | 132 | //$last_exec['aircraftlistjson'] = 0; |
133 | 133 | if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
134 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
134 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
135 | 135 | //$formats[$id] = 'radarvirtueljson'; |
136 | 136 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
137 | 137 | //$last_exec['radarvirtueljson'] = 0; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
141 | 141 | exit(0); |
142 | 142 | } |
143 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
143 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
144 | 144 | //$formats[$id] = 'planeupdatefaa'; |
145 | 145 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
146 | 146 | //$last_exec['planeupdatefaa'] = 0; |
@@ -149,26 +149,26 @@ discard block |
||
149 | 149 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
150 | 150 | exit(0); |
151 | 151 | } |
152 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
152 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
153 | 153 | //$formats[$id] = 'phpvmacars'; |
154 | 154 | $globalSources[$id]['format'] = 'phpvmacars'; |
155 | 155 | //$last_exec['phpvmacars'] = 0; |
156 | 156 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
157 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
157 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
158 | 158 | //$formats[$id] = 'phpvmacars'; |
159 | 159 | $globalSources[$id]['format'] = 'vam'; |
160 | 160 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
161 | - } else if (preg_match('/whazzup/i',$host)) { |
|
161 | + } else if (preg_match('/whazzup/i', $host)) { |
|
162 | 162 | //$formats[$id] = 'whazzup'; |
163 | 163 | $globalSources[$id]['format'] = 'whazzup'; |
164 | 164 | //$last_exec['whazzup'] = 0; |
165 | 165 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
166 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
166 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
167 | 167 | //$formats[$id] = 'pirepsjson'; |
168 | 168 | $globalSources[$id]['format'] = 'pirepsjson'; |
169 | 169 | //$last_exec['pirepsjson'] = 0; |
170 | 170 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
171 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
171 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
172 | 172 | //$formats[$id] = 'fr24json'; |
173 | 173 | $globalSources[$id]['format'] = 'fr24json'; |
174 | 174 | //$last_exec['fr24json'] = 0; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
178 | 178 | exit(0); |
179 | 179 | } |
180 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
180 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
181 | 181 | //$formats[$id] = 'fr24json'; |
182 | 182 | $globalSources[$id]['format'] = 'myshiptracking'; |
183 | 183 | //$last_exec['fr24json'] = 0; |
@@ -187,22 +187,22 @@ discard block |
||
187 | 187 | exit(0); |
188 | 188 | } |
189 | 189 | //} else if (preg_match('/10001/',$host)) { |
190 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
190 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
191 | 191 | //$formats[$id] = 'tsv'; |
192 | 192 | $globalSources[$id]['format'] = 'tsv'; |
193 | 193 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
194 | 194 | } |
195 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
195 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
196 | 196 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
197 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
197 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
198 | 198 | if ($idf !== false) { |
199 | 199 | $httpfeeds[$id] = $idf; |
200 | 200 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
201 | 201 | } |
202 | 202 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
203 | 203 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
204 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
205 | - $hostport = explode(':',$host); |
|
204 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
205 | + $hostport = explode(':', $host); |
|
206 | 206 | if (isset($hostport[1])) { |
207 | 207 | $port = $hostport[1]; |
208 | 208 | $hostn = $hostport[0]; |
@@ -212,19 +212,19 @@ discard block |
||
212 | 212 | } |
213 | 213 | $Common = new Common(); |
214 | 214 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
215 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
215 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
216 | 216 | } else { |
217 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
217 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
218 | 218 | } |
219 | 219 | if ($s) { |
220 | 220 | $sockets[$id] = $s; |
221 | 221 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
222 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
222 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
223 | 223 | //$formats[$id] = 'aprs'; |
224 | 224 | $globalSources[$id]['format'] = 'aprs'; |
225 | 225 | //$aprs_connect = 0; |
226 | 226 | //$use_aprs = true; |
227 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
227 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
228 | 228 | $globalSources[$id]['format'] = 'vrstcp'; |
229 | 229 | } elseif ($port == '10001') { |
230 | 230 | //$formats[$id] = 'tsv'; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
264 | 264 | else $timeout = 20; |
265 | 265 | $errno = ''; |
266 | -$errstr=''; |
|
266 | +$errstr = ''; |
|
267 | 267 | |
268 | 268 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
269 | 269 | /* Initiate connections to all the hosts simultaneously */ |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | //connect_all($globalSources); |
272 | 272 | |
273 | 273 | if (isset($globalProxy) && $globalProxy) { |
274 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
274 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
275 | 275 | } else { |
276 | 276 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
277 | 277 | } |
@@ -298,16 +298,16 @@ discard block |
||
298 | 298 | |
299 | 299 | if ($use_aprs) { |
300 | 300 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
301 | - $APRS=new APRS(); |
|
301 | + $APRS = new APRS(); |
|
302 | 302 | $aprs_connect = 0; |
303 | 303 | $aprs_keep = 120; |
304 | 304 | $aprs_last_tx = time(); |
305 | 305 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
306 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
306 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
307 | 307 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
308 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
308 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
309 | 309 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
310 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
310 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
311 | 311 | if ($aprs_full) $aprs_filter = ''; |
312 | 312 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
313 | 313 | else $aprs_pass = '-1'; |
@@ -322,12 +322,12 @@ discard block |
||
322 | 322 | sleep(1); |
323 | 323 | if ($globalDebug) echo "SCAN MODE \n\n"; |
324 | 324 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
325 | -$endtime = time()+$globalCronEnd; |
|
325 | +$endtime = time() + $globalCronEnd; |
|
326 | 326 | $i = 1; |
327 | 327 | $tt = array(); |
328 | 328 | // Delete all ATC |
329 | 329 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
330 | - $ATC=new ATC($Connection->db); |
|
330 | + $ATC = new ATC($Connection->db); |
|
331 | 331 | } |
332 | 332 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
333 | 333 | $ATC->deleteAll(); |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | |
336 | 336 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
337 | 337 | while ($i > 0) { |
338 | - if (!$globalDaemon) $i = $endtime-time(); |
|
338 | + if (!$globalDaemon) $i = $endtime - time(); |
|
339 | 339 | // Delete old ATC |
340 | 340 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
341 | 341 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | } |
351 | 351 | if ($max != $globalMinFetch) { |
352 | 352 | if ($globalDebug) echo 'Sleeping...'."\n"; |
353 | - sleep($globalMinFetch-$max+2); |
|
353 | + sleep($globalMinFetch - $max + 2); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | //$buffer = $Common->getData($hosts[$id]); |
364 | 364 | $buffer = $Common->getData($value['host']); |
365 | 365 | if ($buffer != '') $reset = 0; |
366 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
367 | - $buffer = explode('\n',$buffer); |
|
366 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
367 | + $buffer = explode('\n', $buffer); |
|
368 | 368 | foreach ($buffer as $line) { |
369 | 369 | if ($line != '' && count($line) > 7) { |
370 | 370 | $line = explode(',', $line); |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | $last_exec[$id]['last'] = time(); |
392 | 392 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
393 | 393 | date_default_timezone_set('CET'); |
394 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
394 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
395 | 395 | date_default_timezone_set('UTC'); |
396 | 396 | if ($buffer != '') $reset = 0; |
397 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
398 | - $buffer = explode('\n',$buffer); |
|
397 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
398 | + $buffer = explode('\n', $buffer); |
|
399 | 399 | foreach ($buffer as $line) { |
400 | 400 | if ($line != '') { |
401 | 401 | echo "'".$line."'\n"; |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
414 | 414 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
415 | 415 | if (isset($ais_data['timestamp'])) { |
416 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
416 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
417 | 417 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
418 | 418 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
419 | 419 | $add = true; |
@@ -436,12 +436,12 @@ discard block |
||
436 | 436 | $w = $e = null; |
437 | 437 | |
438 | 438 | if (isset($arr[$id])) { |
439 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
439 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
440 | 440 | if ($nn > 0) { |
441 | 441 | foreach ($httpfeeds as $feed) { |
442 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
443 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
444 | - $buffer = explode('\n',$buffer); |
|
442 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
443 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
444 | + $buffer = explode('\n', $buffer); |
|
445 | 445 | foreach ($buffer as $line) { |
446 | 446 | if ($line != '') { |
447 | 447 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -457,9 +457,9 @@ discard block |
||
457 | 457 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
458 | 458 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
459 | 459 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
460 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
460 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
461 | 461 | if (isset($ais_data['timestamp'])) { |
462 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
462 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
463 | 463 | } else { |
464 | 464 | $data['datetime'] = date('Y-m-d H:i:s'); |
465 | 465 | } |
@@ -473,10 +473,10 @@ discard block |
||
473 | 473 | } |
474 | 474 | } |
475 | 475 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
476 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
476 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
477 | 477 | if ($buffer != '') { |
478 | 478 | //echo $buffer; |
479 | - $all_data = json_decode($buffer,true); |
|
479 | + $all_data = json_decode($buffer, true); |
|
480 | 480 | //print_r($all_data); |
481 | 481 | if (isset($all_data[0]['DATA'])) { |
482 | 482 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
492 | 492 | $data['imo'] = $line['IMO']; |
493 | 493 | //$data['arrival_code'] = $ais_data['destination']; |
494 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
494 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
495 | 495 | $data['format_source'] = 'myshiptracking'; |
496 | 496 | $data['id_source'] = $id_source; |
497 | 497 | $MI->add($data); |
@@ -503,9 +503,9 @@ discard block |
||
503 | 503 | } |
504 | 504 | $last_exec[$id]['last'] = time(); |
505 | 505 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
506 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
506 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
507 | 507 | if ($buffer != '') { |
508 | - $all_data = json_decode($buffer,true); |
|
508 | + $all_data = json_decode($buffer, true); |
|
509 | 509 | if (isset($all_data[0]['mmsi'])) { |
510 | 510 | foreach ($all_data as $line) { |
511 | 511 | if ($line != '') { |
@@ -532,27 +532,27 @@ discard block |
||
532 | 532 | $last_exec[$id]['last'] = time(); |
533 | 533 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
534 | 534 | echo 'download...'; |
535 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
535 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
536 | 536 | echo 'done !'."\n"; |
537 | 537 | if ($buffer != '') $reset = 0; |
538 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
539 | - $buffer = explode('\n',$buffer); |
|
538 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
539 | + $buffer = explode('\n', $buffer); |
|
540 | 540 | foreach ($buffer as $line) { |
541 | 541 | if ($line != '') { |
542 | 542 | $data = array(); |
543 | - $data['mmsi'] = (int)substr($line,0,9); |
|
544 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
543 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
544 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
545 | 545 | //$data['status'] = substr($line,21,2); |
546 | 546 | //$data['type'] = substr($line,24,3); |
547 | - $data['latitude'] = substr($line,29,9); |
|
548 | - $data['longitude'] = substr($line,41,9); |
|
549 | - $data['speed'] = round(substr($line,51,5)); |
|
547 | + $data['latitude'] = substr($line, 29, 9); |
|
548 | + $data['longitude'] = substr($line, 41, 9); |
|
549 | + $data['speed'] = round(substr($line, 51, 5)); |
|
550 | 550 | //$data['course'] = substr($line,57,5); |
551 | - $data['heading'] = round(substr($line,63,3)); |
|
551 | + $data['heading'] = round(substr($line, 63, 3)); |
|
552 | 552 | //$data['draft'] = substr($line,67,4); |
553 | 553 | //$data['length'] = substr($line,72,3); |
554 | 554 | //$data['beam'] = substr($line,76,2); |
555 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
555 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
556 | 556 | //$data['callsign'] = trim(substr($line,100,7); |
557 | 557 | //$data['dest'] = substr($line,108,20); |
558 | 558 | //$data['etaDate'] = substr($line,129,5); |
@@ -570,8 +570,8 @@ discard block |
||
570 | 570 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
571 | 571 | //$buffer = $Common->getData($hosts[$id]); |
572 | 572 | $buffer = $Common->getData($value['host']); |
573 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
574 | - $buffer = explode('\n',$buffer); |
|
573 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
574 | + $buffer = explode('\n', $buffer); |
|
575 | 575 | $reset = 0; |
576 | 576 | foreach ($buffer as $line) { |
577 | 577 | if ($line != '') { |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
583 | 583 | $data['pilot_id'] = $line[1]; |
584 | 584 | $data['pilot_name'] = $line[2]; |
585 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
585 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
586 | 586 | $data['ident'] = $line[0]; // ident |
587 | 587 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
588 | 588 | $data['speed'] = $line[8]; // speed |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
599 | 599 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
600 | 600 | $data['departure_airport_icao'] = $line[11]; |
601 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
601 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
602 | 602 | $data['arrival_airport_icao'] = $line[13]; |
603 | 603 | $data['frequency'] = $line[4]; |
604 | 604 | $data['type'] = $line[18]; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | $data['id_source'] = $id_source; |
608 | 608 | //$data['arrival_airport_time'] = ; |
609 | 609 | if ($line[9] != '') { |
610 | - $aircraft_data = explode('/',$line[9]); |
|
610 | + $aircraft_data = explode('/', $line[9]); |
|
611 | 611 | if (isset($aircraft_data[1])) { |
612 | 612 | $data['aircraft_icao'] = $aircraft_data[1]; |
613 | 613 | } |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | if ($line[3] == 'PILOT') $SI->add($data); |
622 | 622 | elseif ($line[3] == 'ATC') { |
623 | 623 | //print_r($data); |
624 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
625 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
626 | - $typec = substr($data['ident'],-3); |
|
624 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
625 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
626 | + $typec = substr($data['ident'], -3); |
|
627 | 627 | if ($typec == 'APP') $data['type'] = 'Approach'; |
628 | 628 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
629 | 629 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
635 | 635 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
636 | 636 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
637 | - if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
637 | + if (isset($ATC)) echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
638 | 638 | } |
639 | 639 | unset($data); |
640 | 640 | } |
@@ -645,9 +645,9 @@ discard block |
||
645 | 645 | $last_exec[$id]['last'] = time(); |
646 | 646 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
647 | 647 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
648 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
648 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
649 | 649 | if ($buffer != '') { |
650 | - $all_data = json_decode($buffer,true); |
|
650 | + $all_data = json_decode($buffer, true); |
|
651 | 651 | if (isset($all_data['acList'])) { |
652 | 652 | $reset = 0; |
653 | 653 | foreach ($all_data['acList'] as $line) { |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
704 | 704 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
705 | 705 | $buffer = $Common->getData($value['host']); |
706 | - $all_data = json_decode($buffer,true); |
|
706 | + $all_data = json_decode($buffer, true); |
|
707 | 707 | if (isset($all_data['planes'])) { |
708 | 708 | $reset = 0; |
709 | 709 | foreach ($all_data['planes'] as $key => $line) { |
@@ -720,12 +720,12 @@ discard block |
||
720 | 720 | $data['emergency'] = ''; // emergency |
721 | 721 | $data['registration'] = $line[2]; |
722 | 722 | $data['aircraft_icao'] = $line[0]; |
723 | - $deparr = explode('-',$line[1]); |
|
723 | + $deparr = explode('-', $line[1]); |
|
724 | 724 | if (count($deparr) == 2) { |
725 | 725 | $data['departure_airport_icao'] = $deparr[0]; |
726 | 726 | $data['arrival_airport_icao'] = $deparr[1]; |
727 | 727 | } |
728 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
728 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
729 | 729 | $data['format_source'] = 'planeupdatefaa'; |
730 | 730 | $data['id_source'] = $id_source; |
731 | 731 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | $last_exec[$id]['last'] = time(); |
738 | 738 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
739 | 739 | $buffer = $Common->getData($value['host']); |
740 | - $all_data = json_decode($buffer,true); |
|
740 | + $all_data = json_decode($buffer, true); |
|
741 | 741 | if (isset($all_data['states'])) { |
742 | 742 | $reset = 0; |
743 | 743 | foreach ($all_data['states'] as $key => $line) { |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | //$data['emergency'] = ''; // emergency |
755 | 755 | //$data['registration'] = $line[2]; |
756 | 756 | //$data['aircraft_icao'] = $line[0]; |
757 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
757 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
758 | 758 | $data['format_source'] = 'opensky'; |
759 | 759 | $data['id_source'] = $id_source; |
760 | 760 | $SI->add($data); |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
768 | 768 | //$buffer = $Common->getData($hosts[$id]); |
769 | 769 | $buffer = $Common->getData($value['host']); |
770 | - $all_data = json_decode($buffer,true); |
|
770 | + $all_data = json_decode($buffer, true); |
|
771 | 771 | if (!empty($all_data)) $reset = 0; |
772 | 772 | foreach ($all_data as $key => $line) { |
773 | 773 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -799,11 +799,11 @@ discard block |
||
799 | 799 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
800 | 800 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
801 | 801 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
802 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
802 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
803 | 803 | //echo $buffer; |
804 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
805 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
806 | - $all_data = json_decode($buffer,true); |
|
804 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
805 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
806 | + $all_data = json_decode($buffer, true); |
|
807 | 807 | if (json_last_error() != JSON_ERROR_NONE) { |
808 | 808 | die(json_last_error_msg()); |
809 | 809 | } |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | //$data['departure_airport_iata'] = $line[11]; |
827 | 827 | //$data['arrival_airport_iata'] = $line[12]; |
828 | 828 | //$data['emergency'] = ''; // emergency |
829 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
829 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
830 | 830 | $data['format_source'] = 'radarvirtueljson'; |
831 | 831 | $data['id_source'] = $id_source; |
832 | 832 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -841,14 +841,14 @@ discard block |
||
841 | 841 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
842 | 842 | //$buffer = $Common->getData($hosts[$id]); |
843 | 843 | $buffer = $Common->getData($value['host'].'?'.time()); |
844 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
844 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
845 | 845 | |
846 | 846 | if (isset($all_data['pireps'])) { |
847 | 847 | $reset = 0; |
848 | 848 | foreach ($all_data['pireps'] as $line) { |
849 | 849 | $data = array(); |
850 | 850 | $data['id'] = $line['id']; |
851 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
851 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
852 | 852 | $data['ident'] = $line['callsign']; // ident |
853 | 853 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
854 | 854 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -877,9 +877,9 @@ discard block |
||
877 | 877 | $SI->add($data); |
878 | 878 | // print_r($data); |
879 | 879 | } elseif ($line['icon'] == 'ct') { |
880 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
881 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
882 | - $typec = substr($data['ident'],-3); |
|
880 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
881 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
882 | + $typec = substr($data['ident'], -3); |
|
883 | 883 | $data['type'] = ''; |
884 | 884 | if ($typec == 'APP') $data['type'] = 'Approach'; |
885 | 885 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
891 | 891 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
892 | 892 | else $data['type'] = 'Observer'; |
893 | - 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']); |
|
893 | + 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']); |
|
894 | 894 | } |
895 | 895 | unset($data); |
896 | 896 | } |
@@ -902,14 +902,14 @@ discard block |
||
902 | 902 | //$buffer = $Common->getData($hosts[$id]); |
903 | 903 | if ($globalDebug) echo 'Get Data...'."\n"; |
904 | 904 | $buffer = $Common->getData($value['host']); |
905 | - $all_data = json_decode($buffer,true); |
|
905 | + $all_data = json_decode($buffer, true); |
|
906 | 906 | if ($buffer != '' && is_array($all_data)) { |
907 | 907 | $reset = 0; |
908 | 908 | foreach ($all_data as $line) { |
909 | 909 | $data = array(); |
910 | 910 | //$data['id'] = $line['id']; // id not usable |
911 | 911 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
912 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
912 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
913 | 913 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
914 | 914 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
915 | 915 | $data['ident'] = $line['flightnum']; // ident |
@@ -932,12 +932,12 @@ discard block |
||
932 | 932 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
933 | 933 | if (isset($line['aircraftname'])) { |
934 | 934 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
935 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
936 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
935 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
936 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
937 | 937 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
938 | 938 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
939 | 939 | else { |
940 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
940 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
941 | 941 | if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
942 | 942 | else $data['aircraft_icao'] = $line['aircraftname']; |
943 | 943 | } |
@@ -959,14 +959,14 @@ discard block |
||
959 | 959 | //$buffer = $Common->getData($hosts[$id]); |
960 | 960 | if ($globalDebug) echo 'Get Data...'."\n"; |
961 | 961 | $buffer = $Common->getData($value['host']); |
962 | - $all_data = json_decode($buffer,true); |
|
962 | + $all_data = json_decode($buffer, true); |
|
963 | 963 | if ($buffer != '' && is_array($all_data)) { |
964 | 964 | $reset = 0; |
965 | 965 | foreach ($all_data as $line) { |
966 | 966 | $data = array(); |
967 | 967 | //$data['id'] = $line['id']; // id not usable |
968 | 968 | $data['id'] = trim($line['flight_id']); |
969 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
969 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
970 | 970 | $data['pilot_name'] = $line['pilot_name']; |
971 | 971 | $data['pilot_id'] = $line['pilot_id']; |
972 | 972 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1017,9 +1017,9 @@ discard block |
||
1017 | 1017 | //$value = $formats[$nb]; |
1018 | 1018 | $format = $globalSources[$nb]['format']; |
1019 | 1019 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') { |
1020 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
1020 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
1021 | 1021 | } else { |
1022 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1022 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1023 | 1023 | } |
1024 | 1024 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1025 | 1025 | //echo $buffer."\n"; |
@@ -1028,8 +1028,8 @@ discard block |
||
1028 | 1028 | $error = false; |
1029 | 1029 | //$SI::del(); |
1030 | 1030 | if ($format == 'vrstcp') { |
1031 | - $buffer = explode('},{',$buffer); |
|
1032 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1031 | + $buffer = explode('},{', $buffer); |
|
1032 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1033 | 1033 | // SBS format is CSV format |
1034 | 1034 | if ($buffer != '') { |
1035 | 1035 | $tt[$format] = 0; |
@@ -1061,10 +1061,10 @@ discard block |
||
1061 | 1061 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1062 | 1062 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1063 | 1063 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1064 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1064 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1065 | 1065 | |
1066 | 1066 | if (isset($ais_data['timestamp'])) { |
1067 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1067 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1068 | 1068 | } else { |
1069 | 1069 | $data['datetime'] = date('Y-m-d H:i:s'); |
1070 | 1070 | } |
@@ -1075,10 +1075,10 @@ discard block |
||
1075 | 1075 | } elseif ($format == 'flightgearsp') { |
1076 | 1076 | //echo $buffer."\n"; |
1077 | 1077 | if (strlen($buffer) > 5) { |
1078 | - $line = explode(',',$buffer); |
|
1078 | + $line = explode(',', $buffer); |
|
1079 | 1079 | $data = array(); |
1080 | 1080 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1081 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1081 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1082 | 1082 | $data['ident'] = $line[6]; |
1083 | 1083 | $data['aircraft_name'] = $line[7]; |
1084 | 1084 | $data['longitude'] = $line[1]; |
@@ -1089,21 +1089,21 @@ discard block |
||
1089 | 1089 | $data['datetime'] = date('Y-m-d H:i:s'); |
1090 | 1090 | $data['format_source'] = 'flightgearsp'; |
1091 | 1091 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1092 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1092 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1093 | 1093 | } |
1094 | 1094 | } elseif ($format == 'acars') { |
1095 | 1095 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1096 | 1096 | $ACARS->add(trim($buffer)); |
1097 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1097 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1098 | 1098 | $ACARS->deleteLiveAcarsData(); |
1099 | 1099 | } elseif ($format == 'flightgearmp') { |
1100 | - if (substr($buffer,0,1) != '#') { |
|
1100 | + if (substr($buffer, 0, 1) != '#') { |
|
1101 | 1101 | $data = array(); |
1102 | 1102 | //echo $buffer."\n"; |
1103 | - $line = explode(' ',$buffer); |
|
1103 | + $line = explode(' ', $buffer); |
|
1104 | 1104 | if (count($line) == 11) { |
1105 | - $userserver = explode('@',$line[0]); |
|
1106 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1105 | + $userserver = explode('@', $line[0]); |
|
1106 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1107 | 1107 | $data['ident'] = $userserver[0]; |
1108 | 1108 | $data['registration'] = $userserver[0]; |
1109 | 1109 | $data['latitude'] = $line[4]; |
@@ -1111,8 +1111,8 @@ discard block |
||
1111 | 1111 | $data['altitude'] = $line[6]; |
1112 | 1112 | $data['datetime'] = date('Y-m-d H:i:s'); |
1113 | 1113 | $aircraft_type = $line[10]; |
1114 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1115 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1114 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1115 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1116 | 1116 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1117 | 1117 | } |
1118 | 1118 | } |
@@ -1120,8 +1120,8 @@ discard block |
||
1120 | 1120 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1121 | 1121 | die; |
1122 | 1122 | } elseif ($format == 'vrstcp') { |
1123 | - foreach($buffer as $all_data) { |
|
1124 | - $line = json_decode('{'.$all_data.'}',true); |
|
1123 | + foreach ($buffer as $all_data) { |
|
1124 | + $line = json_decode('{'.$all_data.'}', true); |
|
1125 | 1125 | $data = array(); |
1126 | 1126 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1127 | 1127 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1146,16 +1146,16 @@ discard block |
||
1146 | 1146 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1147 | 1147 | unset($data); |
1148 | 1148 | } |
1149 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1149 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1150 | 1150 | $line = explode("\t", $buffer); |
1151 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1151 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1152 | 1152 | $key = $line[$k]; |
1153 | - $lined[$key] = $line[$k+1]; |
|
1153 | + $lined[$key] = $line[$k + 1]; |
|
1154 | 1154 | } |
1155 | 1155 | if (count($lined) > 3) { |
1156 | 1156 | $data['hex'] = $lined['hexid']; |
1157 | 1157 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1158 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1158 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1159 | 1159 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1160 | 1160 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1161 | 1161 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1173,22 +1173,22 @@ discard block |
||
1173 | 1173 | } else $error = true; |
1174 | 1174 | } elseif ($format == 'aprs' && $use_aprs) { |
1175 | 1175 | if ($aprs_connect == 0) { |
1176 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1176 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1177 | 1177 | $aprs_connect = 1; |
1178 | 1178 | } |
1179 | 1179 | |
1180 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1180 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1181 | 1181 | $aprs_last_tx = time(); |
1182 | 1182 | $data_aprs = "# Keep alive"; |
1183 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1183 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1187 | 1187 | //echo 'APRS data : '.$buffer."\n"; |
1188 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1189 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1188 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1189 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1190 | 1190 | //echo $buffer."\n"; |
1191 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1191 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1192 | 1192 | $line = $APRS->parse($buffer); |
1193 | 1193 | //print_r($line); |
1194 | 1194 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
@@ -1197,7 +1197,7 @@ discard block |
||
1197 | 1197 | $data = array(); |
1198 | 1198 | //print_r($line); |
1199 | 1199 | if (isset($line['address'])) $data['hex'] = $line['address']; |
1200 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1200 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1201 | 1201 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1202 | 1202 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1203 | 1203 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1223,7 +1223,7 @@ discard block |
||
1223 | 1223 | $currentdate = date('Y-m-d H:i:s'); |
1224 | 1224 | $aprsdate = strtotime($data['datetime']); |
1225 | 1225 | // Accept data if time <= system time + 20s |
1226 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1226 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1227 | 1227 | $send = $SI->add($data); |
1228 | 1228 | } elseif (isset($line['stealth'])) { |
1229 | 1229 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
@@ -1320,7 +1320,7 @@ discard block |
||
1320 | 1320 | connect_all($sourceee); |
1321 | 1321 | $sourceee = array(); |
1322 | 1322 | //connect_all($globalSources); |
1323 | - $tt[$format]=0; |
|
1323 | + $tt[$format] = 0; |
|
1324 | 1324 | break; |
1325 | 1325 | } |
1326 | 1326 | } |
@@ -1329,14 +1329,14 @@ discard block |
||
1329 | 1329 | } else { |
1330 | 1330 | $error = socket_strerror(socket_last_error()); |
1331 | 1331 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1332 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1332 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1333 | 1333 | if (isset($globalDebug)) echo "Restarting...\n"; |
1334 | 1334 | // Restart the script if possible |
1335 | 1335 | if (is_array($sockets)) { |
1336 | 1336 | if ($globalDebug) echo "Shutdown all sockets..."; |
1337 | 1337 | |
1338 | 1338 | foreach ($sockets as $sock) { |
1339 | - @socket_shutdown($sock,2); |
|
1339 | + @socket_shutdown($sock, 2); |
|
1340 | 1340 | @socket_close($sock); |
1341 | 1341 | } |
1342 | 1342 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | -$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
|
3 | +$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING); |
|
4 | 4 | if ($date == '') $date = date('Y-m-d'); |
5 | 5 | header('Location: '.$globalURL.'/date/'.$date); |
6 | 6 | ?> |
7 | 7 | \ No newline at end of file |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | -$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
|
3 | +$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING); |
|
4 | 4 | if ($date == '') $date = date('Y-m-d'); |
5 | 5 | header('Location: '.$globalURL.'/accident/'.$date); |
6 | 6 | ?> |
7 | 7 | \ No newline at end of file |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | $currentdate = date('Y-m-d'); |
33 | 33 | $sourcestat = $Stats->getStatsSource($currentdate); |
34 | 34 | if (!empty($sourcestat)) { |
35 | - foreach($sourcestat as $srcst) { |
|
35 | + foreach ($sourcestat as $srcst) { |
|
36 | 36 | $type = $srcst['stats_type']; |
37 | 37 | if ($type == 'polar' || $type == 'hist') { |
38 | 38 | $source = $srcst['source_name']; |
39 | 39 | $data = $srcst['source_data']; |
40 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
40 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | } |
50 | 50 | |
51 | - public function get_Schedule($id,$ident) { |
|
51 | + public function get_Schedule($id, $ident) { |
|
52 | 52 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
53 | 53 | // Get schedule here, so it's done only one time |
54 | 54 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | $schedule = $Schedule->fetchSchedule($operator); |
74 | 74 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
75 | 75 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
76 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
77 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
76 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
77 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
78 | 78 | // Should also check if route schedule = route from DB |
79 | 79 | if ($schedule['DepartureAirportIATA'] != '') { |
80 | 80 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
97 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
97 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
98 | 98 | } |
99 | 99 | } else $scheduleexist = true; |
100 | 100 | } else $scheduleexist = true; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | if ($scheduleexist) { |
103 | 103 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
104 | 104 | $sch = $Schedule->getSchedule($operator); |
105 | - $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'])); |
|
105 | + $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'])); |
|
106 | 106 | } |
107 | 107 | $Spotter->db = null; |
108 | 108 | $Schedule->db = null; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
130 | 130 | $Spotter = new Spotter($this->db); |
131 | 131 | $real_arrival = $this->arrival($key); |
132 | - $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']); |
|
132 | + $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']); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $airport_time = ''; |
144 | 144 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
145 | 145 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
146 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
146 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
147 | 147 | if (isset($closestAirports[0])) { |
148 | 148 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
149 | 149 | $airport_icao = $closestAirports[0]['icao']; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | break; |
159 | 159 | } |
160 | 160 | } |
161 | - } 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))) { |
|
161 | + } 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))) { |
|
162 | 162 | $airport_icao = $closestAirports[0]['icao']; |
163 | 163 | $airport_time = $this->all_flights[$key]['datetime']; |
164 | 164 | } else { |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } else { |
172 | 172 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
173 | 173 | } |
174 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
174 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
183 | 183 | foreach ($this->all_flights as $key => $flight) { |
184 | 184 | if (isset($flight['lastupdate'])) { |
185 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
185 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
186 | 186 | if (isset($this->all_flights[$key]['id'])) { |
187 | 187 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
188 | 188 | /* |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $real_arrival = $this->arrival($key); |
195 | 195 | $Spotter = new Spotter($this->db); |
196 | 196 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
197 | - $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']); |
|
197 | + $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']); |
|
198 | 198 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
199 | 199 | } |
200 | 200 | // Put in archive |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $send = false; |
232 | 232 | |
233 | 233 | // SBS format is CSV format |
234 | - if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
234 | + if (is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
|
235 | 235 | //print_r($line); |
236 | 236 | 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)) { |
237 | 237 | |
@@ -264,25 +264,25 @@ discard block |
||
264 | 264 | |
265 | 265 | if (!isset($this->all_flights[$id])) { |
266 | 266 | $this->all_flights[$id] = array(); |
267 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
268 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
269 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
267 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
268 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '')); |
|
269 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
270 | 270 | if (!isset($line['id'])) { |
271 | 271 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
272 | 272 | // 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'))); |
273 | 273 | // 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'))); |
274 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
274 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
275 | 275 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
276 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
276 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
277 | 277 | if ($globalAllFlights !== FALSE) $dataFound = true; |
278 | 278 | } |
279 | 279 | if (isset($line['source_type']) && $line['source_type'] != '') { |
280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type'])); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | //print_r($this->all_flights); |
284 | 284 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
285 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
285 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
286 | 286 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
287 | 287 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
288 | 288 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -291,20 +291,20 @@ discard block |
||
291 | 291 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
292 | 292 | $Spotter = new Spotter($this->db); |
293 | 293 | if (isset($this->all_flights[$id]['source_type'])) { |
294 | - $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
|
294 | + $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']); |
|
295 | 295 | } else { |
296 | 296 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
297 | 297 | } |
298 | 298 | $Spotter->db = null; |
299 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
300 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
299 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
300 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | if ($globalAllFlights !== FALSE) $dataFound = true; |
304 | 304 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
305 | 305 | } |
306 | 306 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
307 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
307 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao'])); |
|
308 | 308 | } |
309 | 309 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
310 | 310 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $Spotter = new Spotter($this->db); |
313 | 313 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
314 | 314 | $Spotter->db = null; |
315 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
315 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
@@ -320,15 +320,15 @@ discard block |
||
320 | 320 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
321 | 321 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
322 | 322 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
323 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
323 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
324 | 324 | } |
325 | 325 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
326 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
326 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
327 | 327 | } |
328 | 328 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
329 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
|
329 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60) { |
|
330 | 330 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
331 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
331 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
332 | 332 | } else { |
333 | 333 | 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"; |
334 | 334 | 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"; |
@@ -341,24 +341,24 @@ discard block |
||
341 | 341 | } |
342 | 342 | } else { |
343 | 343 | date_default_timezone_set('UTC'); |
344 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
344 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
348 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
348 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
349 | 349 | } |
350 | 350 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
351 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
351 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
352 | 352 | } |
353 | 353 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
354 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
354 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id'])); |
|
355 | 355 | } |
356 | 356 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
357 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
357 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name'])); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | 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'])) { |
361 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
361 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
362 | 362 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
363 | 363 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
364 | 364 | $timeelapsed = microtime(true); |
@@ -369,10 +369,10 @@ discard block |
||
369 | 369 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
370 | 370 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
371 | 371 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
372 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
372 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
373 | 373 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
374 | 374 | $Spotter->db = null; |
375 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
375 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | |
@@ -384,25 +384,25 @@ discard block |
||
384 | 384 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
385 | 385 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
386 | 386 | */ |
387 | - 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'])); |
|
387 | + 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'])); |
|
388 | 388 | |
389 | 389 | //$putinarchive = true; |
390 | 390 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
391 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
391 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
392 | 392 | } |
393 | 393 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
394 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
394 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
395 | 395 | } |
396 | 396 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
397 | - $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' => '')); |
|
397 | + $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' => '')); |
|
398 | 398 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
399 | 399 | $timeelapsed = microtime(true); |
400 | 400 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
401 | 401 | $Spotter = new Spotter($this->db); |
402 | 402 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
403 | 403 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
404 | - $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' => '')); |
|
405 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
404 | + $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' => '')); |
|
405 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
406 | 406 | } |
407 | 407 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
408 | 408 | $timeelapsed = microtime(true); |
@@ -416,34 +416,34 @@ discard block |
||
416 | 416 | $Translation->db = null; |
417 | 417 | } |
418 | 418 | $Spotter->db = null; |
419 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
419 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
420 | 420 | } |
421 | 421 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
422 | 422 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
423 | 423 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
424 | 424 | // $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'])); |
425 | - $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'])); |
|
425 | + $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'])); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | if (!isset($globalFork)) $globalFork = TRUE; |
429 | 429 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
430 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
430 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | 435 | if (isset($line['speed']) && $line['speed'] != '') { |
436 | 436 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
437 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
438 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
437 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
438 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
439 | 439 | //$dataFound = true; |
440 | 440 | } 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'])) { |
441 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
441 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
442 | 442 | if ($distance > 1000 && $distance < 10000) { |
443 | 443 | // use datetime |
444 | 444 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
445 | 445 | $speed = $speed*3.6; |
446 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
446 | + if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
447 | 447 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
448 | 448 | } |
449 | 449 | } |
@@ -451,11 +451,11 @@ discard block |
||
451 | 451 | |
452 | 452 | |
453 | 453 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
454 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
454 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
455 | 455 | else unset($timediff); |
456 | - if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
456 | + if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) { |
|
457 | 457 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
458 | - if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
458 | + if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
459 | 459 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
460 | 460 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
461 | 461 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -465,10 +465,10 @@ discard block |
||
465 | 465 | $timeelapsed = microtime(true); |
466 | 466 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
467 | 467 | $Spotter = new Spotter($this->db); |
468 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
468 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
469 | 469 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
470 | 470 | $Spotter->db = null; |
471 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
471 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
472 | 472 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
473 | 473 | } |
474 | 474 | } |
@@ -478,13 +478,13 @@ discard block |
||
478 | 478 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
479 | 479 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
480 | 480 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
481 | - 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') { |
|
481 | + 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') { |
|
482 | 482 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
483 | 483 | $dataFound = true; |
484 | 484 | $this->all_flights[$id]['time_last_coord'] = time(); |
485 | 485 | } |
486 | 486 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
487 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
487 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
488 | 488 | /* |
489 | 489 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
490 | 490 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -502,13 +502,13 @@ discard block |
||
502 | 502 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
503 | 503 | //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) { |
504 | 504 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
505 | - 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') { |
|
505 | + 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') { |
|
506 | 506 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
507 | 507 | $dataFound = true; |
508 | 508 | $this->all_flights[$id]['time_last_coord'] = time(); |
509 | 509 | } |
510 | 510 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
511 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
511 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
512 | 512 | /* |
513 | 513 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
514 | 514 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -526,46 +526,46 @@ discard block |
||
526 | 526 | } else if ($globalDebug && $timediff > 30) { |
527 | 527 | $this->tmd = $this->tmd + 1; |
528 | 528 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
529 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
530 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
529 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
530 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
531 | 531 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
532 | 532 | } |
533 | 533 | } |
534 | 534 | if (isset($line['last_update']) && $line['last_update'] != '') { |
535 | 535 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
536 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
536 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
537 | 537 | } |
538 | 538 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
539 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
539 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
540 | 540 | //$dataFound = true; |
541 | 541 | } |
542 | 542 | if (isset($line['format_source']) && $line['format_source'] != '') { |
543 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
543 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
544 | 544 | } |
545 | 545 | if (isset($line['source_name']) && $line['source_name'] != '') { |
546 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
546 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
547 | 547 | } |
548 | 548 | if (isset($line['emergency']) && $line['emergency'] != '') { |
549 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
549 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
550 | 550 | //$dataFound = true; |
551 | 551 | } |
552 | 552 | if (isset($line['ground']) && $line['ground'] != '') { |
553 | 553 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
554 | 554 | // Here we force archive of flight because after ground it's a new one (or should be) |
555 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
556 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
557 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
558 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
559 | - 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'])); |
|
555 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
556 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
557 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
558 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
559 | + 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'])); |
|
560 | 560 | } |
561 | 561 | if ($line['ground'] != 1) $line['ground'] = 0; |
562 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
562 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
563 | 563 | //$dataFound = true; |
564 | 564 | } |
565 | 565 | if (isset($line['squawk']) && $line['squawk'] != '') { |
566 | 566 | 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'])) { |
567 | 567 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
568 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
568 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
569 | 569 | $highlight = ''; |
570 | 570 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
571 | 571 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -574,47 +574,47 @@ discard block |
||
574 | 574 | $timeelapsed = microtime(true); |
575 | 575 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
576 | 576 | $Spotter = new Spotter($this->db); |
577 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
577 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
578 | 578 | $Spotter->db = null; |
579 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
579 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
580 | 580 | } |
581 | 581 | //$putinarchive = true; |
582 | 582 | //$highlight = ''; |
583 | 583 | } |
584 | 584 | |
585 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
585 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
586 | 586 | //$dataFound = true; |
587 | 587 | } |
588 | 588 | |
589 | 589 | if (isset($line['altitude']) && $line['altitude'] != '') { |
590 | 590 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
591 | - 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; |
|
592 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
593 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
591 | + 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; |
|
592 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
593 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
594 | 594 | //$dataFound = true; |
595 | 595 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
596 | 596 | } |
597 | 597 | |
598 | 598 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
599 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
599 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | if (isset($line['heading']) && $line['heading'] != '') { |
603 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
604 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
605 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
603 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
604 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
605 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
606 | 606 | //$dataFound = true; |
607 | 607 | } 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']) { |
608 | - $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']); |
|
609 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
610 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
608 | + $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']); |
|
609 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
610 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
611 | 611 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
612 | 612 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
613 | 613 | // If not enough messages and ACARS set heading to 0 |
614 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
614 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
615 | 615 | } |
616 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
617 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
616 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
617 | + elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
618 | 618 | |
619 | 619 | // print_r($this->all_flights[$id]); |
620 | 620 | //gets the callsign from the last hour |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
625 | 625 | $this->all_flights[$id]['lastupdate'] = time(); |
626 | 626 | if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
627 | - 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'])) { |
|
627 | + 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'])) { |
|
628 | 628 | //print_r($this->all_flights); |
629 | 629 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
630 | 630 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -635,61 +635,61 @@ discard block |
||
635 | 635 | $SpotterLive = new SpotterLive($this->db); |
636 | 636 | 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')) { |
637 | 637 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
638 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
638 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
639 | 639 | } elseif (isset($line['id'])) { |
640 | 640 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
641 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
641 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
642 | 642 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
643 | 643 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
644 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
644 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
645 | 645 | } else $recent_ident = ''; |
646 | - $SpotterLive->db=null; |
|
646 | + $SpotterLive->db = null; |
|
647 | 647 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
648 | 648 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
649 | 649 | } else $recent_ident = ''; |
650 | 650 | } else { |
651 | 651 | $recent_ident = ''; |
652 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
652 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
653 | 653 | } |
654 | 654 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
655 | - if($recent_ident == "") |
|
655 | + if ($recent_ident == "") |
|
656 | 656 | { |
657 | 657 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
658 | 658 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
659 | 659 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
660 | 660 | //adds the spotter data for the archive |
661 | 661 | $ignoreImport = false; |
662 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
662 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
663 | 663 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
664 | 664 | $ignoreImport = true; |
665 | 665 | } |
666 | 666 | } |
667 | 667 | if (count($globalAirportAccept) > 0) { |
668 | 668 | $ignoreImport = true; |
669 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
669 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
670 | 670 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
671 | 671 | $ignoreImport = false; |
672 | 672 | } |
673 | 673 | } |
674 | 674 | } |
675 | 675 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
676 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
677 | - 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)) { |
|
676 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
677 | + 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)) { |
|
678 | 678 | $ignoreImport = true; |
679 | 679 | } |
680 | 680 | } |
681 | 681 | } |
682 | 682 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
683 | 683 | $ignoreImport = true; |
684 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
685 | - 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)) { |
|
684 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
685 | + 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)) { |
|
686 | 686 | $ignoreImport = false; |
687 | 687 | } |
688 | 688 | } |
689 | 689 | } |
690 | 690 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
691 | 691 | $ignoreImport = true; |
692 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
692 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
693 | 693 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
694 | 694 | $ignoreImport = false; |
695 | 695 | } |
@@ -701,32 +701,32 @@ discard block |
||
701 | 701 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
702 | 702 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
703 | 703 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
704 | - 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'))); |
|
704 | + 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'))); |
|
705 | 705 | $timeelapsed = microtime(true); |
706 | 706 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
707 | 707 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
708 | 708 | $Spotter = new Spotter($this->db); |
709 | - $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']); |
|
709 | + $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']); |
|
710 | 710 | $Spotter->db = null; |
711 | 711 | if ($globalDebug && isset($result)) echo $result."\n"; |
712 | 712 | } |
713 | 713 | } |
714 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
714 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
715 | 715 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
716 | 716 | |
717 | 717 | // Add source stat in DB |
718 | 718 | $Stats = new Stats($this->db); |
719 | 719 | if (!empty($this->stats)) { |
720 | 720 | if ($globalDebug) echo 'Add source stats : '; |
721 | - foreach($this->stats as $date => $data) { |
|
722 | - foreach($data as $source => $sourced) { |
|
721 | + foreach ($this->stats as $date => $data) { |
|
722 | + foreach ($data as $source => $sourced) { |
|
723 | 723 | //print_r($sourced); |
724 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
725 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
724 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
725 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
726 | 726 | if (isset($sourced['msg'])) { |
727 | 727 | if (time() - $sourced['msg']['date'] > 10) { |
728 | 728 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
729 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
729 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
730 | 730 | unset($this->stats[$date][$source]['msg']); |
731 | 731 | } |
732 | 732 | } |
@@ -764,14 +764,14 @@ discard block |
||
764 | 764 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
765 | 765 | $SpotterLive = new SpotterLive($this->db); |
766 | 766 | $SpotterLive->deleteLiveSpotterData(); |
767 | - $SpotterLive->db=null; |
|
767 | + $SpotterLive->db = null; |
|
768 | 768 | } |
769 | 769 | } |
770 | 770 | if ($globalDebug) echo " Done\n"; |
771 | 771 | $this->last_delete = time(); |
772 | 772 | } |
773 | 773 | } else { |
774 | - 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')) { |
|
774 | + 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')) { |
|
775 | 775 | $this->all_flights[$id]['id'] = $recent_ident; |
776 | 776 | $this->all_flights[$id]['addedSpotter'] = 1; |
777 | 777 | } |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
780 | 780 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
781 | 781 | $Spotter = new Spotter($this->db); |
782 | - $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']); |
|
782 | + $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']); |
|
783 | 783 | $Spotter->db = null; |
784 | 784 | } |
785 | 785 | } |
@@ -805,37 +805,37 @@ discard block |
||
805 | 805 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
806 | 806 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
807 | 807 | |
808 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
808 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
809 | 809 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
810 | 810 | $ignoreImport = true; |
811 | 811 | } |
812 | 812 | } |
813 | 813 | if (count($globalAirportAccept) > 0) { |
814 | 814 | $ignoreImport = true; |
815 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
815 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
816 | 816 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
817 | 817 | $ignoreImport = false; |
818 | 818 | } |
819 | 819 | } |
820 | 820 | } |
821 | 821 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
822 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
823 | - 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)) { |
|
822 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
823 | + 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)) { |
|
824 | 824 | $ignoreImport = true; |
825 | 825 | } |
826 | 826 | } |
827 | 827 | } |
828 | 828 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
829 | 829 | $ignoreImport = true; |
830 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
831 | - 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)) { |
|
830 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
831 | + 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)) { |
|
832 | 832 | $ignoreImport = false; |
833 | 833 | } |
834 | 834 | } |
835 | 835 | } |
836 | 836 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
837 | 837 | $ignoreImport = true; |
838 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
838 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
839 | 839 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
840 | 840 | $ignoreImport = false; |
841 | 841 | } |
@@ -843,23 +843,23 @@ discard block |
||
843 | 843 | } |
844 | 844 | |
845 | 845 | if (!$ignoreImport) { |
846 | - 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'])) { |
|
847 | - 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'))); |
|
846 | + 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'])) { |
|
847 | + 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'))); |
|
848 | 848 | $timeelapsed = microtime(true); |
849 | 849 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
850 | 850 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
851 | 851 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
852 | 852 | $SpotterLive = new SpotterLive($this->db); |
853 | - $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']); |
|
853 | + $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']); |
|
854 | 854 | $SpotterLive->db = null; |
855 | 855 | if ($globalDebug) echo $result."\n"; |
856 | 856 | } |
857 | 857 | } |
858 | 858 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
859 | - $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']); |
|
859 | + $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']); |
|
860 | 860 | } |
861 | 861 | $this->all_flights[$id]['putinarchive'] = false; |
862 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
862 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
863 | 863 | |
864 | 864 | // Put statistics in $this->stats variable |
865 | 865 | //if ($line['format_source'] != 'aprs') { |
@@ -878,19 +878,19 @@ discard block |
||
878 | 878 | $latitude = $globalCenterLatitude; |
879 | 879 | $longitude = $globalCenterLongitude; |
880 | 880 | } |
881 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
881 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
882 | 882 | } else { |
883 | 883 | $latitude = $this->source_location[$source]['latitude']; |
884 | 884 | $longitude = $this->source_location[$source]['longitude']; |
885 | 885 | } |
886 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
886 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
887 | 887 | //$stats_heading = $stats_heading%22.5; |
888 | 888 | $stats_heading = round($stats_heading/22.5); |
889 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
889 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
890 | 890 | $current_date = date('Y-m-d'); |
891 | 891 | if ($stats_heading == 16) $stats_heading = 0; |
892 | 892 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
893 | - for ($i=0;$i<=15;$i++) { |
|
893 | + for ($i = 0; $i <= 15; $i++) { |
|
894 | 894 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
895 | 895 | } |
896 | 896 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -905,9 +905,9 @@ discard block |
||
905 | 905 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
906 | 906 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
907 | 907 | end($this->stats[$current_date][$source]['hist']); |
908 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
908 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
909 | 909 | } else $mini = 0; |
910 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
910 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
911 | 911 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
912 | 912 | } |
913 | 913 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | $this->all_flights[$id]['lastupdate'] = time(); |
921 | 921 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
922 | 922 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
923 | - } 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"; |
|
923 | + } 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"; |
|
924 | 924 | //$this->del(); |
925 | 925 | |
926 | 926 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |