@@ -46,20 +46,20 @@ discard block |
||
46 | 46 | die; |
47 | 47 | } |
48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
49 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
49 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
|
53 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver')); |
|
54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); |
55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
56 | 56 | if (isset($options['s'])) { |
57 | 57 | $globalSources = array(); |
58 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); |
|
59 | 59 | else $globalSources[] = array('host' => $options['s']); |
60 | 60 | } elseif (isset($options['source'])) { |
61 | 61 | $globalSources = array(); |
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); |
|
63 | 63 | else $globalSources[] = array('host' => $options['source']); |
64 | 64 | } |
65 | 65 | if (isset($options['aprsserverhost'])) { |
@@ -76,28 +76,28 @@ discard block |
||
76 | 76 | else $id_source = 1; |
77 | 77 | if (isset($globalServer) && $globalServer) { |
78 | 78 | if ($globalDebug) echo "Using Server Mode\n"; |
79 | - $SI=new SpotterServer(); |
|
79 | + $SI = new SpotterServer(); |
|
80 | 80 | /* |
81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
82 | 82 | $SI = new adsb2aprs(); |
83 | 83 | $SI->connect(); |
84 | 84 | */ |
85 | -} else $SI=new SpotterImport($Connection->db); |
|
85 | +} else $SI = new SpotterImport($Connection->db); |
|
86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
87 | 87 | if (isset($globalMarine) && $globalMarine) { |
88 | 88 | $AIS = new AIS(); |
89 | 89 | $MI = new MarineImport($Connection->db); |
90 | 90 | } |
91 | 91 | //$APRS=new APRS($Connection->db); |
92 | -$SBS=new SBS(); |
|
93 | -$ACARS=new ACARS($Connection->db); |
|
94 | -$Source=new Source($Connection->db); |
|
95 | -$Common=new Common(); |
|
92 | +$SBS = new SBS(); |
|
93 | +$ACARS = new ACARS($Connection->db); |
|
94 | +$Source = new Source($Connection->db); |
|
95 | +$Common = new Common(); |
|
96 | 96 | date_default_timezone_set('UTC'); |
97 | 97 | //$servertz = system('date +%Z'); |
98 | 98 | // signal handler - playing nice with sockets and dump1090 |
99 | 99 | if (function_exists('pcntl_fork')) { |
100 | - pcntl_signal(SIGINT, function() { |
|
100 | + pcntl_signal(SIGINT, function() { |
|
101 | 101 | global $sockets; |
102 | 102 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
103 | 103 | die("Bye!\n"); |
@@ -113,30 +113,30 @@ discard block |
||
113 | 113 | |
114 | 114 | function connect_all($hosts) { |
115 | 115 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
116 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; |
|
117 | 117 | $reset++; |
118 | 118 | if ($globalDebug) echo 'Connect to all...'."\n"; |
119 | 119 | foreach ($hosts as $id => $value) { |
120 | 120 | $host = $value['host']; |
121 | 121 | $globalSources[$id]['last_exec'] = 0; |
122 | 122 | // Here we check type of source(s) |
123 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
124 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
125 | 125 | //$formats[$id] = 'deltadbtxt'; |
126 | 126 | $globalSources[$id]['format'] = 'deltadbtxt'; |
127 | 127 | //$last_exec['deltadbtxt'] = 0; |
128 | 128 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
129 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
130 | 130 | //$formats[$id] = 'vatsimtxt'; |
131 | 131 | $globalSources[$id]['format'] = 'vatsimtxt'; |
132 | 132 | //$last_exec['vatsimtxt'] = 0; |
133 | 133 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
134 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
135 | 135 | //$formats[$id] = 'aircraftlistjson'; |
136 | 136 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
137 | 137 | //$last_exec['aircraftlistjson'] = 0; |
138 | 138 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
139 | - } else if (preg_match('/opensky/i',$host)) { |
|
139 | + } else if (preg_match('/opensky/i', $host)) { |
|
140 | 140 | //$formats[$id] = 'aircraftlistjson'; |
141 | 141 | $globalSources[$id]['format'] = 'opensky'; |
142 | 142 | //$last_exec['aircraftlistjson'] = 0; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | exit(0); |
154 | 154 | } |
155 | 155 | */ |
156 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
156 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
157 | 157 | //$formats[$id] = 'planeupdatefaa'; |
158 | 158 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
159 | 159 | //$last_exec['planeupdatefaa'] = 0; |
@@ -162,29 +162,29 @@ discard block |
||
162 | 162 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
163 | 163 | exit(0); |
164 | 164 | } |
165 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
165 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
166 | 166 | //$formats[$id] = 'phpvmacars'; |
167 | 167 | $globalSources[$id]['format'] = 'phpvmacars'; |
168 | 168 | //$last_exec['phpvmacars'] = 0; |
169 | 169 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
170 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
170 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
171 | 171 | //$formats[$id] = 'phpvmacars'; |
172 | 172 | $globalSources[$id]['format'] = 'vam'; |
173 | 173 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
174 | - } else if (preg_match('/whazzup/i',$host)) { |
|
174 | + } else if (preg_match('/whazzup/i', $host)) { |
|
175 | 175 | //$formats[$id] = 'whazzup'; |
176 | 176 | $globalSources[$id]['format'] = 'whazzup'; |
177 | 177 | //$last_exec['whazzup'] = 0; |
178 | 178 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
179 | - } else if (preg_match('/airwhere/i',$host)) { |
|
179 | + } else if (preg_match('/airwhere/i', $host)) { |
|
180 | 180 | $globalSources[$id]['format'] = 'airwhere'; |
181 | 181 | if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
182 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
182 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
183 | 183 | //$formats[$id] = 'pirepsjson'; |
184 | 184 | $globalSources[$id]['format'] = 'pirepsjson'; |
185 | 185 | //$last_exec['pirepsjson'] = 0; |
186 | 186 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
187 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
187 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
188 | 188 | //$formats[$id] = 'fr24json'; |
189 | 189 | $globalSources[$id]['format'] = 'fr24json'; |
190 | 190 | //$last_exec['fr24json'] = 0; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
194 | 194 | exit(0); |
195 | 195 | } |
196 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
196 | + } else if (preg_match(':myshiptracking.com/:i', $host)) { |
|
197 | 197 | //$formats[$id] = 'fr24json'; |
198 | 198 | $globalSources[$id]['format'] = 'myshiptracking'; |
199 | 199 | //$last_exec['fr24json'] = 0; |
@@ -203,22 +203,22 @@ discard block |
||
203 | 203 | exit(0); |
204 | 204 | } |
205 | 205 | //} else if (preg_match('/10001/',$host)) { |
206 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
206 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
207 | 207 | //$formats[$id] = 'tsv'; |
208 | 208 | $globalSources[$id]['format'] = 'tsv'; |
209 | 209 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
210 | 210 | } |
211 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
211 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
212 | 212 | if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
213 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
213 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); |
|
214 | 214 | if ($idf !== false) { |
215 | 215 | $httpfeeds[$id] = $idf; |
216 | 216 | if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
217 | 217 | } |
218 | 218 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
219 | 219 | } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
220 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
221 | - $hostport = explode(':',$host); |
|
220 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
221 | + $hostport = explode(':', $host); |
|
222 | 222 | if (isset($hostport[1])) { |
223 | 223 | $port = $hostport[1]; |
224 | 224 | $hostn = $hostport[0]; |
@@ -228,19 +228,19 @@ discard block |
||
228 | 228 | } |
229 | 229 | $Common = new Common(); |
230 | 230 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
231 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
231 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); |
|
232 | 232 | } else { |
233 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
233 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); |
|
234 | 234 | } |
235 | 235 | if ($s) { |
236 | 236 | $sockets[$id] = $s; |
237 | 237 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
238 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
238 | + if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { |
|
239 | 239 | //$formats[$id] = 'aprs'; |
240 | 240 | $globalSources[$id]['format'] = 'aprs'; |
241 | 241 | //$aprs_connect = 0; |
242 | 242 | //$use_aprs = true; |
243 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
243 | + } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
244 | 244 | $globalSources[$id]['format'] = 'vrstcp'; |
245 | 245 | } elseif ($port == '10001') { |
246 | 246 | //$formats[$id] = 'tsv'; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
280 | 280 | else $timeout = 20; |
281 | 281 | $errno = ''; |
282 | -$errstr=''; |
|
282 | +$errstr = ''; |
|
283 | 283 | |
284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
285 | 285 | /* Initiate connections to all the hosts simultaneously */ |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | //connect_all($globalSources); |
288 | 288 | |
289 | 289 | if (isset($globalProxy) && $globalProxy) { |
290 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
290 | + $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); |
|
291 | 291 | } else { |
292 | 292 | $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
293 | 293 | } |
@@ -314,16 +314,16 @@ discard block |
||
314 | 314 | |
315 | 315 | if ($use_aprs) { |
316 | 316 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
317 | - $APRS=new APRS(); |
|
317 | + $APRS = new APRS(); |
|
318 | 318 | $aprs_connect = 0; |
319 | 319 | $aprs_keep = 120; |
320 | 320 | $aprs_last_tx = time(); |
321 | 321 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
322 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
322 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
323 | 323 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
324 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
324 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
325 | 325 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
326 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
326 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
327 | 327 | if ($aprs_full) $aprs_filter = ''; |
328 | 328 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; |
329 | 329 | else $aprs_pass = '-1'; |
@@ -337,12 +337,12 @@ discard block |
||
337 | 337 | sleep(1); |
338 | 338 | if ($globalDebug) echo "SCAN MODE \n\n"; |
339 | 339 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
340 | -$endtime = time()+$globalCronEnd; |
|
340 | +$endtime = time() + $globalCronEnd; |
|
341 | 341 | $i = 1; |
342 | 342 | $tt = array(); |
343 | 343 | // Delete all ATC |
344 | 344 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
345 | - $ATC=new ATC($Connection->db); |
|
345 | + $ATC = new ATC($Connection->db); |
|
346 | 346 | } |
347 | 347 | if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
348 | 348 | $ATC->deleteAll(); |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | |
351 | 351 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
352 | 352 | while ($i > 0) { |
353 | - if (!$globalDaemon) $i = $endtime-time(); |
|
353 | + if (!$globalDaemon) $i = $endtime - time(); |
|
354 | 354 | // Delete old ATC |
355 | 355 | if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
356 | 356 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | } |
365 | 365 | if ($max != $globalMinFetch) { |
366 | 366 | if ($globalDebug) echo 'Sleeping...'."\n"; |
367 | - sleep($globalMinFetch-$max+2); |
|
367 | + sleep($globalMinFetch - $max + 2); |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | //$buffer = $Common->getData($hosts[$id]); |
378 | 378 | $buffer = $Common->getData($value['host']); |
379 | 379 | if ($buffer != '') $reset = 0; |
380 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
381 | - $buffer = explode('\n',$buffer); |
|
380 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
381 | + $buffer = explode('\n', $buffer); |
|
382 | 382 | foreach ($buffer as $line) { |
383 | 383 | if ($line != '' && count($line) > 7) { |
384 | 384 | $line = explode(',', $line); |
@@ -406,11 +406,11 @@ discard block |
||
406 | 406 | $last_exec[$id]['last'] = time(); |
407 | 407 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
408 | 408 | date_default_timezone_set('CET'); |
409 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
409 | + $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); |
|
410 | 410 | date_default_timezone_set('UTC'); |
411 | 411 | if ($buffer != '') $reset = 0; |
412 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
413 | - $buffer = explode('\n',$buffer); |
|
412 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
413 | + $buffer = explode('\n', $buffer); |
|
414 | 414 | foreach ($buffer as $line) { |
415 | 415 | if ($line != '') { |
416 | 416 | //echo "'".$line."'\n"; |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
429 | 429 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
430 | 430 | if (isset($ais_data['timestamp'])) { |
431 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
431 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
432 | 432 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
433 | 433 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
434 | 434 | $add = true; |
@@ -451,12 +451,12 @@ discard block |
||
451 | 451 | $w = $e = null; |
452 | 452 | |
453 | 453 | if (isset($arr[$id])) { |
454 | - $nn = stream_select($arr,$w,$e,$timeout); |
|
454 | + $nn = stream_select($arr, $w, $e, $timeout); |
|
455 | 455 | if ($nn > 0) { |
456 | 456 | foreach ($httpfeeds as $feed) { |
457 | - $buffer = stream_get_line($feed,2000,"\n"); |
|
458 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
459 | - $buffer = explode('\n',$buffer); |
|
457 | + $buffer = stream_get_line($feed, 2000, "\n"); |
|
458 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
459 | + $buffer = explode('\n', $buffer); |
|
460 | 460 | foreach ($buffer as $line) { |
461 | 461 | if ($line != '') { |
462 | 462 | $ais_data = $AIS->parse_line(trim($line)); |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
475 | 475 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
476 | 476 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
477 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
477 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
478 | 478 | if (isset($ais_data['timestamp'])) { |
479 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
479 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
480 | 480 | } else { |
481 | 481 | $data['datetime'] = date('Y-m-d H:i:s'); |
482 | 482 | } |
@@ -502,10 +502,10 @@ discard block |
||
502 | 502 | } |
503 | 503 | } |
504 | 504 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
505 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
505 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
506 | 506 | if ($buffer != '') { |
507 | 507 | //echo $buffer; |
508 | - $all_data = json_decode($buffer,true); |
|
508 | + $all_data = json_decode($buffer, true); |
|
509 | 509 | //print_r($all_data); |
510 | 510 | if (isset($all_data[0]['DATA'])) { |
511 | 511 | foreach ($all_data[0]['DATA'] as $line) { |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
521 | 521 | $data['imo'] = $line['IMO']; |
522 | 522 | //$data['arrival_code'] = $ais_data['destination']; |
523 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
523 | + $data['datetime'] = date('Y-m-d H:i:s', $line['T']); |
|
524 | 524 | $data['format_source'] = 'myshiptracking'; |
525 | 525 | $data['id_source'] = $id_source; |
526 | 526 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -532,9 +532,9 @@ discard block |
||
532 | 532 | } |
533 | 533 | $last_exec[$id]['last'] = time(); |
534 | 534 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
535 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
535 | + $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); |
|
536 | 536 | if ($buffer != '') { |
537 | - $all_data = json_decode($buffer,true); |
|
537 | + $all_data = json_decode($buffer, true); |
|
538 | 538 | if (isset($all_data[0]['mmsi'])) { |
539 | 539 | foreach ($all_data as $line) { |
540 | 540 | if ($line != '') { |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | } elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
564 | 564 | $buffer = $Common->getData($value['host']); |
565 | 565 | if ($buffer != '') { |
566 | - $all_data = json_decode($buffer,true); |
|
566 | + $all_data = json_decode($buffer, true); |
|
567 | 567 | if (isset($all_data['features'][0]['id'])) { |
568 | 568 | foreach ($all_data['features'] as $line) { |
569 | 569 | $data = array(); |
@@ -591,27 +591,27 @@ discard block |
||
591 | 591 | $last_exec[$id]['last'] = time(); |
592 | 592 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
593 | 593 | echo 'download...'; |
594 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
594 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); |
|
595 | 595 | echo 'done !'."\n"; |
596 | 596 | if ($buffer != '') $reset = 0; |
597 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
598 | - $buffer = explode('\n',$buffer); |
|
597 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
598 | + $buffer = explode('\n', $buffer); |
|
599 | 599 | foreach ($buffer as $line) { |
600 | 600 | if ($line != '') { |
601 | 601 | $data = array(); |
602 | - $data['mmsi'] = (int)substr($line,0,9); |
|
603 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
602 | + $data['mmsi'] = (int) substr($line, 0, 9); |
|
603 | + $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); |
|
604 | 604 | //$data['status'] = substr($line,21,2); |
605 | 605 | //$data['type'] = substr($line,24,3); |
606 | - $data['latitude'] = substr($line,29,9); |
|
607 | - $data['longitude'] = substr($line,41,9); |
|
608 | - $data['speed'] = round(substr($line,51,5)); |
|
606 | + $data['latitude'] = substr($line, 29, 9); |
|
607 | + $data['longitude'] = substr($line, 41, 9); |
|
608 | + $data['speed'] = round(substr($line, 51, 5)); |
|
609 | 609 | //$data['course'] = substr($line,57,5); |
610 | - $data['heading'] = round(substr($line,63,3)); |
|
610 | + $data['heading'] = round(substr($line, 63, 3)); |
|
611 | 611 | //$data['draft'] = substr($line,67,4); |
612 | 612 | //$data['length'] = substr($line,72,3); |
613 | 613 | //$data['beam'] = substr($line,76,2); |
614 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
614 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); |
|
615 | 615 | //$data['callsign'] = trim(substr($line,100,7); |
616 | 616 | //$data['dest'] = substr($line,108,20); |
617 | 617 | //$data['etaDate'] = substr($line,129,5); |
@@ -630,8 +630,8 @@ discard block |
||
630 | 630 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
631 | 631 | //$buffer = $Common->getData($hosts[$id]); |
632 | 632 | $buffer = $Common->getData($value['host']); |
633 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
634 | - $buffer = explode('\n',$buffer); |
|
633 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
634 | + $buffer = explode('\n', $buffer); |
|
635 | 635 | $reset = 0; |
636 | 636 | foreach ($buffer as $line) { |
637 | 637 | if ($line != '') { |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
643 | 643 | $data['pilot_id'] = $line[1]; |
644 | 644 | $data['pilot_name'] = $line[2]; |
645 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
645 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
646 | 646 | $data['ident'] = $line[0]; // ident |
647 | 647 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
648 | 648 | $data['speed'] = $line[8]; // speed |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
659 | 659 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
660 | 660 | $data['departure_airport_icao'] = $line[11]; |
661 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
661 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
662 | 662 | $data['arrival_airport_icao'] = $line[13]; |
663 | 663 | $data['frequency'] = $line[4]; |
664 | 664 | $data['type'] = $line[18]; |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | $data['id_source'] = $id_source; |
668 | 668 | //$data['arrival_airport_time'] = ; |
669 | 669 | if ($line[9] != '') { |
670 | - $aircraft_data = explode('/',$line[9]); |
|
670 | + $aircraft_data = explode('/', $line[9]); |
|
671 | 671 | if (isset($aircraft_data[1])) { |
672 | 672 | $data['aircraft_icao'] = $aircraft_data[1]; |
673 | 673 | } |
@@ -682,9 +682,9 @@ discard block |
||
682 | 682 | if ($line[3] == 'PILOT') $SI->add($data); |
683 | 683 | elseif ($line[3] == 'ATC') { |
684 | 684 | //print_r($data); |
685 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
686 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
687 | - $typec = substr($data['ident'],-3); |
|
685 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
686 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
687 | + $typec = substr($data['ident'], -3); |
|
688 | 688 | if ($typec == 'APP') $data['type'] = 'Approach'; |
689 | 689 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
690 | 690 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -696,8 +696,8 @@ discard block |
||
696 | 696 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
697 | 697 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
698 | 698 | if (isset($ATC)) { |
699 | - if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
700 | - else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
|
699 | + if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
700 | + else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']); |
|
701 | 701 | } |
702 | 702 | } |
703 | 703 | unset($data); |
@@ -708,24 +708,24 @@ discard block |
||
708 | 708 | //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
709 | 709 | $last_exec[$id]['last'] = time(); |
710 | 710 | } elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
711 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
711 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); |
|
712 | 712 | if ($buffer != '') { |
713 | 713 | $all_data = simplexml_load_string($buffer); |
714 | - foreach($all_data->children() as $childdata) { |
|
714 | + foreach ($all_data->children() as $childdata) { |
|
715 | 715 | $data = array(); |
716 | 716 | $line = $childdata; |
717 | 717 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); |
718 | - $data['id'] = date('Ymd').(int)$line['pktPilotID']; |
|
719 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); |
|
720 | - $data['latitude'] = (float)$line['pktLatitude']; |
|
721 | - $data['longitude'] = (float)$line['pktLongitude']; |
|
722 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; |
|
723 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; |
|
724 | - $data['altitude'] = round((int)$line['pktAltitude']*3.28084); |
|
718 | + $data['id'] = date('Ymd').(int) $line['pktPilotID']; |
|
719 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); |
|
720 | + $data['latitude'] = (float) $line['pktLatitude']; |
|
721 | + $data['longitude'] = (float) $line['pktLongitude']; |
|
722 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; |
|
723 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; |
|
724 | + $data['altitude'] = round((int) $line['pktAltitude']*3.28084); |
|
725 | 725 | $data['altitude_relative'] = 'AMSL'; |
726 | - $data['pilot_id'] = (int)$line['pktPilotID']; |
|
726 | + $data['pilot_id'] = (int) $line['pktPilotID']; |
|
727 | 727 | $data['aircraft_icao'] = 'PARAGLIDER'; |
728 | - $pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
728 | + $pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); |
|
729 | 729 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; |
730 | 730 | $data['format_source'] = $value['format']; |
731 | 731 | $SI->add($data); |
@@ -733,31 +733,31 @@ discard block |
||
733 | 733 | } |
734 | 734 | } |
735 | 735 | $Source->deleteOldLocationByType('gs'); |
736 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
736 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); |
|
737 | 737 | if ($buffer != '') { |
738 | 738 | $all_data = simplexml_load_string($buffer); |
739 | - foreach($all_data->children() as $childdata) { |
|
739 | + foreach ($all_data->children() as $childdata) { |
|
740 | 740 | $data = array(); |
741 | 741 | $line = $childdata; |
742 | - $data['id'] = (int)$line['gsID']; |
|
743 | - $data['latitude'] = (float)$line['gsLatitude']; |
|
744 | - $data['longitude'] = (float)$line['gsLongitude']; |
|
745 | - $data['altitude'] = round((int)$line['gsHeight']*3.28084); |
|
742 | + $data['id'] = (int) $line['gsID']; |
|
743 | + $data['latitude'] = (float) $line['gsLatitude']; |
|
744 | + $data['longitude'] = (float) $line['gsLongitude']; |
|
745 | + $data['altitude'] = round((int) $line['gsHeight']*3.28084); |
|
746 | 746 | $data['altitude_relative'] = 'AMSL'; |
747 | - $data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); |
|
747 | + $data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); |
|
748 | 748 | if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { |
749 | - $Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
749 | + $Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
750 | 750 | } else { |
751 | - $Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); |
|
751 | + $Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); |
|
752 | 752 | } |
753 | 753 | unset($data); |
754 | 754 | } |
755 | 755 | } |
756 | 756 | $last_exec[$id]['last'] = time(); |
757 | 757 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
758 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
758 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
759 | 759 | if ($buffer != '') { |
760 | - $all_data = json_decode($buffer,true); |
|
760 | + $all_data = json_decode($buffer, true); |
|
761 | 761 | if (isset($all_data['acList'])) { |
762 | 762 | $reset = 0; |
763 | 763 | foreach ($all_data['acList'] as $line) { |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | $data['emergency'] = ''; // emergency |
775 | 775 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
776 | 776 | |
777 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
777 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
778 | 778 | else $data['datetime'] = date('Y-m-d H:i:s'); |
779 | 779 | |
780 | 780 | //$data['datetime'] = date('Y-m-d H:i:s'); |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | $data['verticalrate'] = $line['vrt']; // verticale rate |
801 | 801 | $data['squawk'] = $line['squawk']; // squawk |
802 | 802 | $data['emergency'] = ''; // emergency |
803 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
803 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); |
|
804 | 804 | else $data['datetime'] = date('Y-m-d H:i:s'); |
805 | 805 | $data['format_source'] = 'aircraftlistjson'; |
806 | 806 | $data['id_source'] = $id_source; |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
817 | 817 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
818 | 818 | $buffer = $Common->getData($value['host']); |
819 | - $all_data = json_decode($buffer,true); |
|
819 | + $all_data = json_decode($buffer, true); |
|
820 | 820 | if (isset($all_data['planes'])) { |
821 | 821 | $reset = 0; |
822 | 822 | foreach ($all_data['planes'] as $key => $line) { |
@@ -833,12 +833,12 @@ discard block |
||
833 | 833 | $data['emergency'] = ''; // emergency |
834 | 834 | $data['registration'] = $line[2]; |
835 | 835 | $data['aircraft_icao'] = $line[0]; |
836 | - $deparr = explode('-',$line[1]); |
|
836 | + $deparr = explode('-', $line[1]); |
|
837 | 837 | if (count($deparr) == 2) { |
838 | 838 | $data['departure_airport_icao'] = $deparr[0]; |
839 | 839 | $data['arrival_airport_icao'] = $deparr[1]; |
840 | 840 | } |
841 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
841 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
842 | 842 | $data['format_source'] = 'planeupdatefaa'; |
843 | 843 | $data['id_source'] = $id_source; |
844 | 844 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | $last_exec[$id]['last'] = time(); |
852 | 852 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
853 | 853 | $buffer = $Common->getData($value['host']); |
854 | - $all_data = json_decode($buffer,true); |
|
854 | + $all_data = json_decode($buffer, true); |
|
855 | 855 | if (isset($all_data['states'])) { |
856 | 856 | $reset = 0; |
857 | 857 | foreach ($all_data['states'] as $key => $line) { |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | //$data['emergency'] = ''; // emergency |
869 | 869 | //$data['registration'] = $line[2]; |
870 | 870 | //$data['aircraft_icao'] = $line[0]; |
871 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
871 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
872 | 872 | $data['format_source'] = 'opensky'; |
873 | 873 | $data['id_source'] = $id_source; |
874 | 874 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
883 | 883 | //$buffer = $Common->getData($hosts[$id]); |
884 | 884 | $buffer = $Common->getData($value['host']); |
885 | - $all_data = json_decode($buffer,true); |
|
885 | + $all_data = json_decode($buffer, true); |
|
886 | 886 | if (!empty($all_data)) $reset = 0; |
887 | 887 | foreach ($all_data as $key => $line) { |
888 | 888 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -915,11 +915,11 @@ discard block |
||
915 | 915 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
916 | 916 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
917 | 917 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
918 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
918 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
919 | 919 | //echo $buffer; |
920 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
921 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
922 | - $all_data = json_decode($buffer,true); |
|
920 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
921 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
922 | + $all_data = json_decode($buffer, true); |
|
923 | 923 | if (json_last_error() != JSON_ERROR_NONE) { |
924 | 924 | die(json_last_error_msg()); |
925 | 925 | } |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | //$data['departure_airport_iata'] = $line[11]; |
943 | 943 | //$data['arrival_airport_iata'] = $line[12]; |
944 | 944 | //$data['emergency'] = ''; // emergency |
945 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
945 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
946 | 946 | $data['format_source'] = 'radarvirtueljson'; |
947 | 947 | $data['id_source'] = $id_source; |
948 | 948 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
@@ -958,14 +958,14 @@ discard block |
||
958 | 958 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
959 | 959 | //$buffer = $Common->getData($hosts[$id]); |
960 | 960 | $buffer = $Common->getData($value['host'].'?'.time()); |
961 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
961 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
962 | 962 | |
963 | 963 | if (isset($all_data['pireps'])) { |
964 | 964 | $reset = 0; |
965 | 965 | foreach ($all_data['pireps'] as $line) { |
966 | 966 | $data = array(); |
967 | 967 | $data['id'] = $line['id']; |
968 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
968 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
969 | 969 | $data['ident'] = $line['callsign']; // ident |
970 | 970 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
971 | 971 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -995,9 +995,9 @@ discard block |
||
995 | 995 | $SI->add($data); |
996 | 996 | // print_r($data); |
997 | 997 | } elseif ($line['icon'] == 'ct') { |
998 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
999 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
1000 | - $typec = substr($data['ident'],-3); |
|
998 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
999 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
1000 | + $typec = substr($data['ident'], -3); |
|
1001 | 1001 | $data['type'] = ''; |
1002 | 1002 | if ($typec == 'APP') $data['type'] = 'Approach'; |
1003 | 1003 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
1009 | 1009 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
1010 | 1010 | else $data['type'] = 'Observer'; |
1011 | - 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']); |
|
1011 | + 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']); |
|
1012 | 1012 | } |
1013 | 1013 | unset($data); |
1014 | 1014 | } |
@@ -1020,14 +1020,14 @@ discard block |
||
1020 | 1020 | //$buffer = $Common->getData($hosts[$id]); |
1021 | 1021 | if ($globalDebug) echo 'Get Data...'."\n"; |
1022 | 1022 | $buffer = $Common->getData($value['host']); |
1023 | - $all_data = json_decode($buffer,true); |
|
1023 | + $all_data = json_decode($buffer, true); |
|
1024 | 1024 | if ($buffer != '' && is_array($all_data)) { |
1025 | 1025 | $reset = 0; |
1026 | 1026 | foreach ($all_data as $line) { |
1027 | 1027 | $data = array(); |
1028 | 1028 | //$data['id'] = $line['id']; // id not usable |
1029 | 1029 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
1030 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1030 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1031 | 1031 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
1032 | 1032 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
1033 | 1033 | $data['ident'] = $line['flightnum']; // ident |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | //$data['datetime'] = $line['lastupdate']; |
1043 | 1043 | //$data['last_update'] = $line['lastupdate']; |
1044 | 1044 | if (isset($value['timezone'])) { |
1045 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1045 | + $datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone'])); |
|
1046 | 1046 | $datetime->setTimeZone(new DateTimeZone('UTC')); |
1047 | 1047 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1048 | 1048 | } else $data['datetime'] = date('Y-m-d H:i:s'); |
@@ -1055,14 +1055,14 @@ discard block |
||
1055 | 1055 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
1056 | 1056 | if (isset($line['aircraftname'])) { |
1057 | 1057 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1058 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
1059 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1058 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
1059 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
1060 | 1060 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
1061 | 1061 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
1062 | 1062 | else { |
1063 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1064 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1065 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1063 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
1064 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); |
|
1065 | + else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); |
|
1066 | 1066 | } |
1067 | 1067 | } |
1068 | 1068 | if (isset($line['route'])) $data['waypoints'] = $line['route']; |
@@ -1082,14 +1082,14 @@ discard block |
||
1082 | 1082 | //$buffer = $Common->getData($hosts[$id]); |
1083 | 1083 | if ($globalDebug) echo 'Get Data...'."\n"; |
1084 | 1084 | $buffer = $Common->getData($value['host']); |
1085 | - $all_data = json_decode($buffer,true); |
|
1085 | + $all_data = json_decode($buffer, true); |
|
1086 | 1086 | if ($buffer != '' && is_array($all_data)) { |
1087 | 1087 | $reset = 0; |
1088 | 1088 | foreach ($all_data as $line) { |
1089 | 1089 | $data = array(); |
1090 | 1090 | //$data['id'] = $line['id']; // id not usable |
1091 | 1091 | $data['id'] = trim($line['flight_id']); |
1092 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1092 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
1093 | 1093 | $data['pilot_name'] = $line['pilot_name']; |
1094 | 1094 | $data['pilot_id'] = $line['pilot_id']; |
1095 | 1095 | $data['ident'] = trim($line['callsign']); // ident |
@@ -1141,11 +1141,11 @@ discard block |
||
1141 | 1141 | //$value = $formats[$nb]; |
1142 | 1142 | $format = $globalSources[$nb]['format']; |
1143 | 1143 | if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
1144 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
|
1144 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); |
|
1145 | 1145 | } elseif ($format == 'vrstcp') { |
1146 | 1146 | $buffer = @socket_read($r, 6000); |
1147 | 1147 | } else { |
1148 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
1148 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
1149 | 1149 | } |
1150 | 1150 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
1151 | 1151 | //echo $buffer."\n"; |
@@ -1154,8 +1154,8 @@ discard block |
||
1154 | 1154 | $error = false; |
1155 | 1155 | //$SI::del(); |
1156 | 1156 | if ($format == 'vrstcp') { |
1157 | - $buffer = explode('},{',$buffer); |
|
1158 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1157 | + $buffer = explode('},{', $buffer); |
|
1158 | + } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
1159 | 1159 | // SBS format is CSV format |
1160 | 1160 | if ($buffer !== FALSE && $buffer != '') { |
1161 | 1161 | $tt[$format] = 0; |
@@ -1189,13 +1189,13 @@ discard block |
||
1189 | 1189 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
1190 | 1190 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
1191 | 1191 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
1192 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1192 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); |
|
1193 | 1193 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1194 | 1194 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1195 | 1195 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1196 | 1196 | |
1197 | 1197 | if (isset($ais_data['timestamp'])) { |
1198 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
1198 | + $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); |
|
1199 | 1199 | } else { |
1200 | 1200 | $data['datetime'] = date('Y-m-d H:i:s'); |
1201 | 1201 | } |
@@ -1206,10 +1206,10 @@ discard block |
||
1206 | 1206 | } elseif ($format == 'flightgearsp') { |
1207 | 1207 | //echo $buffer."\n"; |
1208 | 1208 | if (strlen($buffer) > 5) { |
1209 | - $line = explode(',',$buffer); |
|
1209 | + $line = explode(',', $buffer); |
|
1210 | 1210 | $data = array(); |
1211 | 1211 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
1212 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
1212 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
1213 | 1213 | $data['ident'] = $line[6]; |
1214 | 1214 | $data['aircraft_name'] = $line[7]; |
1215 | 1215 | $data['longitude'] = $line[1]; |
@@ -1226,16 +1226,16 @@ discard block |
||
1226 | 1226 | } elseif ($format == 'acars') { |
1227 | 1227 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
1228 | 1228 | $ACARS->add(trim($buffer)); |
1229 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1229 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
1230 | 1230 | $ACARS->deleteLiveAcarsData(); |
1231 | 1231 | } elseif ($format == 'flightgearmp') { |
1232 | - if (substr($buffer,0,1) != '#') { |
|
1232 | + if (substr($buffer, 0, 1) != '#') { |
|
1233 | 1233 | $data = array(); |
1234 | 1234 | //echo $buffer."\n"; |
1235 | - $line = explode(' ',$buffer); |
|
1235 | + $line = explode(' ', $buffer); |
|
1236 | 1236 | if (count($line) == 11) { |
1237 | - $userserver = explode('@',$line[0]); |
|
1238 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1237 | + $userserver = explode('@', $line[0]); |
|
1238 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
1239 | 1239 | $data['ident'] = $userserver[0]; |
1240 | 1240 | $data['registration'] = $userserver[0]; |
1241 | 1241 | $data['latitude'] = $line[4]; |
@@ -1243,8 +1243,8 @@ discard block |
||
1243 | 1243 | $data['altitude'] = $line[6]; |
1244 | 1244 | $data['datetime'] = date('Y-m-d H:i:s'); |
1245 | 1245 | $aircraft_type = $line[10]; |
1246 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1247 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1246 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
1247 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
1248 | 1248 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1249 | 1249 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1250 | 1250 | } |
@@ -1253,8 +1253,8 @@ discard block |
||
1253 | 1253 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
1254 | 1254 | die; |
1255 | 1255 | } elseif ($format == 'vrstcp') { |
1256 | - foreach($buffer as $all_data) { |
|
1257 | - $line = json_decode('{'.$all_data.'}',true); |
|
1256 | + foreach ($buffer as $all_data) { |
|
1257 | + $line = json_decode('{'.$all_data.'}', true); |
|
1258 | 1258 | $data = array(); |
1259 | 1259 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
1260 | 1260 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -1280,16 +1280,16 @@ discard block |
||
1280 | 1280 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1281 | 1281 | unset($data); |
1282 | 1282 | } |
1283 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
1283 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
1284 | 1284 | $line = explode("\t", $buffer); |
1285 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1285 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
1286 | 1286 | $key = $line[$k]; |
1287 | - $lined[$key] = $line[$k+1]; |
|
1287 | + $lined[$key] = $line[$k + 1]; |
|
1288 | 1288 | } |
1289 | 1289 | if (count($lined) > 3) { |
1290 | 1290 | $data['hex'] = $lined['hexid']; |
1291 | 1291 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
1292 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1292 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
1293 | 1293 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
1294 | 1294 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
1295 | 1295 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -1308,22 +1308,22 @@ discard block |
||
1308 | 1308 | } else $error = true; |
1309 | 1309 | } elseif ($format == 'aprs' && $use_aprs) { |
1310 | 1310 | if ($aprs_connect == 0) { |
1311 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
1311 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
1312 | 1312 | $aprs_connect = 1; |
1313 | 1313 | } |
1314 | 1314 | |
1315 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1315 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
1316 | 1316 | $aprs_last_tx = time(); |
1317 | 1317 | $data_aprs = "# Keep alive"; |
1318 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
1318 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
1319 | 1319 | } |
1320 | 1320 | |
1321 | 1321 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
1322 | 1322 | //echo 'APRS data : '.$buffer."\n"; |
1323 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1324 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1323 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
1324 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
1325 | 1325 | //echo $buffer."\n"; |
1326 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1326 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
1327 | 1327 | $line = $APRS->parse($buffer); |
1328 | 1328 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1329 | 1329 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
@@ -1338,7 +1338,7 @@ discard block |
||
1338 | 1338 | if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; |
1339 | 1339 | if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; |
1340 | 1340 | if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; |
1341 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1341 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
1342 | 1342 | else $data['datetime'] = date('Y-m-d H:i:s'); |
1343 | 1343 | //$data['datetime'] = date('Y-m-d H:i:s'); |
1344 | 1344 | if (isset($line['ident'])) $data['ident'] = $line['ident']; |
@@ -1386,9 +1386,9 @@ discard block |
||
1386 | 1386 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1387 | 1387 | $Source->deleteOldLocationByType('gs'); |
1388 | 1388 | if (count($Source->getLocationInfoByName($data['ident'])) > 0) { |
1389 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1389 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1390 | 1390 | } else { |
1391 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
|
1391 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); |
|
1392 | 1392 | } |
1393 | 1393 | } else { |
1394 | 1394 | echo '/!\ Not added: '.$buffer."\n"; |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | } |
1402 | 1402 | |
1403 | 1403 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1404 | - $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
|
1404 | + $Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']); |
|
1405 | 1405 | } |
1406 | 1406 | /* |
1407 | 1407 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) { |
@@ -1488,7 +1488,7 @@ discard block |
||
1488 | 1488 | connect_all($sourceee); |
1489 | 1489 | $sourceee = array(); |
1490 | 1490 | //connect_all($globalSources); |
1491 | - $tt[$format]=0; |
|
1491 | + $tt[$format] = 0; |
|
1492 | 1492 | break; |
1493 | 1493 | } |
1494 | 1494 | } |
@@ -1497,14 +1497,14 @@ discard block |
||
1497 | 1497 | } else { |
1498 | 1498 | $error = socket_strerror(socket_last_error()); |
1499 | 1499 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1500 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
1500 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
1501 | 1501 | if (isset($globalDebug)) echo "Restarting...\n"; |
1502 | 1502 | // Restart the script if possible |
1503 | 1503 | if (is_array($sockets)) { |
1504 | 1504 | if ($globalDebug) echo "Shutdown all sockets..."; |
1505 | 1505 | |
1506 | 1506 | foreach ($sockets as $sock) { |
1507 | - @socket_shutdown($sock,2); |
|
1507 | + @socket_shutdown($sock, 2); |
|
1508 | 1508 | @socket_close($sock); |
1509 | 1509 | } |
1510 | 1510 |
@@ -55,23 +55,23 @@ discard block |
||
55 | 55 | $min = true; |
56 | 56 | $allhistory = false; |
57 | 57 | $filter['source'] = array(); |
58 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
59 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
60 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
61 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs')); |
|
62 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
63 | -if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING); |
|
64 | -if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING); |
|
65 | -if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING); |
|
66 | -if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING); |
|
67 | -if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING); |
|
58 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt')); |
|
59 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup')); |
|
60 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars')); |
|
61 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs')); |
|
62 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs')); |
|
63 | +if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING); |
|
64 | +if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING); |
|
65 | +if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING); |
|
66 | +if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING); |
|
67 | +if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING); |
|
68 | 68 | |
69 | 69 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
70 | 70 | $min = true; |
71 | 71 | } else $min = false; |
72 | 72 | |
73 | 73 | if (isset($_GET['ident'])) { |
74 | - $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
|
74 | + $ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING)); |
|
75 | 75 | if ($tracker) { |
76 | 76 | $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident); |
77 | 77 | } elseif ($marine) { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | $allhistory = true; |
87 | 87 | } elseif (isset($_GET['flightaware_id'])) { |
88 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
88 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
89 | 89 | $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id); |
90 | 90 | if (empty($spotter_array)) { |
91 | 91 | $from_archive = true; |
@@ -93,44 +93,44 @@ discard block |
||
93 | 93 | } |
94 | 94 | $allhistory = true; |
95 | 95 | } elseif (isset($_GET['famtrack_id'])) { |
96 | - $famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING)); |
|
96 | + $famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING)); |
|
97 | 97 | $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id); |
98 | 98 | $allhistory = true; |
99 | 99 | } elseif (isset($_GET['fammarine_id'])) { |
100 | - $fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING)); |
|
100 | + $fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING)); |
|
101 | 101 | $spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id); |
102 | 102 | $allhistory = true; |
103 | 103 | } elseif (isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) { |
104 | 104 | //} elseif (isset($_GET['coord'])) { |
105 | 105 | $usecoord = true; |
106 | - $coord = explode(',',$_GET['coord']); |
|
106 | + $coord = explode(',', $_GET['coord']); |
|
107 | 107 | if ($tracker) { |
108 | - $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter); |
|
108 | + $spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord, $filter); |
|
109 | 109 | } elseif ($marine) { |
110 | - $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter); |
|
110 | + $spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord, $filter); |
|
111 | 111 | } else { |
112 | - $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter); |
|
112 | + $spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter); |
|
113 | 113 | } |
114 | 114 | } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) { |
115 | 115 | $usecoord = true; |
116 | - $coord = explode(',',$_GET['coord']); |
|
116 | + $coord = explode(',', $_GET['coord']); |
|
117 | 117 | if ($tracker) { |
118 | - $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter); |
|
118 | + $spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter); |
|
119 | 119 | } elseif ($marine) { |
120 | - $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter); |
|
120 | + $spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter); |
|
121 | 121 | } else { |
122 | - $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter); |
|
122 | + $spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter); |
|
123 | 123 | } |
124 | 124 | } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) { |
125 | 125 | $from_archive = true; |
126 | 126 | // $begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
127 | 127 | // $enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~'))); |
128 | - $begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT); |
|
129 | - $enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT); |
|
130 | - $archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT); |
|
131 | - $begindate = date('Y-m-d H:i:s',$begindate); |
|
132 | - $enddate = date('Y-m-d H:i:s',$enddate); |
|
133 | - $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter); |
|
128 | + $begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT); |
|
129 | + $enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT); |
|
130 | + $archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT); |
|
131 | + $begindate = date('Y-m-d H:i:s', $begindate); |
|
132 | + $enddate = date('Y-m-d H:i:s', $enddate); |
|
133 | + $spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter); |
|
134 | 134 | } elseif ($min) { |
135 | 135 | if ($tracker) { |
136 | 136 | $spotter_array = $TrackerLive->getMinLiveTrackerData($filter); |
@@ -142,18 +142,18 @@ discard block |
||
142 | 142 | # $min = true; |
143 | 143 | } else { |
144 | 144 | if ($tracker) { |
145 | - $spotter_array = $TrackerLive->getLiveTrackerData('','',$filter); |
|
145 | + $spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter); |
|
146 | 146 | } elseif ($marine) { |
147 | - $spotter_array = $marineLive->getLiveMarineData('','',$filter); |
|
147 | + $spotter_array = $marineLive->getLiveMarineData('', '', $filter); |
|
148 | 148 | } else { |
149 | - $spotter_array = $SpotterLive->getLiveSpotterData('','',$filter); |
|
149 | + $spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | if (!empty($spotter_array) || $usecoord) { |
154 | 154 | if ($usecoord) { |
155 | 155 | if (isset($_GET['archive'])) { |
156 | - $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
|
156 | + $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter); |
|
157 | 157 | } else { |
158 | 158 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
159 | 159 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | if ($flightcnt == '') $flightcnt = 0; |
162 | 162 | } else $flightcnt = 0; |
163 | 163 | |
164 | -$sqltime = round(microtime(true)-$begintime,2); |
|
164 | +$sqltime = round(microtime(true) - $begintime, 2); |
|
165 | 165 | |
166 | 166 | if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false; |
167 | 167 | else $usenextlatlon = true; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | if (!empty($spotter_array) && is_array($spotter_array)) |
179 | 179 | { |
180 | 180 | $output .= '"features": ['; |
181 | - foreach($spotter_array as $spotter_item) |
|
181 | + foreach ($spotter_array as $spotter_item) |
|
182 | 182 | { |
183 | 183 | $j++; |
184 | 184 | date_default_timezone_set('UTC'); |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | */ |
235 | 235 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
236 | 236 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
237 | - if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
238 | - else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",'; |
|
237 | + if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
238 | + else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",'; |
|
239 | 239 | //" |
240 | 240 | } else { |
241 | 241 | if ($compress) $output .= '"c": "NA",'; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
245 | 245 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
246 | 246 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
247 | - $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
|
247 | + $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",'; |
|
248 | 248 | } elseif (isset($spotter_item['aircraft_type'])) { |
249 | 249 | $output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",'; |
250 | 250 | } elseif (!$min) { |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
386 | 386 | |
387 | 387 | if (isset($archivespeed)) { |
388 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
|
388 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed); |
|
389 | 389 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
390 | 390 | } elseif ($usenextlatlon) { |
391 | - $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
|
391 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']); |
|
392 | 392 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
393 | 393 | } |
394 | 394 | |
395 | 395 | if (!$min) $output .= '"image": "'.$image.'",'; |
396 | 396 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
397 | - $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
|
397 | + $output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",'; |
|
398 | 398 | } |
399 | 399 | if (isset($spotter_item['image_source_website'])) { |
400 | 400 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | $output .= '"waypoints": "'.$spotter_item['waypoints'].'",'; |
417 | 417 | } |
418 | 418 | if (isset($spotter_item['acars'])) { |
419 | - $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
|
419 | + $output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",'; |
|
420 | 420 | } |
421 | 421 | // type when not aircraft ? |
422 | 422 | if (isset($spotter_item['type'])) { |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | |
495 | 495 | } |
496 | 496 | */ |
497 | - $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
|
497 | + $history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING); |
|
498 | 498 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
499 | 499 | |
500 | 500 | if ( |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
503 | 503 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
504 | 504 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
505 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
505 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
506 | 506 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
507 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
507 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id'])) |
|
508 | 508 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
509 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
509 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid'])) |
|
510 | 510 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
511 | 511 | ) { |
512 | 512 | if ($tracker) { |
@@ -543,9 +543,9 @@ discard block |
||
543 | 543 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
544 | 544 | } |
545 | 545 | $output_history .= '['; |
546 | - $output_history .= $spotter_history['longitude'].', '; |
|
547 | - $output_history .= $spotter_history['latitude'].', '; |
|
548 | - $output_history .= $spotter_history['altitude']*30.48; |
|
546 | + $output_history .= $spotter_history['longitude'].', '; |
|
547 | + $output_history .= $spotter_history['latitude'].', '; |
|
548 | + $output_history .= $spotter_history['altitude']*30.48; |
|
549 | 549 | $output_history .= '],'; |
550 | 550 | /* |
551 | 551 | if ($from_archive === false) { |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": ['; |
564 | 564 | } else $d = true; |
565 | 565 | $output_history .= '['; |
566 | - $output_history .= $spotter_history['longitude'].', '; |
|
567 | - $output_history .= $spotter_history['latitude']; |
|
566 | + $output_history .= $spotter_history['longitude'].', '; |
|
567 | + $output_history .= $spotter_history['latitude']; |
|
568 | 568 | $output_history .= '],'; |
569 | 569 | /* |
570 | 570 | if ($from_archive === false) { |
@@ -580,9 +580,9 @@ discard block |
||
580 | 580 | |
581 | 581 | if ($from_archive === false) { |
582 | 582 | $output_historyd = '['; |
583 | - $output_historyd .= $spotter_item['longitude'].', '; |
|
584 | - $output_historyd .= $spotter_item['latitude']; |
|
585 | - if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
583 | + $output_historyd .= $spotter_item['longitude'].', '; |
|
584 | + $output_historyd .= $spotter_item['latitude']; |
|
585 | + if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48; |
|
586 | 586 | $output_historyd .= '],'; |
587 | 587 | //$output_history = $output_historyd.$output_history; |
588 | 588 | $output_history = $output_history.$output_historyd; |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | } |
597 | 597 | } |
598 | 598 | |
599 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
599 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
600 | 600 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
601 | 601 | && (isset($spotter_item['departure_airport']) |
602 | 602 | && $spotter_item['departure_airport'] != 'NA' |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | |
631 | 631 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
632 | 632 | //if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
633 | - if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
633 | + if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id'])) |
|
634 | 634 | || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) |
635 | 635 | && (isset($spotter_item['arrival_airport']) |
636 | 636 | && $spotter_item['arrival_airport'] != 'NA' |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | $output = substr($output, 0, -1); |
662 | 662 | $output .= ']'; |
663 | 663 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
664 | - $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
|
664 | + $output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",'; |
|
665 | 665 | if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
666 | 666 | $output .= '"fc": "'.$j.'"'; |
667 | 667 | } else { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if (isset($this->all_tracked[$key]['id'])) { |
48 | 48 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
49 | 49 | $Tracker = new Tracker($this->db); |
50 | - $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
50 | + $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
59 | 59 | foreach ($this->all_tracked as $key => $flight) { |
60 | 60 | if (isset($flight['lastupdate'])) { |
61 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
61 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
62 | 62 | if (isset($this->all_tracked[$key]['id'])) { |
63 | 63 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
64 | 64 | /* |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | //$real_arrival = $this->arrival($key); |
70 | 70 | $Tracker = new Tracker($this->db); |
71 | 71 | if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
72 | - $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
|
72 | + $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']); |
|
73 | 73 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
74 | 74 | } |
75 | 75 | // Put in archive |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $send = false; |
90 | 90 | |
91 | 91 | // SBS format is CSV format |
92 | - if(is_array($line) && isset($line['ident'])) { |
|
92 | + if (is_array($line) && isset($line['ident'])) { |
|
93 | 93 | //print_r($line); |
94 | 94 | if (isset($line['ident'])) { |
95 | 95 | |
@@ -113,33 +113,33 @@ discard block |
||
113 | 113 | |
114 | 114 | if (!isset($this->all_tracked[$id])) { |
115 | 115 | $this->all_tracked[$id] = array(); |
116 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
116 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0)); |
|
117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '')); |
|
118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time())); |
|
119 | 119 | if (!isset($line['id'])) { |
120 | 120 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
121 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
122 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
121 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
122 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id'])); |
|
123 | 123 | if ($globalAllTracked !== FALSE) $dataFound = true; |
124 | 124 | } |
125 | 125 | |
126 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
|
126 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) { |
|
127 | 127 | if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
128 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
|
128 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime'])); |
|
129 | 129 | } else { |
130 | 130 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n"; |
131 | 131 | 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]['ident']." - format : ".$line['format_source']."\n"; |
132 | 132 | return ''; |
133 | 133 | } |
134 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
|
134 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) { |
|
135 | 135 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
136 | 136 | return ''; |
137 | - } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) { |
|
137 | + } elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) { |
|
138 | 138 | if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
139 | 139 | return ''; |
140 | 140 | } elseif (!isset($line['datetime'])) { |
141 | 141 | date_default_timezone_set('UTC'); |
142 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
142 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
143 | 143 | } else { |
144 | 144 | if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n"; |
145 | 145 | return ''; |
@@ -147,38 +147,38 @@ discard block |
||
147 | 147 | |
148 | 148 | //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'])) { |
149 | 149 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
150 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
150 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident']))); |
|
151 | 151 | if ($this->all_tracked[$id]['addedTracker'] == 1) { |
152 | 152 | $timeelapsed = microtime(true); |
153 | 153 | $Tracker = new Tracker($this->db); |
154 | 154 | $fromsource = NULL; |
155 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
155 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource); |
|
156 | 156 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
157 | 157 | $Tracker->db = null; |
158 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
158 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
159 | 159 | } |
160 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
160 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'])); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | if (isset($line['speed']) && $line['speed'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed']))); |
|
165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true)); |
|
166 | 166 | } 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'])) { |
167 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
167 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'); |
|
168 | 168 | if ($distance > 100 && $distance < 10000) { |
169 | 169 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
170 | 170 | $speed = $speed*3.6; |
171 | - if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
|
171 | + if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed))); |
|
172 | 172 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n"; |
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | 176 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
177 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
177 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']); |
|
178 | 178 | else unset($timediff); |
179 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) { |
|
179 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) { |
|
180 | 180 | 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'])) { |
181 | - 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'])) { |
|
181 | + 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'])) { |
|
182 | 182 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
183 | 183 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
184 | 184 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
187 | 187 | $timeelapsed = microtime(true); |
188 | 188 | $Tracker = new Tracker($this->db); |
189 | - $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
189 | + $all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
190 | 190 | if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
191 | 191 | $Tracker->db = null; |
192 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
192 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
193 | 193 | $this->tmd = 0; |
194 | 194 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
195 | 195 | } |
@@ -197,75 +197,75 @@ discard block |
||
197 | 197 | |
198 | 198 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
199 | 199 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
200 | - 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') { |
|
200 | + 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') { |
|
201 | 201 | $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
202 | 202 | $dataFound = true; |
203 | 203 | $this->all_tracked[$id]['time_last_coord'] = time(); |
204 | 204 | } |
205 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
|
205 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude'])); |
|
206 | 206 | } |
207 | 207 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
208 | 208 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
209 | 209 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
210 | - 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') { |
|
210 | + 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') { |
|
211 | 211 | $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
212 | 212 | $dataFound = true; |
213 | 213 | $this->all_tracked[$id]['time_last_coord'] = time(); |
214 | 214 | } |
215 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
|
215 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude'])); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | } else if ($globalDebug && $timediff > 20) { |
219 | 219 | $this->tmd = $this->tmd + 1; |
220 | 220 | if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) { |
221 | 221 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
222 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
|
223 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
222 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -"; |
|
223 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
224 | 224 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
225 | 225 | } |
226 | 226 | } |
227 | 227 | } |
228 | 228 | if (isset($line['last_update']) && $line['last_update'] != '') { |
229 | 229 | if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
230 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
230 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update'])); |
|
231 | 231 | } |
232 | 232 | if (isset($line['format_source']) && $line['format_source'] != '') { |
233 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
233 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source'])); |
|
234 | 234 | } |
235 | 235 | if (isset($line['source_name']) && $line['source_name'] != '') { |
236 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
236 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name'])); |
|
237 | 237 | } |
238 | 238 | if (isset($line['comment']) && $line['comment'] != '') { |
239 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
239 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment'])); |
|
240 | 240 | //$dataFound = true; |
241 | 241 | } |
242 | 242 | if (isset($line['type']) && $line['type'] != '') { |
243 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
243 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type'])); |
|
244 | 244 | //$dataFound = true; |
245 | 245 | } |
246 | 246 | |
247 | 247 | if (isset($line['altitude']) && $line['altitude'] != '') { |
248 | 248 | //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
249 | - if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
250 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude'])); |
|
251 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
|
249 | + if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
|
250 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => $line['altitude'])); |
|
251 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude'])); |
|
252 | 252 | //$dataFound = true; |
253 | 253 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
254 | 254 | } |
255 | 255 | |
256 | 256 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
257 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
257 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | if (isset($line['heading']) && $line['heading'] != '') { |
261 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
263 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
261 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading']))); |
|
263 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true)); |
|
264 | 264 | //$dataFound = true; |
265 | 265 | } 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']) { |
266 | - $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']); |
|
267 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
268 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
266 | + $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']); |
|
267 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading))); |
|
268 | + if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
269 | 269 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
270 | 270 | } |
271 | 271 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
@@ -273,54 +273,54 @@ discard block |
||
273 | 273 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
274 | 274 | $this->all_tracked[$id]['lastupdate'] = time(); |
275 | 275 | if ($this->all_tracked[$id]['addedTracker'] == 0) { |
276 | - 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'])) { |
|
276 | + 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'])) { |
|
277 | 277 | if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
278 | 278 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
279 | 279 | $timeelapsed = microtime(true); |
280 | 280 | $TrackerLive = new TrackerLive($this->db); |
281 | 281 | if (isset($line['id'])) { |
282 | 282 | $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
283 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
283 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
284 | 284 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
285 | 285 | $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
286 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
286 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
287 | 287 | } else $recent_ident = ''; |
288 | - $TrackerLive->db=null; |
|
288 | + $TrackerLive->db = null; |
|
289 | 289 | |
290 | 290 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
291 | 291 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
292 | 292 | } else { |
293 | 293 | $recent_ident = ''; |
294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
|
294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0)); |
|
295 | 295 | } |
296 | 296 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
297 | - if($recent_ident == "") |
|
297 | + if ($recent_ident == "") |
|
298 | 298 | { |
299 | 299 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
300 | 300 | //adds the spotter data for the archive |
301 | 301 | $highlight = ''; |
302 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
302 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
303 | 303 | $timeelapsed = microtime(true); |
304 | 304 | $Tracker = new Tracker($this->db); |
305 | - $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
305 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']); |
|
306 | 306 | $Tracker->db = null; |
307 | 307 | if ($globalDebug && isset($result)) echo $result."\n"; |
308 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
308 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
309 | 309 | |
310 | 310 | |
311 | 311 | // Add source stat in DB |
312 | 312 | $Stats = new Stats($this->db); |
313 | 313 | if (!empty($this->stats)) { |
314 | 314 | if ($globalDebug) echo 'Add source stats : '; |
315 | - foreach($this->stats as $date => $data) { |
|
316 | - foreach($data as $source => $sourced) { |
|
315 | + foreach ($this->stats as $date => $data) { |
|
316 | + foreach ($data as $source => $sourced) { |
|
317 | 317 | //print_r($sourced); |
318 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date); |
|
319 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date); |
|
318 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_tracker', $date); |
|
319 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_tracker', $date); |
|
320 | 320 | if (isset($sourced['msg'])) { |
321 | 321 | if (time() - $sourced['msg']['date'] > 10) { |
322 | 322 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
323 | - echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date); |
|
323 | + echo $Stats->addStatSource($nbmsg, $source, 'msg_tracker', $date); |
|
324 | 324 | unset($this->stats[$date][$source]['msg']); |
325 | 325 | } |
326 | 326 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
344 | 344 | $TrackerLive = new TrackerLive($this->db); |
345 | 345 | $TrackerLive->deleteLiveTrackerData(); |
346 | - $TrackerLive->db=null; |
|
346 | + $TrackerLive->db = null; |
|
347 | 347 | if ($globalDebug) echo " Done\n"; |
348 | 348 | $this->last_delete = time(); |
349 | 349 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $this->all_tracked[$id]['addedTracker'] = 1; |
353 | 353 | if (isset($globalDaemon) && !$globalDaemon) { |
354 | 354 | $Tracker = new Tracker($this->db); |
355 | - $Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
|
355 | + $Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']); |
|
356 | 356 | $Tracker->db = null; |
357 | 357 | } |
358 | 358 | |
@@ -366,14 +366,14 @@ discard block |
||
366 | 366 | $ignoreImport = false; |
367 | 367 | |
368 | 368 | if (!$ignoreImport) { |
369 | - 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'])) { |
|
369 | + 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'])) { |
|
370 | 370 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
371 | 371 | $timeelapsed = microtime(true); |
372 | 372 | $TrackerLive = new TrackerLive($this->db); |
373 | - $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
373 | + $result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']); |
|
374 | 374 | $TrackerLive->db = null; |
375 | 375 | $this->all_tracked[$id]['putinarchive'] = false; |
376 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
376 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
377 | 377 | |
378 | 378 | // Put statistics in $this->stats variable |
379 | 379 | |
@@ -390,19 +390,19 @@ discard block |
||
390 | 390 | $latitude = $globalCenterLatitude; |
391 | 391 | $longitude = $globalCenterLongitude; |
392 | 392 | } |
393 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
393 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
394 | 394 | } else { |
395 | 395 | $latitude = $this->source_location[$source]['latitude']; |
396 | 396 | $longitude = $this->source_location[$source]['longitude']; |
397 | 397 | } |
398 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
398 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
399 | 399 | //$stats_heading = $stats_heading%22.5; |
400 | 400 | $stats_heading = round($stats_heading/22.5); |
401 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
401 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']); |
|
402 | 402 | $current_date = date('Y-m-d'); |
403 | 403 | if ($stats_heading == 16) $stats_heading = 0; |
404 | 404 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
405 | - for ($i=0;$i<=15;$i++) { |
|
405 | + for ($i = 0; $i <= 15; $i++) { |
|
406 | 406 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
407 | 407 | } |
408 | 408 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -417,9 +417,9 @@ discard block |
||
417 | 417 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
418 | 418 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
419 | 419 | end($this->stats[$current_date][$source]['hist']); |
420 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
420 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
421 | 421 | } else $mini = 0; |
422 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
422 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
423 | 423 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
424 | 424 | } |
425 | 425 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | $this->all_tracked[$id]['lastupdate'] = time(); |
432 | 432 | if ($this->all_tracked[$id]['putinarchive']) $send = true; |
433 | 433 | if ($globalDebug) echo $result."\n"; |
434 | - } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
434 | + } elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
435 | 435 | //$this->del(); |
436 | 436 | |
437 | 437 |
@@ -16,33 +16,33 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | if (isset($filter[0]['source'])) { |
30 | - $filters = array_merge($filters,$filter); |
|
30 | + $filters = array_merge($filters, $filter); |
|
31 | 31 | } |
32 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
33 | 33 | $filter_query_join = ''; |
34 | 34 | $filter_query_where = ''; |
35 | - foreach($filters as $flt) { |
|
35 | + foreach ($filters as $flt) { |
|
36 | 36 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
37 | 37 | if (isset($flt['source'])) { |
38 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
39 | 39 | } else { |
40 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
40 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid"; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | if (isset($filter['source']) && !empty($filter['source'])) { |
45 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
45 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
46 | 46 | } |
47 | 47 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
48 | 48 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'"; |
72 | 72 | } |
73 | 73 | } |
74 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
74 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid"; |
|
75 | 75 | } |
76 | 76 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
77 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
77 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
78 | 78 | } |
79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
80 | 80 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
81 | 81 | if ($filter_query_where != '') { |
82 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
82 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
83 | 83 | } |
84 | 84 | $filter_query = $filter_query_join.$filter_query_where; |
85 | 85 | return $filter_query; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | if ($limit != '') |
103 | 103 | { |
104 | 104 | $limit_array = explode(',', $limit); |
105 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
106 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
105 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
106 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
107 | 107 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
108 | 108 | { |
109 | 109 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } else { |
127 | 127 | $query = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query; |
128 | 128 | } |
129 | - $spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true); |
|
129 | + $spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true); |
|
130 | 130 | |
131 | 131 | return $spotter_array; |
132 | 132 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
143 | 143 | date_default_timezone_set('UTC'); |
144 | 144 | |
145 | - $filter_query = $this->getFilter($filter,true,true); |
|
145 | + $filter_query = $this->getFilter($filter, true, true); |
|
146 | 146 | |
147 | 147 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
148 | 148 | if ($globalDBdriver == 'mysql') { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | try { |
161 | 161 | $sth = $this->db->prepare($query); |
162 | 162 | $sth->execute(); |
163 | - } catch(PDOException $e) { |
|
163 | + } catch (PDOException $e) { |
|
164 | 164 | echo $e->getMessage(); |
165 | 165 | die; |
166 | 166 | } |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | global $globalDBdriver, $globalLiveInterval; |
181 | 181 | date_default_timezone_set('UTC'); |
182 | 182 | |
183 | - $filter_query = $this->getFilter($filter,true,true); |
|
183 | + $filter_query = $this->getFilter($filter, true, true); |
|
184 | 184 | |
185 | 185 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
186 | 186 | if ($globalDBdriver == 'mysql') { |
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 |
|
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 | 190 | } else { |
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 |
|
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 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | try { |
197 | 197 | $sth = $this->db->prepare($query); |
198 | 198 | $sth->execute(); |
199 | - } catch(PDOException $e) { |
|
199 | + } catch (PDOException $e) { |
|
200 | 200 | echo $e->getMessage(); |
201 | 201 | die; |
202 | 202 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | public function getLiveTrackerCount($filter = array()) |
214 | 214 | { |
215 | 215 | global $globalDBdriver, $globalLiveInterval; |
216 | - $filter_query = $this->getFilter($filter,true,true); |
|
216 | + $filter_query = $this->getFilter($filter, true, true); |
|
217 | 217 | |
218 | 218 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
219 | 219 | if ($globalDBdriver == 'mysql') { |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | try { |
225 | 225 | $sth = $this->db->prepare($query); |
226 | 226 | $sth->execute(); |
227 | - } catch(PDOException $e) { |
|
227 | + } catch (PDOException $e) { |
|
228 | 228 | echo $e->getMessage(); |
229 | 229 | die; |
230 | 230 | } |
@@ -247,10 +247,10 @@ discard block |
||
247 | 247 | $filter_query = $this->getFilter($filter); |
248 | 248 | |
249 | 249 | if (is_array($coord)) { |
250 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
251 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
252 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
253 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
250 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
251 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
252 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
253 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
254 | 254 | } else return array(); |
255 | 255 | if ($globalDBdriver == 'mysql') { |
256 | 256 | $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query; |
@@ -275,17 +275,17 @@ discard block |
||
275 | 275 | $filter_query = $this->getFilter($filter); |
276 | 276 | |
277 | 277 | if (is_array($coord)) { |
278 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
279 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
280 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
281 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
278 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
279 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
280 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
281 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
282 | 282 | } else return array(); |
283 | 283 | if ($globalDBdriver == 'mysql') { |
284 | 284 | $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 |
285 | 285 | 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' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong." |
286 | 286 | ORDER BY tracker_live.famtrackid, tracker_live.date"; |
287 | 287 | } else { |
288 | - $query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
288 | + $query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source |
|
289 | 289 | FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date l.latitude BETWEEN ".$minlat." AND ".$maxlat." AND l.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query." tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'"; |
290 | 290 | } |
291 | 291 | $spotter_array = $Spotter->getDataFromDB($query); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | if ($interval == '1m') |
334 | 334 | { |
335 | 335 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
336 | - } else if ($interval == '15m'){ |
|
336 | + } else if ($interval == '15m') { |
|
337 | 337 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
338 | 338 | } |
339 | 339 | } |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
342 | 342 | } |
343 | 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 |
|
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 | 353 | return $spotter_array; |
354 | 354 | } |
@@ -366,9 +366,9 @@ discard block |
||
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 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
371 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
372 | 372 | |
373 | 373 | return $spotter_array; |
374 | 374 | } |
@@ -379,16 +379,16 @@ discard block |
||
379 | 379 | * @return Array the spotter information |
380 | 380 | * |
381 | 381 | */ |
382 | - public function getDateLiveTrackerDataByIdent($ident,$date) |
|
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); |
|
391 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
390 | + $date = date('c', $date); |
|
391 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
392 | 392 | |
393 | 393 | return $spotter_array; |
394 | 394 | } |
@@ -405,9 +405,9 @@ discard block |
||
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 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
|
410 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true); |
|
411 | 411 | |
412 | 412 | return $spotter_array; |
413 | 413 | } |
@@ -418,15 +418,15 @@ discard block |
||
418 | 418 | * @return Array the spotter information |
419 | 419 | * |
420 | 420 | */ |
421 | - public function getDateLiveTrackerDataById($id,$date) |
|
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); |
|
429 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
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 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
430 | 430 | |
431 | 431 | return $spotter_array; |
432 | 432 | } |
@@ -443,13 +443,13 @@ discard block |
||
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 | 448 | try { |
449 | 449 | |
450 | 450 | $sth = $this->db->prepare($query); |
451 | 451 | $sth->execute(array(':ident' => $ident)); |
452 | - } catch(PDOException $e) { |
|
452 | + } catch (PDOException $e) { |
|
453 | 453 | echo $e->getMessage(); |
454 | 454 | die; |
455 | 455 | } |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | * @return Array the spotter information |
465 | 465 | * |
466 | 466 | */ |
467 | - public function getAllLiveTrackerDataById($id,$liveinterval = false) |
|
467 | + public function getAllLiveTrackerDataById($id, $liveinterval = false) |
|
468 | 468 | { |
469 | 469 | global $globalDBdriver, $globalLiveInterval; |
470 | 470 | date_default_timezone_set('UTC'); |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | try { |
484 | 484 | $sth = $this->db->prepare($query); |
485 | 485 | $sth->execute(array(':id' => $id)); |
486 | - } catch(PDOException $e) { |
|
486 | + } catch (PDOException $e) { |
|
487 | 487 | echo $e->getMessage(); |
488 | 488 | die; |
489 | 489 | } |
@@ -501,12 +501,12 @@ discard block |
||
501 | 501 | { |
502 | 502 | date_default_timezone_set('UTC'); |
503 | 503 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
504 | - $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
504 | + $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
|
505 | 505 | try { |
506 | 506 | |
507 | 507 | $sth = $this->db->prepare($query); |
508 | 508 | $sth->execute(array(':ident' => $ident)); |
509 | - } catch(PDOException $e) { |
|
509 | + } catch (PDOException $e) { |
|
510 | 510 | echo $e->getMessage(); |
511 | 511 | die; |
512 | 512 | } |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | |
537 | 537 | $sth = $this->db->prepare($query); |
538 | 538 | $sth->execute(); |
539 | - } catch(PDOException $e) { |
|
539 | + } catch (PDOException $e) { |
|
540 | 540 | return "error"; |
541 | 541 | } |
542 | 542 | |
@@ -559,14 +559,14 @@ discard block |
||
559 | 559 | |
560 | 560 | $sth = $this->db->prepare($query); |
561 | 561 | $sth->execute(); |
562 | - } catch(PDOException $e) { |
|
562 | + } catch (PDOException $e) { |
|
563 | 563 | return "error"; |
564 | 564 | } |
565 | 565 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
566 | 566 | $i = 0; |
567 | - $j =0; |
|
567 | + $j = 0; |
|
568 | 568 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
569 | - foreach($all as $row) |
|
569 | + foreach ($all as $row) |
|
570 | 570 | { |
571 | 571 | $i++; |
572 | 572 | $j++; |
@@ -574,9 +574,9 @@ discard block |
||
574 | 574 | if ($globalDebug) echo "."; |
575 | 575 | try { |
576 | 576 | |
577 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
577 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
578 | 578 | $sth->execute(); |
579 | - } catch(PDOException $e) { |
|
579 | + } catch (PDOException $e) { |
|
580 | 580 | return "error"; |
581 | 581 | } |
582 | 582 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
@@ -587,9 +587,9 @@ discard block |
||
587 | 587 | if ($i > 0) { |
588 | 588 | try { |
589 | 589 | |
590 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
590 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
591 | 591 | $sth->execute(); |
592 | - } catch(PDOException $e) { |
|
592 | + } catch (PDOException $e) { |
|
593 | 593 | return "error"; |
594 | 594 | } |
595 | 595 | } |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | |
603 | 603 | $sth = $this->db->prepare($query); |
604 | 604 | $sth->execute(); |
605 | - } catch(PDOException $e) { |
|
605 | + } catch (PDOException $e) { |
|
606 | 606 | return "error"; |
607 | 607 | } |
608 | 608 | /* $query_delete = "DELETE FROM tracker_live WHERE famtrackid IN ("; |
@@ -650,13 +650,13 @@ discard block |
||
650 | 650 | public function deleteLiveTrackerDataByIdent($ident) |
651 | 651 | { |
652 | 652 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
653 | - $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
653 | + $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
|
654 | 654 | |
655 | 655 | try { |
656 | 656 | |
657 | 657 | $sth = $this->db->prepare($query); |
658 | 658 | $sth->execute(array(':ident' => $ident)); |
659 | - } catch(PDOException $e) { |
|
659 | + } catch (PDOException $e) { |
|
660 | 660 | return "error"; |
661 | 661 | } |
662 | 662 | |
@@ -672,13 +672,13 @@ discard block |
||
672 | 672 | public function deleteLiveTrackerDataById($id) |
673 | 673 | { |
674 | 674 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
675 | - $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
675 | + $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
|
676 | 676 | |
677 | 677 | try { |
678 | 678 | |
679 | 679 | $sth = $this->db->prepare($query); |
680 | 680 | $sth->execute(array(':id' => $id)); |
681 | - } catch(PDOException $e) { |
|
681 | + } catch (PDOException $e) { |
|
682 | 682 | return "error"; |
683 | 683 | } |
684 | 684 | |
@@ -696,13 +696,13 @@ discard block |
||
696 | 696 | { |
697 | 697 | global $globalDBdriver, $globalTimezone; |
698 | 698 | if ($globalDBdriver == 'mysql') { |
699 | - $query = 'SELECT tracker_live.ident FROM tracker_live |
|
699 | + $query = 'SELECT tracker_live.ident FROM tracker_live |
|
700 | 700 | WHERE tracker_live.ident = :ident |
701 | 701 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
702 | 702 | AND tracker_live.date < UTC_TIMESTAMP()'; |
703 | 703 | $query_data = array(':ident' => $ident); |
704 | 704 | } else { |
705 | - $query = "SELECT tracker_live.ident FROM tracker_live |
|
705 | + $query = "SELECT tracker_live.ident FROM tracker_live |
|
706 | 706 | WHERE tracker_live.ident = :ident |
707 | 707 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
708 | 708 | AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -711,8 +711,8 @@ discard block |
||
711 | 711 | |
712 | 712 | $sth = $this->db->prepare($query); |
713 | 713 | $sth->execute($query_data); |
714 | - $ident_result=''; |
|
715 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
714 | + $ident_result = ''; |
|
715 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
716 | 716 | { |
717 | 717 | $ident_result = $row['ident']; |
718 | 718 | } |
@@ -729,13 +729,13 @@ discard block |
||
729 | 729 | { |
730 | 730 | global $globalDBdriver, $globalTimezone; |
731 | 731 | if ($globalDBdriver == 'mysql') { |
732 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
732 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
733 | 733 | WHERE tracker_live.ident = :ident |
734 | 734 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
735 | 735 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
736 | 736 | $query_data = array(':ident' => $ident); |
737 | 737 | } else { |
738 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
738 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
739 | 739 | WHERE tracker_live.ident = :ident |
740 | 740 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
741 | 741 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -744,8 +744,8 @@ discard block |
||
744 | 744 | |
745 | 745 | $sth = $this->db->prepare($query); |
746 | 746 | $sth->execute($query_data); |
747 | - $ident_result=''; |
|
748 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
747 | + $ident_result = ''; |
|
748 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
749 | 749 | { |
750 | 750 | $ident_result = $row['famtrackid']; |
751 | 751 | } |
@@ -762,13 +762,13 @@ discard block |
||
762 | 762 | { |
763 | 763 | global $globalDBdriver, $globalTimezone; |
764 | 764 | if ($globalDBdriver == 'mysql') { |
765 | - $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
765 | + $query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
766 | 766 | WHERE tracker_live.famtrackid = :id |
767 | 767 | AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
768 | 768 | // AND tracker_live.date < UTC_TIMESTAMP()"; |
769 | 769 | $query_data = array(':id' => $id); |
770 | 770 | } else { |
771 | - $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
771 | + $query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live |
|
772 | 772 | WHERE tracker_live.famtrackid = :id |
773 | 773 | AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
774 | 774 | // AND tracker_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -777,8 +777,8 @@ discard block |
||
777 | 777 | |
778 | 778 | $sth = $this->db->prepare($query); |
779 | 779 | $sth->execute($query_data); |
780 | - $ident_result=''; |
|
781 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
780 | + $ident_result = ''; |
|
781 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
782 | 782 | { |
783 | 783 | $ident_result = $row['famtrackid']; |
784 | 784 | } |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | * @return String success or false |
797 | 797 | * |
798 | 798 | */ |
799 | - public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
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; |
802 | 802 | $Common = new Common(); |
@@ -855,21 +855,21 @@ discard block |
||
855 | 855 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
856 | 856 | |
857 | 857 | |
858 | - $famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING); |
|
859 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
860 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
861 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
862 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
863 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
864 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
865 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
866 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
867 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
868 | - $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
|
869 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
870 | - |
|
871 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
872 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
858 | + $famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING); |
|
859 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
860 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
861 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
862 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
863 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
864 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
865 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
866 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
867 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
868 | + $comment = filter_var($comment, FILTER_SANITIZE_STRING); |
|
869 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
870 | + |
|
871 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
872 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
873 | 873 | |
874 | 874 | $query = ''; |
875 | 875 | if ($globalArchive) { |
@@ -879,12 +879,12 @@ discard block |
||
879 | 879 | $query .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
880 | 880 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
881 | 881 | |
882 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type); |
|
882 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type); |
|
883 | 883 | try { |
884 | 884 | |
885 | 885 | $sth = $this->db->prepare($query); |
886 | 886 | $sth->execute($query_values); |
887 | - } catch(PDOException $e) { |
|
887 | + } catch (PDOException $e) { |
|
888 | 888 | return "error : ".$e->getMessage(); |
889 | 889 | } |
890 | 890 | /* |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
895 | 895 | if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
896 | 896 | $TrackerArchive = new TrackerArchive($this->db); |
897 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
897 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type, $noarchive, $format_source, $source_name, $over_country); |
|
898 | 898 | if ($globalDebug) echo $result.')'; |
899 | 899 | } |
900 | 900 | |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | |
905 | 905 | public function getOrderBy() |
906 | 906 | { |
907 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
907 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC")); |
|
908 | 908 | return $orderby; |
909 | 909 | } |
910 | 910 |
@@ -11,14 +11,14 @@ discard block |
||
11 | 11 | |
12 | 12 | $from_archive = false; |
13 | 13 | if (isset($_GET['ident'])) { |
14 | - $ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING)); |
|
14 | + $ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING)); |
|
15 | 15 | if (isset($_GET['currenttime'])) { |
16 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
16 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
17 | 17 | $currenttime = round($currenttime/1000); |
18 | - $spotter_array = $TrackerLive->getDateLiveTrackerDataByIdent($ident,$currenttime); |
|
18 | + $spotter_array = $TrackerLive->getDateLiveTrackerDataByIdent($ident, $currenttime); |
|
19 | 19 | if (empty($spotter_array)) { |
20 | 20 | $from_archive = true; |
21 | - $spotter_array = $TrackerArchive->getDateArchiveTrackerDataByIdent($ident,$currenttime); |
|
21 | + $spotter_array = $TrackerArchive->getDateArchiveTrackerDataByIdent($ident, $currenttime); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | } else { |
@@ -30,16 +30,16 @@ discard block |
||
30 | 30 | } |
31 | 31 | } |
32 | 32 | if (isset($_GET['famtrackid'])) { |
33 | - $famtrackid = urldecode(filter_input(INPUT_GET,'famtrackid',FILTER_SANITIZE_STRING)); |
|
33 | + $famtrackid = urldecode(filter_input(INPUT_GET, 'famtrackid', FILTER_SANITIZE_STRING)); |
|
34 | 34 | if (isset($_GET['currenttime'])) { |
35 | - $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT); |
|
35 | + $currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT); |
|
36 | 36 | $currenttime = round($currenttime/1000); |
37 | - $spotter_array = $TrackerLive->getDateLiveTrackerDataById($famtrackid,$currenttime); |
|
37 | + $spotter_array = $TrackerLive->getDateLiveTrackerDataById($famtrackid, $currenttime); |
|
38 | 38 | |
39 | 39 | if (empty($spotter_array)) { |
40 | 40 | $from_archive = true; |
41 | 41 | // $spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id); |
42 | - $spotter_array = $TrackerArchive->getDateArchiveTrackerDataById($flightaware_id,$currenttime); |
|
42 | + $spotter_array = $TrackerArchive->getDateArchiveTrackerDataById($flightaware_id, $currenttime); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | } else { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "") |
60 | 60 | { |
61 | 61 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
62 | - $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
|
62 | + $image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']); |
|
63 | 63 | } else $image = $spotter_item['image_thumbnail']; |
64 | 64 | |
65 | 65 | } |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | print '<div><span>'._("Altitude").'</span>'; |
80 | 80 | if (isset($globalGroundAltitude) && $globalGroundAltitude) { |
81 | 81 | try { |
82 | - $groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']); |
|
83 | - } catch(Exception $e) { |
|
82 | + $groundAltitude = $Elevation->getElevation($spotter_item['latitude'], $spotter_item['longitude']); |
|
83 | + } catch (Exception $e) { |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |