@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | require_once(dirname(__FILE__).'/class.Common.php'); |
4 | 4 | class aprs { |
5 | - private $socket; |
|
6 | - private $connected = false; |
|
5 | + private $socket; |
|
6 | + private $connected = false; |
|
7 | 7 | |
8 | - protected $symbols = array('!' => 'Police', |
|
8 | + protected $symbols = array('!' => 'Police', |
|
9 | 9 | '#' => 'DIGI', |
10 | 10 | '$' => 'Phone', |
11 | 11 | '%' => 'DX Cluster', |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | 'y' => 'Yagi At QTH'); |
90 | 90 | |
91 | 91 | |
92 | - private function urshift($n, $s) { |
|
92 | + private function urshift($n, $s) { |
|
93 | 93 | return ($n >= 0) ? ($n >> $s) : |
94 | - (($n & 0x7fffffff) >> $s) | |
|
94 | + (($n & 0x7fffffff) >> $s) | |
|
95 | 95 | (0x40000000 >> ($s - 1)); |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | - public function parse($input) { |
|
98 | + public function parse($input) { |
|
99 | 99 | global $globalDebug; |
100 | 100 | $debug = false; |
101 | 101 | $result = array(); |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | |
108 | 108 | /* Check that end was found and body has at least one byte. */ |
109 | 109 | if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { |
110 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
111 | - return false; |
|
110 | + if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; |
|
111 | + return false; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | if ($debug) echo 'input : '.$input."\n"; |
@@ -122,31 +122,31 @@ discard block |
||
122 | 122 | /* Parse source, target and path. */ |
123 | 123 | //FLRDF0A52>APRS,qAS,LSTB |
124 | 124 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
125 | - $ident = $matches[1]; |
|
126 | - $all_elements = $matches[2]; |
|
127 | - if ($ident == 'AIRCRAFT') { |
|
125 | + $ident = $matches[1]; |
|
126 | + $all_elements = $matches[2]; |
|
127 | + if ($ident == 'AIRCRAFT') { |
|
128 | 128 | $result['format_source'] = 'famaprs'; |
129 | 129 | $result['source_type'] = 'modes'; |
130 | - } elseif ($ident == 'MARINE') { |
|
130 | + } elseif ($ident == 'MARINE') { |
|
131 | 131 | $result['format_source'] = 'famaprs'; |
132 | 132 | $result['source_type'] = 'ais'; |
133 | - } else { |
|
133 | + } else { |
|
134 | 134 | if ($debug) echo 'ident : '.$ident."\n"; |
135 | 135 | $result['ident'] = $ident; |
136 | - } |
|
136 | + } |
|
137 | 137 | } else return false; |
138 | 138 | $elements = explode(',',$all_elements); |
139 | 139 | $source = end($elements); |
140 | 140 | $result['source'] = $source; |
141 | 141 | foreach ($elements as $element) { |
142 | - if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
143 | - //echo "ok"; |
|
144 | - //if ($element == 'TCPIP*') return false; |
|
145 | - } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
142 | + if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
|
143 | + //echo "ok"; |
|
144 | + //if ($element == 'TCPIP*') return false; |
|
145 | + } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { |
|
146 | 146 | if ($debug) echo 'element : '.$element."\n"; |
147 | 147 | return false; |
148 | - } |
|
149 | - /* |
|
148 | + } |
|
149 | + /* |
|
150 | 150 | } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
151 | 151 | //echo "ok"; |
152 | 152 | } else { |
@@ -173,49 +173,49 @@ discard block |
||
173 | 173 | $body_parse = substr($body,1); |
174 | 174 | //echo 'Body : '.$body."\n"; |
175 | 175 | if (preg_match('/^;(.){9}\*/',$body,$matches)) { |
176 | - $body_parse = substr($body_parse,10); |
|
177 | - $find = true; |
|
178 | - //echo $body_parse."\n"; |
|
176 | + $body_parse = substr($body_parse,10); |
|
177 | + $find = true; |
|
178 | + //echo $body_parse."\n"; |
|
179 | 179 | } |
180 | 180 | if (preg_match('/^`(.*)\//',$body,$matches)) { |
181 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
182 | - $find = true; |
|
183 | - //echo $body_parse."\n"; |
|
181 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
182 | + $find = true; |
|
183 | + //echo $body_parse."\n"; |
|
184 | 184 | } |
185 | 185 | if (preg_match("/^'(.*)\//",$body,$matches)) { |
186 | - $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
187 | - $find = true; |
|
188 | - //echo $body_parse."\n"; |
|
186 | + $body_parse = substr($body_parse,strlen($matches[1])-1); |
|
187 | + $find = true; |
|
188 | + //echo $body_parse."\n"; |
|
189 | 189 | } |
190 | 190 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { |
191 | - $find = true; |
|
192 | - //print_r($matches); |
|
193 | - $timestamp = $matches[0]; |
|
194 | - if ($matches[4] == 'h') { |
|
191 | + $find = true; |
|
192 | + //print_r($matches); |
|
193 | + $timestamp = $matches[0]; |
|
194 | + if ($matches[4] == 'h') { |
|
195 | 195 | $timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]); |
196 | 196 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; |
197 | 197 | /* |
198 | 198 | if (time() + 3900 < $timestamp) $timestamp -= 86400; |
199 | 199 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; |
200 | 200 | */ |
201 | - } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
201 | + } elseif ($matches[4] == 'z' || $matches[4] == '/') { |
|
202 | 202 | // This work or not ? |
203 | 203 | $timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); |
204 | - } |
|
205 | - $body_parse = substr($body_parse,7); |
|
206 | - $result['timestamp'] = $timestamp; |
|
207 | - //echo date('Ymd H:i:s',$timestamp); |
|
204 | + } |
|
205 | + $body_parse = substr($body_parse,7); |
|
206 | + $result['timestamp'] = $timestamp; |
|
207 | + //echo date('Ymd H:i:s',$timestamp); |
|
208 | 208 | } |
209 | 209 | if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { |
210 | - $find = true; |
|
211 | - $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
212 | - $body_parse = substr($body_parse,8); |
|
213 | - $result['timestamp'] = $timestamp; |
|
214 | - //echo date('Ymd H:i:s',$timestamp); |
|
210 | + $find = true; |
|
211 | + $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); |
|
212 | + $body_parse = substr($body_parse,8); |
|
213 | + $result['timestamp'] = $timestamp; |
|
214 | + //echo date('Ymd H:i:s',$timestamp); |
|
215 | 215 | } |
216 | 216 | //if (strlen($body_parse) > 19) { |
217 | - 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)) { |
|
218 | - $find = true; |
|
217 | + 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)) { |
|
218 | + $find = true; |
|
219 | 219 | // 4658.70N/00707.78Ez |
220 | 220 | //print_r(str_split($body_parse)); |
221 | 221 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $lon = intval($lon_deg); |
233 | 233 | if ($lat > 89 || $lon > 179) return false; |
234 | 234 | |
235 | - /* |
|
235 | + /* |
|
236 | 236 | $tmp_5b = str_replace('.','',$lat_min); |
237 | 237 | if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { |
238 | 238 | print_r($matches); |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | $result['longitude'] = $longitude; |
247 | 247 | $body_parse = substr($body_parse,18); |
248 | 248 | $body_parse_len = strlen($body_parse); |
249 | - } |
|
250 | - $body_parse_len = strlen($body_parse); |
|
251 | - if ($body_parse_len > 0) { |
|
249 | + } |
|
250 | + $body_parse_len = strlen($body_parse); |
|
251 | + if ($body_parse_len > 0) { |
|
252 | 252 | /* |
253 | 253 | if (!isset($result['timestamp']) && !isset($result['latitude'])) { |
254 | 254 | $body_split = str_split($body); |
@@ -278,89 +278,89 @@ discard block |
||
278 | 278 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; |
279 | 279 | if ($symbol_code != '_') { |
280 | 280 | } |
281 | - //$body_parse = substr($body_parse,1); |
|
282 | - //$body_parse = trim($body_parse); |
|
283 | - //$body_parse_len = strlen($body_parse); |
|
284 | - if ($body_parse_len >= 7) { |
|
281 | + //$body_parse = substr($body_parse,1); |
|
282 | + //$body_parse = trim($body_parse); |
|
283 | + //$body_parse_len = strlen($body_parse); |
|
284 | + if ($body_parse_len >= 7) { |
|
285 | 285 | |
286 | - if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
287 | - $course = substr($body_parse,0,3); |
|
288 | - $tmp_s = intval($course); |
|
289 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
290 | - $speed = substr($body_parse,4,3); |
|
291 | - if ($speed != '...') { |
|
292 | - //$result['speed'] = round($speed*1.852); |
|
293 | - $result['speed'] = intval($speed); |
|
294 | - } |
|
295 | - $body_parse = substr($body_parse,7); |
|
296 | - } |
|
297 | - // Check PHGR, PHG, RNG |
|
298 | - } |
|
299 | - /* |
|
286 | + if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
|
287 | + $course = substr($body_parse,0,3); |
|
288 | + $tmp_s = intval($course); |
|
289 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); |
|
290 | + $speed = substr($body_parse,4,3); |
|
291 | + if ($speed != '...') { |
|
292 | + //$result['speed'] = round($speed*1.852); |
|
293 | + $result['speed'] = intval($speed); |
|
294 | + } |
|
295 | + $body_parse = substr($body_parse,7); |
|
296 | + } |
|
297 | + // Check PHGR, PHG, RNG |
|
298 | + } |
|
299 | + /* |
|
300 | 300 | else if ($body_parse_len > 0) { |
301 | 301 | $rest = $body_parse; |
302 | 302 | } |
303 | 303 | */ |
304 | - if (strlen($body_parse) > 0) { |
|
305 | - if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
306 | - $altitude = intval($matches[1]); |
|
307 | - //$result['altitude'] = round($altitude*0.3048); |
|
308 | - $result['altitude'] = $altitude; |
|
309 | - //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
310 | - $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
311 | - } |
|
312 | - } |
|
304 | + if (strlen($body_parse) > 0) { |
|
305 | + if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { |
|
306 | + $altitude = intval($matches[1]); |
|
307 | + //$result['altitude'] = round($altitude*0.3048); |
|
308 | + $result['altitude'] = $altitude; |
|
309 | + //$body_parse = trim(substr($body_parse,strlen($matches[0]))); |
|
310 | + $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); |
|
311 | + } |
|
312 | + } |
|
313 | 313 | |
314 | - // Telemetry |
|
315 | - /* |
|
314 | + // Telemetry |
|
315 | + /* |
|
316 | 316 | if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) { |
317 | 317 | // Nothing yet... |
318 | 318 | } |
319 | 319 | */ |
320 | - // DAO |
|
320 | + // DAO |
|
321 | 321 | |
322 | - if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
322 | + if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { |
|
323 | 323 | |
324 | - $dao = $matches[1]; |
|
325 | - if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
324 | + $dao = $matches[1]; |
|
325 | + if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { |
|
326 | 326 | $dao_split = str_split($dao); |
327 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
328 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
327 | + $lat_off = (($dao_split[1])-48.0)*0.001/60.0; |
|
328 | + $lon_off = (($dao_split[2])-48.0)*0.001/60.0; |
|
329 | 329 | |
330 | 330 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
331 | 331 | else $result['latitude'] += $lat_off; |
332 | 332 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
333 | 333 | else $result['longitude'] += $lon_off; |
334 | - } |
|
334 | + } |
|
335 | 335 | |
336 | - $body_parse = substr($body_parse,6); |
|
337 | - } |
|
336 | + $body_parse = substr($body_parse,6); |
|
337 | + } |
|
338 | 338 | |
339 | - if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
339 | + if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
340 | 340 | $result['ident'] = $matches[1]; |
341 | - } |
|
342 | - if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
341 | + } |
|
342 | + if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { |
|
343 | 343 | $result['squawk'] = $matches[1]; |
344 | - } |
|
345 | - if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
344 | + } |
|
345 | + if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { |
|
346 | 346 | $result['aircraft_icao'] = $matches[1]; |
347 | - } |
|
348 | - if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
347 | + } |
|
348 | + if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { |
|
349 | 349 | $result['typeid'] = $matches[1]; |
350 | - } |
|
351 | - if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
350 | + } |
|
351 | + if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { |
|
352 | 352 | $result['imo'] = $matches[1]; |
353 | - } |
|
354 | - if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
353 | + } |
|
354 | + if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { |
|
355 | 355 | $result['arrival_date'] = $matches[1]; |
356 | - } |
|
357 | - if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
356 | + } |
|
357 | + if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) { |
|
358 | 358 | $result['arrival_code'] = $matches[1]; |
359 | - } |
|
360 | - // OGN comment |
|
359 | + } |
|
360 | + // OGN comment |
|
361 | 361 | // echo "Before OGN : ".$body_parse."\n"; |
362 | - //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
363 | - if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
362 | + //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { |
|
363 | + if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { |
|
364 | 364 | $id = $matches[1]; |
365 | 365 | //$mode = substr($id,0,2); |
366 | 366 | $address = substr($id,2); |
@@ -390,53 +390,53 @@ discard block |
||
390 | 390 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
391 | 391 | $result['stealth'] = $stealth; |
392 | 392 | $result['address'] = $address; |
393 | - } |
|
393 | + } |
|
394 | 394 | |
395 | - //Comment |
|
396 | - $result['comment'] = trim($body_parse); |
|
395 | + //Comment |
|
396 | + $result['comment'] = trim($body_parse); |
|
397 | 397 | } else { |
398 | - // parse weather |
|
399 | - //$body_parse = substr($body_parse,1); |
|
400 | - //$body_parse_len = strlen($body_parse); |
|
398 | + // parse weather |
|
399 | + //$body_parse = substr($body_parse,1); |
|
400 | + //$body_parse_len = strlen($body_parse); |
|
401 | 401 | |
402 | - if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
403 | - $result['wind_dir'] = intval($matches[1]); |
|
404 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
405 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
406 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
407 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
408 | - } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
402 | + if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
403 | + $result['wind_dir'] = intval($matches[1]); |
|
404 | + $result['wind_speed'] = round(intval($matches[2])*1.60934,1); |
|
405 | + $result['wind_gust'] = round(intval($matches[3])*1.60934,1); |
|
406 | + $result['temp'] = round(5/9*((intval($matches[4]))-32),1); |
|
407 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
408 | + } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
409 | 409 | $result['wind_dir'] = intval($matches[1]); |
410 | 410 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
411 | 411 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
412 | 412 | $result['temp'] = round(5/9*(($matches[4])-32),1); |
413 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
414 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
413 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
414 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { |
|
415 | 415 | $result['wind_dir'] = intval($matches[1]); |
416 | 416 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
417 | 417 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
418 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
419 | - } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
418 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
419 | + } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { |
|
420 | 420 | $result['wind_dir'] = intval($matches[1]); |
421 | 421 | $result['wind_speed'] = round($matches[2]*1.60934,1); |
422 | 422 | $result['wind_gust'] = round($matches[3]*1.60934,1); |
423 | - $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
424 | - } |
|
425 | - if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
423 | + $body_parse = substr($body_parse,strlen($matches[0])+1); |
|
424 | + } |
|
425 | + if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { |
|
426 | 426 | $result['temp'] = round(5/9*(($matches[1])-32),1); |
427 | - } |
|
427 | + } |
|
428 | 428 | } |
429 | 429 | } else $result['comment'] = trim($body_parse); |
430 | 430 | |
431 | - } |
|
431 | + } |
|
432 | 432 | //} |
433 | 433 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
434 | 434 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
435 | 435 | if ($debug) print_r($result); |
436 | 436 | return $result; |
437 | - } |
|
437 | + } |
|
438 | 438 | |
439 | - public function connect() { |
|
439 | + public function connect() { |
|
440 | 440 | global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; |
441 | 441 | $aprs_connect = 0; |
442 | 442 | $aprs_keep = 120; |
@@ -459,32 +459,32 @@ discard block |
||
459 | 459 | $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); |
460 | 460 | while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { |
461 | 461 | if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { |
462 | - echo 'APRS user verified !'."\n"; |
|
463 | - $this->connected = true; |
|
464 | - return true; |
|
465 | - break; |
|
462 | + echo 'APRS user verified !'."\n"; |
|
463 | + $this->connected = true; |
|
464 | + return true; |
|
465 | + break; |
|
466 | 466 | } |
467 | 467 | if (time()-$authstart > 5) { |
468 | - echo 'APRS timeout'."\n"; |
|
469 | - break; |
|
468 | + echo 'APRS timeout'."\n"; |
|
469 | + break; |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE); |
473 | 473 | } |
474 | - } |
|
474 | + } |
|
475 | 475 | |
476 | - public function disconnect() { |
|
476 | + public function disconnect() { |
|
477 | 477 | socket_close($this->socket); |
478 | - } |
|
478 | + } |
|
479 | 479 | |
480 | - public function send($data) { |
|
480 | + public function send($data) { |
|
481 | 481 | if ($this->connected === false) $this->connect(); |
482 | 482 | $send = socket_send( $this->socket , $data , strlen($data),0); |
483 | 483 | if ($send === FALSE) { |
484 | 484 | socket_close($this->socket); |
485 | 485 | $this->connect(); |
486 | 486 | } |
487 | - } |
|
487 | + } |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | class APRSSpotter extends APRS { |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | $this->db = $Connection->db; |
9 | 9 | } |
10 | 10 | |
11 | - /** |
|
12 | - * Get SQL query part for filter used |
|
13 | - * @param Array $filter the filter |
|
14 | - * @return Array the SQL part |
|
15 | - */ |
|
16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
11 | + /** |
|
12 | + * Get SQL query part for filter used |
|
13 | + * @param Array $filter the filter |
|
14 | + * @return Array the SQL part |
|
15 | + */ |
|
16 | + public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
18 | 18 | $filters = array(); |
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
@@ -30,88 +30,88 @@ discard block |
||
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | 32 | foreach($filters as $flt) { |
33 | - if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
33 | + if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
34 | 34 | if ($flt['airlines'][0] != '') { |
35 | - if (isset($flt['source'])) { |
|
35 | + if (isset($flt['source'])) { |
|
36 | 36 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
37 | - } else { |
|
37 | + } else { |
|
38 | 38 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
39 | - } |
|
39 | + } |
|
40 | + } |
|
40 | 41 | } |
41 | - } |
|
42 | - if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
42 | + if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
43 | 43 | if (isset($flt['source'])) { |
44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
45 | 45 | } else { |
46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
47 | 47 | } |
48 | - } |
|
49 | - if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
48 | + } |
|
49 | + if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
50 | 50 | if (isset($flt['source'])) { |
51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
52 | 52 | } else { |
53 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
53 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
54 | + } |
|
54 | 55 | } |
55 | - } |
|
56 | - if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
56 | + if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
57 | 57 | if (isset($flt['source'])) { |
58 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
58 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
59 | 59 | } else { |
60 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
60 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
61 | + } |
|
61 | 62 | } |
62 | - } |
|
63 | - if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
63 | + if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
64 | 64 | if (isset($flt['source'])) { |
65 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
65 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
66 | + } |
|
66 | 67 | } |
67 | - } |
|
68 | 68 | } |
69 | 69 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
70 | - if ($filter['airlines'][0] != '') { |
|
70 | + if ($filter['airlines'][0] != '') { |
|
71 | 71 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
72 | - } |
|
72 | + } |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
76 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
76 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
77 | 77 | } |
78 | 78 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
79 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
79 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
80 | 80 | } |
81 | 81 | if (isset($filter['source']) && !empty($filter['source'])) { |
82 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
82 | + $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
83 | 83 | } |
84 | 84 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
85 | - $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
85 | + $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
86 | 86 | } |
87 | 87 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
88 | 88 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
89 | 89 | } |
90 | 90 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
91 | - $filter_query_date = ''; |
|
91 | + $filter_query_date = ''; |
|
92 | 92 | |
93 | - if (isset($filter['year']) && $filter['year'] != '') { |
|
93 | + if (isset($filter['year']) && $filter['year'] != '') { |
|
94 | 94 | if ($globalDBdriver == 'mysql') { |
95 | - $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
95 | + $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
96 | 96 | } else { |
97 | - $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
97 | + $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
98 | + } |
|
98 | 99 | } |
99 | - } |
|
100 | - if (isset($filter['month']) && $filter['month'] != '') { |
|
100 | + if (isset($filter['month']) && $filter['month'] != '') { |
|
101 | 101 | if ($globalDBdriver == 'mysql') { |
102 | - $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
102 | + $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
103 | 103 | } else { |
104 | - $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
104 | + $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
105 | 105 | } |
106 | - } |
|
107 | - if (isset($filter['day']) && $filter['day'] != '') { |
|
106 | + } |
|
107 | + if (isset($filter['day']) && $filter['day'] != '') { |
|
108 | 108 | if ($globalDBdriver == 'mysql') { |
109 | - $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
109 | + $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
110 | 110 | } else { |
111 | - $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
111 | + $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
112 | + } |
|
112 | 113 | } |
113 | - } |
|
114 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
114 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
115 | 115 | } |
116 | 116 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
117 | 117 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | $filter_query = $filter_query_join.$filter_query_where; |
122 | 122 | return $filter_query; |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | 125 | // Spotter_archive |
126 | 126 | public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
@@ -151,44 +151,44 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | |
154 | - /** |
|
155 | - * Gets all the spotter information based on a particular callsign |
|
156 | - * |
|
157 | - * @return Array the spotter information |
|
158 | - * |
|
159 | - */ |
|
160 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
161 | - { |
|
154 | + /** |
|
155 | + * Gets all the spotter information based on a particular callsign |
|
156 | + * |
|
157 | + * @return Array the spotter information |
|
158 | + * |
|
159 | + */ |
|
160 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
161 | + { |
|
162 | 162 | $Spotter = new Spotter($this->db); |
163 | - date_default_timezone_set('UTC'); |
|
163 | + date_default_timezone_set('UTC'); |
|
164 | 164 | |
165 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
166 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
167 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
165 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
166 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
167 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
168 | 168 | |
169 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
169 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
170 | 170 | |
171 | - return $spotter_array; |
|
172 | - } |
|
171 | + return $spotter_array; |
|
172 | + } |
|
173 | 173 | |
174 | 174 | |
175 | - /** |
|
176 | - * Gets last the spotter information based on a particular id |
|
177 | - * |
|
178 | - * @return Array the spotter information |
|
179 | - * |
|
180 | - */ |
|
181 | - public function getLastArchiveSpotterDataById($id) |
|
182 | - { |
|
183 | - $Spotter = new Spotter($this->db); |
|
184 | - date_default_timezone_set('UTC'); |
|
185 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
186 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
187 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
188 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
175 | + /** |
|
176 | + * Gets last the spotter information based on a particular id |
|
177 | + * |
|
178 | + * @return Array the spotter information |
|
179 | + * |
|
180 | + */ |
|
181 | + public function getLastArchiveSpotterDataById($id) |
|
182 | + { |
|
183 | + $Spotter = new Spotter($this->db); |
|
184 | + date_default_timezone_set('UTC'); |
|
185 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
186 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
187 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
188 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
189 | 189 | |
190 | 190 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
191 | - /* |
|
191 | + /* |
|
192 | 192 | try { |
193 | 193 | $Connection = new Connection(); |
194 | 194 | $sth = Connection->$db->prepare($query); |
@@ -198,232 +198,232 @@ discard block |
||
198 | 198 | } |
199 | 199 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
200 | 200 | */ |
201 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
202 | - |
|
203 | - return $spotter_array; |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * Gets all the spotter information based on a particular id |
|
208 | - * |
|
209 | - * @return Array the spotter information |
|
210 | - * |
|
211 | - */ |
|
212 | - public function getAllArchiveSpotterDataById($id) |
|
213 | - { |
|
214 | - date_default_timezone_set('UTC'); |
|
215 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
216 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
201 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
202 | + |
|
203 | + return $spotter_array; |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * Gets all the spotter information based on a particular id |
|
208 | + * |
|
209 | + * @return Array the spotter information |
|
210 | + * |
|
211 | + */ |
|
212 | + public function getAllArchiveSpotterDataById($id) |
|
213 | + { |
|
214 | + date_default_timezone_set('UTC'); |
|
215 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
216 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
217 | 217 | |
218 | 218 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
219 | 219 | |
220 | - try { |
|
221 | - $sth = $this->db->prepare($query); |
|
222 | - $sth->execute(array(':id' => $id)); |
|
223 | - } catch(PDOException $e) { |
|
224 | - echo $e->getMessage(); |
|
225 | - die; |
|
226 | - } |
|
227 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
228 | - |
|
229 | - return $spotter_array; |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * Gets coordinate & time spotter information based on a particular id |
|
234 | - * |
|
235 | - * @return Array the spotter information |
|
236 | - * |
|
237 | - */ |
|
238 | - public function getCoordArchiveSpotterDataById($id) |
|
239 | - { |
|
240 | - date_default_timezone_set('UTC'); |
|
241 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
242 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
220 | + try { |
|
221 | + $sth = $this->db->prepare($query); |
|
222 | + $sth->execute(array(':id' => $id)); |
|
223 | + } catch(PDOException $e) { |
|
224 | + echo $e->getMessage(); |
|
225 | + die; |
|
226 | + } |
|
227 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
228 | + |
|
229 | + return $spotter_array; |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * Gets coordinate & time spotter information based on a particular id |
|
234 | + * |
|
235 | + * @return Array the spotter information |
|
236 | + * |
|
237 | + */ |
|
238 | + public function getCoordArchiveSpotterDataById($id) |
|
239 | + { |
|
240 | + date_default_timezone_set('UTC'); |
|
241 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
242 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
243 | 243 | |
244 | 244 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
245 | 245 | |
246 | - try { |
|
247 | - $sth = $this->db->prepare($query); |
|
248 | - $sth->execute(array(':id' => $id)); |
|
249 | - } catch(PDOException $e) { |
|
250 | - echo $e->getMessage(); |
|
251 | - die; |
|
252 | - } |
|
253 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
246 | + try { |
|
247 | + $sth = $this->db->prepare($query); |
|
248 | + $sth->execute(array(':id' => $id)); |
|
249 | + } catch(PDOException $e) { |
|
250 | + echo $e->getMessage(); |
|
251 | + die; |
|
252 | + } |
|
253 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
254 | 254 | |
255 | - return $spotter_array; |
|
256 | - } |
|
255 | + return $spotter_array; |
|
256 | + } |
|
257 | 257 | |
258 | 258 | |
259 | - /** |
|
260 | - * Gets altitude information based on a particular callsign |
|
261 | - * |
|
262 | - * @return Array the spotter information |
|
263 | - * |
|
264 | - */ |
|
265 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
266 | - { |
|
259 | + /** |
|
260 | + * Gets altitude information based on a particular callsign |
|
261 | + * |
|
262 | + * @return Array the spotter information |
|
263 | + * |
|
264 | + */ |
|
265 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
266 | + { |
|
267 | 267 | |
268 | - date_default_timezone_set('UTC'); |
|
268 | + date_default_timezone_set('UTC'); |
|
269 | 269 | |
270 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
271 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
270 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
271 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
272 | 272 | |
273 | - try { |
|
274 | - $sth = $this->db->prepare($query); |
|
275 | - $sth->execute(array(':ident' => $ident)); |
|
276 | - } catch(PDOException $e) { |
|
277 | - echo $e->getMessage(); |
|
278 | - die; |
|
279 | - } |
|
280 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
273 | + try { |
|
274 | + $sth = $this->db->prepare($query); |
|
275 | + $sth->execute(array(':ident' => $ident)); |
|
276 | + } catch(PDOException $e) { |
|
277 | + echo $e->getMessage(); |
|
278 | + die; |
|
279 | + } |
|
280 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
281 | 281 | |
282 | - return $spotter_array; |
|
283 | - } |
|
282 | + return $spotter_array; |
|
283 | + } |
|
284 | 284 | |
285 | - /** |
|
286 | - * Gets altitude information based on a particular id |
|
287 | - * |
|
288 | - * @return Array the spotter information |
|
289 | - * |
|
290 | - */ |
|
291 | - public function getAltitudeArchiveSpotterDataById($id) |
|
292 | - { |
|
285 | + /** |
|
286 | + * Gets altitude information based on a particular id |
|
287 | + * |
|
288 | + * @return Array the spotter information |
|
289 | + * |
|
290 | + */ |
|
291 | + public function getAltitudeArchiveSpotterDataById($id) |
|
292 | + { |
|
293 | 293 | |
294 | - date_default_timezone_set('UTC'); |
|
294 | + date_default_timezone_set('UTC'); |
|
295 | 295 | |
296 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
297 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
296 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
297 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
298 | 298 | |
299 | - try { |
|
300 | - $sth = $this->db->prepare($query); |
|
301 | - $sth->execute(array(':id' => $id)); |
|
302 | - } catch(PDOException $e) { |
|
303 | - echo $e->getMessage(); |
|
304 | - die; |
|
305 | - } |
|
306 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
299 | + try { |
|
300 | + $sth = $this->db->prepare($query); |
|
301 | + $sth->execute(array(':id' => $id)); |
|
302 | + } catch(PDOException $e) { |
|
303 | + echo $e->getMessage(); |
|
304 | + die; |
|
305 | + } |
|
306 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
307 | 307 | |
308 | - return $spotter_array; |
|
309 | - } |
|
308 | + return $spotter_array; |
|
309 | + } |
|
310 | 310 | |
311 | - /** |
|
312 | - * Gets altitude & speed information based on a particular id |
|
313 | - * |
|
314 | - * @return Array the spotter information |
|
315 | - * |
|
316 | - */ |
|
317 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
318 | - { |
|
311 | + /** |
|
312 | + * Gets altitude & speed information based on a particular id |
|
313 | + * |
|
314 | + * @return Array the spotter information |
|
315 | + * |
|
316 | + */ |
|
317 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
318 | + { |
|
319 | 319 | |
320 | - date_default_timezone_set('UTC'); |
|
320 | + date_default_timezone_set('UTC'); |
|
321 | 321 | |
322 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
323 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
322 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
323 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
324 | 324 | |
325 | - try { |
|
326 | - $sth = $this->db->prepare($query); |
|
327 | - $sth->execute(array(':id' => $id)); |
|
328 | - } catch(PDOException $e) { |
|
329 | - echo $e->getMessage(); |
|
330 | - die; |
|
331 | - } |
|
332 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
325 | + try { |
|
326 | + $sth = $this->db->prepare($query); |
|
327 | + $sth->execute(array(':id' => $id)); |
|
328 | + } catch(PDOException $e) { |
|
329 | + echo $e->getMessage(); |
|
330 | + die; |
|
331 | + } |
|
332 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
333 | 333 | |
334 | - return $spotter_array; |
|
335 | - } |
|
334 | + return $spotter_array; |
|
335 | + } |
|
336 | 336 | |
337 | 337 | |
338 | - /** |
|
339 | - * Gets altitude information based on a particular callsign |
|
340 | - * |
|
341 | - * @return Array the spotter information |
|
342 | - * |
|
343 | - */ |
|
344 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
345 | - { |
|
338 | + /** |
|
339 | + * Gets altitude information based on a particular callsign |
|
340 | + * |
|
341 | + * @return Array the spotter information |
|
342 | + * |
|
343 | + */ |
|
344 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
345 | + { |
|
346 | 346 | |
347 | - date_default_timezone_set('UTC'); |
|
347 | + date_default_timezone_set('UTC'); |
|
348 | 348 | |
349 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
350 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
349 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
350 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
351 | 351 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
352 | 352 | |
353 | - try { |
|
354 | - $sth = $this->db->prepare($query); |
|
355 | - $sth->execute(array(':ident' => $ident)); |
|
356 | - } catch(PDOException $e) { |
|
357 | - echo $e->getMessage(); |
|
358 | - die; |
|
359 | - } |
|
360 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
353 | + try { |
|
354 | + $sth = $this->db->prepare($query); |
|
355 | + $sth->execute(array(':ident' => $ident)); |
|
356 | + } catch(PDOException $e) { |
|
357 | + echo $e->getMessage(); |
|
358 | + die; |
|
359 | + } |
|
360 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
361 | 361 | |
362 | - return $spotter_array; |
|
363 | - } |
|
362 | + return $spotter_array; |
|
363 | + } |
|
364 | 364 | |
365 | 365 | |
366 | 366 | |
367 | - /** |
|
368 | - * Gets all the archive spotter information |
|
369 | - * |
|
370 | - * @return Array the spotter information |
|
371 | - * |
|
372 | - */ |
|
373 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
374 | - { |
|
375 | - $Spotter = new Spotter($this->db); |
|
376 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
377 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
367 | + /** |
|
368 | + * Gets all the archive spotter information |
|
369 | + * |
|
370 | + * @return Array the spotter information |
|
371 | + * |
|
372 | + */ |
|
373 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
374 | + { |
|
375 | + $Spotter = new Spotter($this->db); |
|
376 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
377 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
378 | 378 | |
379 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
379 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
380 | 380 | |
381 | - return $spotter_array; |
|
382 | - } |
|
381 | + return $spotter_array; |
|
382 | + } |
|
383 | 383 | |
384 | - public function deleteSpotterArchiveTrackData() |
|
385 | - { |
|
384 | + public function deleteSpotterArchiveTrackData() |
|
385 | + { |
|
386 | 386 | global $globalArchiveKeepTrackMonths; |
387 | - date_default_timezone_set('UTC'); |
|
387 | + date_default_timezone_set('UTC'); |
|
388 | 388 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
389 | - try { |
|
390 | - $sth = $this->db->prepare($query); |
|
391 | - $sth->execute(); |
|
392 | - } catch(PDOException $e) { |
|
393 | - echo $e->getMessage(); |
|
394 | - die; |
|
395 | - } |
|
389 | + try { |
|
390 | + $sth = $this->db->prepare($query); |
|
391 | + $sth->execute(); |
|
392 | + } catch(PDOException $e) { |
|
393 | + echo $e->getMessage(); |
|
394 | + die; |
|
395 | + } |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
399 | - * Gets Minimal Live Spotter data |
|
400 | - * |
|
401 | - * @return Array the spotter information |
|
402 | - * |
|
403 | - */ |
|
404 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
405 | - { |
|
406 | - global $globalDBdriver, $globalLiveInterval; |
|
407 | - date_default_timezone_set('UTC'); |
|
408 | - |
|
409 | - $filter_query = ''; |
|
410 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
411 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
412 | - } |
|
413 | - // Use spotter_output also ? |
|
414 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
415 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
416 | - } |
|
417 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
418 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
419 | - } |
|
420 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
421 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
422 | - } |
|
423 | - |
|
424 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
425 | - if ($globalDBdriver == 'mysql') { |
|
426 | - /* |
|
399 | + * Gets Minimal Live Spotter data |
|
400 | + * |
|
401 | + * @return Array the spotter information |
|
402 | + * |
|
403 | + */ |
|
404 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
405 | + { |
|
406 | + global $globalDBdriver, $globalLiveInterval; |
|
407 | + date_default_timezone_set('UTC'); |
|
408 | + |
|
409 | + $filter_query = ''; |
|
410 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
411 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
412 | + } |
|
413 | + // Use spotter_output also ? |
|
414 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
415 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
416 | + } |
|
417 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
418 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
419 | + } |
|
420 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
421 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
422 | + } |
|
423 | + |
|
424 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
425 | + if ($globalDBdriver == 'mysql') { |
|
426 | + /* |
|
427 | 427 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
428 | 428 | FROM spotter_archive |
429 | 429 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -442,56 +442,56 @@ discard block |
||
442 | 442 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
443 | 443 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
444 | 444 | '.$filter_query.' ORDER BY flightaware_id'; |
445 | - } else { |
|
446 | - //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
447 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
445 | + } else { |
|
446 | + //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
447 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
448 | 448 | FROM spotter_archive |
449 | 449 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
450 | 450 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
451 | 451 | '.$filter_query.' ORDER BY flightaware_id'; |
452 | - } |
|
453 | - //echo $query; |
|
454 | - try { |
|
455 | - $sth = $this->db->prepare($query); |
|
456 | - $sth->execute(); |
|
457 | - } catch(PDOException $e) { |
|
458 | - echo $e->getMessage(); |
|
459 | - die; |
|
460 | - } |
|
461 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
462 | - |
|
463 | - return $spotter_array; |
|
464 | - } |
|
452 | + } |
|
453 | + //echo $query; |
|
454 | + try { |
|
455 | + $sth = $this->db->prepare($query); |
|
456 | + $sth->execute(); |
|
457 | + } catch(PDOException $e) { |
|
458 | + echo $e->getMessage(); |
|
459 | + die; |
|
460 | + } |
|
461 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
462 | + |
|
463 | + return $spotter_array; |
|
464 | + } |
|
465 | 465 | |
466 | 466 | /** |
467 | - * Gets Minimal Live Spotter data |
|
468 | - * |
|
469 | - * @return Array the spotter information |
|
470 | - * |
|
471 | - */ |
|
472 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
473 | - { |
|
474 | - global $globalDBdriver, $globalLiveInterval; |
|
475 | - date_default_timezone_set('UTC'); |
|
476 | - |
|
477 | - $filter_query = ''; |
|
478 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
479 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
480 | - } |
|
481 | - // Should use spotter_output also ? |
|
482 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
483 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
484 | - } |
|
485 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
486 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
487 | - } |
|
488 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
489 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
490 | - } |
|
491 | - |
|
492 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
493 | - if ($globalDBdriver == 'mysql') { |
|
494 | - /* |
|
467 | + * Gets Minimal Live Spotter data |
|
468 | + * |
|
469 | + * @return Array the spotter information |
|
470 | + * |
|
471 | + */ |
|
472 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
473 | + { |
|
474 | + global $globalDBdriver, $globalLiveInterval; |
|
475 | + date_default_timezone_set('UTC'); |
|
476 | + |
|
477 | + $filter_query = ''; |
|
478 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
479 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
480 | + } |
|
481 | + // Should use spotter_output also ? |
|
482 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
483 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
484 | + } |
|
485 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
486 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
487 | + } |
|
488 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
489 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
490 | + } |
|
491 | + |
|
492 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
493 | + if ($globalDBdriver == 'mysql') { |
|
494 | + /* |
|
495 | 495 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
496 | 496 | FROM spotter_archive |
497 | 497 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -502,95 +502,95 @@ discard block |
||
502 | 502 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
503 | 503 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
504 | 504 | |
505 | - } else { |
|
506 | - //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
507 | - /* |
|
505 | + } else { |
|
506 | + //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
507 | + /* |
|
508 | 508 | $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
509 | 509 | FROM spotter_archive_output |
510 | 510 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
511 | 511 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
512 | 512 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
513 | 513 | */ |
514 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
514 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
515 | 515 | FROM spotter_archive_output |
516 | 516 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
517 | 517 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
518 | 518 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
519 | 519 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
520 | 520 | |
521 | - } |
|
522 | - //echo $query; |
|
523 | - try { |
|
524 | - $sth = $this->db->prepare($query); |
|
525 | - $sth->execute(); |
|
526 | - } catch(PDOException $e) { |
|
527 | - echo $e->getMessage(); |
|
528 | - die; |
|
529 | - } |
|
530 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
531 | - |
|
532 | - return $spotter_array; |
|
533 | - } |
|
521 | + } |
|
522 | + //echo $query; |
|
523 | + try { |
|
524 | + $sth = $this->db->prepare($query); |
|
525 | + $sth->execute(); |
|
526 | + } catch(PDOException $e) { |
|
527 | + echo $e->getMessage(); |
|
528 | + die; |
|
529 | + } |
|
530 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
531 | + |
|
532 | + return $spotter_array; |
|
533 | + } |
|
534 | 534 | |
535 | 535 | /** |
536 | - * Gets count Live Spotter data |
|
537 | - * |
|
538 | - * @return Array the spotter information |
|
539 | - * |
|
540 | - */ |
|
541 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
542 | - { |
|
543 | - global $globalDBdriver, $globalLiveInterval; |
|
544 | - date_default_timezone_set('UTC'); |
|
545 | - |
|
546 | - $filter_query = ''; |
|
547 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
548 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
549 | - } |
|
550 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
551 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
552 | - } |
|
553 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
554 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
555 | - } |
|
556 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
557 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
558 | - } |
|
559 | - |
|
560 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
561 | - if ($globalDBdriver == 'mysql') { |
|
536 | + * Gets count Live Spotter data |
|
537 | + * |
|
538 | + * @return Array the spotter information |
|
539 | + * |
|
540 | + */ |
|
541 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
542 | + { |
|
543 | + global $globalDBdriver, $globalLiveInterval; |
|
544 | + date_default_timezone_set('UTC'); |
|
545 | + |
|
546 | + $filter_query = ''; |
|
547 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
548 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
549 | + } |
|
550 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
551 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
552 | + } |
|
553 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
554 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
555 | + } |
|
556 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
557 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
558 | + } |
|
559 | + |
|
560 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
561 | + if ($globalDBdriver == 'mysql') { |
|
562 | 562 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
563 | 563 | FROM spotter_archive l |
564 | 564 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
565 | - } else { |
|
565 | + } else { |
|
566 | 566 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
567 | - } |
|
568 | - //echo $query; |
|
569 | - try { |
|
570 | - $sth = $this->db->prepare($query); |
|
571 | - $sth->execute(); |
|
572 | - } catch(PDOException $e) { |
|
573 | - echo $e->getMessage(); |
|
574 | - die; |
|
575 | - } |
|
567 | + } |
|
568 | + //echo $query; |
|
569 | + try { |
|
570 | + $sth = $this->db->prepare($query); |
|
571 | + $sth->execute(); |
|
572 | + } catch(PDOException $e) { |
|
573 | + echo $e->getMessage(); |
|
574 | + die; |
|
575 | + } |
|
576 | 576 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
577 | 577 | $sth->closeCursor(); |
578 | - return $result['nb']; |
|
578 | + return $result['nb']; |
|
579 | 579 | |
580 | - } |
|
580 | + } |
|
581 | 581 | |
582 | 582 | |
583 | 583 | |
584 | 584 | // Spotter_Archive_output |
585 | 585 | |
586 | - /** |
|
587 | - * Gets all the spotter information |
|
588 | - * |
|
589 | - * @return Array the spotter information |
|
590 | - * |
|
591 | - */ |
|
592 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
593 | - { |
|
586 | + /** |
|
587 | + * Gets all the spotter information |
|
588 | + * |
|
589 | + * @return Array the spotter information |
|
590 | + * |
|
591 | + */ |
|
592 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
593 | + { |
|
594 | 594 | global $globalTimezone, $globalDBdriver; |
595 | 595 | require_once(dirname(__FILE__).'/class.Translation.php'); |
596 | 596 | $Translation = new Translation(); |
@@ -604,159 +604,159 @@ discard block |
||
604 | 604 | $filter_query = $this->getFilter($filters); |
605 | 605 | if ($q != "") |
606 | 606 | { |
607 | - if (!is_string($q)) |
|
608 | - { |
|
607 | + if (!is_string($q)) |
|
608 | + { |
|
609 | 609 | return false; |
610 | - } else { |
|
610 | + } else { |
|
611 | 611 | |
612 | 612 | $q_array = explode(" ", $q); |
613 | 613 | |
614 | 614 | foreach ($q_array as $q_item){ |
615 | - $additional_query .= " AND ("; |
|
616 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
617 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
618 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
619 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
620 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
621 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
622 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
623 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
624 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
625 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
626 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
627 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
628 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
629 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
630 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
631 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
632 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
633 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
634 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
635 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
636 | - $translate = $Translation->ident2icao($q_item); |
|
637 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
638 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
639 | - $additional_query .= ")"; |
|
640 | - } |
|
641 | - } |
|
615 | + $additional_query .= " AND ("; |
|
616 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
617 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
618 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
619 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
620 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
621 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
622 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
623 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
624 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
625 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
626 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
627 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
628 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
629 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
630 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
631 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
632 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
633 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
634 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
635 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
636 | + $translate = $Translation->ident2icao($q_item); |
|
637 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
638 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
639 | + $additional_query .= ")"; |
|
640 | + } |
|
641 | + } |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | if ($registration != "") |
645 | 645 | { |
646 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
647 | - if (!is_string($registration)) |
|
648 | - { |
|
646 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
647 | + if (!is_string($registration)) |
|
648 | + { |
|
649 | 649 | return false; |
650 | - } else { |
|
650 | + } else { |
|
651 | 651 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
652 | - } |
|
652 | + } |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | if ($aircraft_icao != "") |
656 | 656 | { |
657 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
658 | - if (!is_string($aircraft_icao)) |
|
659 | - { |
|
657 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
658 | + if (!is_string($aircraft_icao)) |
|
659 | + { |
|
660 | 660 | return false; |
661 | - } else { |
|
661 | + } else { |
|
662 | 662 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
663 | - } |
|
663 | + } |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | if ($aircraft_manufacturer != "") |
667 | 667 | { |
668 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
669 | - if (!is_string($aircraft_manufacturer)) |
|
670 | - { |
|
668 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
669 | + if (!is_string($aircraft_manufacturer)) |
|
670 | + { |
|
671 | 671 | return false; |
672 | - } else { |
|
672 | + } else { |
|
673 | 673 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
674 | - } |
|
674 | + } |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | if ($highlights == "true") |
678 | 678 | { |
679 | - if (!is_string($highlights)) |
|
680 | - { |
|
679 | + if (!is_string($highlights)) |
|
680 | + { |
|
681 | 681 | return false; |
682 | - } else { |
|
682 | + } else { |
|
683 | 683 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
684 | - } |
|
684 | + } |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | if ($airline_icao != "") |
688 | 688 | { |
689 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
690 | - if (!is_string($airline_icao)) |
|
691 | - { |
|
689 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
690 | + if (!is_string($airline_icao)) |
|
691 | + { |
|
692 | 692 | return false; |
693 | - } else { |
|
693 | + } else { |
|
694 | 694 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
695 | - } |
|
695 | + } |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | if ($airline_country != "") |
699 | 699 | { |
700 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
701 | - if (!is_string($airline_country)) |
|
702 | - { |
|
700 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
701 | + if (!is_string($airline_country)) |
|
702 | + { |
|
703 | 703 | return false; |
704 | - } else { |
|
704 | + } else { |
|
705 | 705 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
706 | - } |
|
706 | + } |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | if ($airline_type != "") |
710 | 710 | { |
711 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
712 | - if (!is_string($airline_type)) |
|
713 | - { |
|
711 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
712 | + if (!is_string($airline_type)) |
|
713 | + { |
|
714 | 714 | return false; |
715 | - } else { |
|
715 | + } else { |
|
716 | 716 | if ($airline_type == "passenger") |
717 | 717 | { |
718 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
718 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
719 | 719 | } |
720 | 720 | if ($airline_type == "cargo") |
721 | 721 | { |
722 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
722 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
723 | 723 | } |
724 | 724 | if ($airline_type == "military") |
725 | 725 | { |
726 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
726 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
727 | + } |
|
727 | 728 | } |
728 | - } |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | if ($airport != "") |
732 | 732 | { |
733 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
734 | - if (!is_string($airport)) |
|
735 | - { |
|
733 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
734 | + if (!is_string($airport)) |
|
735 | + { |
|
736 | 736 | return false; |
737 | - } else { |
|
737 | + } else { |
|
738 | 738 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
739 | - } |
|
739 | + } |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | if ($airport_country != "") |
743 | 743 | { |
744 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
745 | - if (!is_string($airport_country)) |
|
746 | - { |
|
744 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
745 | + if (!is_string($airport_country)) |
|
746 | + { |
|
747 | 747 | return false; |
748 | - } else { |
|
748 | + } else { |
|
749 | 749 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
750 | - } |
|
750 | + } |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | if ($callsign != "") |
754 | 754 | { |
755 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
756 | - if (!is_string($callsign)) |
|
757 | - { |
|
755 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
756 | + if (!is_string($callsign)) |
|
757 | + { |
|
758 | 758 | return false; |
759 | - } else { |
|
759 | + } else { |
|
760 | 760 | $translate = $Translation->ident2icao($callsign); |
761 | 761 | if ($translate != $callsign) { |
762 | 762 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -764,99 +764,99 @@ discard block |
||
764 | 764 | } else { |
765 | 765 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
766 | 766 | } |
767 | - } |
|
767 | + } |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | if ($owner != "") |
771 | 771 | { |
772 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
773 | - if (!is_string($owner)) |
|
774 | - { |
|
772 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
773 | + if (!is_string($owner)) |
|
774 | + { |
|
775 | 775 | return false; |
776 | - } else { |
|
776 | + } else { |
|
777 | 777 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
778 | - } |
|
778 | + } |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | if ($pilot_name != "") |
782 | 782 | { |
783 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
784 | - if (!is_string($pilot_name)) |
|
785 | - { |
|
783 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
784 | + if (!is_string($pilot_name)) |
|
785 | + { |
|
786 | 786 | return false; |
787 | - } else { |
|
787 | + } else { |
|
788 | 788 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
789 | - } |
|
789 | + } |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | if ($pilot_id != "") |
793 | 793 | { |
794 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
795 | - if (!is_string($pilot_id)) |
|
796 | - { |
|
794 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
795 | + if (!is_string($pilot_id)) |
|
796 | + { |
|
797 | 797 | return false; |
798 | - } else { |
|
798 | + } else { |
|
799 | 799 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
800 | - } |
|
800 | + } |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | if ($departure_airport_route != "") |
804 | 804 | { |
805 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
806 | - if (!is_string($departure_airport_route)) |
|
807 | - { |
|
805 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
806 | + if (!is_string($departure_airport_route)) |
|
807 | + { |
|
808 | 808 | return false; |
809 | - } else { |
|
809 | + } else { |
|
810 | 810 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
811 | - } |
|
811 | + } |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | if ($arrival_airport_route != "") |
815 | 815 | { |
816 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
817 | - if (!is_string($arrival_airport_route)) |
|
818 | - { |
|
816 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
817 | + if (!is_string($arrival_airport_route)) |
|
818 | + { |
|
819 | 819 | return false; |
820 | - } else { |
|
820 | + } else { |
|
821 | 821 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
822 | - } |
|
822 | + } |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | if ($altitude != "") |
826 | 826 | { |
827 | - $altitude_array = explode(",", $altitude); |
|
827 | + $altitude_array = explode(",", $altitude); |
|
828 | 828 | |
829 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
830 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
829 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
830 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
831 | 831 | |
832 | 832 | |
833 | - if ($altitude_array[1] != "") |
|
834 | - { |
|
833 | + if ($altitude_array[1] != "") |
|
834 | + { |
|
835 | 835 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
836 | 836 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
837 | 837 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
838 | - } else { |
|
838 | + } else { |
|
839 | 839 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
840 | 840 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
841 | - } |
|
841 | + } |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | if ($date_posted != "") |
845 | 845 | { |
846 | - $date_array = explode(",", $date_posted); |
|
846 | + $date_array = explode(",", $date_posted); |
|
847 | 847 | |
848 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
849 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
848 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
849 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
850 | 850 | |
851 | - if ($globalTimezone != '') { |
|
851 | + if ($globalTimezone != '') { |
|
852 | 852 | date_default_timezone_set($globalTimezone); |
853 | 853 | $datetime = new DateTime(); |
854 | 854 | $offset = $datetime->format('P'); |
855 | - } else $offset = '+00:00'; |
|
855 | + } else $offset = '+00:00'; |
|
856 | 856 | |
857 | 857 | |
858 | - if ($date_array[1] != "") |
|
859 | - { |
|
858 | + if ($date_array[1] != "") |
|
859 | + { |
|
860 | 860 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
861 | 861 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
862 | 862 | if ($globalDBdriver == 'mysql') { |
@@ -864,28 +864,28 @@ discard block |
||
864 | 864 | } else { |
865 | 865 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
866 | 866 | } |
867 | - } else { |
|
867 | + } else { |
|
868 | 868 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
869 | - if ($globalDBdriver == 'mysql') { |
|
869 | + if ($globalDBdriver == 'mysql') { |
|
870 | 870 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
871 | 871 | } else { |
872 | 872 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
873 | 873 | } |
874 | - } |
|
874 | + } |
|
875 | 875 | } |
876 | 876 | |
877 | 877 | if ($limit != "") |
878 | 878 | { |
879 | - $limit_array = explode(",", $limit); |
|
879 | + $limit_array = explode(",", $limit); |
|
880 | 880 | |
881 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
882 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
881 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
882 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
883 | 883 | |
884 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
885 | - { |
|
884 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
885 | + { |
|
886 | 886 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
887 | 887 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
888 | - } |
|
888 | + } |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | |
@@ -916,33 +916,33 @@ discard block |
||
916 | 916 | $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
917 | 917 | |
918 | 918 | return $spotter_array; |
919 | - } |
|
919 | + } |
|
920 | 920 | |
921 | - public function deleteSpotterArchiveData() |
|
922 | - { |
|
921 | + public function deleteSpotterArchiveData() |
|
922 | + { |
|
923 | 923 | global $globalArchiveKeepMonths, $globalDBdriver; |
924 | - date_default_timezone_set('UTC'); |
|
925 | - if ($globalDBdriver == 'mysql') { |
|
924 | + date_default_timezone_set('UTC'); |
|
925 | + if ($globalDBdriver == 'mysql') { |
|
926 | 926 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
927 | 927 | } else { |
928 | 928 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
929 | 929 | } |
930 | - try { |
|
931 | - $sth = $this->db->prepare($query); |
|
932 | - $sth->execute(); |
|
933 | - } catch(PDOException $e) { |
|
934 | - return "error"; |
|
935 | - } |
|
930 | + try { |
|
931 | + $sth = $this->db->prepare($query); |
|
932 | + $sth->execute(); |
|
933 | + } catch(PDOException $e) { |
|
934 | + return "error"; |
|
935 | + } |
|
936 | 936 | } |
937 | 937 | |
938 | - /** |
|
939 | - * Gets all the spotter information based on the callsign |
|
940 | - * |
|
941 | - * @return Array the spotter information |
|
942 | - * |
|
943 | - */ |
|
944 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
945 | - { |
|
938 | + /** |
|
939 | + * Gets all the spotter information based on the callsign |
|
940 | + * |
|
941 | + * @return Array the spotter information |
|
942 | + * |
|
943 | + */ |
|
944 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
945 | + { |
|
946 | 946 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
947 | 947 | |
948 | 948 | date_default_timezone_set('UTC'); |
@@ -954,35 +954,35 @@ discard block |
||
954 | 954 | |
955 | 955 | if ($ident != "") |
956 | 956 | { |
957 | - if (!is_string($ident)) |
|
958 | - { |
|
957 | + if (!is_string($ident)) |
|
958 | + { |
|
959 | 959 | return false; |
960 | - } else { |
|
960 | + } else { |
|
961 | 961 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
962 | 962 | $query_values = array(':ident' => $ident); |
963 | - } |
|
963 | + } |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | if ($limit != "") |
967 | 967 | { |
968 | - $limit_array = explode(",", $limit); |
|
968 | + $limit_array = explode(",", $limit); |
|
969 | 969 | |
970 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
971 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
970 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
971 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
972 | 972 | |
973 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
974 | - { |
|
973 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
974 | + { |
|
975 | 975 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
976 | 976 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
977 | - } |
|
977 | + } |
|
978 | 978 | } |
979 | 979 | |
980 | 980 | if ($sort != "") |
981 | 981 | { |
982 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
983 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
982 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
983 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
984 | 984 | } else { |
985 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
985 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -990,17 +990,17 @@ discard block |
||
990 | 990 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
991 | 991 | |
992 | 992 | return $spotter_array; |
993 | - } |
|
993 | + } |
|
994 | 994 | |
995 | 995 | |
996 | - /** |
|
997 | - * Gets all the spotter information based on the owner |
|
998 | - * |
|
999 | - * @return Array the spotter information |
|
1000 | - * |
|
1001 | - */ |
|
1002 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
1003 | - { |
|
996 | + /** |
|
997 | + * Gets all the spotter information based on the owner |
|
998 | + * |
|
999 | + * @return Array the spotter information |
|
1000 | + * |
|
1001 | + */ |
|
1002 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
1003 | + { |
|
1004 | 1004 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
1005 | 1005 | |
1006 | 1006 | date_default_timezone_set('UTC'); |
@@ -1013,35 +1013,35 @@ discard block |
||
1013 | 1013 | |
1014 | 1014 | if ($owner != "") |
1015 | 1015 | { |
1016 | - if (!is_string($owner)) |
|
1017 | - { |
|
1016 | + if (!is_string($owner)) |
|
1017 | + { |
|
1018 | 1018 | return false; |
1019 | - } else { |
|
1019 | + } else { |
|
1020 | 1020 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
1021 | 1021 | $query_values = array(':owner' => $owner); |
1022 | - } |
|
1022 | + } |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | if ($limit != "") |
1026 | 1026 | { |
1027 | - $limit_array = explode(",", $limit); |
|
1027 | + $limit_array = explode(",", $limit); |
|
1028 | 1028 | |
1029 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1030 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1029 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1030 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1031 | 1031 | |
1032 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1033 | - { |
|
1032 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1033 | + { |
|
1034 | 1034 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1035 | 1035 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1036 | - } |
|
1036 | + } |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | if ($sort != "") |
1040 | 1040 | { |
1041 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1042 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1041 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1042 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1043 | 1043 | } else { |
1044 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1044 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | $query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1049,16 +1049,16 @@ discard block |
||
1049 | 1049 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1050 | 1050 | |
1051 | 1051 | return $spotter_array; |
1052 | - } |
|
1053 | - |
|
1054 | - /** |
|
1055 | - * Gets all the spotter information based on the pilot |
|
1056 | - * |
|
1057 | - * @return Array the spotter information |
|
1058 | - * |
|
1059 | - */ |
|
1060 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1061 | - { |
|
1052 | + } |
|
1053 | + |
|
1054 | + /** |
|
1055 | + * Gets all the spotter information based on the pilot |
|
1056 | + * |
|
1057 | + * @return Array the spotter information |
|
1058 | + * |
|
1059 | + */ |
|
1060 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1061 | + { |
|
1062 | 1062 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
1063 | 1063 | |
1064 | 1064 | date_default_timezone_set('UTC'); |
@@ -1077,24 +1077,24 @@ discard block |
||
1077 | 1077 | |
1078 | 1078 | if ($limit != "") |
1079 | 1079 | { |
1080 | - $limit_array = explode(",", $limit); |
|
1080 | + $limit_array = explode(",", $limit); |
|
1081 | 1081 | |
1082 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1083 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1082 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1083 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1084 | 1084 | |
1085 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1086 | - { |
|
1085 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1086 | + { |
|
1087 | 1087 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1088 | 1088 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1089 | - } |
|
1089 | + } |
|
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | if ($sort != "") |
1093 | 1093 | { |
1094 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1095 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1094 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1095 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1096 | 1096 | } else { |
1097 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1097 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1098 | 1098 | } |
1099 | 1099 | |
1100 | 1100 | $query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1102,16 +1102,16 @@ discard block |
||
1102 | 1102 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1103 | 1103 | |
1104 | 1104 | return $spotter_array; |
1105 | - } |
|
1106 | - |
|
1107 | - /** |
|
1108 | - * Gets all number of flight over countries |
|
1109 | - * |
|
1110 | - * @return Array the airline country list |
|
1111 | - * |
|
1112 | - */ |
|
1113 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1114 | - { |
|
1105 | + } |
|
1106 | + |
|
1107 | + /** |
|
1108 | + * Gets all number of flight over countries |
|
1109 | + * |
|
1110 | + * @return Array the airline country list |
|
1111 | + * |
|
1112 | + */ |
|
1113 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1114 | + { |
|
1115 | 1115 | global $globalDBdriver; |
1116 | 1116 | /* |
1117 | 1117 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1121,14 +1121,14 @@ discard block |
||
1121 | 1121 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1122 | 1122 | FROM countries c, spotter_archive s |
1123 | 1123 | WHERE c.iso2 = s.over_country "; |
1124 | - if ($olderthanmonths > 0) { |
|
1125 | - if ($globalDBdriver == 'mysql') { |
|
1124 | + if ($olderthanmonths > 0) { |
|
1125 | + if ($globalDBdriver == 'mysql') { |
|
1126 | 1126 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1127 | 1127 | } else { |
1128 | 1128 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1129 | 1129 | } |
1130 | 1130 | } |
1131 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1131 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1132 | 1132 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1133 | 1133 | if ($limit) $query .= " LIMIT 0,10"; |
1134 | 1134 | |
@@ -1141,23 +1141,23 @@ discard block |
||
1141 | 1141 | |
1142 | 1142 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1143 | 1143 | { |
1144 | - $temp_array['flight_count'] = $row['nb']; |
|
1145 | - $temp_array['flight_country'] = $row['name']; |
|
1146 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1147 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1148 | - $flight_array[] = $temp_array; |
|
1144 | + $temp_array['flight_count'] = $row['nb']; |
|
1145 | + $temp_array['flight_country'] = $row['name']; |
|
1146 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1147 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1148 | + $flight_array[] = $temp_array; |
|
1149 | 1149 | } |
1150 | 1150 | return $flight_array; |
1151 | - } |
|
1152 | - |
|
1153 | - /** |
|
1154 | - * Gets all number of flight over countries |
|
1155 | - * |
|
1156 | - * @return Array the airline country list |
|
1157 | - * |
|
1158 | - */ |
|
1159 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1160 | - { |
|
1151 | + } |
|
1152 | + |
|
1153 | + /** |
|
1154 | + * Gets all number of flight over countries |
|
1155 | + * |
|
1156 | + * @return Array the airline country list |
|
1157 | + * |
|
1158 | + */ |
|
1159 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1160 | + { |
|
1161 | 1161 | global $globalDBdriver; |
1162 | 1162 | /* |
1163 | 1163 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1167,14 +1167,14 @@ discard block |
||
1167 | 1167 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1168 | 1168 | FROM countries c, spotter_archive s, spotter_output o |
1169 | 1169 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id "; |
1170 | - if ($olderthanmonths > 0) { |
|
1171 | - if ($globalDBdriver == 'mysql') { |
|
1170 | + if ($olderthanmonths > 0) { |
|
1171 | + if ($globalDBdriver == 'mysql') { |
|
1172 | 1172 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1173 | 1173 | } else { |
1174 | 1174 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1175 | 1175 | } |
1176 | 1176 | } |
1177 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1177 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1178 | 1178 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1179 | 1179 | if ($limit) $query .= " LIMIT 0,10"; |
1180 | 1180 | |
@@ -1187,24 +1187,24 @@ discard block |
||
1187 | 1187 | |
1188 | 1188 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1189 | 1189 | { |
1190 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1191 | - $temp_array['flight_count'] = $row['nb']; |
|
1192 | - $temp_array['flight_country'] = $row['name']; |
|
1193 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1194 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1195 | - $flight_array[] = $temp_array; |
|
1190 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1191 | + $temp_array['flight_count'] = $row['nb']; |
|
1192 | + $temp_array['flight_country'] = $row['name']; |
|
1193 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1194 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1195 | + $flight_array[] = $temp_array; |
|
1196 | 1196 | } |
1197 | 1197 | return $flight_array; |
1198 | - } |
|
1199 | - |
|
1200 | - /** |
|
1201 | - * Gets last spotter information based on a particular callsign |
|
1202 | - * |
|
1203 | - * @return Array the spotter information |
|
1204 | - * |
|
1205 | - */ |
|
1206 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1207 | - { |
|
1198 | + } |
|
1199 | + |
|
1200 | + /** |
|
1201 | + * Gets last spotter information based on a particular callsign |
|
1202 | + * |
|
1203 | + * @return Array the spotter information |
|
1204 | + * |
|
1205 | + */ |
|
1206 | + public function getDateArchiveSpotterDataById($id,$date) |
|
1207 | + { |
|
1208 | 1208 | $Spotter = new Spotter($this->db); |
1209 | 1209 | date_default_timezone_set('UTC'); |
1210 | 1210 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1212,16 +1212,16 @@ discard block |
||
1212 | 1212 | $date = date('c',$date); |
1213 | 1213 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1214 | 1214 | return $spotter_array; |
1215 | - } |
|
1216 | - |
|
1217 | - /** |
|
1218 | - * Gets all the spotter information based on a particular callsign |
|
1219 | - * |
|
1220 | - * @return Array the spotter information |
|
1221 | - * |
|
1222 | - */ |
|
1223 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1224 | - { |
|
1215 | + } |
|
1216 | + |
|
1217 | + /** |
|
1218 | + * Gets all the spotter information based on a particular callsign |
|
1219 | + * |
|
1220 | + * @return Array the spotter information |
|
1221 | + * |
|
1222 | + */ |
|
1223 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1224 | + { |
|
1225 | 1225 | $Spotter = new Spotter($this->db); |
1226 | 1226 | date_default_timezone_set('UTC'); |
1227 | 1227 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1229,16 +1229,16 @@ discard block |
||
1229 | 1229 | $date = date('c',$date); |
1230 | 1230 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1231 | 1231 | return $spotter_array; |
1232 | - } |
|
1233 | - |
|
1234 | - /** |
|
1235 | - * Gets all the spotter information based on the airport |
|
1236 | - * |
|
1237 | - * @return Array the spotter information |
|
1238 | - * |
|
1239 | - */ |
|
1240 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1241 | - { |
|
1232 | + } |
|
1233 | + |
|
1234 | + /** |
|
1235 | + * Gets all the spotter information based on the airport |
|
1236 | + * |
|
1237 | + * @return Array the spotter information |
|
1238 | + * |
|
1239 | + */ |
|
1240 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1241 | + { |
|
1242 | 1242 | global $global_query; |
1243 | 1243 | $Spotter = new Spotter(); |
1244 | 1244 | date_default_timezone_set('UTC'); |
@@ -1249,35 +1249,35 @@ discard block |
||
1249 | 1249 | |
1250 | 1250 | if ($airport != "") |
1251 | 1251 | { |
1252 | - if (!is_string($airport)) |
|
1253 | - { |
|
1252 | + if (!is_string($airport)) |
|
1253 | + { |
|
1254 | 1254 | return false; |
1255 | - } else { |
|
1255 | + } else { |
|
1256 | 1256 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
1257 | 1257 | $query_values = array(':airport' => $airport); |
1258 | - } |
|
1258 | + } |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | if ($limit != "") |
1262 | 1262 | { |
1263 | - $limit_array = explode(",", $limit); |
|
1263 | + $limit_array = explode(",", $limit); |
|
1264 | 1264 | |
1265 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1266 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1265 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1266 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1267 | 1267 | |
1268 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1269 | - { |
|
1268 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1269 | + { |
|
1270 | 1270 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1271 | 1271 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1272 | - } |
|
1272 | + } |
|
1273 | 1273 | } |
1274 | 1274 | |
1275 | 1275 | if ($sort != "") |
1276 | 1276 | { |
1277 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1278 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1277 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1278 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1279 | 1279 | } else { |
1280 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1280 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1281 | 1281 | } |
1282 | 1282 | |
1283 | 1283 | $query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1285,6 +1285,6 @@ discard block |
||
1285 | 1285 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1286 | 1286 | |
1287 | 1287 | return $spotter_array; |
1288 | - } |
|
1288 | + } |
|
1289 | 1289 | } |
1290 | 1290 | ?> |
1291 | 1291 | \ No newline at end of file |
@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Stats.php'); |
10 | 10 | require_once(dirname(__FILE__).'/class.Source.php'); |
11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | class MarineImport { |
16 | - private $all_tracked = array(); |
|
17 | - private $last_delete_hourly = 0; |
|
18 | - private $last_delete = 0; |
|
19 | - private $stats = array(); |
|
20 | - private $tmd = 0; |
|
21 | - private $source_location = array(); |
|
22 | - public $db = null; |
|
23 | - public $nb = 0; |
|
16 | + private $all_tracked = array(); |
|
17 | + private $last_delete_hourly = 0; |
|
18 | + private $last_delete = 0; |
|
19 | + private $stats = array(); |
|
20 | + private $tmd = 0; |
|
21 | + private $source_location = array(); |
|
22 | + public $db = null; |
|
23 | + public $nb = 0; |
|
24 | 24 | |
25 | - public function __construct($dbc = null) { |
|
25 | + public function __construct($dbc = null) { |
|
26 | 26 | global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB; |
27 | 27 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
28 | - $Connection = new Connection($dbc); |
|
29 | - $this->db = $Connection->db(); |
|
30 | - date_default_timezone_set('UTC'); |
|
28 | + $Connection = new Connection($dbc); |
|
29 | + $this->db = $Connection->db(); |
|
30 | + date_default_timezone_set('UTC'); |
|
31 | 31 | } |
32 | 32 | // Get previous source stats |
33 | 33 | /* |
@@ -46,55 +46,55 @@ discard block |
||
46 | 46 | } |
47 | 47 | */ |
48 | 48 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
49 | - $APRSMarine = new APRSMarine(); |
|
50 | - //$APRSSpotter->connect(); |
|
49 | + $APRSMarine = new APRSMarine(); |
|
50 | + //$APRSSpotter->connect(); |
|
51 | + } |
|
51 | 52 | } |
52 | - } |
|
53 | 53 | |
54 | - public function checkAll() { |
|
54 | + public function checkAll() { |
|
55 | 55 | global $globalDebug; |
56 | 56 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
57 | 57 | foreach ($this->all_tracked as $key => $flight) { |
58 | - if (isset($this->all_tracked[$key]['id'])) { |
|
58 | + if (isset($this->all_tracked[$key]['id'])) { |
|
59 | 59 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
60 | - $Marine = new Marine($this->db); |
|
61 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
62 | - } |
|
60 | + $Marine = new Marine($this->db); |
|
61 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
62 | + } |
|
63 | + } |
|
63 | 64 | } |
64 | - } |
|
65 | 65 | |
66 | - public function del() { |
|
66 | + public function del() { |
|
67 | 67 | global $globalDebug, $globalNoDB, $globalNoImport; |
68 | 68 | // Delete old infos |
69 | 69 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
70 | 70 | foreach ($this->all_tracked as $key => $flight) { |
71 | - if (isset($flight['lastupdate'])) { |
|
72 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
73 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
74 | - if (isset($this->all_tracked[$key]['id'])) { |
|
75 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
76 | - /* |
|
71 | + if (isset($flight['lastupdate'])) { |
|
72 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
73 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
74 | + if (isset($this->all_tracked[$key]['id'])) { |
|
75 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
76 | + /* |
|
77 | 77 | $MarineLive = new MarineLive(); |
78 | 78 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
79 | 79 | $MarineLive->db = null; |
80 | 80 | */ |
81 | - //$real_arrival = $this->arrival($key); |
|
82 | - $Marine = new Marine($this->db); |
|
83 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
81 | + //$real_arrival = $this->arrival($key); |
|
82 | + $Marine = new Marine($this->db); |
|
83 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
84 | 84 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
85 | 85 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
86 | - } |
|
87 | - // Put in archive |
|
86 | + } |
|
87 | + // Put in archive |
|
88 | 88 | // $Marine->db = null; |
89 | 89 | } |
90 | - } |
|
91 | - unset($this->all_tracked[$key]); |
|
92 | - } |
|
93 | - } |
|
94 | - } |
|
95 | - } |
|
90 | + } |
|
91 | + unset($this->all_tracked[$key]); |
|
92 | + } |
|
93 | + } |
|
94 | + } |
|
95 | + } |
|
96 | 96 | |
97 | - public function add($line) { |
|
97 | + public function add($line) { |
|
98 | 98 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
99 | 99 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
100 | 100 | date_default_timezone_set('UTC'); |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | |
104 | 104 | // SBS format is CSV format |
105 | 105 | if(is_array($line) && isset($line['mmsi'])) { |
106 | - //print_r($line); |
|
107 | - if (isset($line['mmsi'])) { |
|
106 | + //print_r($line); |
|
107 | + if (isset($line['mmsi'])) { |
|
108 | 108 | |
109 | 109 | /* |
110 | 110 | // Increment message number |
@@ -121,64 +121,64 @@ discard block |
||
121 | 121 | |
122 | 122 | $Common = new Common(); |
123 | 123 | $AIS = new AIS(); |
124 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
125 | - else $id = trim($line['id']); |
|
124 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
125 | + else $id = trim($line['id']); |
|
126 | 126 | |
127 | 127 | if (!isset($this->all_tracked[$id])) { |
128 | - $this->all_tracked[$id] = array(); |
|
129 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
130 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
131 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
132 | - if (!isset($line['id'])) { |
|
128 | + $this->all_tracked[$id] = array(); |
|
129 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
130 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
131 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
132 | + if (!isset($line['id'])) { |
|
133 | 133 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
134 | 134 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
135 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
136 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
135 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
136 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
140 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
141 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
140 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
141 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
142 | 142 | $Marine = new Marine($this->db); |
143 | 143 | $identity = $Marine->getIdentity($line['mmsi']); |
144 | 144 | if (!empty($identity)) { |
145 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
146 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
145 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
146 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
147 | 147 | } |
148 | 148 | //print_r($identity); |
149 | 149 | unset($Marine); |
150 | 150 | //$dataFound = true; |
151 | - } |
|
151 | + } |
|
152 | 152 | } |
153 | 153 | if (isset($line['type_id']) && $line['type_id'] != '') { |
154 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
154 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
155 | 155 | } |
156 | 156 | if (isset($line['type']) && $line['type'] != '') { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
158 | 158 | } |
159 | 159 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
160 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
160 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
161 | 161 | } |
162 | 162 | if (isset($line['imo']) && $line['imo'] != '') { |
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
164 | 164 | } |
165 | 165 | if (isset($line['callsign']) && $line['callsign'] != '') { |
166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
167 | 167 | } |
168 | 168 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
170 | 170 | } |
171 | 171 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
172 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
172 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
176 | 176 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
177 | 177 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
178 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
179 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
178 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
179 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
180 | 180 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
181 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
181 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
182 | 182 | $timeelapsed = microtime(true); |
183 | 183 | $Marine = new Marine($this->db); |
184 | 184 | $fromsource = NULL; |
@@ -186,31 +186,31 @@ discard block |
||
186 | 186 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
187 | 187 | $Marine->db = null; |
188 | 188 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
189 | - } |
|
189 | + } |
|
190 | 190 | } |
191 | - } |
|
192 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
191 | + } |
|
192 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | if (isset($line['speed']) && $line['speed'] != '') { |
196 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
197 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
196 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
197 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
198 | 198 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
199 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
200 | - if ($distance > 1000 && $distance < 10000) { |
|
199 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
200 | + if ($distance > 1000 && $distance < 10000) { |
|
201 | 201 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
202 | 202 | $speed = $speed*3.6; |
203 | 203 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
204 | 204 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
205 | - } |
|
205 | + } |
|
206 | 206 | } |
207 | 207 | |
208 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
209 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
210 | - else unset($timediff); |
|
211 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
208 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
209 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
210 | + else unset($timediff); |
|
211 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
212 | 212 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
213 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
213 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
214 | 214 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
215 | 215 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
216 | 216 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -218,84 +218,84 @@ discard block |
||
218 | 218 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
219 | 219 | $timeelapsed = microtime(true); |
220 | 220 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
221 | - $Marine = new Marine($this->db); |
|
222 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
223 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
224 | - $Marine->db = null; |
|
225 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
221 | + $Marine = new Marine($this->db); |
|
222 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
223 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
224 | + $Marine->db = null; |
|
225 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
226 | 226 | } |
227 | 227 | $this->tmd = 0; |
228 | 228 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
229 | - } |
|
229 | + } |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
233 | 233 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
234 | 234 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
235 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
236 | - $dataFound = true; |
|
237 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
235 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
236 | + $dataFound = true; |
|
237 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
238 | 238 | } |
239 | 239 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
240 | 240 | } |
241 | 241 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
242 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
242 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
243 | 243 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
244 | 244 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
245 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
246 | - $dataFound = true; |
|
247 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
245 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
246 | + $dataFound = true; |
|
247 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
248 | 248 | } |
249 | 249 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
250 | 250 | } |
251 | 251 | |
252 | - } else if ($globalDebug && $timediff > 20) { |
|
252 | + } else if ($globalDebug && $timediff > 20) { |
|
253 | 253 | $this->tmd = $this->tmd + 1; |
254 | 254 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
255 | 255 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
256 | 256 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
257 | 257 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
258 | - } |
|
258 | + } |
|
259 | 259 | } |
260 | 260 | if (isset($line['last_update']) && $line['last_update'] != '') { |
261 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
261 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
263 | 263 | } |
264 | 264 | if (isset($line['format_source']) && $line['format_source'] != '') { |
265 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
265 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
266 | 266 | } |
267 | 267 | if (isset($line['source_name']) && $line['source_name'] != '') { |
268 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
268 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
269 | 269 | } |
270 | 270 | if (isset($line['status']) && $line['status'] != '') { |
271 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
271 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
275 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
275 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | if (isset($line['heading']) && $line['heading'] != '') { |
279 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
280 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
281 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
282 | - //$dataFound = true; |
|
279 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
280 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
281 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
282 | + //$dataFound = true; |
|
283 | 283 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
284 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
285 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
286 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
287 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
284 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
285 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
286 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
287 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
288 | 288 | } |
289 | 289 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
290 | 290 | |
291 | 291 | if (isset($line['datetime'])) { |
292 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
292 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
293 | 293 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
294 | - } else { |
|
294 | + } else { |
|
295 | 295 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
296 | 296 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
297 | 297 | return ''; |
298 | - } |
|
298 | + } |
|
299 | 299 | } else { |
300 | 300 | date_default_timezone_set('UTC'); |
301 | 301 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -303,50 +303,50 @@ discard block |
||
303 | 303 | |
304 | 304 | |
305 | 305 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
306 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
307 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
308 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
309 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
306 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
307 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
308 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
309 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
310 | 310 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
311 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
312 | - $timeelapsed = microtime(true); |
|
313 | - $MarineLive = new MarineLive($this->db); |
|
314 | - if (isset($line['id'])) { |
|
311 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
312 | + $timeelapsed = microtime(true); |
|
313 | + $MarineLive = new MarineLive($this->db); |
|
314 | + if (isset($line['id'])) { |
|
315 | 315 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
316 | 316 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
317 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
317 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
318 | 318 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
319 | 319 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
320 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
320 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
321 | 321 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
322 | 322 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
323 | - } else $recent_ident = ''; |
|
324 | - $MarineLive->db=null; |
|
325 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
326 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
323 | + } else $recent_ident = ''; |
|
324 | + $MarineLive->db=null; |
|
325 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
326 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
327 | 327 | } else $recent_ident = ''; |
328 | - } else { |
|
328 | + } else { |
|
329 | 329 | $recent_ident = ''; |
330 | 330 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
331 | - } |
|
332 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
333 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
334 | - { |
|
331 | + } |
|
332 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
333 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
334 | + { |
|
335 | 335 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
336 | 336 | //adds the spotter data for the archive |
337 | - $highlight = ''; |
|
338 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
339 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
337 | + $highlight = ''; |
|
338 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
339 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
340 | 340 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
341 | - $timeelapsed = microtime(true); |
|
342 | - $Marine = new Marine($this->db); |
|
343 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
344 | - $Marine->db = null; |
|
345 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
346 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
341 | + $timeelapsed = microtime(true); |
|
342 | + $Marine = new Marine($this->db); |
|
343 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
344 | + $Marine->db = null; |
|
345 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
346 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
347 | 347 | } |
348 | - } |
|
349 | - /* |
|
348 | + } |
|
349 | + /* |
|
350 | 350 | // Add source stat in DB |
351 | 351 | $Stats = new Stats($this->db); |
352 | 352 | if (!empty($this->stats)) { |
@@ -373,56 +373,56 @@ discard block |
||
373 | 373 | } |
374 | 374 | $Stats->db = null; |
375 | 375 | */ |
376 | - $this->del(); |
|
376 | + $this->del(); |
|
377 | 377 | //$ignoreImport = false; |
378 | 378 | $this->all_tracked[$id]['addedMarine'] = 1; |
379 | 379 | //print_r($this->all_tracked[$id]); |
380 | 380 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
381 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
382 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
383 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
381 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
382 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
383 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
384 | 384 | $MarineLive = new MarineLive($this->db); |
385 | 385 | $MarineLive->deleteLiveMarineData(); |
386 | 386 | $MarineLive->db=null; |
387 | 387 | if ($globalDebug) echo " Done\n"; |
388 | - } |
|
389 | - $this->last_delete = time(); |
|
388 | + } |
|
389 | + $this->last_delete = time(); |
|
390 | 390 | } |
391 | - } elseif ($recent_ident != '') { |
|
391 | + } elseif ($recent_ident != '') { |
|
392 | 392 | $this->all_tracked[$id]['id'] = $recent_ident; |
393 | 393 | $this->all_tracked[$id]['addedMarine'] = 1; |
394 | 394 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
395 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
395 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
396 | 396 | $Marine = new Marine($this->db); |
397 | 397 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
398 | 398 | $Marine->db = null; |
399 | - } |
|
399 | + } |
|
400 | 400 | } |
401 | 401 | |
402 | - } |
|
402 | + } |
|
403 | 403 | } |
404 | - } |
|
405 | - //adds the spotter LIVE data |
|
406 | - if ($globalDebug) { |
|
404 | + } |
|
405 | + //adds the spotter LIVE data |
|
406 | + if ($globalDebug) { |
|
407 | 407 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
408 | - } |
|
409 | - $ignoreImport = false; |
|
408 | + } |
|
409 | + $ignoreImport = false; |
|
410 | 410 | |
411 | - if (!$ignoreImport) { |
|
411 | + if (!$ignoreImport) { |
|
412 | 412 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
413 | 413 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
414 | 414 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
415 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
415 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
416 | 416 | $timeelapsed = microtime(true); |
417 | 417 | $MarineLive = new MarineLive($this->db); |
418 | 418 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
419 | 419 | $MarineLive->db = null; |
420 | 420 | if ($globalDebug) echo $result."\n"; |
421 | 421 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
422 | - } |
|
422 | + } |
|
423 | 423 | } |
424 | 424 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
425 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
425 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
426 | 426 | } |
427 | 427 | $this->all_tracked[$id]['putinarchive'] = false; |
428 | 428 | |
@@ -487,24 +487,24 @@ discard block |
||
487 | 487 | |
488 | 488 | |
489 | 489 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
490 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
490 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
491 | 491 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
492 | 492 | $MarineLive = new MarineLive($this->db); |
493 | 493 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
494 | 494 | $MarineLive->db = null; |
495 | 495 | //MarineLive->deleteLiveMarineData(); |
496 | 496 | if ($globalDebug) echo " Done\n"; |
497 | - } |
|
498 | - $this->last_delete_hourly = time(); |
|
497 | + } |
|
498 | + $this->last_delete_hourly = time(); |
|
499 | 499 | } |
500 | 500 | |
501 | - } |
|
502 | - //$ignoreImport = false; |
|
501 | + } |
|
502 | + //$ignoreImport = false; |
|
503 | 503 | } |
504 | 504 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
505 | 505 | if ($send) return $this->all_tracked[$id]; |
506 | - } |
|
506 | + } |
|
507 | + } |
|
507 | 508 | } |
508 | - } |
|
509 | 509 | } |
510 | 510 | ?> |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * Gets all the spotter information based on the latest data entry |
|
90 | - * |
|
91 | - * @return Array the spotter information |
|
92 | - * |
|
93 | - */ |
|
89 | + * Gets all the spotter information based on the latest data entry |
|
90 | + * |
|
91 | + * @return Array the spotter information |
|
92 | + * |
|
93 | + */ |
|
94 | 94 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
95 | 95 | { |
96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Gets Minimal Live Spotter data |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
135 | + * Gets Minimal Live Spotter data |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | 140 | public function getMinLiveMarineData($filter = array()) |
141 | 141 | { |
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | - * Gets Minimal Live Spotter data since xx seconds |
|
170 | - * |
|
171 | - * @return Array the spotter information |
|
172 | - * |
|
173 | - */ |
|
169 | + * Gets Minimal Live Spotter data since xx seconds |
|
170 | + * |
|
171 | + * @return Array the spotter information |
|
172 | + * |
|
173 | + */ |
|
174 | 174 | public function getMinLastLiveMarineData($filter = array()) |
175 | 175 | { |
176 | 176 | global $globalDBdriver, $globalLiveInterval; |
@@ -183,13 +183,13 @@ discard block |
||
183 | 183 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
184 | 184 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
185 | 185 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
186 | - } else { |
|
186 | + } else { |
|
187 | 187 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
188 | 188 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
189 | 189 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
190 | 190 | } |
191 | 191 | |
192 | - try { |
|
192 | + try { |
|
193 | 193 | $sth = $this->db->prepare($query); |
194 | 194 | $sth->execute(); |
195 | 195 | } catch(PDOException $e) { |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
204 | - * Gets number of latest data entry |
|
205 | - * |
|
206 | - * @return String number of entry |
|
207 | - * |
|
208 | - */ |
|
204 | + * Gets number of latest data entry |
|
205 | + * |
|
206 | + * @return String number of entry |
|
207 | + * |
|
208 | + */ |
|
209 | 209 | public function getLiveMarineCount($filter = array()) |
210 | 210 | { |
211 | 211 | global $globalDBdriver, $globalLiveInterval; |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
233 | - * Gets all the spotter information based on the latest data entry and coord |
|
234 | - * |
|
235 | - * @return Array the spotter information |
|
236 | - * |
|
237 | - */ |
|
233 | + * Gets all the spotter information based on the latest data entry and coord |
|
234 | + * |
|
235 | + * @return Array the spotter information |
|
236 | + * |
|
237 | + */ |
|
238 | 238 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
239 | 239 | { |
240 | 240 | global $globalDBdriver, $globalLiveInterval; |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
261 | - * Gets all the spotter information based on the latest data entry and coord |
|
262 | - * |
|
263 | - * @return Array the spotter information |
|
264 | - * |
|
265 | - */ |
|
261 | + * Gets all the spotter information based on the latest data entry and coord |
|
262 | + * |
|
263 | + * @return Array the spotter information |
|
264 | + * |
|
265 | + */ |
|
266 | 266 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
267 | 267 | { |
268 | 268 | global $globalDBdriver, $globalLiveInterval; |
@@ -290,11 +290,11 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
293 | - * Gets all the spotter information based on a user's latitude and longitude |
|
294 | - * |
|
295 | - * @return Array the spotter information |
|
296 | - * |
|
297 | - */ |
|
293 | + * Gets all the spotter information based on a user's latitude and longitude |
|
294 | + * |
|
295 | + * @return Array the spotter information |
|
296 | + * |
|
297 | + */ |
|
298 | 298 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
299 | 299 | { |
300 | 300 | $Marine = new Marine($this->db); |
@@ -307,134 +307,134 @@ discard block |
||
307 | 307 | if ($lng != '') |
308 | 308 | { |
309 | 309 | if (!is_numeric($lng)) |
310 | - { |
|
311 | - return false; |
|
312 | - } |
|
313 | - } |
|
314 | - |
|
315 | - if ($radius != '') |
|
316 | - { |
|
317 | - if (!is_numeric($radius)) |
|
318 | - { |
|
319 | - return false; |
|
320 | - } |
|
321 | - } |
|
310 | + { |
|
311 | + return false; |
|
312 | + } |
|
313 | + } |
|
314 | + |
|
315 | + if ($radius != '') |
|
316 | + { |
|
317 | + if (!is_numeric($radius)) |
|
318 | + { |
|
319 | + return false; |
|
320 | + } |
|
321 | + } |
|
322 | 322 | $additional_query = ''; |
323 | 323 | if ($interval != '') |
324 | - { |
|
325 | - if (!is_string($interval)) |
|
326 | - { |
|
327 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
328 | - return false; |
|
329 | - } else { |
|
330 | - if ($interval == '1m') |
|
331 | - { |
|
332 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
333 | - } else if ($interval == '15m'){ |
|
334 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
335 | - } |
|
336 | - } |
|
337 | - } else { |
|
338 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
339 | - } |
|
340 | - |
|
341 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
324 | + { |
|
325 | + if (!is_string($interval)) |
|
326 | + { |
|
327 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
328 | + return false; |
|
329 | + } else { |
|
330 | + if ($interval == '1m') |
|
331 | + { |
|
332 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
333 | + } else if ($interval == '15m'){ |
|
334 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
335 | + } |
|
336 | + } |
|
337 | + } else { |
|
338 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
339 | + } |
|
340 | + |
|
341 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
342 | 342 | WHERE marine_live.latitude <> '' |
343 | 343 | AND marine_live.longitude <> '' |
344 | 344 | ".$additional_query." |
345 | 345 | HAVING distance < :radius |
346 | 346 | ORDER BY distance"; |
347 | 347 | |
348 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
348 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
349 | 349 | |
350 | - return $spotter_array; |
|
351 | - } |
|
350 | + return $spotter_array; |
|
351 | + } |
|
352 | 352 | |
353 | 353 | |
354 | - /** |
|
355 | - * Gets all the spotter information based on a particular callsign |
|
356 | - * |
|
357 | - * @return Array the spotter information |
|
358 | - * |
|
359 | - */ |
|
354 | + /** |
|
355 | + * Gets all the spotter information based on a particular callsign |
|
356 | + * |
|
357 | + * @return Array the spotter information |
|
358 | + * |
|
359 | + */ |
|
360 | 360 | public function getLastLiveMarineDataByIdent($ident) |
361 | 361 | { |
362 | 362 | $Marine = new Marine($this->db); |
363 | 363 | date_default_timezone_set('UTC'); |
364 | 364 | |
365 | 365 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
366 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
366 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
367 | 367 | |
368 | 368 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
369 | 369 | |
370 | 370 | return $spotter_array; |
371 | 371 | } |
372 | 372 | |
373 | - /** |
|
374 | - * Gets all the spotter information based on a particular callsign |
|
375 | - * |
|
376 | - * @return Array the spotter information |
|
377 | - * |
|
378 | - */ |
|
373 | + /** |
|
374 | + * Gets all the spotter information based on a particular callsign |
|
375 | + * |
|
376 | + * @return Array the spotter information |
|
377 | + * |
|
378 | + */ |
|
379 | 379 | public function getDateLiveMarineDataByIdent($ident,$date) |
380 | 380 | { |
381 | 381 | $Marine = new Marine($this->db); |
382 | 382 | date_default_timezone_set('UTC'); |
383 | 383 | |
384 | 384 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
385 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
385 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
386 | 386 | |
387 | - $date = date('c',$date); |
|
387 | + $date = date('c',$date); |
|
388 | 388 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
389 | 389 | |
390 | 390 | return $spotter_array; |
391 | 391 | } |
392 | 392 | |
393 | - /** |
|
394 | - * Gets last spotter information based on a particular callsign |
|
395 | - * |
|
396 | - * @return Array the spotter information |
|
397 | - * |
|
398 | - */ |
|
393 | + /** |
|
394 | + * Gets last spotter information based on a particular callsign |
|
395 | + * |
|
396 | + * @return Array the spotter information |
|
397 | + * |
|
398 | + */ |
|
399 | 399 | public function getLastLiveMarineDataById($id) |
400 | 400 | { |
401 | 401 | $Marine = new Marine($this->db); |
402 | 402 | date_default_timezone_set('UTC'); |
403 | 403 | |
404 | 404 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
405 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
405 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
406 | 406 | |
407 | 407 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
408 | 408 | |
409 | 409 | return $spotter_array; |
410 | 410 | } |
411 | 411 | |
412 | - /** |
|
413 | - * Gets last spotter information based on a particular callsign |
|
414 | - * |
|
415 | - * @return Array the spotter information |
|
416 | - * |
|
417 | - */ |
|
412 | + /** |
|
413 | + * Gets last spotter information based on a particular callsign |
|
414 | + * |
|
415 | + * @return Array the spotter information |
|
416 | + * |
|
417 | + */ |
|
418 | 418 | public function getDateLiveMarineDataById($id,$date) |
419 | 419 | { |
420 | 420 | $Marine = new Marine($this->db); |
421 | 421 | date_default_timezone_set('UTC'); |
422 | 422 | |
423 | 423 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
424 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
425 | - $date = date('c',$date); |
|
424 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
425 | + $date = date('c',$date); |
|
426 | 426 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
427 | 427 | |
428 | 428 | return $spotter_array; |
429 | 429 | } |
430 | 430 | |
431 | 431 | |
432 | - /** |
|
433 | - * Gets all the spotter information based on a particular id |
|
434 | - * |
|
435 | - * @return Array the spotter information |
|
436 | - * |
|
437 | - */ |
|
432 | + /** |
|
433 | + * Gets all the spotter information based on a particular id |
|
434 | + * |
|
435 | + * @return Array the spotter information |
|
436 | + * |
|
437 | + */ |
|
438 | 438 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
439 | 439 | { |
440 | 440 | global $globalDBdriver, $globalLiveInterval; |
@@ -462,18 +462,18 @@ discard block |
||
462 | 462 | return $spotter_array; |
463 | 463 | } |
464 | 464 | |
465 | - /** |
|
466 | - * Gets all the spotter information based on a particular ident |
|
467 | - * |
|
468 | - * @return Array the spotter information |
|
469 | - * |
|
470 | - */ |
|
465 | + /** |
|
466 | + * Gets all the spotter information based on a particular ident |
|
467 | + * |
|
468 | + * @return Array the spotter information |
|
469 | + * |
|
470 | + */ |
|
471 | 471 | public function getAllLiveMarineDataByIdent($ident) |
472 | 472 | { |
473 | 473 | date_default_timezone_set('UTC'); |
474 | 474 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
475 | 475 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
476 | - try { |
|
476 | + try { |
|
477 | 477 | |
478 | 478 | $sth = $this->db->prepare($query); |
479 | 479 | $sth->execute(array(':ident' => $ident)); |
@@ -487,23 +487,23 @@ discard block |
||
487 | 487 | |
488 | 488 | |
489 | 489 | /** |
490 | - * Deletes all info in the table |
|
491 | - * |
|
492 | - * @return String success or false |
|
493 | - * |
|
494 | - */ |
|
490 | + * Deletes all info in the table |
|
491 | + * |
|
492 | + * @return String success or false |
|
493 | + * |
|
494 | + */ |
|
495 | 495 | public function deleteLiveMarineData() |
496 | 496 | { |
497 | 497 | global $globalDBdriver; |
498 | 498 | if ($globalDBdriver == 'mysql') { |
499 | 499 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
500 | 500 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
501 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
501 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
502 | 502 | } else { |
503 | 503 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
504 | 504 | } |
505 | 505 | |
506 | - try { |
|
506 | + try { |
|
507 | 507 | |
508 | 508 | $sth = $this->db->prepare($query); |
509 | 509 | $sth->execute(); |
@@ -515,18 +515,18 @@ discard block |
||
515 | 515 | } |
516 | 516 | |
517 | 517 | /** |
518 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
519 | - * |
|
520 | - * @return String success or false |
|
521 | - * |
|
522 | - */ |
|
518 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
519 | + * |
|
520 | + * @return String success or false |
|
521 | + * |
|
522 | + */ |
|
523 | 523 | public function deleteLiveMarineDataNotUpdated() |
524 | 524 | { |
525 | 525 | global $globalDBdriver, $globalDebug; |
526 | 526 | if ($globalDBdriver == 'mysql') { |
527 | 527 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
528 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
529 | - try { |
|
528 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
529 | + try { |
|
530 | 530 | |
531 | 531 | $sth = $this->db->prepare($query); |
532 | 532 | $sth->execute(); |
@@ -534,8 +534,8 @@ discard block |
||
534 | 534 | return "error"; |
535 | 535 | } |
536 | 536 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
537 | - $i = 0; |
|
538 | - $j =0; |
|
537 | + $i = 0; |
|
538 | + $j =0; |
|
539 | 539 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
540 | 540 | foreach($all as $row) |
541 | 541 | { |
@@ -543,20 +543,20 @@ discard block |
||
543 | 543 | $j++; |
544 | 544 | if ($j == 30) { |
545 | 545 | if ($globalDebug) echo "."; |
546 | - try { |
|
546 | + try { |
|
547 | 547 | |
548 | 548 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
549 | 549 | $sth->execute(); |
550 | 550 | } catch(PDOException $e) { |
551 | 551 | return "error"; |
552 | 552 | } |
553 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
554 | - $j = 0; |
|
553 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
554 | + $j = 0; |
|
555 | 555 | } |
556 | 556 | $query_delete .= "'".$row['fammarine_id']."',"; |
557 | 557 | } |
558 | 558 | if ($i > 0) { |
559 | - try { |
|
559 | + try { |
|
560 | 560 | |
561 | 561 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
562 | 562 | $sth->execute(); |
@@ -567,9 +567,9 @@ discard block |
||
567 | 567 | return "success"; |
568 | 568 | } elseif ($globalDBdriver == 'pgsql') { |
569 | 569 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
570 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
571 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
572 | - try { |
|
570 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
571 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
572 | + try { |
|
573 | 573 | |
574 | 574 | $sth = $this->db->prepare($query); |
575 | 575 | $sth->execute(); |
@@ -613,17 +613,17 @@ discard block |
||
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
616 | - * Deletes all info in the table for an ident |
|
617 | - * |
|
618 | - * @return String success or false |
|
619 | - * |
|
620 | - */ |
|
616 | + * Deletes all info in the table for an ident |
|
617 | + * |
|
618 | + * @return String success or false |
|
619 | + * |
|
620 | + */ |
|
621 | 621 | public function deleteLiveMarineDataByIdent($ident) |
622 | 622 | { |
623 | 623 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
624 | 624 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
625 | 625 | |
626 | - try { |
|
626 | + try { |
|
627 | 627 | |
628 | 628 | $sth = $this->db->prepare($query); |
629 | 629 | $sth->execute(array(':ident' => $ident)); |
@@ -635,17 +635,17 @@ discard block |
||
635 | 635 | } |
636 | 636 | |
637 | 637 | /** |
638 | - * Deletes all info in the table for an id |
|
639 | - * |
|
640 | - * @return String success or false |
|
641 | - * |
|
642 | - */ |
|
638 | + * Deletes all info in the table for an id |
|
639 | + * |
|
640 | + * @return String success or false |
|
641 | + * |
|
642 | + */ |
|
643 | 643 | public function deleteLiveMarineDataById($id) |
644 | 644 | { |
645 | 645 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
646 | 646 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
647 | 647 | |
648 | - try { |
|
648 | + try { |
|
649 | 649 | |
650 | 650 | $sth = $this->db->prepare($query); |
651 | 651 | $sth->execute(array(':id' => $id)); |
@@ -658,11 +658,11 @@ discard block |
||
658 | 658 | |
659 | 659 | |
660 | 660 | /** |
661 | - * Gets the aircraft ident within the last hour |
|
662 | - * |
|
663 | - * @return String the ident |
|
664 | - * |
|
665 | - */ |
|
661 | + * Gets the aircraft ident within the last hour |
|
662 | + * |
|
663 | + * @return String the ident |
|
664 | + * |
|
665 | + */ |
|
666 | 666 | public function getIdentFromLastHour($ident) |
667 | 667 | { |
668 | 668 | global $globalDBdriver, $globalTimezone; |
@@ -688,14 +688,14 @@ discard block |
||
688 | 688 | $ident_result = $row['ident']; |
689 | 689 | } |
690 | 690 | return $ident_result; |
691 | - } |
|
691 | + } |
|
692 | 692 | |
693 | 693 | /** |
694 | - * Check recent aircraft |
|
695 | - * |
|
696 | - * @return String the ident |
|
697 | - * |
|
698 | - */ |
|
694 | + * Check recent aircraft |
|
695 | + * |
|
696 | + * @return String the ident |
|
697 | + * |
|
698 | + */ |
|
699 | 699 | public function checkIdentRecent($ident) |
700 | 700 | { |
701 | 701 | global $globalDBdriver, $globalTimezone; |
@@ -721,14 +721,14 @@ discard block |
||
721 | 721 | $ident_result = $row['fammarine_id']; |
722 | 722 | } |
723 | 723 | return $ident_result; |
724 | - } |
|
724 | + } |
|
725 | 725 | |
726 | 726 | /** |
727 | - * Check recent aircraft by id |
|
728 | - * |
|
729 | - * @return String the ident |
|
730 | - * |
|
731 | - */ |
|
727 | + * Check recent aircraft by id |
|
728 | + * |
|
729 | + * @return String the ident |
|
730 | + * |
|
731 | + */ |
|
732 | 732 | public function checkIdRecent($id) |
733 | 733 | { |
734 | 734 | global $globalDBdriver, $globalTimezone; |
@@ -754,14 +754,14 @@ discard block |
||
754 | 754 | $ident_result = $row['fammarine_id']; |
755 | 755 | } |
756 | 756 | return $ident_result; |
757 | - } |
|
757 | + } |
|
758 | 758 | |
759 | 759 | /** |
760 | - * Check recent aircraft by mmsi |
|
761 | - * |
|
762 | - * @return String the ident |
|
763 | - * |
|
764 | - */ |
|
760 | + * Check recent aircraft by mmsi |
|
761 | + * |
|
762 | + * @return String the ident |
|
763 | + * |
|
764 | + */ |
|
765 | 765 | public function checkMMSIRecent($mmsi) |
766 | 766 | { |
767 | 767 | global $globalDBdriver, $globalTimezone; |
@@ -787,19 +787,19 @@ discard block |
||
787 | 787 | $ident_result = $row['fammarine_id']; |
788 | 788 | } |
789 | 789 | return $ident_result; |
790 | - } |
|
790 | + } |
|
791 | 791 | |
792 | 792 | /** |
793 | - * Adds a new spotter data |
|
794 | - * |
|
795 | - * @param String $fammarine_id the ID from flightaware |
|
796 | - * @param String $ident the flight ident |
|
797 | - * @param String $aircraft_icao the aircraft type |
|
798 | - * @param String $departure_airport_icao the departure airport |
|
799 | - * @param String $arrival_airport_icao the arrival airport |
|
800 | - * @return String success or false |
|
801 | - * |
|
802 | - */ |
|
793 | + * Adds a new spotter data |
|
794 | + * |
|
795 | + * @param String $fammarine_id the ID from flightaware |
|
796 | + * @param String $ident the flight ident |
|
797 | + * @param String $aircraft_icao the aircraft type |
|
798 | + * @param String $departure_airport_icao the departure airport |
|
799 | + * @param String $arrival_airport_icao the arrival airport |
|
800 | + * @return String success or false |
|
801 | + * |
|
802 | + */ |
|
803 | 803 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
804 | 804 | { |
805 | 805 | global $globalURL, $globalArchive, $globalDebug; |
@@ -870,9 +870,9 @@ discard block |
||
870 | 870 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
871 | 871 | |
872 | 872 | |
873 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
874 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
875 | - if ($arrival_date == '') $arrival_date = NULL; |
|
873 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
874 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
875 | + if ($arrival_date == '') $arrival_date = NULL; |
|
876 | 876 | $query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
877 | 877 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
878 | 878 | |
@@ -881,9 +881,9 @@ discard block |
||
881 | 881 | |
882 | 882 | $sth = $this->db->prepare($query); |
883 | 883 | $sth->execute($query_values); |
884 | - } catch(PDOException $e) { |
|
885 | - return "error : ".$e->getMessage(); |
|
886 | - } |
|
884 | + } catch(PDOException $e) { |
|
885 | + return "error : ".$e->getMessage(); |
|
886 | + } |
|
887 | 887 | /* |
888 | 888 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
889 | 889 | if ($globalDebug) echo '(Add to SBS archive : '; |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * Gets all the spotter information based on the latest data entry |
|
90 | - * |
|
91 | - * @return Array the spotter information |
|
92 | - * |
|
93 | - */ |
|
89 | + * Gets all the spotter information based on the latest data entry |
|
90 | + * |
|
91 | + * @return Array the spotter information |
|
92 | + * |
|
93 | + */ |
|
94 | 94 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array()) |
95 | 95 | { |
96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Gets Minimal Live Spotter data |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
135 | + * Gets Minimal Live Spotter data |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | 140 | public function getMinLiveTrackerData($filter = array()) |
141 | 141 | { |
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | - * Gets Minimal Live Spotter data since xx seconds |
|
174 | - * |
|
175 | - * @return Array the spotter information |
|
176 | - * |
|
177 | - */ |
|
173 | + * Gets Minimal Live Spotter data since xx seconds |
|
174 | + * |
|
175 | + * @return Array the spotter information |
|
176 | + * |
|
177 | + */ |
|
178 | 178 | public function getMinLastLiveTrackerData($filter = array()) |
179 | 179 | { |
180 | 180 | global $globalDBdriver, $globalLiveInterval; |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | $query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
188 | 188 | FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
189 | 189 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
190 | - } else { |
|
190 | + } else { |
|
191 | 191 | $query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
192 | 192 | FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' |
193 | 193 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
194 | 194 | } |
195 | 195 | |
196 | - try { |
|
196 | + try { |
|
197 | 197 | $sth = $this->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | 199 | } catch(PDOException $e) { |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
208 | - * Gets number of latest data entry |
|
209 | - * |
|
210 | - * @return String number of entry |
|
211 | - * |
|
212 | - */ |
|
208 | + * Gets number of latest data entry |
|
209 | + * |
|
210 | + * @return String number of entry |
|
211 | + * |
|
212 | + */ |
|
213 | 213 | public function getLiveTrackerCount($filter = array()) |
214 | 214 | { |
215 | 215 | global $globalDBdriver, $globalLiveInterval; |
@@ -234,11 +234,11 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
237 | - * Gets all the spotter information based on the latest data entry and coord |
|
238 | - * |
|
239 | - * @return Array the spotter information |
|
240 | - * |
|
241 | - */ |
|
237 | + * Gets all the spotter information based on the latest data entry and coord |
|
238 | + * |
|
239 | + * @return Array the spotter information |
|
240 | + * |
|
241 | + */ |
|
242 | 242 | public function getLiveTrackerDatabyCoord($coord, $filter = array()) |
243 | 243 | { |
244 | 244 | global $globalDBdriver, $globalLiveInterval; |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | - * Gets all the spotter information based on the latest data entry and coord |
|
266 | - * |
|
267 | - * @return Array the spotter information |
|
268 | - * |
|
269 | - */ |
|
265 | + * Gets all the spotter information based on the latest data entry and coord |
|
266 | + * |
|
267 | + * @return Array the spotter information |
|
268 | + * |
|
269 | + */ |
|
270 | 270 | public function getMinLiveTrackerDatabyCoord($coord, $filter = array()) |
271 | 271 | { |
272 | 272 | global $globalDBdriver, $globalLiveInterval; |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
296 | - * Gets all the spotter information based on a user's latitude and longitude |
|
297 | - * |
|
298 | - * @return Array the spotter information |
|
299 | - * |
|
300 | - */ |
|
296 | + * Gets all the spotter information based on a user's latitude and longitude |
|
297 | + * |
|
298 | + * @return Array the spotter information |
|
299 | + * |
|
300 | + */ |
|
301 | 301 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval) |
302 | 302 | { |
303 | 303 | $Tracker = new Tracker($this->db); |
@@ -310,142 +310,142 @@ discard block |
||
310 | 310 | if ($lng != '') |
311 | 311 | { |
312 | 312 | if (!is_numeric($lng)) |
313 | - { |
|
314 | - return false; |
|
315 | - } |
|
316 | - } |
|
317 | - |
|
318 | - if ($radius != '') |
|
319 | - { |
|
320 | - if (!is_numeric($radius)) |
|
321 | - { |
|
322 | - return false; |
|
323 | - } |
|
324 | - } |
|
313 | + { |
|
314 | + return false; |
|
315 | + } |
|
316 | + } |
|
317 | + |
|
318 | + if ($radius != '') |
|
319 | + { |
|
320 | + if (!is_numeric($radius)) |
|
321 | + { |
|
322 | + return false; |
|
323 | + } |
|
324 | + } |
|
325 | 325 | $additional_query = ''; |
326 | 326 | if ($interval != '') |
327 | - { |
|
328 | - if (!is_string($interval)) |
|
329 | - { |
|
330 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
331 | - return false; |
|
332 | - } else { |
|
333 | - if ($interval == '1m') |
|
334 | - { |
|
335 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
336 | - } else if ($interval == '15m'){ |
|
337 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
338 | - } |
|
339 | - } |
|
340 | - } else { |
|
341 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
342 | - } |
|
343 | - |
|
344 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
327 | + { |
|
328 | + if (!is_string($interval)) |
|
329 | + { |
|
330 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
331 | + return false; |
|
332 | + } else { |
|
333 | + if ($interval == '1m') |
|
334 | + { |
|
335 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
336 | + } else if ($interval == '15m'){ |
|
337 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
338 | + } |
|
339 | + } |
|
340 | + } else { |
|
341 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
342 | + } |
|
343 | + |
|
344 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
345 | 345 | WHERE tracker_live.latitude <> '' |
346 | 346 | AND tracker_live.longitude <> '' |
347 | 347 | ".$additional_query." |
348 | 348 | HAVING distance < :radius |
349 | 349 | ORDER BY distance"; |
350 | 350 | |
351 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
351 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
352 | 352 | |
353 | - return $spotter_array; |
|
354 | - } |
|
353 | + return $spotter_array; |
|
354 | + } |
|
355 | 355 | |
356 | 356 | |
357 | - /** |
|
358 | - * Gets all the spotter information based on a particular callsign |
|
359 | - * |
|
360 | - * @return Array the spotter information |
|
361 | - * |
|
362 | - */ |
|
357 | + /** |
|
358 | + * Gets all the spotter information based on a particular callsign |
|
359 | + * |
|
360 | + * @return Array the spotter information |
|
361 | + * |
|
362 | + */ |
|
363 | 363 | public function getLastLiveTrackerDataByIdent($ident) |
364 | 364 | { |
365 | 365 | $Tracker = new Tracker($this->db); |
366 | 366 | date_default_timezone_set('UTC'); |
367 | 367 | |
368 | 368 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
369 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
369 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
370 | 370 | |
371 | 371 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
372 | 372 | |
373 | 373 | return $spotter_array; |
374 | 374 | } |
375 | 375 | |
376 | - /** |
|
377 | - * Gets all the spotter information based on a particular callsign |
|
378 | - * |
|
379 | - * @return Array the spotter information |
|
380 | - * |
|
381 | - */ |
|
376 | + /** |
|
377 | + * Gets all the spotter information based on a particular callsign |
|
378 | + * |
|
379 | + * @return Array the spotter information |
|
380 | + * |
|
381 | + */ |
|
382 | 382 | public function getDateLiveTrackerDataByIdent($ident,$date) |
383 | 383 | { |
384 | 384 | $Tracker = new Tracker($this->db); |
385 | 385 | date_default_timezone_set('UTC'); |
386 | 386 | |
387 | 387 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
388 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
388 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
389 | 389 | |
390 | - $date = date('c',$date); |
|
390 | + $date = date('c',$date); |
|
391 | 391 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
392 | 392 | |
393 | 393 | return $spotter_array; |
394 | 394 | } |
395 | 395 | |
396 | - /** |
|
397 | - * Gets last spotter information based on a particular callsign |
|
398 | - * |
|
399 | - * @return Array the spotter information |
|
400 | - * |
|
401 | - */ |
|
396 | + /** |
|
397 | + * Gets last spotter information based on a particular callsign |
|
398 | + * |
|
399 | + * @return Array the spotter information |
|
400 | + * |
|
401 | + */ |
|
402 | 402 | public function getLastLiveTrackerDataById($id) |
403 | 403 | { |
404 | 404 | $Tracker = new Tracker($this->db); |
405 | 405 | date_default_timezone_set('UTC'); |
406 | 406 | |
407 | 407 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
408 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
408 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
409 | 409 | |
410 | 410 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
411 | 411 | |
412 | 412 | return $spotter_array; |
413 | 413 | } |
414 | 414 | |
415 | - /** |
|
416 | - * Gets last spotter information based on a particular callsign |
|
417 | - * |
|
418 | - * @return Array the spotter information |
|
419 | - * |
|
420 | - */ |
|
415 | + /** |
|
416 | + * Gets last spotter information based on a particular callsign |
|
417 | + * |
|
418 | + * @return Array the spotter information |
|
419 | + * |
|
420 | + */ |
|
421 | 421 | public function getDateLiveTrackerDataById($id,$date) |
422 | 422 | { |
423 | 423 | $Tracker = new Tracker($this->db); |
424 | 424 | date_default_timezone_set('UTC'); |
425 | 425 | |
426 | 426 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
427 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
428 | - $date = date('c',$date); |
|
427 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
428 | + $date = date('c',$date); |
|
429 | 429 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
430 | 430 | |
431 | 431 | return $spotter_array; |
432 | 432 | } |
433 | 433 | |
434 | - /** |
|
435 | - * Gets altitude information based on a particular callsign |
|
436 | - * |
|
437 | - * @return Array the spotter information |
|
438 | - * |
|
439 | - */ |
|
434 | + /** |
|
435 | + * Gets altitude information based on a particular callsign |
|
436 | + * |
|
437 | + * @return Array the spotter information |
|
438 | + * |
|
439 | + */ |
|
440 | 440 | public function getAltitudeLiveTrackerDataByIdent($ident) |
441 | 441 | { |
442 | 442 | |
443 | 443 | date_default_timezone_set('UTC'); |
444 | 444 | |
445 | 445 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
446 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
446 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
447 | 447 | |
448 | - try { |
|
448 | + try { |
|
449 | 449 | |
450 | 450 | $sth = $this->db->prepare($query); |
451 | 451 | $sth->execute(array(':ident' => $ident)); |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | return $spotter_array; |
459 | 459 | } |
460 | 460 | |
461 | - /** |
|
462 | - * Gets all the spotter information based on a particular id |
|
463 | - * |
|
464 | - * @return Array the spotter information |
|
465 | - * |
|
466 | - */ |
|
461 | + /** |
|
462 | + * Gets all the spotter information based on a particular id |
|
463 | + * |
|
464 | + * @return Array the spotter information |
|
465 | + * |
|
466 | + */ |
|
467 | 467 | public function getAllLiveTrackerDataById($id,$liveinterval = false) |
468 | 468 | { |
469 | 469 | global $globalDBdriver, $globalLiveInterval; |
@@ -491,18 +491,18 @@ discard block |
||
491 | 491 | return $spotter_array; |
492 | 492 | } |
493 | 493 | |
494 | - /** |
|
495 | - * Gets all the spotter information based on a particular ident |
|
496 | - * |
|
497 | - * @return Array the spotter information |
|
498 | - * |
|
499 | - */ |
|
494 | + /** |
|
495 | + * Gets all the spotter information based on a particular ident |
|
496 | + * |
|
497 | + * @return Array the spotter information |
|
498 | + * |
|
499 | + */ |
|
500 | 500 | public function getAllLiveTrackerDataByIdent($ident) |
501 | 501 | { |
502 | 502 | date_default_timezone_set('UTC'); |
503 | 503 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
504 | 504 | $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
505 | - try { |
|
505 | + try { |
|
506 | 506 | |
507 | 507 | $sth = $this->db->prepare($query); |
508 | 508 | $sth->execute(array(':ident' => $ident)); |
@@ -516,23 +516,23 @@ discard block |
||
516 | 516 | |
517 | 517 | |
518 | 518 | /** |
519 | - * Deletes all info in the table |
|
520 | - * |
|
521 | - * @return String success or false |
|
522 | - * |
|
523 | - */ |
|
519 | + * Deletes all info in the table |
|
520 | + * |
|
521 | + * @return String success or false |
|
522 | + * |
|
523 | + */ |
|
524 | 524 | public function deleteLiveTrackerData() |
525 | 525 | { |
526 | 526 | global $globalDBdriver; |
527 | 527 | if ($globalDBdriver == 'mysql') { |
528 | 528 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date"; |
529 | 529 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date'; |
530 | - //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
530 | + //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
531 | 531 | } else { |
532 | 532 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date"; |
533 | 533 | } |
534 | 534 | |
535 | - try { |
|
535 | + try { |
|
536 | 536 | |
537 | 537 | $sth = $this->db->prepare($query); |
538 | 538 | $sth->execute(); |
@@ -544,18 +544,18 @@ discard block |
||
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
547 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
548 | - * |
|
549 | - * @return String success or false |
|
550 | - * |
|
551 | - */ |
|
547 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
548 | + * |
|
549 | + * @return String success or false |
|
550 | + * |
|
551 | + */ |
|
552 | 552 | public function deleteLiveTrackerDataNotUpdated() |
553 | 553 | { |
554 | 554 | global $globalDBdriver, $globalDebug; |
555 | 555 | if ($globalDBdriver == 'mysql') { |
556 | 556 | //$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0'; |
557 | - $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
558 | - try { |
|
557 | + $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
558 | + try { |
|
559 | 559 | |
560 | 560 | $sth = $this->db->prepare($query); |
561 | 561 | $sth->execute(); |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | return "error"; |
564 | 564 | } |
565 | 565 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
566 | - $i = 0; |
|
567 | - $j =0; |
|
566 | + $i = 0; |
|
567 | + $j =0; |
|
568 | 568 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
569 | 569 | foreach($all as $row) |
570 | 570 | { |
@@ -572,20 +572,20 @@ discard block |
||
572 | 572 | $j++; |
573 | 573 | if ($j == 30) { |
574 | 574 | if ($globalDebug) echo "."; |
575 | - try { |
|
575 | + try { |
|
576 | 576 | |
577 | 577 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
578 | 578 | $sth->execute(); |
579 | 579 | } catch(PDOException $e) { |
580 | 580 | return "error"; |
581 | 581 | } |
582 | - $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
583 | - $j = 0; |
|
582 | + $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
583 | + $j = 0; |
|
584 | 584 | } |
585 | 585 | $query_delete .= "'".$row['famtrackid']."',"; |
586 | 586 | } |
587 | 587 | if ($i > 0) { |
588 | - try { |
|
588 | + try { |
|
589 | 589 | |
590 | 590 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
591 | 591 | $sth->execute(); |
@@ -596,9 +596,9 @@ discard block |
||
596 | 596 | return "success"; |
597 | 597 | } elseif ($globalDBdriver == 'pgsql') { |
598 | 598 | //$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0"; |
599 | - //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
600 | - $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
601 | - try { |
|
599 | + //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
600 | + $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
601 | + try { |
|
602 | 602 | |
603 | 603 | $sth = $this->db->prepare($query); |
604 | 604 | $sth->execute(); |
@@ -642,17 +642,17 @@ discard block |
||
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
645 | - * Deletes all info in the table for an ident |
|
646 | - * |
|
647 | - * @return String success or false |
|
648 | - * |
|
649 | - */ |
|
645 | + * Deletes all info in the table for an ident |
|
646 | + * |
|
647 | + * @return String success or false |
|
648 | + * |
|
649 | + */ |
|
650 | 650 | public function deleteLiveTrackerDataByIdent($ident) |
651 | 651 | { |
652 | 652 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
653 | 653 | $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
654 | 654 | |
655 | - try { |
|
655 | + try { |
|
656 | 656 | |
657 | 657 | $sth = $this->db->prepare($query); |
658 | 658 | $sth->execute(array(':ident' => $ident)); |
@@ -664,17 +664,17 @@ discard block |
||
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
667 | - * Deletes all info in the table for an id |
|
668 | - * |
|
669 | - * @return String success or false |
|
670 | - * |
|
671 | - */ |
|
667 | + * Deletes all info in the table for an id |
|
668 | + * |
|
669 | + * @return String success or false |
|
670 | + * |
|
671 | + */ |
|
672 | 672 | public function deleteLiveTrackerDataById($id) |
673 | 673 | { |
674 | 674 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
675 | 675 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
676 | 676 | |
677 | - try { |
|
677 | + try { |
|
678 | 678 | |
679 | 679 | $sth = $this->db->prepare($query); |
680 | 680 | $sth->execute(array(':id' => $id)); |
@@ -687,11 +687,11 @@ discard block |
||
687 | 687 | |
688 | 688 | |
689 | 689 | /** |
690 | - * Gets the aircraft ident within the last hour |
|
691 | - * |
|
692 | - * @return String the ident |
|
693 | - * |
|
694 | - */ |
|
690 | + * Gets the aircraft ident within the last hour |
|
691 | + * |
|
692 | + * @return String the ident |
|
693 | + * |
|
694 | + */ |
|
695 | 695 | public function getIdentFromLastHour($ident) |
696 | 696 | { |
697 | 697 | global $globalDBdriver, $globalTimezone; |
@@ -717,14 +717,14 @@ discard block |
||
717 | 717 | $ident_result = $row['ident']; |
718 | 718 | } |
719 | 719 | return $ident_result; |
720 | - } |
|
720 | + } |
|
721 | 721 | |
722 | 722 | /** |
723 | - * Check recent aircraft |
|
724 | - * |
|
725 | - * @return String the ident |
|
726 | - * |
|
727 | - */ |
|
723 | + * Check recent aircraft |
|
724 | + * |
|
725 | + * @return String the ident |
|
726 | + * |
|
727 | + */ |
|
728 | 728 | public function checkIdentRecent($ident) |
729 | 729 | { |
730 | 730 | global $globalDBdriver, $globalTimezone; |
@@ -750,14 +750,14 @@ discard block |
||
750 | 750 | $ident_result = $row['famtrackid']; |
751 | 751 | } |
752 | 752 | return $ident_result; |
753 | - } |
|
753 | + } |
|
754 | 754 | |
755 | 755 | /** |
756 | - * Check recent aircraft by id |
|
757 | - * |
|
758 | - * @return String the ident |
|
759 | - * |
|
760 | - */ |
|
756 | + * Check recent aircraft by id |
|
757 | + * |
|
758 | + * @return String the ident |
|
759 | + * |
|
760 | + */ |
|
761 | 761 | public function checkIdRecent($id) |
762 | 762 | { |
763 | 763 | global $globalDBdriver, $globalTimezone; |
@@ -783,19 +783,19 @@ discard block |
||
783 | 783 | $ident_result = $row['famtrackid']; |
784 | 784 | } |
785 | 785 | return $ident_result; |
786 | - } |
|
786 | + } |
|
787 | 787 | |
788 | 788 | /** |
789 | - * Adds a new spotter data |
|
790 | - * |
|
791 | - * @param String $famtrackid the ID from flightaware |
|
792 | - * @param String $ident the flight ident |
|
793 | - * @param String $aircraft_icao the aircraft type |
|
794 | - * @param String $departure_airport_icao the departure airport |
|
795 | - * @param String $arrival_airport_icao the arrival airport |
|
796 | - * @return String success or false |
|
797 | - * |
|
798 | - */ |
|
789 | + * Adds a new spotter data |
|
790 | + * |
|
791 | + * @param String $famtrackid the ID from flightaware |
|
792 | + * @param String $ident the flight ident |
|
793 | + * @param String $aircraft_icao the aircraft type |
|
794 | + * @param String $departure_airport_icao the departure airport |
|
795 | + * @param String $arrival_airport_icao the arrival airport |
|
796 | + * @return String success or false |
|
797 | + * |
|
798 | + */ |
|
799 | 799 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
800 | 800 | { |
801 | 801 | global $globalURL, $globalArchive, $globalDebug; |
@@ -868,8 +868,8 @@ discard block |
||
868 | 868 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
869 | 869 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
870 | 870 | |
871 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
872 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
871 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
872 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
873 | 873 | |
874 | 874 | $query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
875 | 875 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -879,9 +879,9 @@ discard block |
||
879 | 879 | |
880 | 880 | $sth = $this->db->prepare($query); |
881 | 881 | $sth->execute($query_values); |
882 | - } catch(PDOException $e) { |
|
883 | - return "error : ".$e->getMessage(); |
|
884 | - } |
|
882 | + } catch(PDOException $e) { |
|
883 | + return "error : ".$e->getMessage(); |
|
884 | + } |
|
885 | 885 | /* |
886 | 886 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
887 | 887 | if ($globalDebug) echo '(Add to SBS archive : '; |
@@ -11,10 +11,10 @@ discard block |
||
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
14 | - * Get SQL query part for filter used |
|
15 | - * @param Array $filter the filter |
|
16 | - * @return Array the SQL part |
|
17 | - */ |
|
14 | + * Get SQL query part for filter used |
|
15 | + * @param Array $filter the filter |
|
16 | + * @return Array the SQL part |
|
17 | + */ |
|
18 | 18 | |
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | - * Executes the SQL statements to get the spotter information |
|
82 | - * |
|
83 | - * @param String $query the SQL query |
|
84 | - * @param Array $params parameter of the query |
|
85 | - * @param String $limitQuery the limit query |
|
86 | - * @return Array the spotter information |
|
87 | - * |
|
88 | - */ |
|
81 | + * Executes the SQL statements to get the spotter information |
|
82 | + * |
|
83 | + * @param String $query the SQL query |
|
84 | + * @param Array $params parameter of the query |
|
85 | + * @param String $limitQuery the limit query |
|
86 | + * @return Array the spotter information |
|
87 | + * |
|
88 | + */ |
|
89 | 89 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
90 | 90 | { |
91 | 91 | date_default_timezone_set('UTC'); |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | |
213 | 213 | |
214 | 214 | /** |
215 | - * Gets all the spotter information based on the latest data entry |
|
216 | - * |
|
217 | - * @return Array the spotter information |
|
218 | - * |
|
219 | - */ |
|
215 | + * Gets all the spotter information based on the latest data entry |
|
216 | + * |
|
217 | + * @return Array the spotter information |
|
218 | + * |
|
219 | + */ |
|
220 | 220 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
221 | 221 | { |
222 | 222 | global $global_query; |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
277 | - * Gets all the spotter information based on the callsign |
|
278 | - * |
|
279 | - * @return Array the spotter information |
|
280 | - * |
|
281 | - */ |
|
277 | + * Gets all the spotter information based on the callsign |
|
278 | + * |
|
279 | + * @return Array the spotter information |
|
280 | + * |
|
281 | + */ |
|
282 | 282 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
283 | 283 | { |
284 | 284 | global $global_query; |
@@ -389,12 +389,12 @@ discard block |
||
389 | 389 | |
390 | 390 | |
391 | 391 | /** |
392 | - * Gets all source name |
|
393 | - * |
|
394 | - * @param String type format of source |
|
395 | - * @return Array list of source name |
|
396 | - * |
|
397 | - */ |
|
392 | + * Gets all source name |
|
393 | + * |
|
394 | + * @param String type format of source |
|
395 | + * @return Array list of source name |
|
396 | + * |
|
397 | + */ |
|
398 | 398 | public function getAllSourceName($type = '',$filters = array()) |
399 | 399 | { |
400 | 400 | $filter_query = $this->getFilter($filters,true,true); |
@@ -424,11 +424,11 @@ discard block |
||
424 | 424 | |
425 | 425 | |
426 | 426 | /** |
427 | - * Gets a list of all idents/callsigns |
|
428 | - * |
|
429 | - * @return Array list of ident/callsign names |
|
430 | - * |
|
431 | - */ |
|
427 | + * Gets a list of all idents/callsigns |
|
428 | + * |
|
429 | + * @return Array list of ident/callsign names |
|
430 | + * |
|
431 | + */ |
|
432 | 432 | public function getAllIdents($filters = array()) |
433 | 433 | { |
434 | 434 | $filter_query = $this->getFilter($filters,true,true); |
@@ -452,11 +452,11 @@ discard block |
||
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
455 | - * Gets all info from a mmsi |
|
456 | - * |
|
457 | - * @return Array list of mmsi info |
|
458 | - * |
|
459 | - */ |
|
455 | + * Gets all info from a mmsi |
|
456 | + * |
|
457 | + * @return Array list of mmsi info |
|
458 | + * |
|
459 | + */ |
|
460 | 460 | public function getIdentity($mmsi) |
461 | 461 | { |
462 | 462 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -513,18 +513,18 @@ discard block |
||
513 | 513 | |
514 | 514 | |
515 | 515 | /** |
516 | - * Update ident tracker data |
|
517 | - * |
|
518 | - * @param String $fammarine_id the ID |
|
519 | - * @param String $ident the marine ident |
|
520 | - * @return String success or false |
|
521 | - * |
|
522 | - */ |
|
516 | + * Update ident tracker data |
|
517 | + * |
|
518 | + * @param String $fammarine_id the ID |
|
519 | + * @param String $ident the marine ident |
|
520 | + * @return String success or false |
|
521 | + * |
|
522 | + */ |
|
523 | 523 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
524 | 524 | { |
525 | 525 | |
526 | 526 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
527 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
527 | + $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
528 | 528 | |
529 | 529 | try { |
530 | 530 | $sth = $this->db->prepare($query); |
@@ -537,17 +537,17 @@ discard block |
||
537 | 537 | |
538 | 538 | } |
539 | 539 | /** |
540 | - * Update latest marine data |
|
541 | - * |
|
542 | - * @param String $fammarine_id the ID |
|
543 | - * @param String $ident the marine ident |
|
544 | - * @return String success or false |
|
545 | - * |
|
546 | - */ |
|
540 | + * Update latest marine data |
|
541 | + * |
|
542 | + * @param String $fammarine_id the ID |
|
543 | + * @param String $ident the marine ident |
|
544 | + * @return String success or false |
|
545 | + * |
|
546 | + */ |
|
547 | 547 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
548 | 548 | { |
549 | 549 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
550 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
550 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
551 | 551 | |
552 | 552 | try { |
553 | 553 | $sth = $this->db->prepare($query); |
@@ -561,30 +561,30 @@ discard block |
||
561 | 561 | } |
562 | 562 | |
563 | 563 | /** |
564 | - * Adds a new spotter data |
|
565 | - * |
|
566 | - * @param String $fammarine_id the ID |
|
567 | - * @param String $ident the marine ident |
|
568 | - * @param String $departure_airport_icao the departure airport |
|
569 | - * @param String $arrival_airport_icao the arrival airport |
|
570 | - * @param String $latitude latitude of flight |
|
571 | - * @param String $longitude latitude of flight |
|
572 | - * @param String $waypoints waypoints of flight |
|
573 | - * @param String $heading heading of flight |
|
574 | - * @param String $groundspeed speed of flight |
|
575 | - * @param String $date date of flight |
|
576 | - * @param String $departure_airport_time departure time of flight |
|
577 | - * @param String $arrival_airport_time arrival time of flight |
|
578 | - * @param String $squawk squawk code of flight |
|
579 | - * @param String $route_stop route stop of flight |
|
580 | - * @param String $highlight highlight or not |
|
581 | - * @param String $ModeS ModesS code of flight |
|
582 | - * @param String $registration registration code of flight |
|
583 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
584 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
585 | - * @param String $verticalrate vertival rate of flight |
|
586 | - * @return String success or false |
|
587 | - */ |
|
564 | + * Adds a new spotter data |
|
565 | + * |
|
566 | + * @param String $fammarine_id the ID |
|
567 | + * @param String $ident the marine ident |
|
568 | + * @param String $departure_airport_icao the departure airport |
|
569 | + * @param String $arrival_airport_icao the arrival airport |
|
570 | + * @param String $latitude latitude of flight |
|
571 | + * @param String $longitude latitude of flight |
|
572 | + * @param String $waypoints waypoints of flight |
|
573 | + * @param String $heading heading of flight |
|
574 | + * @param String $groundspeed speed of flight |
|
575 | + * @param String $date date of flight |
|
576 | + * @param String $departure_airport_time departure time of flight |
|
577 | + * @param String $arrival_airport_time arrival time of flight |
|
578 | + * @param String $squawk squawk code of flight |
|
579 | + * @param String $route_stop route stop of flight |
|
580 | + * @param String $highlight highlight or not |
|
581 | + * @param String $ModeS ModesS code of flight |
|
582 | + * @param String $registration registration code of flight |
|
583 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
584 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
585 | + * @param String $verticalrate vertival rate of flight |
|
586 | + * @return String success or false |
|
587 | + */ |
|
588 | 588 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '') |
589 | 589 | { |
590 | 590 | global $globalURL, $globalMarineImageFetch; |
@@ -681,13 +681,13 @@ discard block |
||
681 | 681 | unset($Image); |
682 | 682 | } |
683 | 683 | |
684 | - if ($latitude == '' && $longitude == '') { |
|
685 | - $latitude = 0; |
|
686 | - $longitude = 0; |
|
687 | - } |
|
688 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
689 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
690 | - if ($arrival_date == '') $arrival_date = NULL; |
|
684 | + if ($latitude == '' && $longitude == '') { |
|
685 | + $latitude = 0; |
|
686 | + $longitude = 0; |
|
687 | + } |
|
688 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
689 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
690 | + if ($arrival_date == '') $arrival_date = NULL; |
|
691 | 691 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
692 | 692 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
693 | 693 | |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | $sth->execute($query_values); |
699 | 699 | $this->db = null; |
700 | 700 | } catch (PDOException $e) { |
701 | - return "error : ".$e->getMessage(); |
|
701 | + return "error : ".$e->getMessage(); |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | return "success"; |
@@ -707,11 +707,11 @@ discard block |
||
707 | 707 | |
708 | 708 | |
709 | 709 | /** |
710 | - * Gets the aircraft ident within the last hour |
|
711 | - * |
|
712 | - * @return String the ident |
|
713 | - * |
|
714 | - */ |
|
710 | + * Gets the aircraft ident within the last hour |
|
711 | + * |
|
712 | + * @return String the ident |
|
713 | + * |
|
714 | + */ |
|
715 | 715 | public function getIdentFromLastHour($ident) |
716 | 716 | { |
717 | 717 | global $globalDBdriver, $globalTimezone; |
@@ -727,11 +727,11 @@ discard block |
||
727 | 727 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
728 | 728 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
729 | 729 | $query_data = array(':ident' => $ident); |
730 | - } |
|
730 | + } |
|
731 | 731 | |
732 | 732 | $sth = $this->db->prepare($query); |
733 | 733 | $sth->execute($query_data); |
734 | - $ident_result=''; |
|
734 | + $ident_result=''; |
|
735 | 735 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
736 | 736 | { |
737 | 737 | $ident_result = $row['ident']; |
@@ -742,11 +742,11 @@ discard block |
||
742 | 742 | |
743 | 743 | |
744 | 744 | /** |
745 | - * Gets the aircraft data from the last 20 seconds |
|
746 | - * |
|
747 | - * @return Array the spotter data |
|
748 | - * |
|
749 | - */ |
|
745 | + * Gets the aircraft data from the last 20 seconds |
|
746 | + * |
|
747 | + * @return Array the spotter data |
|
748 | + * |
|
749 | + */ |
|
750 | 750 | public function getRealTimeData($q = '') |
751 | 751 | { |
752 | 752 | global $globalDBdriver; |
@@ -784,11 +784,11 @@ discard block |
||
784 | 784 | |
785 | 785 | |
786 | 786 | /** |
787 | - * Gets all number of flight over countries |
|
788 | - * |
|
789 | - * @return Array the airline country list |
|
790 | - * |
|
791 | - */ |
|
787 | + * Gets all number of flight over countries |
|
788 | + * |
|
789 | + * @return Array the airline country list |
|
790 | + * |
|
791 | + */ |
|
792 | 792 | /* |
793 | 793 | public function countAllTrackedOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
794 | 794 | { |
@@ -839,11 +839,11 @@ discard block |
||
839 | 839 | |
840 | 840 | |
841 | 841 | /** |
842 | - * Gets all callsigns that have flown over |
|
843 | - * |
|
844 | - * @return Array the callsign list |
|
845 | - * |
|
846 | - */ |
|
842 | + * Gets all callsigns that have flown over |
|
843 | + * |
|
844 | + * @return Array the callsign list |
|
845 | + * |
|
846 | + */ |
|
847 | 847 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
848 | 848 | { |
849 | 849 | global $globalDBdriver; |
@@ -910,11 +910,11 @@ discard block |
||
910 | 910 | |
911 | 911 | |
912 | 912 | /** |
913 | - * Counts all dates |
|
914 | - * |
|
915 | - * @return Array the date list |
|
916 | - * |
|
917 | - */ |
|
913 | + * Counts all dates |
|
914 | + * |
|
915 | + * @return Array the date list |
|
916 | + * |
|
917 | + */ |
|
918 | 918 | public function countAllDates($filters = array()) |
919 | 919 | { |
920 | 920 | global $globalTimezone, $globalDBdriver; |
@@ -960,11 +960,11 @@ discard block |
||
960 | 960 | |
961 | 961 | |
962 | 962 | /** |
963 | - * Counts all dates during the last 7 days |
|
964 | - * |
|
965 | - * @return Array the date list |
|
966 | - * |
|
967 | - */ |
|
963 | + * Counts all dates during the last 7 days |
|
964 | + * |
|
965 | + * @return Array the date list |
|
966 | + * |
|
967 | + */ |
|
968 | 968 | public function countAllDatesLast7Days($filters = array()) |
969 | 969 | { |
970 | 970 | global $globalTimezone, $globalDBdriver; |
@@ -986,7 +986,7 @@ discard block |
||
986 | 986 | $query .= " GROUP BY date_name |
987 | 987 | ORDER BY date_name ASC"; |
988 | 988 | $query_data = array(':offset' => $offset); |
989 | - } |
|
989 | + } |
|
990 | 990 | |
991 | 991 | $sth = $this->db->prepare($query); |
992 | 992 | $sth->execute($query_data); |
@@ -1006,11 +1006,11 @@ discard block |
||
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | /** |
1009 | - * Counts all dates during the last month |
|
1010 | - * |
|
1011 | - * @return Array the date list |
|
1012 | - * |
|
1013 | - */ |
|
1009 | + * Counts all dates during the last month |
|
1010 | + * |
|
1011 | + * @return Array the date list |
|
1012 | + * |
|
1013 | + */ |
|
1014 | 1014 | public function countAllDatesLastMonth($filters = array()) |
1015 | 1015 | { |
1016 | 1016 | global $globalTimezone, $globalDBdriver; |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | $query .= " GROUP BY date_name |
1033 | 1033 | ORDER BY date_name ASC"; |
1034 | 1034 | $query_data = array(':offset' => $offset); |
1035 | - } |
|
1035 | + } |
|
1036 | 1036 | |
1037 | 1037 | $sth = $this->db->prepare($query); |
1038 | 1038 | $sth->execute($query_data); |
@@ -1054,11 +1054,11 @@ discard block |
||
1054 | 1054 | |
1055 | 1055 | |
1056 | 1056 | /** |
1057 | - * Counts all month |
|
1058 | - * |
|
1059 | - * @return Array the month list |
|
1060 | - * |
|
1061 | - */ |
|
1057 | + * Counts all month |
|
1058 | + * |
|
1059 | + * @return Array the month list |
|
1060 | + * |
|
1061 | + */ |
|
1062 | 1062 | public function countAllMonths($filters = array()) |
1063 | 1063 | { |
1064 | 1064 | global $globalTimezone, $globalDBdriver; |
@@ -1103,11 +1103,11 @@ discard block |
||
1103 | 1103 | |
1104 | 1104 | |
1105 | 1105 | /** |
1106 | - * Counts all dates during the last year |
|
1107 | - * |
|
1108 | - * @return Array the date list |
|
1109 | - * |
|
1110 | - */ |
|
1106 | + * Counts all dates during the last year |
|
1107 | + * |
|
1108 | + * @return Array the date list |
|
1109 | + * |
|
1110 | + */ |
|
1111 | 1111 | public function countAllMonthsLastYear($filters) |
1112 | 1112 | { |
1113 | 1113 | global $globalTimezone, $globalDBdriver; |
@@ -1129,7 +1129,7 @@ discard block |
||
1129 | 1129 | $query .= " GROUP BY year_name, month_name |
1130 | 1130 | ORDER BY year_name, month_name ASC"; |
1131 | 1131 | $query_data = array(':offset' => $offset); |
1132 | - } |
|
1132 | + } |
|
1133 | 1133 | |
1134 | 1134 | $sth = $this->db->prepare($query); |
1135 | 1135 | $sth->execute($query_data); |
@@ -1152,11 +1152,11 @@ discard block |
||
1152 | 1152 | |
1153 | 1153 | |
1154 | 1154 | /** |
1155 | - * Counts all hours |
|
1156 | - * |
|
1157 | - * @return Array the hour list |
|
1158 | - * |
|
1159 | - */ |
|
1155 | + * Counts all hours |
|
1156 | + * |
|
1157 | + * @return Array the hour list |
|
1158 | + * |
|
1159 | + */ |
|
1160 | 1160 | public function countAllHours($orderby,$filters = array()) |
1161 | 1161 | { |
1162 | 1162 | global $globalTimezone, $globalDBdriver; |
@@ -1219,11 +1219,11 @@ discard block |
||
1219 | 1219 | |
1220 | 1220 | |
1221 | 1221 | /** |
1222 | - * Counts all hours by date |
|
1223 | - * |
|
1224 | - * @return Array the hour list |
|
1225 | - * |
|
1226 | - */ |
|
1222 | + * Counts all hours by date |
|
1223 | + * |
|
1224 | + * @return Array the hour list |
|
1225 | + * |
|
1226 | + */ |
|
1227 | 1227 | public function countAllHoursByDate($date, $filters = array()) |
1228 | 1228 | { |
1229 | 1229 | global $globalTimezone, $globalDBdriver; |
@@ -1267,11 +1267,11 @@ discard block |
||
1267 | 1267 | |
1268 | 1268 | |
1269 | 1269 | /** |
1270 | - * Counts all hours by a ident/callsign |
|
1271 | - * |
|
1272 | - * @return Array the hour list |
|
1273 | - * |
|
1274 | - */ |
|
1270 | + * Counts all hours by a ident/callsign |
|
1271 | + * |
|
1272 | + * @return Array the hour list |
|
1273 | + * |
|
1274 | + */ |
|
1275 | 1275 | public function countAllHoursByIdent($ident, $filters = array()) |
1276 | 1276 | { |
1277 | 1277 | global $globalTimezone, $globalDBdriver; |
@@ -1316,11 +1316,11 @@ discard block |
||
1316 | 1316 | |
1317 | 1317 | |
1318 | 1318 | /** |
1319 | - * Counts all flights that have flown over |
|
1320 | - * |
|
1321 | - * @return Integer the number of flights |
|
1322 | - * |
|
1323 | - */ |
|
1319 | + * Counts all flights that have flown over |
|
1320 | + * |
|
1321 | + * @return Integer the number of flights |
|
1322 | + * |
|
1323 | + */ |
|
1324 | 1324 | public function countOverallTracked($filters = array(),$year = '',$month = '') |
1325 | 1325 | { |
1326 | 1326 | global $globalDBdriver; |
@@ -1355,11 +1355,11 @@ discard block |
||
1355 | 1355 | |
1356 | 1356 | |
1357 | 1357 | /** |
1358 | - * Counts all hours of today |
|
1359 | - * |
|
1360 | - * @return Array the hour list |
|
1361 | - * |
|
1362 | - */ |
|
1358 | + * Counts all hours of today |
|
1359 | + * |
|
1360 | + * @return Array the hour list |
|
1361 | + * |
|
1362 | + */ |
|
1363 | 1363 | public function countAllHoursFromToday($filters = array()) |
1364 | 1364 | { |
1365 | 1365 | global $globalTimezone, $globalDBdriver; |
@@ -1399,12 +1399,12 @@ discard block |
||
1399 | 1399 | } |
1400 | 1400 | |
1401 | 1401 | |
1402 | - /** |
|
1403 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1404 | - * |
|
1405 | - * @return Integer the Barrie Spotter ID |
|
1402 | + /** |
|
1403 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1404 | + * |
|
1405 | + * @return Integer the Barrie Spotter ID |
|
1406 | 1406 | q * |
1407 | - */ |
|
1407 | + */ |
|
1408 | 1408 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1409 | 1409 | { |
1410 | 1410 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1425,13 +1425,13 @@ discard block |
||
1425 | 1425 | |
1426 | 1426 | |
1427 | 1427 | /** |
1428 | - * Parses a date string |
|
1429 | - * |
|
1430 | - * @param String $dateString the date string |
|
1431 | - * @param String $timezone the timezone of a user |
|
1432 | - * @return Array the time information |
|
1433 | - * |
|
1434 | - */ |
|
1428 | + * Parses a date string |
|
1429 | + * |
|
1430 | + * @param String $dateString the date string |
|
1431 | + * @param String $timezone the timezone of a user |
|
1432 | + * @return Array the time information |
|
1433 | + * |
|
1434 | + */ |
|
1435 | 1435 | public function parseDateString($dateString, $timezone = '') |
1436 | 1436 | { |
1437 | 1437 | $time_array = array(); |
@@ -1464,12 +1464,12 @@ discard block |
||
1464 | 1464 | } |
1465 | 1465 | |
1466 | 1466 | /** |
1467 | - * Parses the direction degrees to working |
|
1468 | - * |
|
1469 | - * @param Float $direction the direction in degrees |
|
1470 | - * @return Array the direction information |
|
1471 | - * |
|
1472 | - */ |
|
1467 | + * Parses the direction degrees to working |
|
1468 | + * |
|
1469 | + * @param Float $direction the direction in degrees |
|
1470 | + * @return Array the direction information |
|
1471 | + * |
|
1472 | + */ |
|
1473 | 1473 | public function parseDirection($direction = 0) |
1474 | 1474 | { |
1475 | 1475 | if ($direction == '') $direction = 0; |
@@ -1548,12 +1548,12 @@ discard block |
||
1548 | 1548 | |
1549 | 1549 | |
1550 | 1550 | /** |
1551 | - * Gets Country from latitude/longitude |
|
1552 | - * |
|
1553 | - * @param Float $latitude latitute of the flight |
|
1554 | - * @param Float $longitude longitute of the flight |
|
1555 | - * @return String the countrie |
|
1556 | - */ |
|
1551 | + * Gets Country from latitude/longitude |
|
1552 | + * |
|
1553 | + * @param Float $latitude latitute of the flight |
|
1554 | + * @param Float $longitude longitute of the flight |
|
1555 | + * @return String the countrie |
|
1556 | + */ |
|
1557 | 1557 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1558 | 1558 | { |
1559 | 1559 | global $globalDBdriver, $globalDebug; |
@@ -1590,11 +1590,11 @@ discard block |
||
1590 | 1590 | } |
1591 | 1591 | |
1592 | 1592 | /** |
1593 | - * Gets Country from iso2 |
|
1594 | - * |
|
1595 | - * @param String $iso2 ISO2 country code |
|
1596 | - * @return String the countrie |
|
1597 | - */ |
|
1593 | + * Gets Country from iso2 |
|
1594 | + * |
|
1595 | + * @param String $iso2 ISO2 country code |
|
1596 | + * @return String the countrie |
|
1597 | + */ |
|
1598 | 1598 | public function getCountryFromISO2($iso2) |
1599 | 1599 | { |
1600 | 1600 | global $globalDBdriver, $globalDebug; |
@@ -1623,12 +1623,12 @@ discard block |
||
1623 | 1623 | |
1624 | 1624 | |
1625 | 1625 | /** |
1626 | - * Gets the short url from bit.ly |
|
1627 | - * |
|
1628 | - * @param String $url the full url |
|
1629 | - * @return String the bit.ly url |
|
1630 | - * |
|
1631 | - */ |
|
1626 | + * Gets the short url from bit.ly |
|
1627 | + * |
|
1628 | + * @param String $url the full url |
|
1629 | + * @return String the bit.ly url |
|
1630 | + * |
|
1631 | + */ |
|
1632 | 1632 | public function getBitlyURL($url) |
1633 | 1633 | { |
1634 | 1634 | global $globalBitlyAccessToken; |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * Gets all the spotter information based on the latest data entry |
|
132 | - * |
|
133 | - * @return Array the spotter information |
|
134 | - * |
|
135 | - */ |
|
131 | + * Gets all the spotter information based on the latest data entry |
|
132 | + * |
|
133 | + * @return Array the spotter information |
|
134 | + * |
|
135 | + */ |
|
136 | 136 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
137 | 137 | { |
138 | 138 | global $globalDBdriver, $globalLiveInterval; |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
177 | - * Gets Minimal Live Spotter data |
|
178 | - * |
|
179 | - * @return Array the spotter information |
|
180 | - * |
|
181 | - */ |
|
177 | + * Gets Minimal Live Spotter data |
|
178 | + * |
|
179 | + * @return Array the spotter information |
|
180 | + * |
|
181 | + */ |
|
182 | 182 | public function getMinLiveSpotterData($filter = array()) |
183 | 183 | { |
184 | 184 | global $globalDBdriver, $globalLiveInterval; |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
234 | - * Gets Minimal Live Spotter data since xx seconds |
|
235 | - * |
|
236 | - * @return Array the spotter information |
|
237 | - * |
|
238 | - */ |
|
234 | + * Gets Minimal Live Spotter data since xx seconds |
|
235 | + * |
|
236 | + * @return Array the spotter information |
|
237 | + * |
|
238 | + */ |
|
239 | 239 | public function getMinLastLiveSpotterData($filter = array()) |
240 | 240 | { |
241 | 241 | global $globalDBdriver, $globalLiveInterval; |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
254 | 254 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
255 | 255 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
256 | - } else { |
|
256 | + } else { |
|
257 | 257 | /* |
258 | 258 | $query = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
259 | 259 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | // echo $query; |
266 | 266 | } |
267 | 267 | |
268 | - try { |
|
268 | + try { |
|
269 | 269 | $sth = $this->db->prepare($query); |
270 | 270 | $sth->execute(); |
271 | 271 | } catch(PDOException $e) { |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
280 | - * Gets number of latest data entry |
|
281 | - * |
|
282 | - * @return String number of entry |
|
283 | - * |
|
284 | - */ |
|
280 | + * Gets number of latest data entry |
|
281 | + * |
|
282 | + * @return String number of entry |
|
283 | + * |
|
284 | + */ |
|
285 | 285 | public function getLiveSpotterCount($filter = array()) |
286 | 286 | { |
287 | 287 | global $globalDBdriver, $globalLiveInterval; |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
311 | - * Gets all the spotter information based on the latest data entry and coord |
|
312 | - * |
|
313 | - * @return Array the spotter information |
|
314 | - * |
|
315 | - */ |
|
311 | + * Gets all the spotter information based on the latest data entry and coord |
|
312 | + * |
|
313 | + * @return Array the spotter information |
|
314 | + * |
|
315 | + */ |
|
316 | 316 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
317 | 317 | { |
318 | 318 | global $globalDBdriver, $globalLiveInterval; |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
340 | - * Gets all the spotter information based on the latest data entry and coord |
|
341 | - * |
|
342 | - * @return Array the spotter information |
|
343 | - * |
|
344 | - */ |
|
340 | + * Gets all the spotter information based on the latest data entry and coord |
|
341 | + * |
|
342 | + * @return Array the spotter information |
|
343 | + * |
|
344 | + */ |
|
345 | 345 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
346 | 346 | { |
347 | 347 | global $globalDBdriver, $globalLiveInterval; |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
392 | - * Gets all the spotter information based on a user's latitude and longitude |
|
393 | - * |
|
394 | - * @return Array the spotter information |
|
395 | - * |
|
396 | - */ |
|
392 | + * Gets all the spotter information based on a user's latitude and longitude |
|
393 | + * |
|
394 | + * @return Array the spotter information |
|
395 | + * |
|
396 | + */ |
|
397 | 397 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
398 | 398 | { |
399 | 399 | $Spotter = new Spotter($this->db); |
@@ -403,145 +403,145 @@ discard block |
||
403 | 403 | return false; |
404 | 404 | } |
405 | 405 | } |
406 | - if ($lng != '') |
|
407 | - { |
|
408 | - if (!is_numeric($lng)) |
|
409 | - { |
|
410 | - return false; |
|
411 | - } |
|
412 | - } |
|
413 | - |
|
414 | - if ($radius != '') |
|
415 | - { |
|
416 | - if (!is_numeric($radius)) |
|
417 | - { |
|
418 | - return false; |
|
419 | - } |
|
420 | - } |
|
406 | + if ($lng != '') |
|
407 | + { |
|
408 | + if (!is_numeric($lng)) |
|
409 | + { |
|
410 | + return false; |
|
411 | + } |
|
412 | + } |
|
413 | + |
|
414 | + if ($radius != '') |
|
415 | + { |
|
416 | + if (!is_numeric($radius)) |
|
417 | + { |
|
418 | + return false; |
|
419 | + } |
|
420 | + } |
|
421 | 421 | $additional_query = ''; |
422 | - if ($interval != '') |
|
423 | - { |
|
424 | - if (!is_string($interval)) |
|
425 | - { |
|
426 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
427 | - return false; |
|
428 | - } else { |
|
429 | - if ($interval == '1m') |
|
430 | - { |
|
431 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
432 | - } else if ($interval == '15m'){ |
|
433 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
434 | - } |
|
435 | - } |
|
436 | - } else { |
|
437 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
438 | - } |
|
439 | - |
|
440 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
422 | + if ($interval != '') |
|
423 | + { |
|
424 | + if (!is_string($interval)) |
|
425 | + { |
|
426 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
427 | + return false; |
|
428 | + } else { |
|
429 | + if ($interval == '1m') |
|
430 | + { |
|
431 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
432 | + } else if ($interval == '15m'){ |
|
433 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
434 | + } |
|
435 | + } |
|
436 | + } else { |
|
437 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
438 | + } |
|
439 | + |
|
440 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
441 | 441 | WHERE spotter_live.latitude <> '' |
442 | 442 | AND spotter_live.longitude <> '' |
443 | 443 | ".$additional_query." |
444 | 444 | HAVING distance < :radius |
445 | 445 | ORDER BY distance"; |
446 | 446 | |
447 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
447 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
448 | 448 | |
449 | - return $spotter_array; |
|
450 | - } |
|
449 | + return $spotter_array; |
|
450 | + } |
|
451 | 451 | |
452 | 452 | |
453 | - /** |
|
454 | - * Gets all the spotter information based on a particular callsign |
|
455 | - * |
|
456 | - * @return Array the spotter information |
|
457 | - * |
|
458 | - */ |
|
453 | + /** |
|
454 | + * Gets all the spotter information based on a particular callsign |
|
455 | + * |
|
456 | + * @return Array the spotter information |
|
457 | + * |
|
458 | + */ |
|
459 | 459 | public function getLastLiveSpotterDataByIdent($ident) |
460 | 460 | { |
461 | 461 | $Spotter = new Spotter($this->db); |
462 | 462 | date_default_timezone_set('UTC'); |
463 | 463 | |
464 | 464 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
465 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
465 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
466 | 466 | |
467 | 467 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
468 | 468 | |
469 | 469 | return $spotter_array; |
470 | 470 | } |
471 | 471 | |
472 | - /** |
|
473 | - * Gets all the spotter information based on a particular callsign |
|
474 | - * |
|
475 | - * @return Array the spotter information |
|
476 | - * |
|
477 | - */ |
|
472 | + /** |
|
473 | + * Gets all the spotter information based on a particular callsign |
|
474 | + * |
|
475 | + * @return Array the spotter information |
|
476 | + * |
|
477 | + */ |
|
478 | 478 | public function getDateLiveSpotterDataByIdent($ident,$date) |
479 | 479 | { |
480 | 480 | $Spotter = new Spotter($this->db); |
481 | 481 | date_default_timezone_set('UTC'); |
482 | 482 | |
483 | 483 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
484 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
484 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
485 | 485 | |
486 | - $date = date('c',$date); |
|
486 | + $date = date('c',$date); |
|
487 | 487 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
488 | 488 | |
489 | 489 | return $spotter_array; |
490 | 490 | } |
491 | 491 | |
492 | - /** |
|
493 | - * Gets last spotter information based on a particular callsign |
|
494 | - * |
|
495 | - * @return Array the spotter information |
|
496 | - * |
|
497 | - */ |
|
492 | + /** |
|
493 | + * Gets last spotter information based on a particular callsign |
|
494 | + * |
|
495 | + * @return Array the spotter information |
|
496 | + * |
|
497 | + */ |
|
498 | 498 | public function getLastLiveSpotterDataById($id) |
499 | 499 | { |
500 | 500 | $Spotter = new Spotter($this->db); |
501 | 501 | date_default_timezone_set('UTC'); |
502 | 502 | |
503 | 503 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
504 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
504 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
505 | 505 | |
506 | 506 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
507 | 507 | |
508 | 508 | return $spotter_array; |
509 | 509 | } |
510 | 510 | |
511 | - /** |
|
512 | - * Gets last spotter information based on a particular callsign |
|
513 | - * |
|
514 | - * @return Array the spotter information |
|
515 | - * |
|
516 | - */ |
|
511 | + /** |
|
512 | + * Gets last spotter information based on a particular callsign |
|
513 | + * |
|
514 | + * @return Array the spotter information |
|
515 | + * |
|
516 | + */ |
|
517 | 517 | public function getDateLiveSpotterDataById($id,$date) |
518 | 518 | { |
519 | 519 | $Spotter = new Spotter($this->db); |
520 | 520 | date_default_timezone_set('UTC'); |
521 | 521 | |
522 | 522 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
523 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
524 | - $date = date('c',$date); |
|
523 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
524 | + $date = date('c',$date); |
|
525 | 525 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
526 | 526 | |
527 | 527 | return $spotter_array; |
528 | 528 | } |
529 | 529 | |
530 | - /** |
|
531 | - * Gets altitude information based on a particular callsign |
|
532 | - * |
|
533 | - * @return Array the spotter information |
|
534 | - * |
|
535 | - */ |
|
530 | + /** |
|
531 | + * Gets altitude information based on a particular callsign |
|
532 | + * |
|
533 | + * @return Array the spotter information |
|
534 | + * |
|
535 | + */ |
|
536 | 536 | public function getAltitudeLiveSpotterDataByIdent($ident) |
537 | 537 | { |
538 | 538 | |
539 | 539 | date_default_timezone_set('UTC'); |
540 | 540 | |
541 | 541 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
542 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
542 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
543 | 543 | |
544 | - try { |
|
544 | + try { |
|
545 | 545 | |
546 | 546 | $sth = $this->db->prepare($query); |
547 | 547 | $sth->execute(array(':ident' => $ident)); |
@@ -554,12 +554,12 @@ discard block |
||
554 | 554 | return $spotter_array; |
555 | 555 | } |
556 | 556 | |
557 | - /** |
|
558 | - * Gets all the spotter information based on a particular id |
|
559 | - * |
|
560 | - * @return Array the spotter information |
|
561 | - * |
|
562 | - */ |
|
557 | + /** |
|
558 | + * Gets all the spotter information based on a particular id |
|
559 | + * |
|
560 | + * @return Array the spotter information |
|
561 | + * |
|
562 | + */ |
|
563 | 563 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
564 | 564 | { |
565 | 565 | global $globalDBdriver, $globalLiveInterval; |
@@ -587,18 +587,18 @@ discard block |
||
587 | 587 | return $spotter_array; |
588 | 588 | } |
589 | 589 | |
590 | - /** |
|
591 | - * Gets all the spotter information based on a particular ident |
|
592 | - * |
|
593 | - * @return Array the spotter information |
|
594 | - * |
|
595 | - */ |
|
590 | + /** |
|
591 | + * Gets all the spotter information based on a particular ident |
|
592 | + * |
|
593 | + * @return Array the spotter information |
|
594 | + * |
|
595 | + */ |
|
596 | 596 | public function getAllLiveSpotterDataByIdent($ident) |
597 | 597 | { |
598 | 598 | date_default_timezone_set('UTC'); |
599 | 599 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
600 | 600 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
601 | - try { |
|
601 | + try { |
|
602 | 602 | |
603 | 603 | $sth = $this->db->prepare($query); |
604 | 604 | $sth->execute(array(':ident' => $ident)); |
@@ -612,23 +612,23 @@ discard block |
||
612 | 612 | |
613 | 613 | |
614 | 614 | /** |
615 | - * Deletes all info in the table |
|
616 | - * |
|
617 | - * @return String success or false |
|
618 | - * |
|
619 | - */ |
|
615 | + * Deletes all info in the table |
|
616 | + * |
|
617 | + * @return String success or false |
|
618 | + * |
|
619 | + */ |
|
620 | 620 | public function deleteLiveSpotterData() |
621 | 621 | { |
622 | 622 | global $globalDBdriver; |
623 | 623 | if ($globalDBdriver == 'mysql') { |
624 | 624 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
625 | 625 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
626 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
626 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
627 | 627 | } else { |
628 | 628 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
629 | 629 | } |
630 | 630 | |
631 | - try { |
|
631 | + try { |
|
632 | 632 | |
633 | 633 | $sth = $this->db->prepare($query); |
634 | 634 | $sth->execute(); |
@@ -640,18 +640,18 @@ discard block |
||
640 | 640 | } |
641 | 641 | |
642 | 642 | /** |
643 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
644 | - * |
|
645 | - * @return String success or false |
|
646 | - * |
|
647 | - */ |
|
643 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
644 | + * |
|
645 | + * @return String success or false |
|
646 | + * |
|
647 | + */ |
|
648 | 648 | public function deleteLiveSpotterDataNotUpdated() |
649 | 649 | { |
650 | 650 | global $globalDBdriver, $globalDebug; |
651 | 651 | if ($globalDBdriver == 'mysql') { |
652 | 652 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
653 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
654 | - try { |
|
653 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
654 | + try { |
|
655 | 655 | |
656 | 656 | $sth = $this->db->prepare($query); |
657 | 657 | $sth->execute(); |
@@ -659,8 +659,8 @@ discard block |
||
659 | 659 | return "error"; |
660 | 660 | } |
661 | 661 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
662 | - $i = 0; |
|
663 | - $j =0; |
|
662 | + $i = 0; |
|
663 | + $j =0; |
|
664 | 664 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
665 | 665 | foreach($all as $row) |
666 | 666 | { |
@@ -668,20 +668,20 @@ discard block |
||
668 | 668 | $j++; |
669 | 669 | if ($j == 30) { |
670 | 670 | if ($globalDebug) echo "."; |
671 | - try { |
|
671 | + try { |
|
672 | 672 | |
673 | 673 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
674 | 674 | $sth->execute(); |
675 | 675 | } catch(PDOException $e) { |
676 | 676 | return "error"; |
677 | 677 | } |
678 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
679 | - $j = 0; |
|
678 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
679 | + $j = 0; |
|
680 | 680 | } |
681 | 681 | $query_delete .= "'".$row['flightaware_id']."',"; |
682 | 682 | } |
683 | 683 | if ($i > 0) { |
684 | - try { |
|
684 | + try { |
|
685 | 685 | |
686 | 686 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
687 | 687 | $sth->execute(); |
@@ -692,9 +692,9 @@ discard block |
||
692 | 692 | return "success"; |
693 | 693 | } elseif ($globalDBdriver == 'pgsql') { |
694 | 694 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
695 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
696 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
697 | - try { |
|
695 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
696 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
697 | + try { |
|
698 | 698 | |
699 | 699 | $sth = $this->db->prepare($query); |
700 | 700 | $sth->execute(); |
@@ -738,17 +738,17 @@ discard block |
||
738 | 738 | } |
739 | 739 | |
740 | 740 | /** |
741 | - * Deletes all info in the table for an ident |
|
742 | - * |
|
743 | - * @return String success or false |
|
744 | - * |
|
745 | - */ |
|
741 | + * Deletes all info in the table for an ident |
|
742 | + * |
|
743 | + * @return String success or false |
|
744 | + * |
|
745 | + */ |
|
746 | 746 | public function deleteLiveSpotterDataByIdent($ident) |
747 | 747 | { |
748 | 748 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
749 | 749 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
750 | 750 | |
751 | - try { |
|
751 | + try { |
|
752 | 752 | |
753 | 753 | $sth = $this->db->prepare($query); |
754 | 754 | $sth->execute(array(':ident' => $ident)); |
@@ -760,17 +760,17 @@ discard block |
||
760 | 760 | } |
761 | 761 | |
762 | 762 | /** |
763 | - * Deletes all info in the table for an id |
|
764 | - * |
|
765 | - * @return String success or false |
|
766 | - * |
|
767 | - */ |
|
763 | + * Deletes all info in the table for an id |
|
764 | + * |
|
765 | + * @return String success or false |
|
766 | + * |
|
767 | + */ |
|
768 | 768 | public function deleteLiveSpotterDataById($id) |
769 | 769 | { |
770 | 770 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
771 | 771 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
772 | 772 | |
773 | - try { |
|
773 | + try { |
|
774 | 774 | |
775 | 775 | $sth = $this->db->prepare($query); |
776 | 776 | $sth->execute(array(':id' => $id)); |
@@ -783,11 +783,11 @@ discard block |
||
783 | 783 | |
784 | 784 | |
785 | 785 | /** |
786 | - * Gets the aircraft ident within the last hour |
|
787 | - * |
|
788 | - * @return String the ident |
|
789 | - * |
|
790 | - */ |
|
786 | + * Gets the aircraft ident within the last hour |
|
787 | + * |
|
788 | + * @return String the ident |
|
789 | + * |
|
790 | + */ |
|
791 | 791 | public function getIdentFromLastHour($ident) |
792 | 792 | { |
793 | 793 | global $globalDBdriver, $globalTimezone; |
@@ -813,14 +813,14 @@ discard block |
||
813 | 813 | $ident_result = $row['ident']; |
814 | 814 | } |
815 | 815 | return $ident_result; |
816 | - } |
|
816 | + } |
|
817 | 817 | |
818 | 818 | /** |
819 | - * Check recent aircraft |
|
820 | - * |
|
821 | - * @return String the ident |
|
822 | - * |
|
823 | - */ |
|
819 | + * Check recent aircraft |
|
820 | + * |
|
821 | + * @return String the ident |
|
822 | + * |
|
823 | + */ |
|
824 | 824 | public function checkIdentRecent($ident) |
825 | 825 | { |
826 | 826 | global $globalDBdriver, $globalTimezone; |
@@ -846,14 +846,14 @@ discard block |
||
846 | 846 | $ident_result = $row['flightaware_id']; |
847 | 847 | } |
848 | 848 | return $ident_result; |
849 | - } |
|
849 | + } |
|
850 | 850 | |
851 | 851 | /** |
852 | - * Check recent aircraft by id |
|
853 | - * |
|
854 | - * @return String the ident |
|
855 | - * |
|
856 | - */ |
|
852 | + * Check recent aircraft by id |
|
853 | + * |
|
854 | + * @return String the ident |
|
855 | + * |
|
856 | + */ |
|
857 | 857 | public function checkIdRecent($id) |
858 | 858 | { |
859 | 859 | global $globalDBdriver, $globalTimezone; |
@@ -879,14 +879,14 @@ discard block |
||
879 | 879 | $ident_result = $row['flightaware_id']; |
880 | 880 | } |
881 | 881 | return $ident_result; |
882 | - } |
|
882 | + } |
|
883 | 883 | |
884 | 884 | /** |
885 | - * Check recent aircraft by ModeS |
|
886 | - * |
|
887 | - * @return String the ModeS |
|
888 | - * |
|
889 | - */ |
|
885 | + * Check recent aircraft by ModeS |
|
886 | + * |
|
887 | + * @return String the ModeS |
|
888 | + * |
|
889 | + */ |
|
890 | 890 | public function checkModeSRecent($modes) |
891 | 891 | { |
892 | 892 | global $globalDBdriver, $globalTimezone; |
@@ -913,19 +913,19 @@ discard block |
||
913 | 913 | $ident_result = $row['flightaware_id']; |
914 | 914 | } |
915 | 915 | return $ident_result; |
916 | - } |
|
916 | + } |
|
917 | 917 | |
918 | 918 | /** |
919 | - * Adds a new spotter data |
|
920 | - * |
|
921 | - * @param String $flightaware_id the ID from flightaware |
|
922 | - * @param String $ident the flight ident |
|
923 | - * @param String $aircraft_icao the aircraft type |
|
924 | - * @param String $departure_airport_icao the departure airport |
|
925 | - * @param String $arrival_airport_icao the arrival airport |
|
926 | - * @return String success or false |
|
927 | - * |
|
928 | - */ |
|
919 | + * Adds a new spotter data |
|
920 | + * |
|
921 | + * @param String $flightaware_id the ID from flightaware |
|
922 | + * @param String $ident the flight ident |
|
923 | + * @param String $aircraft_icao the aircraft type |
|
924 | + * @param String $departure_airport_icao the departure airport |
|
925 | + * @param String $arrival_airport_icao the arrival airport |
|
926 | + * @return String success or false |
|
927 | + * |
|
928 | + */ |
|
929 | 929 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
930 | 930 | { |
931 | 931 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1060,10 +1060,10 @@ discard block |
||
1060 | 1060 | $arrival_airport_country = ''; |
1061 | 1061 | |
1062 | 1062 | |
1063 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1064 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1065 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1066 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1063 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1064 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1065 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1066 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1067 | 1067 | |
1068 | 1068 | $query = ''; |
1069 | 1069 | if ($globalArchive) { |
@@ -1083,10 +1083,10 @@ discard block |
||
1083 | 1083 | return "error : ".$e->getMessage(); |
1084 | 1084 | } |
1085 | 1085 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1086 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1087 | - $SpotterArchive = new SpotterArchive($this->db); |
|
1088 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1089 | - if ($globalDebug) echo $result.')'; |
|
1086 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
1087 | + $SpotterArchive = new SpotterArchive($this->db); |
|
1088 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1089 | + if ($globalDebug) echo $result.')'; |
|
1090 | 1090 | } |
1091 | 1091 | return "success"; |
1092 | 1092 |
@@ -7,35 +7,35 @@ discard block |
||
7 | 7 | public $latest_schema = 38; |
8 | 8 | |
9 | 9 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
10 | - global $globalDBdriver, $globalNoDB; |
|
11 | - if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
10 | + global $globalDBdriver, $globalNoDB; |
|
11 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
12 | 12 | $this->db = null; |
13 | - } else { |
|
13 | + } else { |
|
14 | 14 | if ($dbc === null) { |
15 | - if ($this->db === null && $dbname === null) { |
|
15 | + if ($this->db === null && $dbname === null) { |
|
16 | 16 | if ($user === null && $pass === null) { |
17 | - $this->createDBConnection(); |
|
17 | + $this->createDBConnection(); |
|
18 | 18 | } else { |
19 | - $this->createDBConnection(null,$user,$pass); |
|
19 | + $this->createDBConnection(null,$user,$pass); |
|
20 | 20 | } |
21 | - } else { |
|
21 | + } else { |
|
22 | 22 | $this->createDBConnection($dbname); |
23 | - } |
|
23 | + } |
|
24 | 24 | } elseif ($dbname === null || $dbname === 'default') { |
25 | - $this->db = $dbc; |
|
26 | - if ($this->connectionExists() === false) { |
|
25 | + $this->db = $dbc; |
|
26 | + if ($this->connectionExists() === false) { |
|
27 | 27 | /* |
28 | 28 | echo 'Restart Connection !!!'."\n"; |
29 | 29 | $e = new \Exception; |
30 | 30 | var_dump($e->getTraceAsString()); |
31 | 31 | */ |
32 | 32 | $this->createDBConnection(); |
33 | - } |
|
33 | + } |
|
34 | 34 | } else { |
35 | - //$this->connectionExists(); |
|
36 | - $this->dbs[$dbname] = $dbc; |
|
35 | + //$this->connectionExists(); |
|
36 | + $this->dbs[$dbname] = $dbc; |
|
37 | + } |
|
37 | 38 | } |
38 | - } |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function db() { |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | - * Creates the database connection |
|
60 | - * |
|
61 | - * @return Boolean of the database connection |
|
62 | - * |
|
63 | - */ |
|
59 | + * Creates the database connection |
|
60 | + * |
|
61 | + * @return Boolean of the database connection |
|
62 | + * |
|
63 | + */ |
|
64 | 64 | |
65 | 65 | public function createDBConnection($DBname = null, $user = null, $pass = null) |
66 | 66 | { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | if($results->rowCount()>0) { |
160 | - return true; |
|
160 | + return true; |
|
161 | 161 | } |
162 | 162 | else return false; |
163 | 163 | } |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | $sum = $sum->fetchColumn(0); |
175 | 175 | } else $sum = 0; |
176 | 176 | if (intval($sum) !== 2) { |
177 | - return false; |
|
177 | + return false; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | } catch(PDOException $e) { |
181 | 181 | if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
182 | - throw $e; |
|
183 | - } |
|
184 | - //echo 'error ! '.$e->getMessage(); |
|
182 | + throw $e; |
|
183 | + } |
|
184 | + //echo 'error ! '.$e->getMessage(); |
|
185 | 185 | return false; |
186 | 186 | } |
187 | 187 | return true; |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | $version = 0; |
286 | 286 | if ($this->tableExists('aircraft')) { |
287 | 287 | if (!$this->tableExists('config')) { |
288 | - $version = '1'; |
|
289 | - return $version; |
|
288 | + $version = '1'; |
|
289 | + return $version; |
|
290 | 290 | } else { |
291 | 291 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
292 | 292 | try { |
@@ -307,10 +307,10 @@ discard block |
||
307 | 307 | * @return Boolean if latest version or not |
308 | 308 | */ |
309 | 309 | public function latest() { |
310 | - global $globalNoDB; |
|
311 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
312 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
313 | - else return false; |
|
310 | + global $globalNoDB; |
|
311 | + if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
312 | + if ($this->check_schema_version() == $this->latest_schema) return true; |
|
313 | + else return false; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | 16 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
17 | 17 | if (isset($globalMarine) && $globalMarine) { |
18 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
18 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -24,42 +24,42 @@ discard block |
||
24 | 24 | // Check if schema is at latest version |
25 | 25 | $Connection = new Connection(); |
26 | 26 | if ($Connection->latest() === false) { |
27 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | - exit(); |
|
27 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | + exit(); |
|
29 | 29 | } |
30 | 30 | if (PHP_SAPI != 'cli') { |
31 | - echo "This script MUST be called from console, not a web browser."; |
|
31 | + echo "This script MUST be called from console, not a web browser."; |
|
32 | 32 | // exit(); |
33 | 33 | } |
34 | 34 | |
35 | 35 | // This is to be compatible with old version of settings.php |
36 | 36 | if (!isset($globalSources)) { |
37 | - if (isset($globalSBS1Hosts)) { |
|
38 | - //$hosts = $globalSBS1Hosts; |
|
39 | - foreach ($globalSBS1Hosts as $host) { |
|
40 | - $globalSources[] = array('host' => $host); |
|
41 | - } |
|
42 | - } else { |
|
43 | - if (!isset($globalSBS1Host)) { |
|
44 | - echo '$globalSources MUST be defined !'; |
|
45 | - die; |
|
37 | + if (isset($globalSBS1Hosts)) { |
|
38 | + //$hosts = $globalSBS1Hosts; |
|
39 | + foreach ($globalSBS1Hosts as $host) { |
|
40 | + $globalSources[] = array('host' => $host); |
|
41 | + } |
|
42 | + } else { |
|
43 | + if (!isset($globalSBS1Host)) { |
|
44 | + echo '$globalSources MUST be defined !'; |
|
45 | + die; |
|
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | 48 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
49 | - } |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
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'])) { |
56 | - $globalSources = array(); |
|
57 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | - else $globalSources[] = array('host' => $options['s']); |
|
56 | + $globalSources = array(); |
|
57 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | + else $globalSources[] = array('host' => $options['s']); |
|
59 | 59 | } elseif (isset($options['source'])) { |
60 | - $globalSources = array(); |
|
61 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | - else $globalSources[] = array('host' => $options['source']); |
|
60 | + $globalSources = array(); |
|
61 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | + else $globalSources[] = array('host' => $options['source']); |
|
63 | 63 | } |
64 | 64 | if (isset($options['aprsserverhost'])) { |
65 | 65 | $globalServerAPRS = TRUE; |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
75 | 75 | else $id_source = 1; |
76 | 76 | if (isset($globalServer) && $globalServer) { |
77 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
78 | - $SI=new SpotterServer(); |
|
77 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
78 | + $SI=new SpotterServer(); |
|
79 | 79 | /* |
80 | 80 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
81 | 81 | $SI = new adsb2aprs(); |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | } else $SI=new SpotterImport($Connection->db); |
85 | 85 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
86 | 86 | if (isset($globalMarine) && $globalMarine) { |
87 | - $AIS = new AIS(); |
|
88 | - $MI = new MarineImport($Connection->db); |
|
87 | + $AIS = new AIS(); |
|
88 | + $MI = new MarineImport($Connection->db); |
|
89 | 89 | } |
90 | 90 | //$APRS=new APRS($Connection->db); |
91 | 91 | $SBS=new SBS(); |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | //$servertz = system('date +%Z'); |
96 | 96 | // signal handler - playing nice with sockets and dump1090 |
97 | 97 | if (function_exists('pcntl_fork')) { |
98 | - pcntl_signal(SIGINT, function() { |
|
99 | - global $sockets; |
|
100 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
101 | - die("Bye!\n"); |
|
102 | - }); |
|
103 | - pcntl_signal_dispatch(); |
|
98 | + pcntl_signal(SIGINT, function() { |
|
99 | + global $sockets; |
|
100 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
101 | + die("Bye!\n"); |
|
102 | + }); |
|
103 | + pcntl_signal_dispatch(); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // let's try and connect |
@@ -110,153 +110,153 @@ discard block |
||
110 | 110 | $reset = 0; |
111 | 111 | |
112 | 112 | function connect_all($hosts) { |
113 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
114 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
115 | - $reset++; |
|
116 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
117 | - foreach ($hosts as $id => $value) { |
|
113 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
114 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
115 | + $reset++; |
|
116 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
117 | + foreach ($hosts as $id => $value) { |
|
118 | 118 | $host = $value['host']; |
119 | 119 | $globalSources[$id]['last_exec'] = 0; |
120 | 120 | // Here we check type of source(s) |
121 | 121 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
122 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | - //$formats[$id] = 'deltadbtxt'; |
|
124 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
125 | - //$last_exec['deltadbtxt'] = 0; |
|
126 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
127 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
128 | - //$formats[$id] = 'vatsimtxt'; |
|
129 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
130 | - //$last_exec['vatsimtxt'] = 0; |
|
131 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
132 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
133 | - //$formats[$id] = 'aircraftlistjson'; |
|
134 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
135 | - //$last_exec['aircraftlistjson'] = 0; |
|
136 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
137 | - } else if (preg_match('/opensky/i',$host)) { |
|
138 | - //$formats[$id] = 'aircraftlistjson'; |
|
139 | - $globalSources[$id]['format'] = 'opensky'; |
|
140 | - //$last_exec['aircraftlistjson'] = 0; |
|
141 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
142 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
143 | - //$formats[$id] = 'radarvirtueljson'; |
|
144 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
145 | - //$last_exec['radarvirtueljson'] = 0; |
|
146 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
147 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
148 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
149 | - exit(0); |
|
150 | - } |
|
151 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
152 | - //$formats[$id] = 'planeupdatefaa'; |
|
153 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
154 | - //$last_exec['planeupdatefaa'] = 0; |
|
155 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
156 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
157 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
158 | - exit(0); |
|
159 | - } |
|
160 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
161 | - //$formats[$id] = 'phpvmacars'; |
|
162 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
163 | - //$last_exec['phpvmacars'] = 0; |
|
164 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
165 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
166 | - //$formats[$id] = 'phpvmacars'; |
|
167 | - $globalSources[$id]['format'] = 'vam'; |
|
168 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
169 | - } else if (preg_match('/whazzup/i',$host)) { |
|
170 | - //$formats[$id] = 'whazzup'; |
|
171 | - $globalSources[$id]['format'] = 'whazzup'; |
|
172 | - //$last_exec['whazzup'] = 0; |
|
173 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
174 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
175 | - //$formats[$id] = 'pirepsjson'; |
|
176 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
177 | - //$last_exec['pirepsjson'] = 0; |
|
178 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
179 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
180 | - //$formats[$id] = 'fr24json'; |
|
181 | - $globalSources[$id]['format'] = 'fr24json'; |
|
182 | - //$last_exec['fr24json'] = 0; |
|
183 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
184 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
185 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
186 | - exit(0); |
|
187 | - } |
|
188 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
189 | - //$formats[$id] = 'fr24json'; |
|
190 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
191 | - //$last_exec['fr24json'] = 0; |
|
192 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
193 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
194 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
195 | - exit(0); |
|
196 | - } |
|
197 | - //} else if (preg_match('/10001/',$host)) { |
|
198 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
199 | - //$formats[$id] = 'tsv'; |
|
200 | - $globalSources[$id]['format'] = 'tsv'; |
|
201 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
202 | - } |
|
203 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
204 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
205 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
206 | - if ($idf !== false) { |
|
207 | - $httpfeeds[$id] = $idf; |
|
208 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
209 | - } |
|
210 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
211 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
212 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
213 | - $hostport = explode(':',$host); |
|
214 | - if (isset($hostport[1])) { |
|
122 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | + //$formats[$id] = 'deltadbtxt'; |
|
124 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
125 | + //$last_exec['deltadbtxt'] = 0; |
|
126 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
127 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
128 | + //$formats[$id] = 'vatsimtxt'; |
|
129 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
130 | + //$last_exec['vatsimtxt'] = 0; |
|
131 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
132 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
133 | + //$formats[$id] = 'aircraftlistjson'; |
|
134 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
135 | + //$last_exec['aircraftlistjson'] = 0; |
|
136 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
137 | + } else if (preg_match('/opensky/i',$host)) { |
|
138 | + //$formats[$id] = 'aircraftlistjson'; |
|
139 | + $globalSources[$id]['format'] = 'opensky'; |
|
140 | + //$last_exec['aircraftlistjson'] = 0; |
|
141 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
142 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
143 | + //$formats[$id] = 'radarvirtueljson'; |
|
144 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
145 | + //$last_exec['radarvirtueljson'] = 0; |
|
146 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
147 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
148 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
149 | + exit(0); |
|
150 | + } |
|
151 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
152 | + //$formats[$id] = 'planeupdatefaa'; |
|
153 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
154 | + //$last_exec['planeupdatefaa'] = 0; |
|
155 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
156 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
157 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
158 | + exit(0); |
|
159 | + } |
|
160 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
161 | + //$formats[$id] = 'phpvmacars'; |
|
162 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
163 | + //$last_exec['phpvmacars'] = 0; |
|
164 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
165 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
166 | + //$formats[$id] = 'phpvmacars'; |
|
167 | + $globalSources[$id]['format'] = 'vam'; |
|
168 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
169 | + } else if (preg_match('/whazzup/i',$host)) { |
|
170 | + //$formats[$id] = 'whazzup'; |
|
171 | + $globalSources[$id]['format'] = 'whazzup'; |
|
172 | + //$last_exec['whazzup'] = 0; |
|
173 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
174 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
175 | + //$formats[$id] = 'pirepsjson'; |
|
176 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
177 | + //$last_exec['pirepsjson'] = 0; |
|
178 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
179 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
180 | + //$formats[$id] = 'fr24json'; |
|
181 | + $globalSources[$id]['format'] = 'fr24json'; |
|
182 | + //$last_exec['fr24json'] = 0; |
|
183 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
184 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
185 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
186 | + exit(0); |
|
187 | + } |
|
188 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
189 | + //$formats[$id] = 'fr24json'; |
|
190 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
191 | + //$last_exec['fr24json'] = 0; |
|
192 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
193 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
194 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
195 | + exit(0); |
|
196 | + } |
|
197 | + //} else if (preg_match('/10001/',$host)) { |
|
198 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
199 | + //$formats[$id] = 'tsv'; |
|
200 | + $globalSources[$id]['format'] = 'tsv'; |
|
201 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
202 | + } |
|
203 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
204 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
205 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
206 | + if ($idf !== false) { |
|
207 | + $httpfeeds[$id] = $idf; |
|
208 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
209 | + } |
|
210 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
211 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
212 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
213 | + $hostport = explode(':',$host); |
|
214 | + if (isset($hostport[1])) { |
|
215 | 215 | $port = $hostport[1]; |
216 | 216 | $hostn = $hostport[0]; |
217 | - } else { |
|
217 | + } else { |
|
218 | 218 | $port = $globalSources[$id]['port']; |
219 | 219 | $hostn = $globalSources[$id]['host']; |
220 | - } |
|
221 | - $Common = new Common(); |
|
222 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
223 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
224 | - } else { |
|
225 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
226 | - } |
|
227 | - if ($s) { |
|
228 | - $sockets[$id] = $s; |
|
229 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
230 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
220 | + } |
|
221 | + $Common = new Common(); |
|
222 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
223 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
224 | + } else { |
|
225 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
226 | + } |
|
227 | + if ($s) { |
|
228 | + $sockets[$id] = $s; |
|
229 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
230 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
231 | 231 | //$formats[$id] = 'aprs'; |
232 | 232 | $globalSources[$id]['format'] = 'aprs'; |
233 | 233 | //$aprs_connect = 0; |
234 | 234 | //$use_aprs = true; |
235 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
235 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
236 | 236 | $globalSources[$id]['format'] = 'vrstcp'; |
237 | - } elseif ($port == '10001') { |
|
238 | - //$formats[$id] = 'tsv'; |
|
239 | - $globalSources[$id]['format'] = 'tsv'; |
|
240 | - } elseif ($port == '30002') { |
|
241 | - //$formats[$id] = 'raw'; |
|
242 | - $globalSources[$id]['format'] = 'raw'; |
|
243 | - } elseif ($port == '5001') { |
|
244 | - //$formats[$id] = 'raw'; |
|
245 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
246 | - } elseif ($port == '30005') { |
|
237 | + } elseif ($port == '10001') { |
|
238 | + //$formats[$id] = 'tsv'; |
|
239 | + $globalSources[$id]['format'] = 'tsv'; |
|
240 | + } elseif ($port == '30002') { |
|
241 | + //$formats[$id] = 'raw'; |
|
242 | + $globalSources[$id]['format'] = 'raw'; |
|
243 | + } elseif ($port == '5001') { |
|
244 | + //$formats[$id] = 'raw'; |
|
245 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
246 | + } elseif ($port == '30005') { |
|
247 | 247 | // Not yet supported |
248 | - //$formats[$id] = 'beast'; |
|
249 | - $globalSources[$id]['format'] = 'beast'; |
|
250 | - //} else $formats[$id] = 'sbs'; |
|
251 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
252 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
248 | + //$formats[$id] = 'beast'; |
|
249 | + $globalSources[$id]['format'] = 'beast'; |
|
250 | + //} else $formats[$id] = 'sbs'; |
|
251 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
252 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
253 | 253 | } |
254 | 254 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
255 | - } else { |
|
255 | + } else { |
|
256 | 256 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
257 | - } |
|
258 | - } |
|
259 | - } |
|
257 | + } |
|
258 | + } |
|
259 | + } |
|
260 | 260 | } |
261 | 261 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
262 | 262 | |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | //connect_all($globalSources); |
280 | 280 | |
281 | 281 | if (isset($globalProxy) && $globalProxy) { |
282 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
282 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
283 | 283 | } else { |
284 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
284 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | // APRS Configuration |
@@ -290,18 +290,18 @@ discard block |
||
290 | 290 | die; |
291 | 291 | } |
292 | 292 | foreach ($globalSources as $key => $source) { |
293 | - if (!isset($source['format'])) { |
|
294 | - $globalSources[$key]['format'] = 'auto'; |
|
295 | - } |
|
293 | + if (!isset($source['format'])) { |
|
294 | + $globalSources[$key]['format'] = 'auto'; |
|
295 | + } |
|
296 | 296 | } |
297 | 297 | connect_all($globalSources); |
298 | 298 | foreach ($globalSources as $key => $source) { |
299 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
299 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
300 | 300 | $aprs_connect = 0; |
301 | 301 | $use_aprs = true; |
302 | 302 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
303 | 303 | break; |
304 | - } |
|
304 | + } |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | if ($use_aprs) { |
@@ -342,117 +342,117 @@ discard block |
||
342 | 342 | |
343 | 343 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
344 | 344 | while ($i > 0) { |
345 | - if (!$globalDaemon) $i = $endtime-time(); |
|
346 | - // Delete old ATC |
|
347 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
345 | + if (!$globalDaemon) $i = $endtime-time(); |
|
346 | + // Delete old ATC |
|
347 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
348 | 348 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
349 | - $ATC->deleteOldATC(); |
|
350 | - } |
|
349 | + $ATC->deleteOldATC(); |
|
350 | + } |
|
351 | 351 | |
352 | - //if (count($last_exec) > 0) { |
|
353 | - if (count($last_exec) == count($globalSources)) { |
|
352 | + //if (count($last_exec) > 0) { |
|
353 | + if (count($last_exec) == count($globalSources)) { |
|
354 | 354 | $max = $globalMinFetch; |
355 | 355 | foreach ($last_exec as $last) { |
356 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
356 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
357 | 357 | } |
358 | 358 | if ($max != $globalMinFetch) { |
359 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
360 | - sleep($globalMinFetch-$max+2); |
|
359 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
360 | + sleep($globalMinFetch-$max+2); |
|
361 | + } |
|
361 | 362 | } |
362 | - } |
|
363 | 363 | |
364 | 364 | |
365 | - //foreach ($formats as $id => $value) { |
|
366 | - foreach ($globalSources as $id => $value) { |
|
365 | + //foreach ($formats as $id => $value) { |
|
366 | + foreach ($globalSources as $id => $value) { |
|
367 | 367 | date_default_timezone_set('UTC'); |
368 | 368 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
369 | 369 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
370 | - //$buffer = $Common->getData($hosts[$id]); |
|
371 | - $buffer = $Common->getData($value['host']); |
|
372 | - if ($buffer != '') $reset = 0; |
|
373 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
374 | - $buffer = explode('\n',$buffer); |
|
375 | - foreach ($buffer as $line) { |
|
376 | - if ($line != '' && count($line) > 7) { |
|
377 | - $line = explode(',', $line); |
|
378 | - $data = array(); |
|
379 | - $data['hex'] = $line[1]; // hex |
|
380 | - $data['ident'] = $line[2]; // ident |
|
381 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
382 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
383 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
384 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
385 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
386 | - $data['verticalrate'] = ''; // vertical rate |
|
387 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
388 | - $data['emergency'] = ''; // emergency |
|
389 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
390 | - $data['format_source'] = 'deltadbtxt'; |
|
391 | - $data['id_source'] = $id_source; |
|
392 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
393 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
394 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
395 | - $SI->add($data); |
|
396 | - unset($data); |
|
397 | - } |
|
398 | - } |
|
399 | - $last_exec[$id]['last'] = time(); |
|
370 | + //$buffer = $Common->getData($hosts[$id]); |
|
371 | + $buffer = $Common->getData($value['host']); |
|
372 | + if ($buffer != '') $reset = 0; |
|
373 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
374 | + $buffer = explode('\n',$buffer); |
|
375 | + foreach ($buffer as $line) { |
|
376 | + if ($line != '' && count($line) > 7) { |
|
377 | + $line = explode(',', $line); |
|
378 | + $data = array(); |
|
379 | + $data['hex'] = $line[1]; // hex |
|
380 | + $data['ident'] = $line[2]; // ident |
|
381 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
382 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
383 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
384 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
385 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
386 | + $data['verticalrate'] = ''; // vertical rate |
|
387 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
388 | + $data['emergency'] = ''; // emergency |
|
389 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
390 | + $data['format_source'] = 'deltadbtxt'; |
|
391 | + $data['id_source'] = $id_source; |
|
392 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
393 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
394 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
395 | + $SI->add($data); |
|
396 | + unset($data); |
|
397 | + } |
|
398 | + } |
|
399 | + $last_exec[$id]['last'] = time(); |
|
400 | 400 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
401 | - date_default_timezone_set('CET'); |
|
402 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
403 | - date_default_timezone_set('UTC'); |
|
404 | - if ($buffer != '') $reset = 0; |
|
405 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
406 | - $buffer = explode('\n',$buffer); |
|
407 | - foreach ($buffer as $line) { |
|
401 | + date_default_timezone_set('CET'); |
|
402 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
403 | + date_default_timezone_set('UTC'); |
|
404 | + if ($buffer != '') $reset = 0; |
|
405 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
406 | + $buffer = explode('\n',$buffer); |
|
407 | + foreach ($buffer as $line) { |
|
408 | 408 | if ($line != '') { |
409 | - echo "'".$line."'\n"; |
|
410 | - $add = false; |
|
411 | - $ais_data = $AIS->parse_line(trim($line)); |
|
412 | - $data = array(); |
|
413 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
414 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
415 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
416 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
417 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
418 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
419 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
420 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
421 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
422 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
423 | - if (isset($ais_data['timestamp'])) { |
|
409 | + echo "'".$line."'\n"; |
|
410 | + $add = false; |
|
411 | + $ais_data = $AIS->parse_line(trim($line)); |
|
412 | + $data = array(); |
|
413 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
414 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
415 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
416 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
417 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
418 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
419 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
420 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
421 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
422 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
423 | + if (isset($ais_data['timestamp'])) { |
|
424 | 424 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
425 | 425 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
426 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
427 | - $add = true; |
|
426 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
427 | + $add = true; |
|
428 | 428 | } |
429 | - } else { |
|
429 | + } else { |
|
430 | 430 | $data['datetime'] = date('Y-m-d H:i:s'); |
431 | 431 | $add = true; |
432 | - } |
|
433 | - $data['format_source'] = 'aisnmeatxt'; |
|
434 | - $data['id_source'] = $id_source; |
|
435 | - //print_r($data); |
|
436 | - echo 'Add...'."\n"; |
|
437 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
438 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
439 | - unset($data); |
|
432 | + } |
|
433 | + $data['format_source'] = 'aisnmeatxt'; |
|
434 | + $data['id_source'] = $id_source; |
|
435 | + //print_r($data); |
|
436 | + echo 'Add...'."\n"; |
|
437 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
438 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
439 | + unset($data); |
|
440 | 440 | } |
441 | - } |
|
442 | - $last_exec[$id]['last'] = time(); |
|
441 | + } |
|
442 | + $last_exec[$id]['last'] = time(); |
|
443 | 443 | } elseif ($value['format'] == 'aisnmeahttp') { |
444 | - $arr = $httpfeeds; |
|
445 | - $w = $e = null; |
|
444 | + $arr = $httpfeeds; |
|
445 | + $w = $e = null; |
|
446 | 446 | |
447 | - if (isset($arr[$id])) { |
|
447 | + if (isset($arr[$id])) { |
|
448 | 448 | $nn = stream_select($arr,$w,$e,$timeout); |
449 | 449 | if ($nn > 0) { |
450 | - foreach ($httpfeeds as $feed) { |
|
450 | + foreach ($httpfeeds as $feed) { |
|
451 | 451 | $buffer = stream_get_line($feed,2000,"\n"); |
452 | 452 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
453 | 453 | $buffer = explode('\n',$buffer); |
454 | 454 | foreach ($buffer as $line) { |
455 | - if ($line != '') { |
|
455 | + if ($line != '') { |
|
456 | 456 | $ais_data = $AIS->parse_line(trim($line)); |
457 | 457 | $data = array(); |
458 | 458 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -468,39 +468,39 @@ discard block |
||
468 | 468 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
469 | 469 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
470 | 470 | if (isset($ais_data['timestamp'])) { |
471 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
471 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
472 | 472 | } else { |
473 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
473 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
474 | 474 | } |
475 | 475 | $data['format_source'] = 'aisnmeahttp'; |
476 | 476 | $data['id_source'] = $id_source; |
477 | 477 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
478 | 478 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
479 | 479 | unset($data); |
480 | - } |
|
480 | + } |
|
481 | + } |
|
481 | 482 | } |
482 | - } |
|
483 | 483 | } else { |
484 | - $format = $value['format']; |
|
485 | - if (isset($tt[$format])) $tt[$format]++; |
|
486 | - else $tt[$format] = 0; |
|
487 | - if ($tt[$format] > 30) { |
|
484 | + $format = $value['format']; |
|
485 | + if (isset($tt[$format])) $tt[$format]++; |
|
486 | + else $tt[$format] = 0; |
|
487 | + if ($tt[$format] > 30) { |
|
488 | 488 | sleep(2); |
489 | 489 | $sourceeen[] = $value; |
490 | 490 | connect_all($sourceeen); |
491 | 491 | $sourceeen = array(); |
492 | - } |
|
492 | + } |
|
493 | + } |
|
493 | 494 | } |
494 | - } |
|
495 | 495 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
496 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
497 | - if ($buffer != '') { |
|
496 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
497 | + if ($buffer != '') { |
|
498 | 498 | //echo $buffer; |
499 | 499 | $all_data = json_decode($buffer,true); |
500 | 500 | //print_r($all_data); |
501 | 501 | if (isset($all_data[0]['DATA'])) { |
502 | 502 | foreach ($all_data[0]['DATA'] as $line) { |
503 | - if ($line != '') { |
|
503 | + if ($line != '') { |
|
504 | 504 | $data = array(); |
505 | 505 | $data['ident'] = $line['NAME']; |
506 | 506 | $data['mmsi'] = $line['MMSI']; |
@@ -517,89 +517,89 @@ discard block |
||
517 | 517 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
518 | 518 | $MI->add($data); |
519 | 519 | unset($data); |
520 | - } |
|
520 | + } |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
524 | - } |
|
525 | - $last_exec[$id]['last'] = time(); |
|
524 | + } |
|
525 | + $last_exec[$id]['last'] = time(); |
|
526 | 526 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
527 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
528 | - if ($buffer != '') { |
|
527 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
528 | + if ($buffer != '') { |
|
529 | 529 | $all_data = json_decode($buffer,true); |
530 | 530 | if (isset($all_data[0]['mmsi'])) { |
531 | - foreach ($all_data as $line) { |
|
531 | + foreach ($all_data as $line) { |
|
532 | 532 | if ($line != '') { |
533 | - $data = array(); |
|
534 | - $data['ident'] = $line['shipname']; |
|
535 | - $data['callsign'] = $line['callsign']; |
|
536 | - $data['mmsi'] = $line['mmsi']; |
|
537 | - $data['speed'] = $line['sog']; |
|
538 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
539 | - $data['latitude'] = $line['latitude']; |
|
540 | - $data['longitude'] = $line['longitude']; |
|
541 | - $data['type_id'] = $line['shiptype']; |
|
542 | - $data['arrival_code'] = $line['destination']; |
|
543 | - $data['datetime'] = $line['time']; |
|
544 | - $data['format_source'] = 'boatbeaconapp'; |
|
545 | - $data['id_source'] = $id_source; |
|
546 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
547 | - $MI->add($data); |
|
548 | - unset($data); |
|
533 | + $data = array(); |
|
534 | + $data['ident'] = $line['shipname']; |
|
535 | + $data['callsign'] = $line['callsign']; |
|
536 | + $data['mmsi'] = $line['mmsi']; |
|
537 | + $data['speed'] = $line['sog']; |
|
538 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
539 | + $data['latitude'] = $line['latitude']; |
|
540 | + $data['longitude'] = $line['longitude']; |
|
541 | + $data['type_id'] = $line['shiptype']; |
|
542 | + $data['arrival_code'] = $line['destination']; |
|
543 | + $data['datetime'] = $line['time']; |
|
544 | + $data['format_source'] = 'boatbeaconapp'; |
|
545 | + $data['id_source'] = $id_source; |
|
546 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
547 | + $MI->add($data); |
|
548 | + unset($data); |
|
549 | + } |
|
549 | 550 | } |
550 | - } |
|
551 | 551 | } |
552 | 552 | |
553 | - } |
|
554 | - $last_exec[$id]['last'] = time(); |
|
553 | + } |
|
554 | + $last_exec[$id]['last'] = time(); |
|
555 | 555 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
556 | - echo 'download...'; |
|
557 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
558 | - echo 'done !'."\n"; |
|
559 | - if ($buffer != '') $reset = 0; |
|
560 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
561 | - $buffer = explode('\n',$buffer); |
|
562 | - foreach ($buffer as $line) { |
|
556 | + echo 'download...'; |
|
557 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
558 | + echo 'done !'."\n"; |
|
559 | + if ($buffer != '') $reset = 0; |
|
560 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
561 | + $buffer = explode('\n',$buffer); |
|
562 | + foreach ($buffer as $line) { |
|
563 | 563 | if ($line != '') { |
564 | - $data = array(); |
|
565 | - $data['mmsi'] = (int)substr($line,0,9); |
|
566 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
567 | - //$data['status'] = substr($line,21,2); |
|
568 | - //$data['type'] = substr($line,24,3); |
|
569 | - $data['latitude'] = substr($line,29,9); |
|
570 | - $data['longitude'] = substr($line,41,9); |
|
571 | - $data['speed'] = round(substr($line,51,5)); |
|
572 | - //$data['course'] = substr($line,57,5); |
|
573 | - $data['heading'] = round(substr($line,63,3)); |
|
574 | - //$data['draft'] = substr($line,67,4); |
|
575 | - //$data['length'] = substr($line,72,3); |
|
576 | - //$data['beam'] = substr($line,76,2); |
|
577 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
578 | - //$data['callsign'] = trim(substr($line,100,7); |
|
579 | - //$data['dest'] = substr($line,108,20); |
|
580 | - //$data['etaDate'] = substr($line,129,5); |
|
581 | - //$data['etaTime'] = substr($line,135,5); |
|
582 | - $data['format_source'] = 'shipplotter'; |
|
583 | - $data['id_source'] = $id_source; |
|
584 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
585 | - //print_r($data); |
|
586 | - echo 'Add...'."\n"; |
|
587 | - $MI->add($data); |
|
588 | - unset($data); |
|
564 | + $data = array(); |
|
565 | + $data['mmsi'] = (int)substr($line,0,9); |
|
566 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
567 | + //$data['status'] = substr($line,21,2); |
|
568 | + //$data['type'] = substr($line,24,3); |
|
569 | + $data['latitude'] = substr($line,29,9); |
|
570 | + $data['longitude'] = substr($line,41,9); |
|
571 | + $data['speed'] = round(substr($line,51,5)); |
|
572 | + //$data['course'] = substr($line,57,5); |
|
573 | + $data['heading'] = round(substr($line,63,3)); |
|
574 | + //$data['draft'] = substr($line,67,4); |
|
575 | + //$data['length'] = substr($line,72,3); |
|
576 | + //$data['beam'] = substr($line,76,2); |
|
577 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
578 | + //$data['callsign'] = trim(substr($line,100,7); |
|
579 | + //$data['dest'] = substr($line,108,20); |
|
580 | + //$data['etaDate'] = substr($line,129,5); |
|
581 | + //$data['etaTime'] = substr($line,135,5); |
|
582 | + $data['format_source'] = 'shipplotter'; |
|
583 | + $data['id_source'] = $id_source; |
|
584 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
585 | + //print_r($data); |
|
586 | + echo 'Add...'."\n"; |
|
587 | + $MI->add($data); |
|
588 | + unset($data); |
|
589 | 589 | } |
590 | - } |
|
591 | - $last_exec[$id]['last'] = time(); |
|
590 | + } |
|
591 | + $last_exec[$id]['last'] = time(); |
|
592 | 592 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
593 | 593 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
594 | - //$buffer = $Common->getData($hosts[$id]); |
|
595 | - $buffer = $Common->getData($value['host']); |
|
596 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
597 | - $buffer = explode('\n',$buffer); |
|
598 | - $reset = 0; |
|
599 | - foreach ($buffer as $line) { |
|
600 | - if ($line != '') { |
|
601 | - $line = explode(':', $line); |
|
602 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
594 | + //$buffer = $Common->getData($hosts[$id]); |
|
595 | + $buffer = $Common->getData($value['host']); |
|
596 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
597 | + $buffer = explode('\n',$buffer); |
|
598 | + $reset = 0; |
|
599 | + foreach ($buffer as $line) { |
|
600 | + if ($line != '') { |
|
601 | + $line = explode(':', $line); |
|
602 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
603 | 603 | $data = array(); |
604 | 604 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
605 | 605 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -612,37 +612,37 @@ discard block |
||
612 | 612 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
613 | 613 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
614 | 614 | $data['latitude'] = $line[5]; // lat |
615 | - $data['longitude'] = $line[6]; // long |
|
616 | - $data['verticalrate'] = ''; // vertical rate |
|
617 | - $data['squawk'] = ''; // squawk |
|
618 | - $data['emergency'] = ''; // emergency |
|
619 | - $data['waypoints'] = $line[30]; |
|
615 | + $data['longitude'] = $line[6]; // long |
|
616 | + $data['verticalrate'] = ''; // vertical rate |
|
617 | + $data['squawk'] = ''; // squawk |
|
618 | + $data['emergency'] = ''; // emergency |
|
619 | + $data['waypoints'] = $line[30]; |
|
620 | 620 | $data['datetime'] = date('Y-m-d H:i:s'); |
621 | 621 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
622 | 622 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
623 | - $data['departure_airport_icao'] = $line[11]; |
|
624 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
625 | - $data['arrival_airport_icao'] = $line[13]; |
|
623 | + $data['departure_airport_icao'] = $line[11]; |
|
624 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
625 | + $data['arrival_airport_icao'] = $line[13]; |
|
626 | 626 | $data['frequency'] = $line[4]; |
627 | 627 | $data['type'] = $line[18]; |
628 | 628 | $data['range'] = $line[19]; |
629 | 629 | if (isset($line[35])) $data['info'] = $line[35]; |
630 | - $data['id_source'] = $id_source; |
|
631 | - //$data['arrival_airport_time'] = ; |
|
632 | - if ($line[9] != '') { |
|
633 | - $aircraft_data = explode('/',$line[9]); |
|
634 | - if (isset($aircraft_data[1])) { |
|
635 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
636 | - } |
|
637 | - } |
|
638 | - /* |
|
630 | + $data['id_source'] = $id_source; |
|
631 | + //$data['arrival_airport_time'] = ; |
|
632 | + if ($line[9] != '') { |
|
633 | + $aircraft_data = explode('/',$line[9]); |
|
634 | + if (isset($aircraft_data[1])) { |
|
635 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
636 | + } |
|
637 | + } |
|
638 | + /* |
|
639 | 639 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
640 | 640 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
641 | 641 | */ |
642 | - $data['format_source'] = $value['format']; |
|
642 | + $data['format_source'] = $value['format']; |
|
643 | 643 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
644 | 644 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
645 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
645 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
646 | 646 | elseif ($line[3] == 'ATC') { |
647 | 647 | //print_r($data); |
648 | 648 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -660,254 +660,254 @@ discard block |
||
660 | 660 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
661 | 661 | 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']); |
662 | 662 | } |
663 | - unset($data); |
|
664 | - } |
|
665 | - } |
|
666 | - } |
|
667 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
668 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
669 | - $last_exec[$id]['last'] = time(); |
|
670 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
671 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
672 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
673 | - if ($buffer != '') { |
|
674 | - $all_data = json_decode($buffer,true); |
|
675 | - if (isset($all_data['acList'])) { |
|
663 | + unset($data); |
|
664 | + } |
|
665 | + } |
|
666 | + } |
|
667 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
668 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
669 | + $last_exec[$id]['last'] = time(); |
|
670 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
671 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
672 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
673 | + if ($buffer != '') { |
|
674 | + $all_data = json_decode($buffer,true); |
|
675 | + if (isset($all_data['acList'])) { |
|
676 | 676 | $reset = 0; |
677 | 677 | foreach ($all_data['acList'] as $line) { |
678 | - $data = array(); |
|
679 | - $data['hex'] = $line['Icao']; // hex |
|
680 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
681 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
682 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
683 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
684 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
685 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
686 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
687 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
688 | - $data['emergency'] = ''; // emergency |
|
689 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
690 | - /* |
|
678 | + $data = array(); |
|
679 | + $data['hex'] = $line['Icao']; // hex |
|
680 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
681 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
682 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
683 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
684 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
685 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
686 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
687 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
688 | + $data['emergency'] = ''; // emergency |
|
689 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
690 | + /* |
|
691 | 691 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
692 | 692 | else $data['datetime'] = date('Y-m-d H:i:s'); |
693 | 693 | */ |
694 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
695 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
696 | - $data['format_source'] = 'aircraftlistjson'; |
|
697 | - $data['id_source'] = $id_source; |
|
698 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
699 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
700 | - if (isset($data['latitude'])) $SI->add($data); |
|
701 | - unset($data); |
|
694 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
695 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
696 | + $data['format_source'] = 'aircraftlistjson'; |
|
697 | + $data['id_source'] = $id_source; |
|
698 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
699 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
700 | + if (isset($data['latitude'])) $SI->add($data); |
|
701 | + unset($data); |
|
702 | 702 | } |
703 | - } elseif (is_array($all_data)) { |
|
703 | + } elseif (is_array($all_data)) { |
|
704 | 704 | $reset = 0; |
705 | 705 | foreach ($all_data as $line) { |
706 | - $data = array(); |
|
707 | - $data['hex'] = $line['hex']; // hex |
|
708 | - $data['ident'] = $line['flight']; // ident |
|
709 | - $data['altitude'] = $line['altitude']; // altitude |
|
710 | - $data['speed'] = $line['speed']; // speed |
|
711 | - $data['heading'] = $line['track']; // heading |
|
712 | - $data['latitude'] = $line['lat']; // lat |
|
713 | - $data['longitude'] = $line['lon']; // long |
|
714 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
715 | - $data['squawk'] = $line['squawk']; // squawk |
|
716 | - $data['emergency'] = ''; // emergency |
|
717 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
718 | - $data['format_source'] = 'aircraftlistjson'; |
|
719 | - $data['id_source'] = $id_source; |
|
720 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
721 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
722 | - $SI->add($data); |
|
723 | - unset($data); |
|
706 | + $data = array(); |
|
707 | + $data['hex'] = $line['hex']; // hex |
|
708 | + $data['ident'] = $line['flight']; // ident |
|
709 | + $data['altitude'] = $line['altitude']; // altitude |
|
710 | + $data['speed'] = $line['speed']; // speed |
|
711 | + $data['heading'] = $line['track']; // heading |
|
712 | + $data['latitude'] = $line['lat']; // lat |
|
713 | + $data['longitude'] = $line['lon']; // long |
|
714 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
715 | + $data['squawk'] = $line['squawk']; // squawk |
|
716 | + $data['emergency'] = ''; // emergency |
|
717 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
718 | + $data['format_source'] = 'aircraftlistjson'; |
|
719 | + $data['id_source'] = $id_source; |
|
720 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
721 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
722 | + $SI->add($data); |
|
723 | + unset($data); |
|
724 | 724 | } |
725 | - } |
|
726 | - } |
|
727 | - //$last_exec['aircraftlistjson'] = time(); |
|
728 | - $last_exec[$id]['last'] = time(); |
|
729 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
730 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
731 | - $buffer = $Common->getData($value['host']); |
|
732 | - $all_data = json_decode($buffer,true); |
|
733 | - if (isset($all_data['planes'])) { |
|
725 | + } |
|
726 | + } |
|
727 | + //$last_exec['aircraftlistjson'] = time(); |
|
728 | + $last_exec[$id]['last'] = time(); |
|
729 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
730 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
731 | + $buffer = $Common->getData($value['host']); |
|
732 | + $all_data = json_decode($buffer,true); |
|
733 | + if (isset($all_data['planes'])) { |
|
734 | 734 | $reset = 0; |
735 | 735 | foreach ($all_data['planes'] as $key => $line) { |
736 | - $data = array(); |
|
737 | - $data['hex'] = $key; // hex |
|
738 | - $data['ident'] = $line[3]; // ident |
|
739 | - $data['altitude'] = $line[6]; // altitude |
|
740 | - $data['speed'] = $line[8]; // speed |
|
741 | - $data['heading'] = $line[7]; // heading |
|
742 | - $data['latitude'] = $line[4]; // lat |
|
743 | - $data['longitude'] = $line[5]; // long |
|
744 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
745 | - $data['squawk'] = $line[10]; // squawk |
|
746 | - $data['emergency'] = ''; // emergency |
|
747 | - $data['registration'] = $line[2]; |
|
748 | - $data['aircraft_icao'] = $line[0]; |
|
749 | - $deparr = explode('-',$line[1]); |
|
750 | - if (count($deparr) == 2) { |
|
736 | + $data = array(); |
|
737 | + $data['hex'] = $key; // hex |
|
738 | + $data['ident'] = $line[3]; // ident |
|
739 | + $data['altitude'] = $line[6]; // altitude |
|
740 | + $data['speed'] = $line[8]; // speed |
|
741 | + $data['heading'] = $line[7]; // heading |
|
742 | + $data['latitude'] = $line[4]; // lat |
|
743 | + $data['longitude'] = $line[5]; // long |
|
744 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
745 | + $data['squawk'] = $line[10]; // squawk |
|
746 | + $data['emergency'] = ''; // emergency |
|
747 | + $data['registration'] = $line[2]; |
|
748 | + $data['aircraft_icao'] = $line[0]; |
|
749 | + $deparr = explode('-',$line[1]); |
|
750 | + if (count($deparr) == 2) { |
|
751 | 751 | $data['departure_airport_icao'] = $deparr[0]; |
752 | 752 | $data['arrival_airport_icao'] = $deparr[1]; |
753 | - } |
|
754 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
755 | - $data['format_source'] = 'planeupdatefaa'; |
|
756 | - $data['id_source'] = $id_source; |
|
757 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
758 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
759 | - $SI->add($data); |
|
760 | - unset($data); |
|
753 | + } |
|
754 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
755 | + $data['format_source'] = 'planeupdatefaa'; |
|
756 | + $data['id_source'] = $id_source; |
|
757 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
758 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
759 | + $SI->add($data); |
|
760 | + unset($data); |
|
761 | 761 | } |
762 | - } |
|
763 | - //$last_exec['planeupdatefaa'] = time(); |
|
764 | - $last_exec[$id]['last'] = time(); |
|
765 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
766 | - $buffer = $Common->getData($value['host']); |
|
767 | - $all_data = json_decode($buffer,true); |
|
768 | - if (isset($all_data['states'])) { |
|
762 | + } |
|
763 | + //$last_exec['planeupdatefaa'] = time(); |
|
764 | + $last_exec[$id]['last'] = time(); |
|
765 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
766 | + $buffer = $Common->getData($value['host']); |
|
767 | + $all_data = json_decode($buffer,true); |
|
768 | + if (isset($all_data['states'])) { |
|
769 | 769 | $reset = 0; |
770 | 770 | foreach ($all_data['states'] as $key => $line) { |
771 | - $data = array(); |
|
772 | - $data['hex'] = $line[0]; // hex |
|
773 | - $data['ident'] = trim($line[1]); // ident |
|
774 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
775 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
776 | - $data['heading'] = round($line[10]); // heading |
|
777 | - $data['latitude'] = $line[5]; // lat |
|
778 | - $data['longitude'] = $line[6]; // long |
|
779 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
780 | - //$data['squawk'] = $line[10]; // squawk |
|
781 | - //$data['emergency'] = ''; // emergency |
|
782 | - //$data['registration'] = $line[2]; |
|
783 | - //$data['aircraft_icao'] = $line[0]; |
|
784 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
785 | - $data['format_source'] = 'opensky'; |
|
786 | - $data['id_source'] = $id_source; |
|
787 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
788 | - $SI->add($data); |
|
789 | - unset($data); |
|
771 | + $data = array(); |
|
772 | + $data['hex'] = $line[0]; // hex |
|
773 | + $data['ident'] = trim($line[1]); // ident |
|
774 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
775 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
776 | + $data['heading'] = round($line[10]); // heading |
|
777 | + $data['latitude'] = $line[5]; // lat |
|
778 | + $data['longitude'] = $line[6]; // long |
|
779 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
780 | + //$data['squawk'] = $line[10]; // squawk |
|
781 | + //$data['emergency'] = ''; // emergency |
|
782 | + //$data['registration'] = $line[2]; |
|
783 | + //$data['aircraft_icao'] = $line[0]; |
|
784 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
785 | + $data['format_source'] = 'opensky'; |
|
786 | + $data['id_source'] = $id_source; |
|
787 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
788 | + $SI->add($data); |
|
789 | + unset($data); |
|
790 | + } |
|
790 | 791 | } |
791 | - } |
|
792 | - //$last_exec['planeupdatefaa'] = time(); |
|
793 | - $last_exec[$id]['last'] = time(); |
|
794 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
795 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
796 | - //$buffer = $Common->getData($hosts[$id]); |
|
797 | - $buffer = $Common->getData($value['host']); |
|
798 | - $all_data = json_decode($buffer,true); |
|
799 | - if (!empty($all_data)) $reset = 0; |
|
800 | - foreach ($all_data as $key => $line) { |
|
792 | + //$last_exec['planeupdatefaa'] = time(); |
|
793 | + $last_exec[$id]['last'] = time(); |
|
794 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
795 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
796 | + //$buffer = $Common->getData($hosts[$id]); |
|
797 | + $buffer = $Common->getData($value['host']); |
|
798 | + $all_data = json_decode($buffer,true); |
|
799 | + if (!empty($all_data)) $reset = 0; |
|
800 | + foreach ($all_data as $key => $line) { |
|
801 | 801 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
802 | - $data = array(); |
|
803 | - $data['hex'] = $line[0]; |
|
804 | - $data['ident'] = $line[16]; //$line[13] |
|
805 | - $data['altitude'] = $line[4]; // altitude |
|
806 | - $data['speed'] = $line[5]; // speed |
|
807 | - $data['heading'] = $line[3]; // heading |
|
808 | - $data['latitude'] = $line[1]; // lat |
|
809 | - $data['longitude'] = $line[2]; // long |
|
810 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
811 | - $data['squawk'] = $line[6]; // squawk |
|
812 | - $data['aircraft_icao'] = $line[8]; |
|
813 | - $data['registration'] = $line[9]; |
|
814 | - $data['departure_airport_iata'] = $line[11]; |
|
815 | - $data['arrival_airport_iata'] = $line[12]; |
|
816 | - $data['emergency'] = ''; // emergency |
|
817 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
818 | - $data['format_source'] = 'fr24json'; |
|
819 | - $data['id_source'] = $id_source; |
|
820 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
821 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
822 | - $SI->add($data); |
|
823 | - unset($data); |
|
802 | + $data = array(); |
|
803 | + $data['hex'] = $line[0]; |
|
804 | + $data['ident'] = $line[16]; //$line[13] |
|
805 | + $data['altitude'] = $line[4]; // altitude |
|
806 | + $data['speed'] = $line[5]; // speed |
|
807 | + $data['heading'] = $line[3]; // heading |
|
808 | + $data['latitude'] = $line[1]; // lat |
|
809 | + $data['longitude'] = $line[2]; // long |
|
810 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
811 | + $data['squawk'] = $line[6]; // squawk |
|
812 | + $data['aircraft_icao'] = $line[8]; |
|
813 | + $data['registration'] = $line[9]; |
|
814 | + $data['departure_airport_iata'] = $line[11]; |
|
815 | + $data['arrival_airport_iata'] = $line[12]; |
|
816 | + $data['emergency'] = ''; // emergency |
|
817 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
818 | + $data['format_source'] = 'fr24json'; |
|
819 | + $data['id_source'] = $id_source; |
|
820 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
821 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
822 | + $SI->add($data); |
|
823 | + unset($data); |
|
824 | + } |
|
824 | 825 | } |
825 | - } |
|
826 | - //$last_exec['fr24json'] = time(); |
|
827 | - $last_exec[$id]['last'] = time(); |
|
828 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
829 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
830 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
831 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
832 | - //echo $buffer; |
|
833 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
834 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
835 | - $all_data = json_decode($buffer,true); |
|
836 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
826 | + //$last_exec['fr24json'] = time(); |
|
827 | + $last_exec[$id]['last'] = time(); |
|
828 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
829 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
830 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
831 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
832 | + //echo $buffer; |
|
833 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
834 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
835 | + $all_data = json_decode($buffer,true); |
|
836 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
837 | 837 | die(json_last_error_msg()); |
838 | - } |
|
839 | - if (isset($all_data['mrkrs'])) { |
|
838 | + } |
|
839 | + if (isset($all_data['mrkrs'])) { |
|
840 | 840 | $reset = 0; |
841 | 841 | foreach ($all_data['mrkrs'] as $key => $line) { |
842 | - if (isset($line['inf'])) { |
|
842 | + if (isset($line['inf'])) { |
|
843 | 843 | $data = array(); |
844 | 844 | $data['hex'] = $line['inf']['ia']; |
845 | 845 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
846 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
847 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
848 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
849 | - $data['latitude'] = $line['pt'][0]; // lat |
|
850 | - $data['longitude'] = $line['pt'][1]; // long |
|
851 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
852 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
853 | - //$data['aircraft_icao'] = $line[8]; |
|
854 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
846 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
847 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
848 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
849 | + $data['latitude'] = $line['pt'][0]; // lat |
|
850 | + $data['longitude'] = $line['pt'][1]; // long |
|
851 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
852 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
853 | + //$data['aircraft_icao'] = $line[8]; |
|
854 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
855 | 855 | //$data['departure_airport_iata'] = $line[11]; |
856 | 856 | //$data['arrival_airport_iata'] = $line[12]; |
857 | - //$data['emergency'] = ''; // emergency |
|
857 | + //$data['emergency'] = ''; // emergency |
|
858 | 858 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
859 | - $data['format_source'] = 'radarvirtueljson'; |
|
860 | - $data['id_source'] = $id_source; |
|
859 | + $data['format_source'] = 'radarvirtueljson'; |
|
860 | + $data['id_source'] = $id_source; |
|
861 | 861 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
862 | 862 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
863 | 863 | $SI->add($data); |
864 | 864 | unset($data); |
865 | - } |
|
865 | + } |
|
866 | + } |
|
866 | 867 | } |
867 | - } |
|
868 | - //$last_exec['radarvirtueljson'] = time(); |
|
869 | - $last_exec[$id]['last'] = time(); |
|
870 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
871 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
872 | - //$buffer = $Common->getData($hosts[$id]); |
|
873 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
874 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
868 | + //$last_exec['radarvirtueljson'] = time(); |
|
869 | + $last_exec[$id]['last'] = time(); |
|
870 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
871 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
872 | + //$buffer = $Common->getData($hosts[$id]); |
|
873 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
874 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
875 | 875 | |
876 | - if (isset($all_data['pireps'])) { |
|
876 | + if (isset($all_data['pireps'])) { |
|
877 | 877 | $reset = 0; |
878 | - foreach ($all_data['pireps'] as $line) { |
|
879 | - $data = array(); |
|
880 | - $data['id'] = $line['id']; |
|
881 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
882 | - $data['ident'] = $line['callsign']; // ident |
|
883 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
884 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
885 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
886 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
887 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
888 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
889 | - $data['latitude'] = $line['lat']; // lat |
|
890 | - $data['longitude'] = $line['lon']; // long |
|
891 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
892 | - //$data['squawk'] = $line['squawk']; // squawk |
|
893 | - //$data['emergency'] = ''; // emergency |
|
894 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
895 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
896 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
897 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
898 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
899 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
900 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
901 | - else $data['info'] = ''; |
|
902 | - $data['format_source'] = 'pireps'; |
|
903 | - $data['id_source'] = $id_source; |
|
904 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
905 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
906 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
907 | - if ($line['icon'] == 'plane') { |
|
878 | + foreach ($all_data['pireps'] as $line) { |
|
879 | + $data = array(); |
|
880 | + $data['id'] = $line['id']; |
|
881 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
882 | + $data['ident'] = $line['callsign']; // ident |
|
883 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
884 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
885 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
886 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
887 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
888 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
889 | + $data['latitude'] = $line['lat']; // lat |
|
890 | + $data['longitude'] = $line['lon']; // long |
|
891 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
892 | + //$data['squawk'] = $line['squawk']; // squawk |
|
893 | + //$data['emergency'] = ''; // emergency |
|
894 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
895 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
896 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
897 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
898 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
899 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
900 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
901 | + else $data['info'] = ''; |
|
902 | + $data['format_source'] = 'pireps'; |
|
903 | + $data['id_source'] = $id_source; |
|
904 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
905 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
906 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
907 | + if ($line['icon'] == 'plane') { |
|
908 | 908 | $SI->add($data); |
909 | - // print_r($data); |
|
910 | - } elseif ($line['icon'] == 'ct') { |
|
909 | + // print_r($data); |
|
910 | + } elseif ($line['icon'] == 'ct') { |
|
911 | 911 | $data['info'] = str_replace('^§','<br />',$data['info']); |
912 | 912 | $data['info'] = str_replace('&sect;','',$data['info']); |
913 | 913 | $typec = substr($data['ident'],-3); |
@@ -922,196 +922,196 @@ discard block |
||
922 | 922 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
923 | 923 | else $data['type'] = 'Observer'; |
924 | 924 | 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']); |
925 | - } |
|
926 | - unset($data); |
|
925 | + } |
|
926 | + unset($data); |
|
927 | + } |
|
927 | 928 | } |
928 | - } |
|
929 | - //$last_exec['pirepsjson'] = time(); |
|
930 | - $last_exec[$id]['last'] = time(); |
|
931 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
932 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
933 | - //$buffer = $Common->getData($hosts[$id]); |
|
934 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
935 | - $buffer = $Common->getData($value['host']); |
|
936 | - $all_data = json_decode($buffer,true); |
|
937 | - if ($buffer != '' && is_array($all_data)) { |
|
929 | + //$last_exec['pirepsjson'] = time(); |
|
930 | + $last_exec[$id]['last'] = time(); |
|
931 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
932 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
933 | + //$buffer = $Common->getData($hosts[$id]); |
|
934 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
935 | + $buffer = $Common->getData($value['host']); |
|
936 | + $all_data = json_decode($buffer,true); |
|
937 | + if ($buffer != '' && is_array($all_data)) { |
|
938 | 938 | $reset = 0; |
939 | 939 | foreach ($all_data as $line) { |
940 | - $data = array(); |
|
941 | - //$data['id'] = $line['id']; // id not usable |
|
942 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
943 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
944 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
945 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
946 | - $data['ident'] = $line['flightnum']; // ident |
|
947 | - $data['altitude'] = $line['alt']; // altitude |
|
948 | - $data['speed'] = $line['gs']; // speed |
|
949 | - $data['heading'] = $line['heading']; // heading |
|
950 | - $data['latitude'] = $line['lat']; // lat |
|
951 | - $data['longitude'] = $line['lng']; // long |
|
952 | - $data['verticalrate'] = ''; // verticale rate |
|
953 | - $data['squawk'] = ''; // squawk |
|
954 | - $data['emergency'] = ''; // emergency |
|
955 | - //$data['datetime'] = $line['lastupdate']; |
|
956 | - $data['last_update'] = $line['lastupdate']; |
|
957 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
958 | - $data['departure_airport_icao'] = $line['depicao']; |
|
959 | - $data['departure_airport_time'] = $line['deptime']; |
|
960 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
961 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
962 | - $data['registration'] = $line['aircraft']; |
|
963 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
964 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
965 | - if (isset($line['aircraftname'])) { |
|
940 | + $data = array(); |
|
941 | + //$data['id'] = $line['id']; // id not usable |
|
942 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
943 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
944 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
945 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
946 | + $data['ident'] = $line['flightnum']; // ident |
|
947 | + $data['altitude'] = $line['alt']; // altitude |
|
948 | + $data['speed'] = $line['gs']; // speed |
|
949 | + $data['heading'] = $line['heading']; // heading |
|
950 | + $data['latitude'] = $line['lat']; // lat |
|
951 | + $data['longitude'] = $line['lng']; // long |
|
952 | + $data['verticalrate'] = ''; // verticale rate |
|
953 | + $data['squawk'] = ''; // squawk |
|
954 | + $data['emergency'] = ''; // emergency |
|
955 | + //$data['datetime'] = $line['lastupdate']; |
|
956 | + $data['last_update'] = $line['lastupdate']; |
|
957 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
958 | + $data['departure_airport_icao'] = $line['depicao']; |
|
959 | + $data['departure_airport_time'] = $line['deptime']; |
|
960 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
961 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
962 | + $data['registration'] = $line['aircraft']; |
|
963 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
964 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
965 | + if (isset($line['aircraftname'])) { |
|
966 | 966 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
967 | 967 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
968 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
969 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
970 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
971 | - else { |
|
972 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
973 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
974 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
975 | - } |
|
976 | - } |
|
977 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
978 | - $data['id_source'] = $id_source; |
|
979 | - $data['format_source'] = 'phpvmacars'; |
|
980 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
981 | - $SI->add($data); |
|
982 | - unset($data); |
|
968 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
969 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
970 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
971 | + else { |
|
972 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
973 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
974 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
975 | + } |
|
976 | + } |
|
977 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
978 | + $data['id_source'] = $id_source; |
|
979 | + $data['format_source'] = 'phpvmacars'; |
|
980 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
981 | + $SI->add($data); |
|
982 | + unset($data); |
|
983 | 983 | } |
984 | 984 | if ($globalDebug) echo 'No more data...'."\n"; |
985 | 985 | unset($buffer); |
986 | 986 | unset($all_data); |
987 | - } |
|
988 | - //$last_exec['phpvmacars'] = time(); |
|
989 | - $last_exec[$id]['last'] = time(); |
|
990 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
991 | - //$buffer = $Common->getData($hosts[$id]); |
|
992 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
993 | - $buffer = $Common->getData($value['host']); |
|
994 | - $all_data = json_decode($buffer,true); |
|
995 | - if ($buffer != '' && is_array($all_data)) { |
|
987 | + } |
|
988 | + //$last_exec['phpvmacars'] = time(); |
|
989 | + $last_exec[$id]['last'] = time(); |
|
990 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
991 | + //$buffer = $Common->getData($hosts[$id]); |
|
992 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
993 | + $buffer = $Common->getData($value['host']); |
|
994 | + $all_data = json_decode($buffer,true); |
|
995 | + if ($buffer != '' && is_array($all_data)) { |
|
996 | 996 | $reset = 0; |
997 | 997 | foreach ($all_data as $line) { |
998 | - $data = array(); |
|
999 | - //$data['id'] = $line['id']; // id not usable |
|
1000 | - $data['id'] = trim($line['flight_id']); |
|
1001 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1002 | - $data['pilot_name'] = $line['pilot_name']; |
|
1003 | - $data['pilot_id'] = $line['pilot_id']; |
|
1004 | - $data['ident'] = trim($line['callsign']); // ident |
|
1005 | - $data['altitude'] = $line['altitude']; // altitude |
|
1006 | - $data['speed'] = $line['gs']; // speed |
|
1007 | - $data['heading'] = $line['heading']; // heading |
|
1008 | - $data['latitude'] = $line['latitude']; // lat |
|
1009 | - $data['longitude'] = $line['longitude']; // long |
|
1010 | - $data['verticalrate'] = ''; // verticale rate |
|
1011 | - $data['squawk'] = ''; // squawk |
|
1012 | - $data['emergency'] = ''; // emergency |
|
1013 | - //$data['datetime'] = $line['lastupdate']; |
|
1014 | - $data['last_update'] = $line['last_update']; |
|
1015 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1016 | - $data['departure_airport_icao'] = $line['departure']; |
|
1017 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1018 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1019 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1020 | - //$data['registration'] = $line['aircraft']; |
|
1021 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1022 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1023 | - $data['id_source'] = $id_source; |
|
1024 | - $data['format_source'] = 'vam'; |
|
1025 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1026 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1027 | - $SI->add($data); |
|
1028 | - unset($data); |
|
998 | + $data = array(); |
|
999 | + //$data['id'] = $line['id']; // id not usable |
|
1000 | + $data['id'] = trim($line['flight_id']); |
|
1001 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1002 | + $data['pilot_name'] = $line['pilot_name']; |
|
1003 | + $data['pilot_id'] = $line['pilot_id']; |
|
1004 | + $data['ident'] = trim($line['callsign']); // ident |
|
1005 | + $data['altitude'] = $line['altitude']; // altitude |
|
1006 | + $data['speed'] = $line['gs']; // speed |
|
1007 | + $data['heading'] = $line['heading']; // heading |
|
1008 | + $data['latitude'] = $line['latitude']; // lat |
|
1009 | + $data['longitude'] = $line['longitude']; // long |
|
1010 | + $data['verticalrate'] = ''; // verticale rate |
|
1011 | + $data['squawk'] = ''; // squawk |
|
1012 | + $data['emergency'] = ''; // emergency |
|
1013 | + //$data['datetime'] = $line['lastupdate']; |
|
1014 | + $data['last_update'] = $line['last_update']; |
|
1015 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1016 | + $data['departure_airport_icao'] = $line['departure']; |
|
1017 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1018 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1019 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1020 | + //$data['registration'] = $line['aircraft']; |
|
1021 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1022 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1023 | + $data['id_source'] = $id_source; |
|
1024 | + $data['format_source'] = 'vam'; |
|
1025 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1026 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1027 | + $SI->add($data); |
|
1028 | + unset($data); |
|
1029 | 1029 | } |
1030 | 1030 | if ($globalDebug) echo 'No more data...'."\n"; |
1031 | 1031 | unset($buffer); |
1032 | 1032 | unset($all_data); |
1033 | - } |
|
1034 | - //$last_exec['phpvmacars'] = time(); |
|
1035 | - $last_exec[$id]['last'] = time(); |
|
1033 | + } |
|
1034 | + //$last_exec['phpvmacars'] = time(); |
|
1035 | + $last_exec[$id]['last'] = time(); |
|
1036 | 1036 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1037 | 1037 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1038 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1039 | - //$last_exec[$id]['last'] = time(); |
|
1038 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1039 | + //$last_exec[$id]['last'] = time(); |
|
1040 | 1040 | |
1041 | - //$read = array( $sockets[$id] ); |
|
1042 | - $read = $sockets; |
|
1043 | - $write = NULL; |
|
1044 | - $e = NULL; |
|
1045 | - $n = socket_select($read, $write, $e, $timeout); |
|
1046 | - if ($e != NULL) var_dump($e); |
|
1047 | - if ($n > 0) { |
|
1041 | + //$read = array( $sockets[$id] ); |
|
1042 | + $read = $sockets; |
|
1043 | + $write = NULL; |
|
1044 | + $e = NULL; |
|
1045 | + $n = socket_select($read, $write, $e, $timeout); |
|
1046 | + if ($e != NULL) var_dump($e); |
|
1047 | + if ($n > 0) { |
|
1048 | 1048 | $reset = 0; |
1049 | 1049 | foreach ($read as $nb => $r) { |
1050 | - //$value = $formats[$nb]; |
|
1051 | - $format = $globalSources[$nb]['format']; |
|
1052 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1050 | + //$value = $formats[$nb]; |
|
1051 | + $format = $globalSources[$nb]['format']; |
|
1052 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1053 | 1053 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1054 | - } elseif ($format == 'vrstcp') { |
|
1054 | + } elseif ($format == 'vrstcp') { |
|
1055 | 1055 | $buffer = @socket_read($r, 6000); |
1056 | - } else { |
|
1056 | + } else { |
|
1057 | 1057 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1058 | - } |
|
1059 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1060 | - //echo $buffer."\n"; |
|
1061 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1062 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1063 | - $error = false; |
|
1064 | - //$SI::del(); |
|
1065 | - if ($format == 'vrstcp') { |
|
1058 | + } |
|
1059 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1060 | + //echo $buffer."\n"; |
|
1061 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1062 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1063 | + $error = false; |
|
1064 | + //$SI::del(); |
|
1065 | + if ($format == 'vrstcp') { |
|
1066 | 1066 | $buffer = explode('},{',$buffer); |
1067 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1068 | - // SBS format is CSV format |
|
1069 | - if ($buffer !== FALSE && $buffer != '') { |
|
1067 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1068 | + // SBS format is CSV format |
|
1069 | + if ($buffer !== FALSE && $buffer != '') { |
|
1070 | 1070 | $tt[$format] = 0; |
1071 | 1071 | if ($format == 'acarssbs3') { |
1072 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1073 | - $ACARS->add(trim($buffer)); |
|
1074 | - $ACARS->deleteLiveAcarsData(); |
|
1072 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1073 | + $ACARS->add(trim($buffer)); |
|
1074 | + $ACARS->deleteLiveAcarsData(); |
|
1075 | 1075 | } elseif ($format == 'raw') { |
1076 | - // AVR format |
|
1077 | - $data = $SBS->parse($buffer); |
|
1078 | - if (is_array($data)) { |
|
1076 | + // AVR format |
|
1077 | + $data = $SBS->parse($buffer); |
|
1078 | + if (is_array($data)) { |
|
1079 | 1079 | $data['datetime'] = date('Y-m-d H:i:s'); |
1080 | 1080 | $data['format_source'] = 'raw'; |
1081 | 1081 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1082 | 1082 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1083 | 1083 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1084 | 1084 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1085 | - } |
|
1085 | + } |
|
1086 | 1086 | } elseif ($format == 'ais') { |
1087 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1088 | - $data = array(); |
|
1089 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1090 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1091 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1092 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1093 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1094 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1095 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1096 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1097 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1098 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1099 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1100 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1101 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1087 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1088 | + $data = array(); |
|
1089 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1090 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1091 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1092 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1093 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1094 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1095 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1096 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1097 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1098 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1099 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1100 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1101 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1102 | 1102 | |
1103 | - if (isset($ais_data['timestamp'])) { |
|
1103 | + if (isset($ais_data['timestamp'])) { |
|
1104 | 1104 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1105 | - } else { |
|
1105 | + } else { |
|
1106 | 1106 | $data['datetime'] = date('Y-m-d H:i:s'); |
1107 | - } |
|
1108 | - $data['format_source'] = 'aisnmea'; |
|
1109 | - $data['id_source'] = $id_source; |
|
1110 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1111 | - unset($data); |
|
1112 | - } elseif ($format == 'flightgearsp') { |
|
1113 | - //echo $buffer."\n"; |
|
1114 | - if (strlen($buffer) > 5) { |
|
1107 | + } |
|
1108 | + $data['format_source'] = 'aisnmea'; |
|
1109 | + $data['id_source'] = $id_source; |
|
1110 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1111 | + unset($data); |
|
1112 | + } elseif ($format == 'flightgearsp') { |
|
1113 | + //echo $buffer."\n"; |
|
1114 | + if (strlen($buffer) > 5) { |
|
1115 | 1115 | $line = explode(',',$buffer); |
1116 | 1116 | $data = array(); |
1117 | 1117 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1128,38 +1128,38 @@ discard block |
||
1128 | 1128 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1129 | 1129 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1130 | 1130 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1131 | - } |
|
1132 | - } elseif ($format == 'acars') { |
|
1133 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1134 | - $ACARS->add(trim($buffer)); |
|
1135 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1136 | - $ACARS->deleteLiveAcarsData(); |
|
1131 | + } |
|
1132 | + } elseif ($format == 'acars') { |
|
1133 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1134 | + $ACARS->add(trim($buffer)); |
|
1135 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1136 | + $ACARS->deleteLiveAcarsData(); |
|
1137 | 1137 | } elseif ($format == 'flightgearmp') { |
1138 | - if (substr($buffer,0,1) != '#') { |
|
1138 | + if (substr($buffer,0,1) != '#') { |
|
1139 | 1139 | $data = array(); |
1140 | 1140 | //echo $buffer."\n"; |
1141 | 1141 | $line = explode(' ',$buffer); |
1142 | 1142 | if (count($line) == 11) { |
1143 | - $userserver = explode('@',$line[0]); |
|
1144 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1145 | - $data['ident'] = $userserver[0]; |
|
1146 | - $data['registration'] = $userserver[0]; |
|
1147 | - $data['latitude'] = $line[4]; |
|
1148 | - $data['longitude'] = $line[5]; |
|
1149 | - $data['altitude'] = $line[6]; |
|
1150 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1151 | - $aircraft_type = $line[10]; |
|
1152 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1153 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1154 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1155 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1143 | + $userserver = explode('@',$line[0]); |
|
1144 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1145 | + $data['ident'] = $userserver[0]; |
|
1146 | + $data['registration'] = $userserver[0]; |
|
1147 | + $data['latitude'] = $line[4]; |
|
1148 | + $data['longitude'] = $line[5]; |
|
1149 | + $data['altitude'] = $line[6]; |
|
1150 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1151 | + $aircraft_type = $line[10]; |
|
1152 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1153 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1154 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1155 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1156 | + } |
|
1156 | 1157 | } |
1157 | - } |
|
1158 | 1158 | } elseif ($format == 'beast') { |
1159 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1160 | - die; |
|
1159 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1160 | + die; |
|
1161 | 1161 | } elseif ($format == 'vrstcp') { |
1162 | - foreach($buffer as $all_data) { |
|
1162 | + foreach($buffer as $all_data) { |
|
1163 | 1163 | $line = json_decode('{'.$all_data.'}',true); |
1164 | 1164 | $data = array(); |
1165 | 1165 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1179,106 +1179,106 @@ discard block |
||
1179 | 1179 | */ |
1180 | 1180 | $data['datetime'] = date('Y-m-d H:i:s'); |
1181 | 1181 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1182 | - $data['format_source'] = 'vrstcp'; |
|
1182 | + $data['format_source'] = 'vrstcp'; |
|
1183 | 1183 | $data['id_source'] = $id_source; |
1184 | 1184 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1185 | 1185 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1186 | 1186 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1187 | 1187 | unset($data); |
1188 | - } |
|
1188 | + } |
|
1189 | 1189 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1190 | - $line = explode("\t", $buffer); |
|
1191 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1190 | + $line = explode("\t", $buffer); |
|
1191 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1192 | 1192 | $key = $line[$k]; |
1193 | - $lined[$key] = $line[$k+1]; |
|
1194 | - } |
|
1195 | - if (count($lined) > 3) { |
|
1196 | - $data['hex'] = $lined['hexid']; |
|
1197 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1198 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1199 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1200 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1201 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1202 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1203 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1204 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1205 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1206 | - $data['id_source'] = $id_source; |
|
1207 | - $data['format_source'] = 'tsv'; |
|
1208 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1209 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1193 | + $lined[$key] = $line[$k+1]; |
|
1194 | + } |
|
1195 | + if (count($lined) > 3) { |
|
1196 | + $data['hex'] = $lined['hexid']; |
|
1197 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1198 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1199 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1200 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1201 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1202 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1203 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1204 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1205 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1206 | + $data['id_source'] = $id_source; |
|
1207 | + $data['format_source'] = 'tsv'; |
|
1208 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1209 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1210 | 1210 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1211 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1212 | - unset($lined); |
|
1213 | - unset($data); |
|
1214 | - } else $error = true; |
|
1211 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1212 | + unset($lined); |
|
1213 | + unset($data); |
|
1214 | + } else $error = true; |
|
1215 | 1215 | } elseif ($format == 'aprs' && $use_aprs) { |
1216 | - if ($aprs_connect == 0) { |
|
1216 | + if ($aprs_connect == 0) { |
|
1217 | 1217 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1218 | 1218 | $aprs_connect = 1; |
1219 | - } |
|
1219 | + } |
|
1220 | 1220 | |
1221 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1221 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1222 | 1222 | $aprs_last_tx = time(); |
1223 | 1223 | $data_aprs = "# Keep alive"; |
1224 | 1224 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1225 | - } |
|
1225 | + } |
|
1226 | 1226 | |
1227 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1228 | - //echo 'APRS data : '.$buffer."\n"; |
|
1229 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1230 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1231 | - //echo $buffer."\n"; |
|
1232 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1227 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1228 | + //echo 'APRS data : '.$buffer."\n"; |
|
1229 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1230 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1231 | + //echo $buffer."\n"; |
|
1232 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1233 | 1233 | $line = $APRS->parse($buffer); |
1234 | 1234 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1235 | 1235 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1236 | - $aprs_last_tx = time(); |
|
1237 | - $data = array(); |
|
1238 | - //print_r($line); |
|
1239 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1240 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1241 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1242 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1243 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1244 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1245 | - $data['latitude'] = $line['latitude']; |
|
1246 | - $data['longitude'] = $line['longitude']; |
|
1247 | - //$data['verticalrate'] = $line[16]; |
|
1248 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1249 | - else $data['speed'] = 0; |
|
1250 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1251 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1252 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1253 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1254 | - //else $data['heading'] = 0; |
|
1255 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1256 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE)) $data['noarchive'] = true; |
|
1257 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1258 | - $data['id_source'] = $id_source; |
|
1259 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1260 | - else $data['format_source'] = 'aprs'; |
|
1261 | - $data['source_name'] = $line['source']; |
|
1262 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1263 | - else $data['source_type'] = 'flarm'; |
|
1264 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1265 | - $currentdate = date('Y-m-d H:i:s'); |
|
1266 | - $aprsdate = strtotime($data['datetime']); |
|
1267 | - // Accept data if time <= system time + 20s |
|
1268 | - 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'])))) { |
|
1236 | + $aprs_last_tx = time(); |
|
1237 | + $data = array(); |
|
1238 | + //print_r($line); |
|
1239 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1240 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1241 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1242 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1243 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1244 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1245 | + $data['latitude'] = $line['latitude']; |
|
1246 | + $data['longitude'] = $line['longitude']; |
|
1247 | + //$data['verticalrate'] = $line[16]; |
|
1248 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1249 | + else $data['speed'] = 0; |
|
1250 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1251 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1252 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1253 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1254 | + //else $data['heading'] = 0; |
|
1255 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1256 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE)) $data['noarchive'] = true; |
|
1257 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1258 | + $data['id_source'] = $id_source; |
|
1259 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1260 | + else $data['format_source'] = 'aprs'; |
|
1261 | + $data['source_name'] = $line['source']; |
|
1262 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1263 | + else $data['source_type'] = 'flarm'; |
|
1264 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1265 | + $currentdate = date('Y-m-d H:i:s'); |
|
1266 | + $aprsdate = strtotime($data['datetime']); |
|
1267 | + // Accept data if time <= system time + 20s |
|
1268 | + 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'])))) { |
|
1269 | 1269 | $send = $SI->add($data); |
1270 | - } elseif ($data['source_type'] == 'ais') { |
|
1270 | + } elseif ($data['source_type'] == 'ais') { |
|
1271 | 1271 | echo 'add...'."\n"; |
1272 | 1272 | $send = $MI->add($data); |
1273 | - } elseif (isset($line['stealth'])) { |
|
1273 | + } elseif (isset($line['stealth'])) { |
|
1274 | 1274 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1275 | 1275 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1276 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1277 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1276 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1277 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1278 | 1278 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1279 | 1279 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1280 | - } |
|
1281 | - unset($data); |
|
1280 | + } |
|
1281 | + unset($data); |
|
1282 | 1282 | } |
1283 | 1283 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1284 | 1284 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1288,12 +1288,12 @@ discard block |
||
1288 | 1288 | } |
1289 | 1289 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1290 | 1290 | //elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1291 | - } |
|
1291 | + } |
|
1292 | 1292 | } else { |
1293 | - $line = explode(',', $buffer); |
|
1294 | - if (count($line) > 20) { |
|
1295 | - $data['hex'] = $line[4]; |
|
1296 | - /* |
|
1293 | + $line = explode(',', $buffer); |
|
1294 | + if (count($line) > 20) { |
|
1295 | + $data['hex'] = $line[4]; |
|
1296 | + /* |
|
1297 | 1297 | $data['datetime'] = $line[6].' '.$line[7]; |
1298 | 1298 | date_default_timezone_set($globalTimezone); |
1299 | 1299 | $datetime = new DateTime($data['datetime']); |
@@ -1301,30 +1301,30 @@ discard block |
||
1301 | 1301 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1302 | 1302 | date_default_timezone_set('UTC'); |
1303 | 1303 | */ |
1304 | - // Force datetime to current UTC datetime |
|
1305 | - date_default_timezone_set('UTC'); |
|
1306 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1307 | - $data['ident'] = trim($line[10]); |
|
1308 | - $data['latitude'] = $line[14]; |
|
1309 | - $data['longitude'] = $line[15]; |
|
1310 | - $data['verticalrate'] = $line[16]; |
|
1311 | - $data['emergency'] = $line[20]; |
|
1312 | - $data['speed'] = $line[12]; |
|
1313 | - $data['squawk'] = $line[17]; |
|
1314 | - $data['altitude'] = $line[11]; |
|
1315 | - $data['heading'] = $line[13]; |
|
1316 | - $data['ground'] = $line[21]; |
|
1317 | - $data['emergency'] = $line[19]; |
|
1318 | - $data['format_source'] = 'sbs'; |
|
1304 | + // Force datetime to current UTC datetime |
|
1305 | + date_default_timezone_set('UTC'); |
|
1306 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1307 | + $data['ident'] = trim($line[10]); |
|
1308 | + $data['latitude'] = $line[14]; |
|
1309 | + $data['longitude'] = $line[15]; |
|
1310 | + $data['verticalrate'] = $line[16]; |
|
1311 | + $data['emergency'] = $line[20]; |
|
1312 | + $data['speed'] = $line[12]; |
|
1313 | + $data['squawk'] = $line[17]; |
|
1314 | + $data['altitude'] = $line[11]; |
|
1315 | + $data['heading'] = $line[13]; |
|
1316 | + $data['ground'] = $line[21]; |
|
1317 | + $data['emergency'] = $line[19]; |
|
1318 | + $data['format_source'] = 'sbs'; |
|
1319 | 1319 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1320 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1320 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1321 | 1321 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1322 | - $data['id_source'] = $id_source; |
|
1323 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1324 | - else $error = true; |
|
1325 | - unset($data); |
|
1326 | - } else $error = true; |
|
1327 | - if ($error) { |
|
1322 | + $data['id_source'] = $id_source; |
|
1323 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1324 | + else $error = true; |
|
1325 | + unset($data); |
|
1326 | + } else $error = true; |
|
1327 | + if ($error) { |
|
1328 | 1328 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1329 | 1329 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1330 | 1330 | } else { |
@@ -1340,13 +1340,13 @@ discard block |
||
1340 | 1340 | connect_all($sourceer); |
1341 | 1341 | $sourceer = array(); |
1342 | 1342 | } |
1343 | - } |
|
1343 | + } |
|
1344 | 1344 | } |
1345 | 1345 | // Sleep for xxx microseconds |
1346 | 1346 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1347 | - } else { |
|
1347 | + } else { |
|
1348 | 1348 | if ($format == 'flightgearmp') { |
1349 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1349 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1350 | 1350 | //@socket_close($r); |
1351 | 1351 | sleep($globalMinFetch); |
1352 | 1352 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1355,9 +1355,9 @@ discard block |
||
1355 | 1355 | break; |
1356 | 1356 | |
1357 | 1357 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1358 | - if (isset($tt[$format])) $tt[$format]++; |
|
1359 | - else $tt[$format] = 0; |
|
1360 | - if ($tt[$format] > 30) { |
|
1358 | + if (isset($tt[$format])) $tt[$format]++; |
|
1359 | + else $tt[$format] = 0; |
|
1360 | + if ($tt[$format] > 30) { |
|
1361 | 1361 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1362 | 1362 | //@socket_close($r); |
1363 | 1363 | sleep(2); |
@@ -1368,23 +1368,23 @@ discard block |
||
1368 | 1368 | //connect_all($globalSources); |
1369 | 1369 | $tt[$format]=0; |
1370 | 1370 | break; |
1371 | - } |
|
1371 | + } |
|
1372 | + } |
|
1372 | 1373 | } |
1373 | - } |
|
1374 | 1374 | } |
1375 | - } else { |
|
1375 | + } else { |
|
1376 | 1376 | $error = socket_strerror(socket_last_error()); |
1377 | 1377 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1378 | 1378 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1379 | 1379 | if (isset($globalDebug)) echo "Restarting...\n"; |
1380 | 1380 | // Restart the script if possible |
1381 | 1381 | if (is_array($sockets)) { |
1382 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1382 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1383 | 1383 | |
1384 | - foreach ($sockets as $sock) { |
|
1384 | + foreach ($sockets as $sock) { |
|
1385 | 1385 | @socket_shutdown($sock,2); |
1386 | 1386 | @socket_close($sock); |
1387 | - } |
|
1387 | + } |
|
1388 | 1388 | |
1389 | 1389 | } |
1390 | 1390 | if ($globalDebug) echo "Restart all connections..."; |
@@ -1398,13 +1398,13 @@ discard block |
||
1398 | 1398 | if ($reset > 100) exit('Too many attempts...'); |
1399 | 1399 | connect_all($globalSources); |
1400 | 1400 | } |
1401 | - } |
|
1401 | + } |
|
1402 | 1402 | } |
1403 | 1403 | if ($globalDaemon === false) { |
1404 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1405 | - $SI->checkAll(); |
|
1404 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1405 | + $SI->checkAll(); |
|
1406 | + } |
|
1406 | 1407 | } |
1407 | - } |
|
1408 | 1408 | } |
1409 | 1409 | |
1410 | 1410 | ?> |