Completed
Push — master ( 157d06...e82944 )
by Yannick
08:43
created
scripts/daemon-spotter.php 1 patch
Braces   +993 added lines, -342 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -55,35 +59,62 @@  discard block
 block discarded – undo
55 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 60
 if (isset($options['s'])) {
57 61
     $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
-    else $globalSources[] = array('host' => $options['s']);
60
-} elseif (isset($options['source'])) {
62
+    if (isset($options['format'])) {
63
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
64
+    } else {
65
+    	$globalSources[] = array('host' => $options['s']);
66
+    }
67
+    } elseif (isset($options['source'])) {
61 68
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['source']);
64
-}
69
+    if (isset($options['format'])) {
70
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
71
+    } else {
72
+    	$globalSources[] = array('host' => $options['source']);
73
+    }
74
+    }
65 75
 if (isset($options['aprsserverhost'])) {
66 76
 	$globalServerAPRS = TRUE;
67 77
 	$globalServerAPRShost = $options['aprsserverhost'];
68 78
 }
69
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
70
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
71
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
72
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
73
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
74
-if (isset($options['server'])) $globalServer = TRUE;
75
-if (isset($options['idsource'])) $id_source = $options['idsource'];
76
-else $id_source = 1;
79
+if (isset($options['aprsserverport'])) {
80
+	$globalServerAPRSport = $options['aprsserverport'];
81
+}
82
+if (isset($options['aprsserverssid'])) {
83
+	$globalServerAPRSssid = $options['aprsserverssid'];
84
+}
85
+if (isset($options['aprsserverpass'])) {
86
+	$globalServerAPRSpass = $options['aprsserverpass'];
87
+}
88
+if (isset($options['noaprsserver'])) {
89
+	$globalServerAPRS = FALSE;
90
+}
91
+if (isset($options['nodaemon'])) {
92
+	$globalDaemon = FALSE;
93
+}
94
+if (isset($options['server'])) {
95
+	$globalServer = TRUE;
96
+}
97
+if (isset($options['idsource'])) {
98
+	$id_source = $options['idsource'];
99
+} else {
100
+	$id_source = 1;
101
+}
77 102
 if (isset($globalServer) && $globalServer) {
78
-    if ($globalDebug) echo "Using Server Mode\n";
103
+    if ($globalDebug) {
104
+    	echo "Using Server Mode\n";
105
+    }
79 106
     $SI=new SpotterServer();
80 107
 /*
81 108
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 109
     $SI = new adsb2aprs();
83 110
     $SI->connect();
84 111
 */
85
-} else $SI=new SpotterImport($Connection->db);
86
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
112
+} else {
113
+	$SI=new SpotterImport($Connection->db);
114
+}
115
+if (isset($globalTracker) && $globalTracker) {
116
+	$TI = new TrackerImport($Connection->db);
117
+}
87 118
 if (isset($globalMarine) && $globalMarine) {
88 119
     $AIS = new AIS();
89 120
     $MI = new MarineImport($Connection->db);
@@ -106,7 +137,9 @@  discard block
 block discarded – undo
106 137
 }
107 138
 
108 139
 // let's try and connect
109
-if ($globalDebug) echo "Connecting...\n";
140
+if ($globalDebug) {
141
+	echo "Connecting...\n";
142
+}
110 143
 $use_aprs = false;
111 144
 $aprs_full = false;
112 145
 $reset = 0;
@@ -115,7 +148,9 @@  discard block
 block discarded – undo
115 148
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116 149
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117 150
     $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
151
+    if ($globalDebug) {
152
+    	echo 'Connect to all...'."\n";
153
+    }
119 154
     foreach ($hosts as $id => $value) {
120 155
 	$host = $value['host'];
121 156
 	$globalSources[$id]['last_exec'] = 0;
@@ -125,22 +160,30 @@  discard block
 block discarded – undo
125 160
         	//$formats[$id] = 'deltadbtxt';
126 161
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 162
         	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
163
+        	if ($globalDebug) {
164
+        		echo "Connect to deltadb source (".$host.")...\n";
165
+        	}
129 166
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130 167
         	//$formats[$id] = 'vatsimtxt';
131 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 169
         	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
170
+        	if ($globalDebug) {
171
+        		echo "Connect to vatsim source (".$host.")...\n";
172
+        	}
134 173
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135 174
         	//$formats[$id] = 'aircraftlistjson';
136 175
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 176
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
177
+        	if ($globalDebug) {
178
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
179
+        	}
139 180
     	    } else if (preg_match('/opensky/i',$host)) {
140 181
         	//$formats[$id] = 'aircraftlistjson';
141 182
         	$globalSources[$id]['format'] = 'opensky';
142 183
         	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
184
+        	if ($globalDebug) {
185
+        		echo "Connect to opensky source (".$host.")...\n";
186
+        	}
144 187
     	    /*
145 188
     	    // Disabled for now, site change source format
146 189
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -157,7 +200,9 @@  discard block
 block discarded – undo
157 200
         	//$formats[$id] = 'planeupdatefaa';
158 201
         	$globalSources[$id]['format'] = 'planeupdatefaa';
159 202
         	//$last_exec['planeupdatefaa'] = 0;
160
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
203
+        	if ($globalDebug) {
204
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
205
+        	}
161 206
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162 207
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163 208
         	    exit(0);
@@ -166,29 +211,41 @@  discard block
 block discarded – undo
166 211
         	//$formats[$id] = 'phpvmacars';
167 212
         	$globalSources[$id]['format'] = 'phpvmacars';
168 213
         	//$last_exec['phpvmacars'] = 0;
169
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to phpvmacars source (".$host.")...\n";
216
+        	}
170 217
             } else if (preg_match('/VAM-json.php$/i',$host)) {
171 218
         	//$formats[$id] = 'phpvmacars';
172 219
         	$globalSources[$id]['format'] = 'vam';
173
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
220
+        	if ($globalDebug) {
221
+        		echo "Connect to Vam source (".$host.")...\n";
222
+        	}
174 223
             } else if (preg_match('/whazzup/i',$host)) {
175 224
         	//$formats[$id] = 'whazzup';
176 225
         	$globalSources[$id]['format'] = 'whazzup';
177 226
         	//$last_exec['whazzup'] = 0;
178
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
227
+        	if ($globalDebug) {
228
+        		echo "Connect to whazzup source (".$host.")...\n";
229
+        	}
179 230
             } else if (preg_match('/airwhere/i',$host)) {
180 231
         	$globalSources[$id]['format'] = 'airwhere';
181
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
232
+        	if ($globalDebug) {
233
+        		echo "Connect to airwhere source (".$host.")...\n";
234
+        	}
182 235
             } else if (preg_match('/recentpireps/i',$host)) {
183 236
         	//$formats[$id] = 'pirepsjson';
184 237
         	$globalSources[$id]['format'] = 'pirepsjson';
185 238
         	//$last_exec['pirepsjson'] = 0;
186
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
239
+        	if ($globalDebug) {
240
+        		echo "Connect to pirepsjson source (".$host.")...\n";
241
+        	}
187 242
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188 243
         	//$formats[$id] = 'fr24json';
189 244
         	$globalSources[$id]['format'] = 'fr24json';
190 245
         	//$last_exec['fr24json'] = 0;
191
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
246
+        	if ($globalDebug) {
247
+        		echo "Connect to fr24 source (".$host.")...\n";
248
+        	}
192 249
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193 250
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194 251
         	    exit(0);
@@ -197,7 +254,9 @@  discard block
 block discarded – undo
197 254
         	//$formats[$id] = 'fr24json';
198 255
         	$globalSources[$id]['format'] = 'myshiptracking';
199 256
         	//$last_exec['fr24json'] = 0;
200
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
257
+        	if ($globalDebug) {
258
+        		echo "Connect to myshiptracking source (".$host.")...\n";
259
+        	}
201 260
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202 261
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203 262
         	    exit(0);
@@ -206,17 +265,24 @@  discard block
 block discarded – undo
206 265
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207 266
         	//$formats[$id] = 'tsv';
208 267
         	$globalSources[$id]['format'] = 'tsv';
209
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
268
+        	if ($globalDebug) {
269
+        		echo "Connect to tsv source (".$host.")...\n";
270
+        	}
210 271
             }
211 272
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212 273
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213 274
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
214 275
     		    if ($idf !== false) {
215 276
     			$httpfeeds[$id] = $idf;
216
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
277
+        		if ($globalDebug) {
278
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
279
+        		}
280
+    		    } elseif ($globalDebug) {
281
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
217 282
     		    }
218
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
283
+    		} elseif ($globalDebug) {
284
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
+    		}
220 286
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221 287
 	    $hostport = explode(':',$host);
222 288
 	    if (isset($hostport[1])) {
@@ -256,17 +322,25 @@  discard block
 block discarded – undo
256 322
         		//$formats[$id] = 'beast';
257 323
         		$globalSources[$id]['format'] = 'beast';
258 324
 		    //} else $formats[$id] = 'sbs';
259
-		    } else $globalSources[$id]['format'] = 'sbs';
325
+		    } else {
326
+		    	$globalSources[$id]['format'] = 'sbs';
327
+		    }
260 328
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
261 329
 		}
262
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
330
+		if ($globalDebug) {
331
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
332
+		}
263 333
             } else {
264
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
334
+		if ($globalDebug) {
335
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
336
+		}
265 337
     	    }
266 338
         }
267 339
     }
268 340
 }
269
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
341
+if (!isset($globalMinFetch)) {
342
+	$globalMinFetch = 15;
343
+}
270 344
 
271 345
 // Initialize all
272 346
 $status = array();
@@ -275,13 +349,19 @@  discard block
 block discarded – undo
275 349
 $formats = array();
276 350
 $last_exec = array();
277 351
 $time = time();
278
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
279
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
280
-else $timeout = 20;
352
+if (isset($globalSourcesTimeout)) {
353
+	$timeout = $globalSourcesTimeOut;
354
+} else if (isset($globalSBS1TimeOut)) {
355
+	$timeout = $globalSBS1TimeOut;
356
+} else {
357
+	$timeout = 20;
358
+}
281 359
 $errno = '';
282 360
 $errstr='';
283 361
 
284
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
362
+if (!isset($globalDaemon)) {
363
+	$globalDaemon = TRUE;
364
+}
285 365
 /* Initiate connections to all the hosts simultaneously */
286 366
 //connect_all($hosts);
287 367
 //connect_all($globalSources);
@@ -307,7 +387,9 @@  discard block
 block discarded – undo
307 387
     if (isset($source['format']) && $source['format'] == 'aprs') {
308 388
 	$aprs_connect = 0;
309 389
 	$use_aprs = true;
310
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
390
+	if (isset($source['port']) && $source['port'] == '10152') {
391
+		$aprs_full = true;
392
+	}
311 393
 	break;
312 394
     }
313 395
 }
@@ -318,25 +400,48 @@  discard block
 block discarded – undo
318 400
 	$aprs_connect = 0;
319 401
 	$aprs_keep = 120;
320 402
 	$aprs_last_tx = time();
321
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
322
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
323
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
324
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
325
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
326
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
327
-	if ($aprs_full) $aprs_filter = '';
328
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
329
-	else $aprs_pass = '-1';
403
+	if (isset($globalAPRSversion)) {
404
+		$aprs_version = $globalAPRSversion;
405
+	} else {
406
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
407
+	}
408
+	if (isset($globalAPRSssid)) {
409
+		$aprs_ssid = $globalAPRSssid;
410
+	} else {
411
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
412
+	}
413
+	if (isset($globalAPRSfilter)) {
414
+		$aprs_filter = $globalAPRSfilter;
415
+	} else {
416
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
417
+	}
418
+	if ($aprs_full) {
419
+		$aprs_filter = '';
420
+	}
421
+	if (isset($globalAPRSpass)) {
422
+		$aprs_pass = $globalAPRSpass;
423
+	} else {
424
+		$aprs_pass = '-1';
425
+	}
330 426
 
331
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
332
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
333
-}
427
+	if ($aprs_filter != '') {
428
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
429
+	} else {
430
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
431
+	}
432
+	}
334 433
 
335 434
 // connected - lets do some work
336
-if ($globalDebug) echo "Connected!\n";
435
+if ($globalDebug) {
436
+	echo "Connected!\n";
437
+}
337 438
 sleep(1);
338
-if ($globalDebug) echo "SCAN MODE \n\n";
339
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
439
+if ($globalDebug) {
440
+	echo "SCAN MODE \n\n";
441
+}
442
+if (!isset($globalCronEnd)) {
443
+	$globalCronEnd = 60;
444
+}
340 445
 $endtime = time()+$globalCronEnd;
341 446
 $i = 1;
342 447
 $tt = array();
@@ -350,20 +455,28 @@  discard block
 block discarded – undo
350 455
 
351 456
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
352 457
 while ($i > 0) {
353
-    if (!$globalDaemon) $i = $endtime-time();
458
+    if (!$globalDaemon) {
459
+    	$i = $endtime-time();
460
+    }
354 461
     // Delete old ATC
355 462
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
356
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
463
+	if ($globalDebug) {
464
+		echo 'Delete old ATC...'."\n";
465
+	}
357 466
         $ATC->deleteOldATC();
358 467
     }
359 468
     
360 469
     if (count($last_exec) == count($globalSources)) {
361 470
 	$max = $globalMinFetch;
362 471
 	foreach ($last_exec as $last) {
363
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
472
+	    if ((time() - $last['last']) < $max) {
473
+	    	$max = time() - $last['last'];
474
+	    }
364 475
 	}
365 476
 	if ($max != $globalMinFetch) {
366
-	    if ($globalDebug) echo 'Sleeping...'."\n";
477
+	    if ($globalDebug) {
478
+	    	echo 'Sleeping...'."\n";
479
+	    }
367 480
 	    sleep($globalMinFetch-$max+2);
368 481
 	}
369 482
     }
@@ -372,11 +485,15 @@  discard block
 block discarded – undo
372 485
     //foreach ($formats as $id => $value) {
373 486
     foreach ($globalSources as $id => $value) {
374 487
 	date_default_timezone_set('UTC');
375
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
488
+	if (!isset($last_exec[$id]['last'])) {
489
+		$last_exec[$id]['last'] = 0;
490
+	}
376 491
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
377 492
 	    //$buffer = $Common->getData($hosts[$id]);
378 493
 	    $buffer = $Common->getData($value['host']);
379
-	    if ($buffer != '') $reset = 0;
494
+	    if ($buffer != '') {
495
+	    	$reset = 0;
496
+	    }
380 497
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381 498
 	    $buffer = explode('\n',$buffer);
382 499
 	    foreach ($buffer as $line) {
@@ -385,20 +502,41 @@  discard block
 block discarded – undo
385 502
 	            $data = array();
386 503
 	            $data['hex'] = $line[1]; // hex
387 504
 	            $data['ident'] = $line[2]; // ident
388
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
389
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
390
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
391
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
392
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
505
+	            if (isset($line[3])) {
506
+	            	$data['altitude'] = $line[3];
507
+	            }
508
+	            // altitude
509
+	            if (isset($line[4])) {
510
+	            	$data['speed'] = $line[4];
511
+	            }
512
+	            // speed
513
+	            if (isset($line[5])) {
514
+	            	$data['heading'] = $line[5];
515
+	            }
516
+	            // heading
517
+	            if (isset($line[6])) {
518
+	            	$data['latitude'] = $line[6];
519
+	            }
520
+	            // lat
521
+	            if (isset($line[7])) {
522
+	            	$data['longitude'] = $line[7];
523
+	            }
524
+	            // long
393 525
 	            $data['verticalrate'] = ''; // vertical rate
394 526
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
395 527
 	            $data['emergency'] = ''; // emergency
396 528
 		    $data['datetime'] = date('Y-m-d H:i:s');
397 529
 		    $data['format_source'] = 'deltadbtxt';
398 530
     		    $data['id_source'] = $id_source;
399
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
400
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
401
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
531
+		    if (isset($value['name']) && $value['name'] != '') {
532
+		    	$data['source_name'] = $value['name'];
533
+		    }
534
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
535
+		    	$data['noarchive'] = true;
536
+		    }
537
+		    if (isset($value['sourcestats'])) {
538
+		    	$data['sourcestats'] = $value['sourcestats'];
539
+		    }
402 540
     		    $SI->add($data);
403 541
 		    unset($data);
404 542
     		}
@@ -408,7 +546,9 @@  discard block
 block discarded – undo
408 546
 	    date_default_timezone_set('CET');
409 547
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
410 548
 	    date_default_timezone_set('UTC');
411
-	    if ($buffer != '') $reset = 0;
549
+	    if ($buffer != '') {
550
+	    	$reset = 0;
551
+	    }
412 552
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413 553
 	    $buffer = explode('\n',$buffer);
414 554
 	    foreach ($buffer as $line) {
@@ -417,16 +557,36 @@  discard block
 block discarded – undo
417 557
 		    $add = false;
418 558
 		    $ais_data = $AIS->parse_line(trim($line));
419 559
 		    $data = array();
420
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
421
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
422
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
423
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
424
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
425
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
426
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
427
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
428
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
560
+		    if (isset($ais_data['ident'])) {
561
+		    	$data['ident'] = $ais_data['ident'];
562
+		    }
563
+		    if (isset($ais_data['mmsi'])) {
564
+		    	$data['mmsi'] = $ais_data['mmsi'];
565
+		    }
566
+		    if (isset($ais_data['speed'])) {
567
+		    	$data['speed'] = $ais_data['speed'];
568
+		    }
569
+		    if (isset($ais_data['heading'])) {
570
+		    	$data['heading'] = $ais_data['heading'];
571
+		    }
572
+		    if (isset($ais_data['latitude'])) {
573
+		    	$data['latitude'] = $ais_data['latitude'];
574
+		    }
575
+		    if (isset($ais_data['longitude'])) {
576
+		    	$data['longitude'] = $ais_data['longitude'];
577
+		    }
578
+		    if (isset($ais_data['status'])) {
579
+		    	$data['status'] = $ais_data['status'];
580
+		    }
581
+		    if (isset($ais_data['type'])) {
582
+		    	$data['type'] = $ais_data['type'];
583
+		    }
584
+		    if (isset($ais_data['imo'])) {
585
+		    	$data['imo'] = $ais_data['imo'];
586
+		    }
587
+		    if (isset($ais_data['callsign'])) {
588
+		    	$data['callsign'] = $ais_data['callsign'];
589
+		    }
430 590
 		    if (isset($ais_data['timestamp'])) {
431 591
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
432 592
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -440,8 +600,12 @@  discard block
 block discarded – undo
440 600
 		    $data['format_source'] = 'aisnmeatxt';
441 601
     		    $data['id_source'] = $id_source;
442 602
 		    //print_r($data);
443
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
444
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
603
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
604
+		    	$data['noarchive'] = true;
605
+		    }
606
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
607
+		    	$MI->add($data);
608
+		    }
445 609
 		    unset($data);
446 610
 		}
447 611
     	    }
@@ -461,20 +625,48 @@  discard block
 block discarded – undo
461 625
 			    if ($line != '') {
462 626
 				$ais_data = $AIS->parse_line(trim($line));
463 627
 				$data = array();
464
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
465
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
466
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
467
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
468
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
469
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
470
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
471
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
472
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
473
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
474
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
475
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
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']);
628
+				if (isset($ais_data['ident'])) {
629
+					$data['ident'] = $ais_data['ident'];
630
+				}
631
+				if (isset($ais_data['mmsi'])) {
632
+					$data['mmsi'] = $ais_data['mmsi'];
633
+				}
634
+				if (isset($ais_data['speed'])) {
635
+					$data['speed'] = $ais_data['speed'];
636
+				}
637
+				if (isset($ais_data['heading'])) {
638
+					$data['heading'] = $ais_data['heading'];
639
+				}
640
+				if (isset($ais_data['latitude'])) {
641
+					$data['latitude'] = $ais_data['latitude'];
642
+				}
643
+				if (isset($ais_data['longitude'])) {
644
+					$data['longitude'] = $ais_data['longitude'];
645
+				}
646
+				if (isset($ais_data['status'])) {
647
+					$data['status'] = $ais_data['status'];
648
+				}
649
+				if (isset($ais_data['statusid'])) {
650
+					$data['status_id'] = $ais_data['statusid'];
651
+				}
652
+				if (isset($ais_data['type'])) {
653
+					$data['type'] = $ais_data['type'];
654
+				}
655
+				if (isset($ais_data['typeid'])) {
656
+					$data['type_id'] = $ais_data['typeid'];
657
+				}
658
+				if (isset($ais_data['imo'])) {
659
+					$data['imo'] = $ais_data['imo'];
660
+				}
661
+				if (isset($ais_data['callsign'])) {
662
+					$data['callsign'] = $ais_data['callsign'];
663
+				}
664
+				if (isset($ais_data['destination'])) {
665
+					$data['arrival_code'] = $ais_data['destination'];
666
+				}
667
+				if (isset($ais_data['eta_ts'])) {
668
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
669
+				}
478 670
 				if (isset($ais_data['timestamp'])) {
479 671
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
480 672
 				} else {
@@ -482,18 +674,27 @@  discard block
 block discarded – undo
482 674
 				}
483 675
 				$data['format_source'] = 'aisnmeahttp';
484 676
 				$data['id_source'] = $id_source;
485
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
486
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
677
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
678
+					$data['noarchive'] = true;
679
+				}
680
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
681
+					$MI->add($data);
682
+				}
487 683
 				unset($data);
488 684
 			    }
489 685
 			}
490 686
 		    }
491 687
 		} else {
492 688
 		    $format = $value['format'];
493
-		    if (isset($tt[$format])) $tt[$format]++;
494
-		    else $tt[$format] = 0;
689
+		    if (isset($tt[$format])) {
690
+		    	$tt[$format]++;
691
+		    } else {
692
+		    	$tt[$format] = 0;
693
+		    }
495 694
 		    if ($tt[$format] > 30) {
496
-			if ($globalDebug) echo 'Reconnect...'."\n";
695
+			if ($globalDebug) {
696
+				echo 'Reconnect...'."\n";
697
+			}
497 698
 			sleep(2);
498 699
 			$sourceeen[] = $value;
499 700
 			connect_all($sourceeen);
@@ -523,7 +724,9 @@  discard block
 block discarded – undo
523 724
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
524 725
 			    $data['format_source'] = 'myshiptracking';
525 726
 			    $data['id_source'] = $id_source;
526
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
727
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
728
+			    	$data['noarchive'] = true;
729
+			    }
527 730
 			    $MI->add($data);
528 731
 			    unset($data);
529 732
 			}
@@ -543,7 +746,9 @@  discard block
 block discarded – undo
543 746
 			    $data['callsign'] = $line['callsign'];
544 747
 			    $data['mmsi'] = $line['mmsi'];
545 748
 			    $data['speed'] = $line['sog'];
546
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
749
+			    if ($line['heading'] != '511') {
750
+			    	$data['heading'] = $line['heading'];
751
+			    }
547 752
 			    $data['latitude'] = $line['latitude'];
548 753
 			    $data['longitude'] = $line['longitude'];
549 754
 			    $data['type_id'] = $line['shiptype'];
@@ -551,7 +756,9 @@  discard block
 block discarded – undo
551 756
 			    $data['datetime'] = $line['time'];
552 757
 			    $data['format_source'] = 'boatbeaconapp';
553 758
 			    $data['id_source'] = $id_source;
554
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
759
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
760
+			    	$data['noarchive'] = true;
761
+			    }
555 762
 			    $MI->add($data);
556 763
 			    unset($data);
557 764
 			}
@@ -567,22 +774,44 @@  discard block
 block discarded – undo
567 774
 		if (isset($all_data['features'][0]['id'])) {
568 775
 		    foreach ($all_data['features'] as $line) {
569 776
 			$data = array();
570
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
571
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
572
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi'];
573
-			if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo'];
574
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
575
-			if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading'];
777
+			if (isset($line['properties']['name'])) {
778
+				$data['ident'] = $line['properties']['name'];
779
+			}
780
+			if (isset($line['properties']['callsign'])) {
781
+				$data['callsign'] = $line['properties']['callsign'];
782
+			}
783
+			if (isset($line['properties']['mmsi'])) {
784
+				$data['mmsi'] = $line['properties']['mmsi'];
785
+			}
786
+			if (isset($line['properties']['imo'])) {
787
+				$data['mmsi'] = $line['properties']['imo'];
788
+			}
789
+			if (isset($line['properties']['speed'])) {
790
+				$data['speed'] = $line['properties']['speed'];
791
+			}
792
+			if (isset($line['properties']['heading'])) {
793
+				$data['heading'] = $line['properties']['heading'];
794
+			}
576 795
 			$data['latitude'] = $line['geometry']['coordinates'][1];
577 796
 			$data['longitude'] = $line['geometry']['coordinates'][0];
578
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
579
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
580
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
797
+			if (isset($line['properties']['vesselType'])) {
798
+				$data['type'] = $line['properties']['vesselType'];
799
+			}
800
+			if (isset($line['properties']['destination'])) {
801
+				$data['arrival_code'] = $line['properties']['destination'];
802
+			}
803
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
804
+				$data['arrival_date'] = $line['properties']['eta'];
805
+			}
581 806
 			$data['format_source'] = 'boatnerd';
582 807
 			$data['id_source'] = $id_source;
583 808
 			$data['datetime'] = date('Y-m-d H:i:s');
584
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
585
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
809
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
810
+				$data['noarchive'] = true;
811
+			}
812
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
813
+				$MI->add($data);
814
+			}
586 815
 			unset($data);
587 816
 		    }
588 817
 		}
@@ -593,7 +822,9 @@  discard block
 block discarded – undo
593 822
 	    echo 'download...';
594 823
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
595 824
 	    echo 'done !'."\n";
596
-	    if ($buffer != '') $reset = 0;
825
+	    if ($buffer != '') {
826
+	    	$reset = 0;
827
+	    }
597 828
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598 829
 	    $buffer = explode('\n',$buffer);
599 830
 	    foreach ($buffer as $line) {
@@ -618,7 +849,9 @@  discard block
 block discarded – undo
618 849
 		    //$data['etaTime'] = substr($line,135,5);
619 850
 		    $data['format_source'] = 'shipplotter';
620 851
     		    $data['id_source'] = $id_source;
621
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
852
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
853
+		    	$data['noarchive'] = true;
854
+		    }
622 855
 		    //print_r($data);
623 856
 		    echo 'Add...'."\n";
624 857
 		    $MI->add($data);
@@ -638,16 +871,28 @@  discard block
 block discarded – undo
638 871
     		    $line = explode(':', $line);
639 872
     		    if (count($line) > 30 && $line[0] != 'callsign') {
640 873
 			$data = array();
641
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
642
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
874
+			if (isset($line[37]) && $line[37] != '') {
875
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
876
+			} else {
877
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
878
+			}
643 879
 			$data['pilot_id'] = $line[1];
644 880
 			$data['pilot_name'] = $line[2];
645 881
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
646 882
 			$data['ident'] = $line[0]; // ident
647
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
883
+			if ($line[7] != '' && $line[7] != 0) {
884
+				$data['altitude'] = $line[7];
885
+			}
886
+			// altitude
648 887
 			$data['speed'] = $line[8]; // speed
649
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
650
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
888
+			if (isset($line[45])) {
889
+				$data['heading'] = $line[45];
890
+			}
891
+			// heading
892
+			elseif (isset($line[38])) {
893
+				$data['heading'] = $line[38];
894
+			}
895
+			// heading
651 896
 			$data['latitude'] = $line[5]; // lat
652 897
 	        	$data['longitude'] = $line[6]; // long
653 898
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -663,7 +908,9 @@  discard block
 block discarded – undo
663 908
 			$data['frequency'] = $line[4];
664 909
 			$data['type'] = $line[18];
665 910
 			$data['range'] = $line[19];
666
-			if (isset($line[35])) $data['info'] = $line[35];
911
+			if (isset($line[35])) {
912
+				$data['info'] = $line[35];
913
+			}
667 914
     			$data['id_source'] = $id_source;
668 915
 	    		//$data['arrival_airport_time'] = ;
669 916
 	    		if ($line[9] != '') {
@@ -677,27 +924,47 @@  discard block
 block discarded – undo
677 924
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
678 925
 	    		*/
679 926
 	    		$data['format_source'] = $value['format'];
680
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
681
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
682
-    			if ($line[3] == 'PILOT') $SI->add($data);
683
-			elseif ($line[3] == 'ATC') {
927
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
928
+				$data['noarchive'] = true;
929
+			}
930
+			if (isset($value['name']) && $value['name'] != '') {
931
+				$data['source_name'] = $value['name'];
932
+			}
933
+    			if ($line[3] == 'PILOT') {
934
+    				$SI->add($data);
935
+    			} elseif ($line[3] == 'ATC') {
684 936
 				//print_r($data);
685 937
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
686 938
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
687 939
 				$typec = substr($data['ident'],-3);
688
-				if ($typec == 'APP') $data['type'] = 'Approach';
689
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
690
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
691
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
692
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
693
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
694
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
695
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
696
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
697
-				if (!isset($data['source_name'])) $data['source_name'] = '';
940
+				if ($typec == 'APP') {
941
+					$data['type'] = 'Approach';
942
+				} elseif ($typec == 'TWR') {
943
+					$data['type'] = 'Tower';
944
+				} elseif ($typec == 'OBS') {
945
+					$data['type'] = 'Observer';
946
+				} elseif ($typec == 'GND') {
947
+					$data['type'] = 'Ground';
948
+				} elseif ($typec == 'DEL') {
949
+					$data['type'] = 'Delivery';
950
+				} elseif ($typec == 'DEP') {
951
+					$data['type'] = 'Departure';
952
+				} elseif ($typec == 'FSS') {
953
+					$data['type'] = 'Flight Service Station';
954
+				} elseif ($typec == 'CTR') {
955
+					$data['type'] = 'Control Radar or Centre';
956
+				} elseif ($data['type'] == '') {
957
+					$data['type'] = 'Observer';
958
+				}
959
+				if (!isset($data['source_name'])) {
960
+					$data['source_name'] = '';
961
+				}
698 962
 				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']);
963
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
964
+						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']);
965
+					} else {
966
+						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']);
967
+					}
701 968
 				}
702 969
 			}
703 970
     			unset($data);
@@ -719,14 +986,20 @@  discard block
 block discarded – undo
719 986
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
720 987
 			$data['latitude'] = (float)$line['pktLatitude'];
721 988
 			$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'];
989
+			if ((float)$line['pktTrack'] != 0) {
990
+				$data['heading'] = (float)$line['pktTrack'];
991
+			}
992
+			if ((int)$line['pktSpeed'] != 0) {
993
+				$data['speed'] = (int)$line['pktSpeed'];
994
+			}
724 995
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
725 996
 			$data['altitude_relative'] = 'AMSL';
726 997
 			$data['pilot_id'] = (int)$line['pktPilotID'];
727 998
 			$data['aircraft_icao'] = 'PARAGLIDER';
728 999
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
729
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1000
+			if (isset($pilot_data[4])) {
1001
+				$data['pilot_name'] = $pilot_data[4];
1002
+			}
730 1003
 			$data['format_source'] = $value['format'];
731 1004
 			$SI->add($data);
732 1005
 			unset($data);
@@ -763,27 +1036,61 @@  discard block
 block discarded – undo
763 1036
 		foreach ($all_data['acList'] as $line) {
764 1037
 		    $data = array();
765 1038
 		    $data['hex'] = $line['Icao']; // hex
766
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
767
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
768
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
769
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
770
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
771
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1039
+		    if (isset($line['Call'])) {
1040
+		    	$data['ident'] = $line['Call'];
1041
+		    }
1042
+		    // ident
1043
+		    if (isset($line['Alt'])) {
1044
+		    	$data['altitude'] = $line['Alt'];
1045
+		    }
1046
+		    // altitude
1047
+		    if (isset($line['Spd'])) {
1048
+		    	$data['speed'] = $line['Spd'];
1049
+		    }
1050
+		    // speed
1051
+		    if (isset($line['Trak'])) {
1052
+		    	$data['heading'] = $line['Trak'];
1053
+		    }
1054
+		    // heading
1055
+		    if (isset($line['Lat'])) {
1056
+		    	$data['latitude'] = $line['Lat'];
1057
+		    }
1058
+		    // lat
1059
+		    if (isset($line['Long'])) {
1060
+		    	$data['longitude'] = $line['Long'];
1061
+		    }
1062
+		    // long
772 1063
 		    //$data['verticalrate'] = $line['']; // verticale rate
773
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1064
+		    if (isset($line['Sqk'])) {
1065
+		    	$data['squawk'] = $line['Sqk'];
1066
+		    }
1067
+		    // squawk
774 1068
 		    $data['emergency'] = ''; // emergency
775
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1069
+		    if (isset($line['Reg'])) {
1070
+		    	$data['registration'] = $line['Reg'];
1071
+		    }
776 1072
 		    
777
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
778
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1073
+		    if (isset($line['PosTime'])) {
1074
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1075
+		    } else {
1076
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1077
+		    }
779 1078
 		    
780 1079
 		    //$data['datetime'] = date('Y-m-d H:i:s');
781
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1080
+		    if (isset($line['Type'])) {
1081
+		    	$data['aircraft_icao'] = $line['Type'];
1082
+		    }
782 1083
 	    	    $data['format_source'] = 'aircraftlistjson';
783 1084
 		    $data['id_source'] = $id_source;
784
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
785
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
786
-		    if (isset($data['latitude'])) $SI->add($data);
1085
+		    if (isset($value['name']) && $value['name'] != '') {
1086
+		    	$data['source_name'] = $value['name'];
1087
+		    }
1088
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1089
+		    	$data['noarchive'] = true;
1090
+		    }
1091
+		    if (isset($data['latitude'])) {
1092
+		    	$SI->add($data);
1093
+		    }
787 1094
 		    unset($data);
788 1095
 		}
789 1096
 	    } elseif (is_array($all_data)) {
@@ -800,12 +1107,19 @@  discard block
 block discarded – undo
800 1107
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
801 1108
 		    $data['squawk'] = $line['squawk']; // squawk
802 1109
 		    $data['emergency'] = ''; // emergency
803
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
804
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1110
+		    if (isset($line['PosTime'])) {
1111
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1112
+		    } else {
1113
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1114
+		    }
805 1115
 	    	    $data['format_source'] = 'aircraftlistjson';
806 1116
     		    $data['id_source'] = $id_source;
807
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
808
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1117
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1118
+		    	$data['noarchive'] = true;
1119
+		    }
1120
+		    if (isset($value['name']) && $value['name'] != '') {
1121
+		    	$data['source_name'] = $value['name'];
1122
+		    }
809 1123
 		    $SI->add($data);
810 1124
 		    unset($data);
811 1125
 		}
@@ -841,8 +1155,12 @@  discard block
 block discarded – undo
841 1155
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
842 1156
 	    	    $data['format_source'] = 'planeupdatefaa';
843 1157
     		    $data['id_source'] = $id_source;
844
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
845
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1158
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1159
+		    	$data['noarchive'] = true;
1160
+		    }
1161
+		    if (isset($value['name']) && $value['name'] != '') {
1162
+		    	$data['source_name'] = $value['name'];
1163
+		    }
846 1164
 		    $SI->add($data);
847 1165
 		    unset($data);
848 1166
 		}
@@ -871,7 +1189,9 @@  discard block
 block discarded – undo
871 1189
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
872 1190
 	    	    $data['format_source'] = 'opensky';
873 1191
     		    $data['id_source'] = $id_source;
874
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1192
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1193
+		    	$data['noarchive'] = true;
1194
+		    }
875 1195
 		    $SI->add($data);
876 1196
 		    unset($data);
877 1197
 		}
@@ -883,7 +1203,9 @@  discard block
 block discarded – undo
883 1203
 	    //$buffer = $Common->getData($hosts[$id]);
884 1204
 	    $buffer = $Common->getData($value['host']);
885 1205
 	    $all_data = json_decode($buffer,true);
886
-	    if (!empty($all_data)) $reset = 0;
1206
+	    if (!empty($all_data)) {
1207
+	    	$reset = 0;
1208
+	    }
887 1209
 	    foreach ($all_data as $key => $line) {
888 1210
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
889 1211
 		    $data = array();
@@ -904,8 +1226,12 @@  discard block
 block discarded – undo
904 1226
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
905 1227
 	    	    $data['format_source'] = 'fr24json';
906 1228
     		    $data['id_source'] = $id_source;
907
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1229
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1230
+		    	$data['noarchive'] = true;
1231
+		    }
1232
+		    if (isset($value['name']) && $value['name'] != '') {
1233
+		    	$data['source_name'] = $value['name'];
1234
+		    }
909 1235
 		    $SI->add($data);
910 1236
 		    unset($data);
911 1237
 		}
@@ -929,24 +1255,42 @@  discard block
 block discarded – undo
929 1255
 		    if (isset($line['inf'])) {
930 1256
 			$data = array();
931 1257
 			$data['hex'] = $line['inf']['ia'];
932
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1258
+			if (isset($line['inf']['cs'])) {
1259
+				$data['ident'] = $line['inf']['cs'];
1260
+			}
1261
+			//$line[13]
933 1262
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
934
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
935
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1263
+	    		if (isset($line['inf']['gs'])) {
1264
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1265
+	    		}
1266
+	    		// speed
1267
+	    		if (isset($line['inf']['tr'])) {
1268
+	    			$data['heading'] = $line['inf']['tr'];
1269
+	    		}
1270
+	    		// heading
936 1271
 	    		$data['latitude'] = $line['pt'][0]; // lat
937 1272
 	    		$data['longitude'] = $line['pt'][1]; // long
938 1273
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
939
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1274
+	    		if (isset($line['inf']['sq'])) {
1275
+	    			$data['squawk'] = $line['inf']['sq'];
1276
+	    		}
1277
+	    		// squawk
940 1278
 	    		//$data['aircraft_icao'] = $line[8];
941
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1279
+	    		if (isset($line['inf']['rc'])) {
1280
+	    			$data['registration'] = $line['inf']['rc'];
1281
+	    		}
942 1282
 			//$data['departure_airport_iata'] = $line[11];
943 1283
 			//$data['arrival_airport_iata'] = $line[12];
944 1284
 	    		//$data['emergency'] = ''; // emergency
945 1285
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
946 1286
 	    		$data['format_source'] = 'radarvirtueljson';
947 1287
     			$data['id_source'] = $id_source;
948
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
949
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1288
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1289
+				$data['noarchive'] = true;
1290
+			}
1291
+			if (isset($value['name']) && $value['name'] != '') {
1292
+				$data['source_name'] = $value['name'];
1293
+			}
950 1294
 			$SI->add($data);
951 1295
 			unset($data);
952 1296
 		    }
@@ -967,30 +1311,65 @@  discard block
 block discarded – undo
967 1311
 		    $data['id'] = $line['id'];
968 1312
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
969 1313
 		    $data['ident'] = $line['callsign']; // ident
970
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
971
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
972
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
973
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
974
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
975
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1314
+		    if (isset($line['pilotid'])) {
1315
+		    	$data['pilot_id'] = $line['pilotid'];
1316
+		    }
1317
+		    // pilot id
1318
+		    if (isset($line['name'])) {
1319
+		    	$data['pilot_name'] = $line['name'];
1320
+		    }
1321
+		    // pilot name
1322
+		    if (isset($line['alt'])) {
1323
+		    	$data['altitude'] = $line['alt'];
1324
+		    }
1325
+		    // altitude
1326
+		    if (isset($line['gs'])) {
1327
+		    	$data['speed'] = $line['gs'];
1328
+		    }
1329
+		    // speed
1330
+		    if (isset($line['heading'])) {
1331
+		    	$data['heading'] = $line['heading'];
1332
+		    }
1333
+		    // heading
1334
+		    if (isset($line['route'])) {
1335
+		    	$data['waypoints'] = $line['route'];
1336
+		    }
1337
+		    // route
976 1338
 		    $data['latitude'] = $line['lat']; // lat
977 1339
 		    $data['longitude'] = $line['lon']; // long
978 1340
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
979 1341
 		    //$data['squawk'] = $line['squawk']; // squawk
980 1342
 		    //$data['emergency'] = ''; // emergency
981
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
982
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
983
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1343
+		    if (isset($line['depicao'])) {
1344
+		    	$data['departure_airport_icao'] = $line['depicao'];
1345
+		    }
1346
+		    if (isset($line['deptime'])) {
1347
+		    	$data['departure_airport_time'] = $line['deptime'];
1348
+		    }
1349
+		    if (isset($line['arricao'])) {
1350
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1351
+		    }
984 1352
 		    //$data['arrival_airport_time'] = $line['arrtime'];
985
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
986
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
987
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
988
-		    else $data['info'] = '';
1353
+		    if (isset($line['aircraft'])) {
1354
+		    	$data['aircraft_icao'] = $line['aircraft'];
1355
+		    }
1356
+		    if (isset($line['transponder'])) {
1357
+		    	$data['squawk'] = $line['transponder'];
1358
+		    }
1359
+		    if (isset($line['atis'])) {
1360
+		    	$data['info'] = $line['atis'];
1361
+		    } else {
1362
+		    	$data['info'] = '';
1363
+		    }
989 1364
 		    $data['format_source'] = 'pireps';
990 1365
     		    $data['id_source'] = $id_source;
991 1366
 		    $data['datetime'] = date('Y-m-d H:i:s');
992
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
993
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1367
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1368
+		    	$data['noarchive'] = true;
1369
+		    }
1370
+		    if (isset($value['name']) && $value['name'] != '') {
1371
+		    	$data['source_name'] = $value['name'];
1372
+		    }
994 1373
 		    if ($line['icon'] == 'plane') {
995 1374
 			$SI->add($data);
996 1375
 		    //    print_r($data);
@@ -999,16 +1378,28 @@  discard block
 block discarded – undo
999 1378
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1000 1379
 			$typec = substr($data['ident'],-3);
1001 1380
 			$data['type'] = '';
1002
-			if ($typec == 'APP') $data['type'] = 'Approach';
1003
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
1004
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
1005
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
1006
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
1007
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
1008
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1009
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
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']);
1381
+			if ($typec == 'APP') {
1382
+				$data['type'] = 'Approach';
1383
+			} elseif ($typec == 'TWR') {
1384
+				$data['type'] = 'Tower';
1385
+			} elseif ($typec == 'OBS') {
1386
+				$data['type'] = 'Observer';
1387
+			} elseif ($typec == 'GND') {
1388
+				$data['type'] = 'Ground';
1389
+			} elseif ($typec == 'DEL') {
1390
+				$data['type'] = 'Delivery';
1391
+			} elseif ($typec == 'DEP') {
1392
+				$data['type'] = 'Departure';
1393
+			} elseif ($typec == 'FSS') {
1394
+				$data['type'] = 'Flight Service Station';
1395
+			} elseif ($typec == 'CTR') {
1396
+				$data['type'] = 'Control Radar or Centre';
1397
+			} else {
1398
+				$data['type'] = 'Observer';
1399
+			}
1400
+			if (isset($ATC)) {
1401
+				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']);
1402
+			}
1012 1403
 		    }
1013 1404
 		    unset($data);
1014 1405
 		}
@@ -1018,7 +1409,9 @@  discard block
 block discarded – undo
1018 1409
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1019 1410
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1020 1411
 	    //$buffer = $Common->getData($hosts[$id]);
1021
-	    if ($globalDebug) echo 'Get Data...'."\n";
1412
+	    if ($globalDebug) {
1413
+	    	echo 'Get Data...'."\n";
1414
+	    }
1022 1415
 	    $buffer = $Common->getData($value['host']);
1023 1416
 	    $all_data = json_decode($buffer,true);
1024 1417
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1026,10 +1419,16 @@  discard block
 block discarded – undo
1026 1419
 		foreach ($all_data as $line) {
1027 1420
 	    	    $data = array();
1028 1421
 	    	    //$data['id'] = $line['id']; // id not usable
1029
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1422
+	    	    if (isset($line['pilotid'])) {
1423
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1424
+	    	    }
1030 1425
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1031
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1032
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1426
+	    	    if (isset($line['pilotname'])) {
1427
+	    	    	$data['pilot_name'] = $line['pilotname'];
1428
+	    	    }
1429
+	    	    if (isset($line['pilotid'])) {
1430
+	    	    	$data['pilot_id'] = $line['pilotid'];
1431
+	    	    }
1033 1432
 	    	    $data['ident'] = $line['flightnum']; // ident
1034 1433
 	    	    $data['altitude'] = $line['alt']; // altitude
1035 1434
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1045,34 +1444,52 @@  discard block
 block discarded – undo
1045 1444
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1046 1445
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1047 1446
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1048
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1447
+	    	    } else {
1448
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1449
+	    	    }
1049 1450
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1050 1451
 	    	    $data['departure_airport_time'] = $line['deptime'];
1051 1452
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
1052 1453
     		    $data['arrival_airport_time'] = $line['arrtime'];
1053 1454
     		    $data['registration'] = $line['aircraft'];
1054
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1055
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1455
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1456
+		    	$data['noarchive'] = true;
1457
+		    }
1458
+		    if (isset($line['route'])) {
1459
+		    	$data['waypoints'] = $line['route'];
1460
+		    }
1461
+		    // route
1056 1462
 		    if (isset($line['aircraftname'])) {
1057 1463
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1058 1464
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1059 1465
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1060
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1061
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1062
-	    		else {
1466
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1467
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1468
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1469
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1470
+	    		} else {
1063 1471
 	    		    $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']);
1472
+	    		    if (isset($aircraft_data[1])) {
1473
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1474
+	    		    } else {
1475
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1476
+	    		    }
1066 1477
 	    		}
1067 1478
 	    	    }
1068
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1479
+    		    if (isset($line['route'])) {
1480
+    		    	$data['waypoints'] = $line['route'];
1481
+    		    }
1069 1482
     		    $data['id_source'] = $id_source;
1070 1483
 	    	    $data['format_source'] = 'phpvmacars';
1071
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1484
+		    if (isset($value['name']) && $value['name'] != '') {
1485
+		    	$data['source_name'] = $value['name'];
1486
+		    }
1072 1487
 		    $SI->add($data);
1073 1488
 		    unset($data);
1074 1489
 		}
1075
-		if ($globalDebug) echo 'No more data...'."\n";
1490
+		if ($globalDebug) {
1491
+			echo 'No more data...'."\n";
1492
+		}
1076 1493
 		unset($buffer);
1077 1494
 		unset($all_data);
1078 1495
 	    }
@@ -1080,7 +1497,9 @@  discard block
 block discarded – undo
1080 1497
     	    $last_exec[$id]['last'] = time();
1081 1498
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1082 1499
 	    //$buffer = $Common->getData($hosts[$id]);
1083
-	    if ($globalDebug) echo 'Get Data...'."\n";
1500
+	    if ($globalDebug) {
1501
+	    	echo 'Get Data...'."\n";
1502
+	    }
1084 1503
 	    $buffer = $Common->getData($value['host']);
1085 1504
 	    $all_data = json_decode($buffer,true);
1086 1505
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1109,16 +1528,25 @@  discard block
 block discarded – undo
1109 1528
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1110 1529
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1111 1530
     		    //$data['registration'] = $line['aircraft'];
1112
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1531
+		    if (isset($line['route'])) {
1532
+		    	$data['waypoints'] = $line['route'];
1533
+		    }
1534
+		    // route
1113 1535
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1114 1536
     		    $data['id_source'] = $id_source;
1115 1537
 	    	    $data['format_source'] = 'vam';
1116
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1117
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1538
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1539
+		    	$data['noarchive'] = true;
1540
+		    }
1541
+		    if (isset($value['name']) && $value['name'] != '') {
1542
+		    	$data['source_name'] = $value['name'];
1543
+		    }
1118 1544
 		    $SI->add($data);
1119 1545
 		    unset($data);
1120 1546
 		}
1121
-		if ($globalDebug) echo 'No more data...'."\n";
1547
+		if ($globalDebug) {
1548
+			echo 'No more data...'."\n";
1549
+		}
1122 1550
 		unset($buffer);
1123 1551
 		unset($all_data);
1124 1552
 	    }
@@ -1126,7 +1554,9 @@  discard block
 block discarded – undo
1126 1554
     	    $last_exec[$id]['last'] = time();
1127 1555
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1128 1556
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1129
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1557
+	    if (function_exists('pcntl_fork')) {
1558
+	    	pcntl_signal_dispatch();
1559
+	    }
1130 1560
     	    //$last_exec[$id]['last'] = time();
1131 1561
 
1132 1562
 	    //$read = array( $sockets[$id] );
@@ -1134,7 +1564,9 @@  discard block
 block discarded – undo
1134 1564
 	    $write = NULL;
1135 1565
 	    $e = NULL;
1136 1566
 	    $n = socket_select($read, $write, $e, $timeout);
1137
-	    if ($e != NULL) var_dump($e);
1567
+	    if ($e != NULL) {
1568
+	    	var_dump($e);
1569
+	    }
1138 1570
 	    if ($n > 0) {
1139 1571
 		$reset = 0;
1140 1572
 		foreach ($read as $nb => $r) {
@@ -1155,12 +1587,16 @@  discard block
 block discarded – undo
1155 1587
 		    //$SI::del();
1156 1588
 		    if ($format == 'vrstcp') {
1157 1589
 			$buffer = explode('},{',$buffer);
1158
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1590
+		    } else {
1591
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1592
+		    }
1159 1593
 		    // SBS format is CSV format
1160 1594
 		    if ($buffer !== FALSE && $buffer != '') {
1161 1595
 			$tt[$format] = 0;
1162 1596
 			if ($format == 'acarssbs3') {
1163
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1597
+			    if ($globalDebug) {
1598
+			    	echo 'ACARS : '.$buffer."\n";
1599
+			    }
1164 1600
 			    $ACARS->add(trim($buffer));
1165 1601
 			    $ACARS->deleteLiveAcarsData();
1166 1602
 			} elseif ($format == 'raw') {
@@ -1169,30 +1605,70 @@  discard block
 block discarded – undo
1169 1605
 			    if (is_array($data)) {
1170 1606
 				$data['datetime'] = date('Y-m-d H:i:s');
1171 1607
 				$data['format_source'] = 'raw';
1172
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1173
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1174
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1175
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1608
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1609
+					$data['source_name'] = $globalSources[$nb]['name'];
1610
+				}
1611
+				if (isset($globalSources[$nb]['sourcestats'])) {
1612
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1613
+				}
1614
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1615
+					$data['noarchive'] = true;
1616
+				}
1617
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1618
+					$SI->add($data);
1619
+				}
1176 1620
 			    }
1177 1621
 			} elseif ($format == 'ais') {
1178 1622
 			    $ais_data = $AIS->parse_line(trim($buffer));
1179 1623
 			    $data = array();
1180
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1181
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1182
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1183
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1184
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1185
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1186
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1187
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1188
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1189
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1190
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
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']);
1193
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1195
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1624
+			    if (isset($ais_data['ident'])) {
1625
+			    	$data['ident'] = $ais_data['ident'];
1626
+			    }
1627
+			    if (isset($ais_data['mmsi'])) {
1628
+			    	$data['mmsi'] = $ais_data['mmsi'];
1629
+			    }
1630
+			    if (isset($ais_data['speed'])) {
1631
+			    	$data['speed'] = $ais_data['speed'];
1632
+			    }
1633
+			    if (isset($ais_data['heading'])) {
1634
+			    	$data['heading'] = $ais_data['heading'];
1635
+			    }
1636
+			    if (isset($ais_data['latitude'])) {
1637
+			    	$data['latitude'] = $ais_data['latitude'];
1638
+			    }
1639
+			    if (isset($ais_data['longitude'])) {
1640
+			    	$data['longitude'] = $ais_data['longitude'];
1641
+			    }
1642
+			    if (isset($ais_data['status'])) {
1643
+			    	$data['status'] = $ais_data['status'];
1644
+			    }
1645
+			    if (isset($ais_data['statusid'])) {
1646
+			    	$data['status_id'] = $ais_data['statusid'];
1647
+			    }
1648
+			    if (isset($ais_data['type'])) {
1649
+			    	$data['type'] = $ais_data['type'];
1650
+			    }
1651
+			    if (isset($ais_data['imo'])) {
1652
+			    	$data['imo'] = $ais_data['imo'];
1653
+			    }
1654
+			    if (isset($ais_data['callsign'])) {
1655
+			    	$data['callsign'] = $ais_data['callsign'];
1656
+			    }
1657
+			    if (isset($ais_data['destination'])) {
1658
+			    	$data['arrival_code'] = $ais_data['destination'];
1659
+			    }
1660
+			    if (isset($ais_data['eta_ts'])) {
1661
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1662
+			    }
1663
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1664
+			    	$data['noarchive'] = true;
1665
+			    }
1666
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1667
+			    	$data['source_name'] = $globalSources[$nb]['name'];
1668
+			    }
1669
+			    if (isset($globalSources[$nb]['sourcestats'])) {
1670
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1671
+			    }
1196 1672
 
1197 1673
 			    if (isset($ais_data['timestamp'])) {
1198 1674
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1201,7 +1677,9 @@  discard block
 block discarded – undo
1201 1677
 			    }
1202 1678
 			    $data['format_source'] = 'aisnmea';
1203 1679
     			    $data['id_source'] = $id_source;
1204
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1680
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1681
+			    	$MI->add($data);
1682
+			    }
1205 1683
 			    unset($data);
1206 1684
                         } elseif ($format == 'flightgearsp') {
1207 1685
                     	    //echo $buffer."\n";
@@ -1219,12 +1697,18 @@  discard block
 block discarded – undo
1219 1697
 				$data['speed'] = round($line[5]*1.94384);
1220 1698
 				$data['datetime'] = date('Y-m-d H:i:s');
1221 1699
 				$data['format_source'] = 'flightgearsp';
1222
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1223
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1700
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1701
+					$data['noarchive'] = true;
1702
+				}
1703
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1704
+					$SI->add($data);
1705
+				}
1224 1706
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1225 1707
 			    }
1226 1708
                         } elseif ($format == 'acars') {
1227
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1709
+                    	    if ($globalDebug) {
1710
+                    	    	echo 'ACARS : '.$buffer."\n";
1711
+                    	    }
1228 1712
 			    $ACARS->add(trim($buffer));
1229 1713
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1230 1714
 			    $ACARS->deleteLiveAcarsData();
@@ -1245,8 +1729,12 @@  discard block
 block discarded – undo
1245 1729
 				    $aircraft_type = $line[10];
1246 1730
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1247 1731
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1248
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1249
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1732
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1733
+				    	$data['noarchive'] = true;
1734
+				    }
1735
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1736
+				    	$SI->add($data);
1737
+				    }
1250 1738
 				}
1251 1739
 			    }
1252 1740
 			} elseif ($format == 'beast') {
@@ -1256,28 +1744,62 @@  discard block
 block discarded – undo
1256 1744
 			    foreach($buffer as $all_data) {
1257 1745
 				$line = json_decode('{'.$all_data.'}',true);
1258 1746
 				$data = array();
1259
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1260
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1261
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1262
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1263
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1264
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1265
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1747
+				if (isset($line['Icao'])) {
1748
+					$data['hex'] = $line['Icao'];
1749
+				}
1750
+				// hex
1751
+				if (isset($line['Call'])) {
1752
+					$data['ident'] = $line['Call'];
1753
+				}
1754
+				// ident
1755
+				if (isset($line['Alt'])) {
1756
+					$data['altitude'] = $line['Alt'];
1757
+				}
1758
+				// altitude
1759
+				if (isset($line['Spd'])) {
1760
+					$data['speed'] = $line['Spd'];
1761
+				}
1762
+				// speed
1763
+				if (isset($line['Trak'])) {
1764
+					$data['heading'] = $line['Trak'];
1765
+				}
1766
+				// heading
1767
+				if (isset($line['Lat'])) {
1768
+					$data['latitude'] = $line['Lat'];
1769
+				}
1770
+				// lat
1771
+				if (isset($line['Long'])) {
1772
+					$data['longitude'] = $line['Long'];
1773
+				}
1774
+				// long
1266 1775
 				//$data['verticalrate'] = $line['']; // verticale rate
1267
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1776
+				if (isset($line['Sqk'])) {
1777
+					$data['squawk'] = $line['Sqk'];
1778
+				}
1779
+				// squawk
1268 1780
 				$data['emergency'] = ''; // emergency
1269
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1781
+				if (isset($line['Reg'])) {
1782
+					$data['registration'] = $line['Reg'];
1783
+				}
1270 1784
 				/*
1271 1785
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1272 1786
 				else $data['datetime'] = date('Y-m-d H:i:s');
1273 1787
 				*/
1274 1788
 				$data['datetime'] = date('Y-m-d H:i:s');
1275
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1789
+				if (isset($line['Type'])) {
1790
+					$data['aircraft_icao'] = $line['Type'];
1791
+				}
1276 1792
 		    		$data['format_source'] = 'vrstcp';
1277 1793
 				$data['id_source'] = $id_source;
1278
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1279
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1280
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1794
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1795
+					$data['noarchive'] = true;
1796
+				}
1797
+				if (isset($value['name']) && $value['name'] != '') {
1798
+					$data['source_name'] = $value['name'];
1799
+				}
1800
+				if (isset($data['latitude']) && isset($data['hex'])) {
1801
+					$SI->add($data);
1802
+				}
1281 1803
 				unset($data);
1282 1804
 			    }
1283 1805
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1290,22 +1812,46 @@  discard block
 block discarded – undo
1290 1812
     				$data['hex'] = $lined['hexid'];
1291 1813
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1292 1814
     				$data['datetime'] = date('Y-m-d H:i:s');;
1293
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1294
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1295
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1296
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1297
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1298
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1299
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1815
+    				if (isset($lined['ident'])) {
1816
+    					$data['ident'] = $lined['ident'];
1817
+    				}
1818
+    				if (isset($lined['lat'])) {
1819
+    					$data['latitude'] = $lined['lat'];
1820
+    				}
1821
+    				if (isset($lined['lon'])) {
1822
+    					$data['longitude'] = $lined['lon'];
1823
+    				}
1824
+    				if (isset($lined['speed'])) {
1825
+    					$data['speed'] = $lined['speed'];
1826
+    				}
1827
+    				if (isset($lined['squawk'])) {
1828
+    					$data['squawk'] = $lined['squawk'];
1829
+    				}
1830
+    				if (isset($lined['alt'])) {
1831
+    					$data['altitude'] = $lined['alt'];
1832
+    				}
1833
+    				if (isset($lined['heading'])) {
1834
+    					$data['heading'] = $lined['heading'];
1835
+    				}
1300 1836
     				$data['id_source'] = $id_source;
1301 1837
     				$data['format_source'] = 'tsv';
1302
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1303
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1304
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1305
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1838
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1839
+    					$data['source_name'] = $globalSources[$nb]['name'];
1840
+    				}
1841
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1842
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1843
+    				}
1844
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1845
+					$data['noarchive'] = true;
1846
+				}
1847
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1848
+    					$SI->add($data);
1849
+    				}
1306 1850
     				unset($lined);
1307 1851
     				unset($data);
1308
-    			    } else $error = true;
1852
+    			    } else {
1853
+    			    	$error = true;
1854
+    			    }
1309 1855
 			} elseif ($format == 'aprs' && $use_aprs) {
1310 1856
 			    if ($aprs_connect == 0) {
1311 1857
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1330,60 +1876,118 @@  discard block
 block discarded – undo
1330 1876
 				    $aprs_last_tx = time();
1331 1877
 				    $data = array();
1332 1878
 				    //print_r($line);
1333
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1334
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1335
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1336
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1337
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1338
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1339
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
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']);
1342
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1879
+				    if (isset($line['address'])) {
1880
+				    	$data['hex'] = $line['address'];
1881
+				    }
1882
+				    if (isset($line['mmsi'])) {
1883
+				    	$data['mmsi'] = $line['mmsi'];
1884
+				    }
1885
+				    if (isset($line['imo'])) {
1886
+				    	$data['imo'] = $line['imo'];
1887
+				    }
1888
+				    if (isset($line['squawk'])) {
1889
+				    	$data['squawk'] = $line['squawk'];
1890
+				    }
1891
+				    if (isset($line['arrival_code'])) {
1892
+				    	$data['arrical_code'] = $line['arrival_code'];
1893
+				    }
1894
+				    if (isset($line['arrival_date'])) {
1895
+				    	$data['arrical_date'] = $line['arrival_date'];
1896
+				    }
1897
+				    if (isset($line['type_id'])) {
1898
+				    	$data['type_id'] = $line['typeid'];
1899
+				    }
1900
+				    if (isset($line['status_id'])) {
1901
+				    	$data['status_id'] = $line['statusid'];
1902
+				    }
1903
+				    if (isset($line['timestamp'])) {
1904
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1905
+				    } else {
1906
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1907
+				    }
1343 1908
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1344
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1909
+				    if (isset($line['ident'])) {
1910
+				    	$data['ident'] = $line['ident'];
1911
+				    }
1345 1912
 				    $data['latitude'] = $line['latitude'];
1346 1913
 				    $data['longitude'] = $line['longitude'];
1347 1914
 				    //$data['verticalrate'] = $line[16];
1348
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1915
+				    if (isset($line['speed'])) {
1916
+				    	$data['speed'] = $line['speed'];
1917
+				    }
1349 1918
 				    //else $data['speed'] = 0;
1350
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1351
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1352
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1353
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1919
+				    if (isset($line['altitude'])) {
1920
+				    	$data['altitude'] = $line['altitude'];
1921
+				    }
1922
+				    if (isset($line['comment'])) {
1923
+				    	$data['comment'] = $line['comment'];
1924
+				    }
1925
+				    if (isset($line['symbol'])) {
1926
+				    	$data['type'] = $line['symbol'];
1927
+				    }
1928
+				    if (isset($line['heading'])) {
1929
+				    	$data['heading'] = $line['heading'];
1930
+				    }
1354 1931
 				    //else $data['heading'] = 0;
1355
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1932
+				    if (isset($line['stealth'])) {
1933
+				    	$data['aircraft_type'] = $line['stealth'];
1934
+				    }
1356 1935
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1357
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1358
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1359
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1360
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1936
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
1937
+				    	$data['noarchive'] = true;
1938
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
1939
+				    	$data['noarchive'] = false;
1940
+				    }
1941
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1942
+				    	$data['noarchive'] = true;
1943
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
1944
+				    	$data['noarchive'] = false;
1945
+				    }
1361 1946
     				    $data['id_source'] = $id_source;
1362
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1363
-				    else $data['format_source'] = 'aprs';
1947
+    				    if (isset($line['format_source'])) {
1948
+    				    	$data['format_source'] = $line['format_source'];
1949
+    				    } else {
1950
+				    	$data['format_source'] = 'aprs';
1951
+				    }
1364 1952
 				    $data['source_name'] = $line['source'];
1365
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1366
-				    else $data['source_type'] = 'flarm';
1367
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1953
+				    if (isset($line['source_type'])) {
1954
+				    	$data['source_type'] = $line['source_type'];
1955
+				    } else {
1956
+				    	$data['source_type'] = 'flarm';
1957
+				    }
1958
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1959
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1960
+    				    }
1368 1961
 				    $currentdate = date('Y-m-d H:i:s');
1369 1962
 				    $aprsdate = strtotime($data['datetime']);
1370
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1963
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
1964
+				    	$data['altitude_relative'] = 'AMSL';
1965
+				    }
1371 1966
 				    // Accept data if time <= system time + 20s
1372 1967
 				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1373 1968
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1374 1969
 					$send = $SI->add($data);
1375 1970
 				    } elseif ($data['source_type'] == 'ais') {
1376
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1971
+					if (isset($globalMarine) && $globalMarine) {
1972
+						$send = $MI->add($data);
1973
+					}
1377 1974
 				    } elseif (isset($line['stealth'])) {
1378
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1379
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1975
+					if ($line['stealth'] != 0) {
1976
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1977
+					} else {
1978
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1979
+					}
1380 1980
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1381 1981
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1382 1982
 				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1383 1983
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1384
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1984
+					if (isset($globalTracker) && $globalTracker) {
1985
+						$send = $TI->add($data);
1986
+					}
1385 1987
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1386
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
1988
+					if (!isset($data['altitude'])) {
1989
+						$data['altitude'] = 0;
1990
+					}
1387 1991
 					$Source->deleteOldLocationByType('gs');
1388 1992
 					if (count($Source->getLocationInfoByName($data['ident'])) > 0) {
1389 1993
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1395,12 +1999,9 @@  discard block
 block discarded – undo
1395 1999
 				    	print_r($line);
1396 2000
 				    }
1397 2001
 				    unset($data);
1398
-				} 
1399
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
2002
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1400 2003
 					echo '!! Weather Station not yet supported'."\n";
1401
-				}
1402
-				 
1403
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2004
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1404 2005
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1405 2006
 				}
1406 2007
 				/*
@@ -1409,7 +2010,9 @@  discard block
 block discarded – undo
1409 2010
 				}
1410 2011
 				*/
1411 2012
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1412
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2013
+				elseif ($line == true && $globalDebug) {
2014
+					echo '!! Failed : '.$buffer."!!\n";
2015
+				}
1413 2016
 			    }
1414 2017
 			} else {
1415 2018
 			    $line = explode(',', $buffer);
@@ -1438,26 +2041,45 @@  discard block
 block discarded – undo
1438 2041
     				$data['ground'] = $line[21];
1439 2042
     				$data['emergency'] = $line[19];
1440 2043
     				$data['format_source'] = 'sbs';
1441
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1442
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1443
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2044
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2045
+					$data['source_name'] = $globalSources[$nb]['name'];
2046
+				}
2047
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2048
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2049
+    				}
2050
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2051
+					$data['noarchive'] = true;
2052
+				}
1444 2053
     				$data['id_source'] = $id_source;
1445
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1446
-    				else $error = true;
2054
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2055
+    					$send = $SI->add($data);
2056
+    				} else {
2057
+    					$error = true;
2058
+    				}
1447 2059
     				unset($data);
1448
-    			    } else $error = true;
2060
+    			    } else {
2061
+    			    	$error = true;
2062
+    			    }
1449 2063
 			    if ($error) {
1450 2064
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1451
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2065
+					if ($globalDebug) {
2066
+						echo "Not a message. Ignoring... \n";
2067
+					}
1452 2068
 				} else {
1453
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2069
+					if ($globalDebug) {
2070
+						echo "Wrong line format. Ignoring... \n";
2071
+					}
1454 2072
 					if ($globalDebug) {
1455 2073
 						echo $buffer;
1456 2074
 						//print_r($line);
1457 2075
 					}
1458 2076
 					//socket_close($r);
1459
-					if ($globalDebug) echo "Reconnect after an error...\n";
1460
-					if ($format == 'aprs') $aprs_connect = 0;
2077
+					if ($globalDebug) {
2078
+						echo "Reconnect after an error...\n";
2079
+					}
2080
+					if ($format == 'aprs') {
2081
+						$aprs_connect = 0;
2082
+					}
1461 2083
 					$sourceer[$nb] = $globalSources[$nb];
1462 2084
 					connect_all($sourceer);
1463 2085
 					$sourceer = array();
@@ -1465,10 +2087,14 @@  discard block
 block discarded – undo
1465 2087
 			    }
1466 2088
 			}
1467 2089
 			// Sleep for xxx microseconds
1468
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2090
+			if (isset($globalSBSSleep)) {
2091
+				usleep($globalSBSSleep);
2092
+			}
1469 2093
 		    } else {
1470 2094
 			if ($format == 'flightgearmp') {
1471
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2095
+			    	if ($globalDebug) {
2096
+			    		echo "Reconnect FlightGear MP...";
2097
+			    	}
1472 2098
 				//@socket_close($r);
1473 2099
 				sleep($globalMinFetch);
1474 2100
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1477,10 +2103,15 @@  discard block
 block discarded – undo
1477 2103
 				break;
1478 2104
 				
1479 2105
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1480
-			    if (isset($tt[$format])) $tt[$format]++;
1481
-			    else $tt[$format] = 0;
2106
+			    if (isset($tt[$format])) {
2107
+			    	$tt[$format]++;
2108
+			    } else {
2109
+			    	$tt[$format] = 0;
2110
+			    }
1482 2111
 			    if ($tt[$format] > 30) {
1483
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2112
+				if ($globalDebug) {
2113
+					echo "ERROR : Reconnect ".$format."...";
2114
+				}
1484 2115
 				//@socket_close($r);
1485 2116
 				sleep(2);
1486 2117
 				$aprs_connect = 0;
@@ -1497,11 +2128,17 @@  discard block
 block discarded – undo
1497 2128
 	    } else {
1498 2129
 		$error = socket_strerror(socket_last_error());
1499 2130
 		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";
1501
-			if (isset($globalDebug)) echo "Restarting...\n";
2131
+			if ($globalDebug) {
2132
+				echo "ERROR : socket_select give this error ".$error . "\n";
2133
+			}
2134
+			if (isset($globalDebug)) {
2135
+				echo "Restarting...\n";
2136
+			}
1502 2137
 			// Restart the script if possible
1503 2138
 			if (is_array($sockets)) {
1504
-			    if ($globalDebug) echo "Shutdown all sockets...";
2139
+			    if ($globalDebug) {
2140
+			    	echo "Shutdown all sockets...";
2141
+			    }
1505 2142
 			    
1506 2143
 			    foreach ($sockets as $sock) {
1507 2144
 				@socket_shutdown($sock,2);
@@ -1509,22 +2146,36 @@  discard block
 block discarded – undo
1509 2146
 			    }
1510 2147
 			    
1511 2148
 			}
1512
-			if ($globalDebug) echo "Waiting...";
2149
+			if ($globalDebug) {
2150
+				echo "Waiting...";
2151
+			}
1513 2152
 			sleep(2);
1514 2153
 			$time = time();
1515 2154
 			//connect_all($hosts);
1516 2155
 			$aprs_connect = 0;
1517
-			if ($reset%5 == 0) sleep(20);
1518
-			if ($reset%10 == 0) sleep(100);
1519
-			if ($reset%20 == 0) sleep(200);
1520
-			if ($reset > 100) exit('Too many attempts...');
1521
-			if ($globalDebug) echo "Restart all connections...";
2156
+			if ($reset%5 == 0) {
2157
+				sleep(20);
2158
+			}
2159
+			if ($reset%10 == 0) {
2160
+				sleep(100);
2161
+			}
2162
+			if ($reset%20 == 0) {
2163
+				sleep(200);
2164
+			}
2165
+			if ($reset > 100) {
2166
+				exit('Too many attempts...');
2167
+			}
2168
+			if ($globalDebug) {
2169
+				echo "Restart all connections...";
2170
+			}
1522 2171
 			connect_all($globalSources);
1523 2172
 		}
1524 2173
 	    }
1525 2174
 	}
1526 2175
 	if ($globalDaemon === false) {
1527
-	    if ($globalDebug) echo 'Check all...'."\n";
2176
+	    if ($globalDebug) {
2177
+	    	echo 'Check all...'."\n";
2178
+	    }
1528 2179
 	    $SI->checkAll();
1529 2180
 	}
1530 2181
     }
Please login to merge, or discard this patch.
live-geojson.php 1 patch
Braces   +291 added lines, -114 removed lines patch added patch discarded remove patch
@@ -48,27 +48,52 @@  discard block
 block discarded – undo
48 48
 }
49 49
 header('Content-Type: text/javascript');
50 50
 
51
-if (!isset($globalJsonCompress)) $compress = true;
52
-else $compress = $globalJsonCompress;
51
+if (!isset($globalJsonCompress)) {
52
+	$compress = true;
53
+} else {
54
+	$compress = $globalJsonCompress;
55
+}
53 56
 
54 57
 $from_archive = false;
55 58
 $min = true;
56 59
 $allhistory = false;
57 60
 $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);
61
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
62
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
63
+}
64
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
65
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
66
+}
67
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
68
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
69
+}
70
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
71
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
72
+}
73
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
74
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
75
+}
76
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
77
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
78
+}
79
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
80
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
81
+}
82
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
83
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
84
+}
85
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
86
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
87
+}
88
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
89
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
90
+}
68 91
 
69 92
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
70 93
 	$min = true;
71
-} else $min = false;
94
+} else {
95
+	$min = false;
96
+}
72 97
 
73 98
 if (isset($_GET['ident'])) {
74 99
 	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
@@ -157,21 +182,33 @@  discard block
 block discarded – undo
157 182
 		} else {
158 183
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
159 184
 		}
160
-	} else $flightcnt = count($spotter_array);
161
-	if ($flightcnt == '') $flightcnt = 0;
162
-} else $flightcnt = 0;
185
+	} else {
186
+		$flightcnt = count($spotter_array);
187
+	}
188
+	if ($flightcnt == '') {
189
+		$flightcnt = 0;
190
+	}
191
+	} else {
192
+	$flightcnt = 0;
193
+}
163 194
 
164 195
 $sqltime = round(microtime(true)-$begintime,2);
165 196
 
166
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
167
-else $usenextlatlon = true;
197
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
198
+	$usenextlatlon = false;
199
+} else {
200
+	$usenextlatlon = true;
201
+}
168 202
 $j = 0;
169 203
 $prev_flightaware_id = '';
170 204
 $aircrafts_shadow = array();
171 205
 $output = '{';
172 206
 	$output .= '"type": "FeatureCollection",';
173
-		if ($min) $output .= '"minimal": "true",';
174
-		else $output .= '"minimal": "false",';
207
+		if ($min) {
208
+			$output .= '"minimal": "true",';
209
+		} else {
210
+			$output .= '"minimal": "false",';
211
+		}
175 212
 		//$output .= '"fc": "'.$flightcnt.'",';
176 213
 		$output .= '"sqt": "'.$sqltime.'",';
177 214
 
@@ -215,18 +252,29 @@  discard block
 block discarded – undo
215 252
 						}
216 253
 						$output .= '"properties": {';
217 254
 						if (isset($spotter_item['flightaware_id'])) {
218
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
219
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
255
+							if ($compress) {
256
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
257
+							} else {
258
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
259
+							}
220 260
 						} elseif (isset($spotter_item['famtrackid'])) {
221
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
222
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
261
+							if ($compress) {
262
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
263
+							} else {
264
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
265
+							}
223 266
 						} elseif (isset($spotter_item['fammarine_id'])) {
224
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
225
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
267
+							if ($compress) {
268
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
269
+							} else {
270
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
271
+							}
226 272
 						}
227 273
 							$output .= '"fc": "'.$flightcnt.'",';
228 274
 							$output .= '"sqt": "'.$sqltime.'",';
229
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
275
+							if (isset($begindate)) {
276
+								$output .= '"archive_date": "'.$begindate.'",';
277
+							}
230 278
 
231 279
 /*
232 280
 							if ($min) $output .= '"minimal": "true",';
@@ -234,14 +282,22 @@  discard block
 block discarded – undo
234 282
 */
235 283
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
236 284
 						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']).'",';
285
+							if ($compress) {
286
+								$output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
287
+							} else {
288
+								$output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
289
+							}
239 290
 							//"
240 291
 						} else {
241
-							if ($compress) $output .= '"c": "NA",';
242
-							else $output .= '"callsign": "NA",';
292
+							if ($compress) {
293
+								$output .= '"c": "NA",';
294
+							} else {
295
+								$output .= '"callsign": "NA",';
296
+							}
297
+						}
298
+						if (isset($spotter_item['registration'])) {
299
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
243 300
 						}
244
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
245 301
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
246 302
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
247 303
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -254,16 +310,23 @@  discard block
 block discarded – undo
254 310
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
255 311
 						}
256 312
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
257
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
258
-							else {
313
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
314
+								$spotter_item['aircraft_shadow'] = '';
315
+							} else {
259 316
 								$aircraft_icao = $spotter_item['aircraft_icao'];
260
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
261
-								else {
317
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
318
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
319
+								} else {
262 320
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
263
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
264
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
265
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
266
-									else $spotter_item['aircraft_shadow'] = '';
321
+									if (count($aircraft_info) > 0) {
322
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
323
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
324
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
325
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
326
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
327
+									} else {
328
+										$spotter_item['aircraft_shadow'] = '';
329
+									}
267 330
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
268 331
 								}
269 332
 							}
@@ -271,73 +334,139 @@  discard block
 block discarded – undo
271 334
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
272 335
 							if ($tracker) {
273 336
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
274
-									if ($compress) $output .= '"as": "ambulance.png",';
275
-									else $output .= '"aircraft_shadow": "ambulance.png",';
337
+									if ($compress) {
338
+										$output .= '"as": "ambulance.png",';
339
+									} else {
340
+										$output .= '"aircraft_shadow": "ambulance.png",';
341
+									}
276 342
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
277
-									if ($compress) $output .= '"as": "police.png",';
278
-									else $output .= '"aircraft_shadow": "police.png",';
343
+									if ($compress) {
344
+										$output .= '"as": "police.png",';
345
+									} else {
346
+										$output .= '"aircraft_shadow": "police.png",';
347
+									}
279 348
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
280
-									if ($compress) $output .= '"as": "ship.png",';
281
-									else $output .= '"aircraft_shadow": "ship.png",';
349
+									if ($compress) {
350
+										$output .= '"as": "ship.png",';
351
+									} else {
352
+										$output .= '"aircraft_shadow": "ship.png",';
353
+									}
282 354
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
283
-									if ($compress) $output .= '"as": "ship.png",';
284
-									else $output .= '"aircraft_shadow": "ship.png",';
355
+									if ($compress) {
356
+										$output .= '"as": "ship.png",';
357
+									} else {
358
+										$output .= '"aircraft_shadow": "ship.png",';
359
+									}
285 360
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
286
-									if ($compress) $output .= '"as": "ship.png",';
287
-									else $output .= '"aircraft_shadow": "ship.png",';
361
+									if ($compress) {
362
+										$output .= '"as": "ship.png",';
363
+									} else {
364
+										$output .= '"aircraft_shadow": "ship.png",';
365
+									}
288 366
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
289
-									if ($compress) $output .= '"as": "truck.png",';
290
-									else $output .= '"aircraft_shadow": "truck.png",';
367
+									if ($compress) {
368
+										$output .= '"as": "truck.png",';
369
+									} else {
370
+										$output .= '"aircraft_shadow": "truck.png",';
371
+									}
291 372
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
292
-									if ($compress) $output .= '"as": "truck.png",';
293
-									else $output .= '"aircraft_shadow": "truck.png",';
373
+									if ($compress) {
374
+										$output .= '"as": "truck.png",';
375
+									} else {
376
+										$output .= '"aircraft_shadow": "truck.png",';
377
+									}
294 378
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
295
-									if ($compress) $output .= '"as": "aircraft.png",';
296
-									else $output .= '"aircraft_shadow": "aircraft.png",';
379
+									if ($compress) {
380
+										$output .= '"as": "aircraft.png",';
381
+									} else {
382
+										$output .= '"aircraft_shadow": "aircraft.png",';
383
+									}
297 384
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
298
-									if ($compress) $output .= '"as": "aircraft.png",';
299
-									else $output .= '"aircraft_shadow": "aircraft.png",';
385
+									if ($compress) {
386
+										$output .= '"as": "aircraft.png",';
387
+									} else {
388
+										$output .= '"aircraft_shadow": "aircraft.png",';
389
+									}
300 390
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
301
-									if ($compress) $output .= '"as": "helico.png",';
302
-									else $output .= '"aircraft_shadow": "helico.png",';
391
+									if ($compress) {
392
+										$output .= '"as": "helico.png",';
393
+									} else {
394
+										$output .= '"aircraft_shadow": "helico.png",';
395
+									}
303 396
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
304
-									if ($compress) $output .= '"as": "rail.png",';
305
-									else $output .= '"aircraft_shadow": "rail.png",';
397
+									if ($compress) {
398
+										$output .= '"as": "rail.png",';
399
+									} else {
400
+										$output .= '"aircraft_shadow": "rail.png",';
401
+									}
306 402
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
307
-									if ($compress) $output .= '"as": "firetruck.png",';
308
-									else $output .= '"aircraft_shadow": "firetruck.png",';
403
+									if ($compress) {
404
+										$output .= '"as": "firetruck.png",';
405
+									} else {
406
+										$output .= '"aircraft_shadow": "firetruck.png",';
407
+									}
309 408
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
310
-									if ($compress) $output .= '"as": "bus.png",';
311
-									else $output .= '"aircraft_shadow": "bus.png",';
409
+									if ($compress) {
410
+										$output .= '"as": "bus.png",';
411
+									} else {
412
+										$output .= '"aircraft_shadow": "bus.png",';
413
+									}
312 414
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
313
-									if ($compress) $output .= '"as": "phone.png",';
314
-									else $output .= '"aircraft_shadow": "phone.png",';
415
+									if ($compress) {
416
+										$output .= '"as": "phone.png",';
417
+									} else {
418
+										$output .= '"aircraft_shadow": "phone.png",';
419
+									}
315 420
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
316
-									if ($compress) $output .= '"as": "jogger.png",';
317
-									else $output .= '"aircraft_shadow": "jogger.png",';
421
+									if ($compress) {
422
+										$output .= '"as": "jogger.png",';
423
+									} else {
424
+										$output .= '"aircraft_shadow": "jogger.png",';
425
+									}
318 426
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
319
-									if ($compress) $output .= '"as": "bike.png",';
320
-									else $output .= '"aircraft_shadow": "bike.png",';
427
+									if ($compress) {
428
+										$output .= '"as": "bike.png",';
429
+									} else {
430
+										$output .= '"aircraft_shadow": "bike.png",';
431
+									}
321 432
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
322
-									if ($compress) $output .= '"as": "motorcycle.png",';
323
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
433
+									if ($compress) {
434
+										$output .= '"as": "motorcycle.png",';
435
+									} else {
436
+										$output .= '"aircraft_shadow": "motorcycle.png",';
437
+									}
324 438
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
325
-									if ($compress) $output .= '"as": "balloon.png",';
326
-									else $output .= '"aircraft_shadow": "balloon.png",';
439
+									if ($compress) {
440
+										$output .= '"as": "balloon.png",';
441
+									} else {
442
+										$output .= '"aircraft_shadow": "balloon.png",';
443
+									}
327 444
 								} else {
328
-									if ($compress) $output .= '"as": "car.png",';
329
-									else $output .= '"aircraft_shadow": "car.png",';
445
+									if ($compress) {
446
+										$output .= '"as": "car.png",';
447
+									} else {
448
+										$output .= '"aircraft_shadow": "car.png",';
449
+									}
330 450
 								}
331 451
 							} elseif ($marine) {
332
-								if ($compress) $output .= '"as": "ship.png",';
333
-								else $output .= '"aircraft_shadow": "ship.png",';
452
+								if ($compress) {
453
+									$output .= '"as": "ship.png",';
454
+								} else {
455
+									$output .= '"aircraft_shadow": "ship.png",';
456
+								}
334 457
 							} else {
335
-								if ($compress) $output .= '"as": "default.png",';
336
-								else $output .= '"aircraft_shadow": "default.png",';
458
+								if ($compress) {
459
+									$output .= '"as": "default.png",';
460
+								} else {
461
+									$output .= '"aircraft_shadow": "default.png",';
462
+								}
337 463
 							}
338 464
 						} else {
339
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
340
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
465
+							if ($compress) {
466
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
467
+							} else {
468
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
469
+							}
341 470
 						}
342 471
 						if (isset($spotter_item['airline_name'])) {
343 472
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -345,8 +474,11 @@  discard block
 block discarded – undo
345 474
 							$output .= '"airline_name": "NA",';
346 475
 						}
347 476
 						if (isset($spotter_item['departure_airport'])) {
348
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
349
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
477
+							if ($compress) {
478
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
479
+							} else {
480
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
481
+							}
350 482
 						}
351 483
 						if (isset($spotter_item['departure_airport_city'])) {
352 484
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -358,8 +490,11 @@  discard block
 block discarded – undo
358 490
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
359 491
 						}
360 492
 						if (isset($spotter_item['arrival_airport'])) {
361
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
362
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
493
+							if ($compress) {
494
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
495
+							} else {
496
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
497
+							}
363 498
 						}
364 499
 						if (isset($spotter_item['arrival_airport_city'])) {
365 500
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -378,11 +513,17 @@  discard block
 block discarded – undo
378 513
 						}
379 514
 						
380 515
 						if (isset($spotter_item['altitude'])) {
381
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
382
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
516
+							if ($compress) {
517
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
518
+							} else {
519
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
520
+							}
521
+						}
522
+						if ($compress) {
523
+							$output .= '"h": "'.$spotter_item['heading'].'",';
524
+						} else {
525
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
383 526
 						}
384
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
385
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
386 527
 						
387 528
 						if (isset($archivespeed)) {
388 529
 							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
@@ -392,7 +533,9 @@  discard block
 block discarded – undo
392 533
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
393 534
 						}
394 535
 
395
-						if (!$min) $output .= '"image": "'.$image.'",';
536
+						if (!$min) {
537
+							$output .= '"image": "'.$image.'",';
538
+						}
396 539
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
397 540
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
398 541
 						}
@@ -400,8 +543,11 @@  discard block
 block discarded – undo
400 543
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
401 544
 						}
402 545
 						if (isset($spotter_item['squawk'])) {
403
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
404
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
546
+							if ($compress) {
547
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
548
+							} else {
549
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
550
+							}
405 551
 						}
406 552
 						if (isset($spotter_item['squawk_usage'])) {
407 553
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -420,14 +566,23 @@  discard block
 block discarded – undo
420 566
 						}
421 567
 						// type when not aircraft ?
422 568
 						if (isset($spotter_item['type'])) {
423
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
424
-							else $output .= '"type": "'.$spotter_item['type'].'"';
569
+							if ($compress) {
570
+								$output .= '"t": "'.$spotter_item['type'].'"';
571
+							} else {
572
+								$output .= '"type": "'.$spotter_item['type'].'"';
573
+							}
425 574
 						} elseif ($marine) {
426
-							if ($compress) $output .= '"t": "ship"';
427
-							else $output .= '"type": "ship"';
575
+							if ($compress) {
576
+								$output .= '"t": "ship"';
577
+							} else {
578
+								$output .= '"type": "ship"';
579
+							}
428 580
 						} else {
429
-							if ($compress) $output .= '"t": "aircraft"';
430
-							else $output .= '"type": "aircraft"';
581
+							if ($compress) {
582
+								$output .= '"t": "aircraft"';
583
+							} else {
584
+								$output .= '"type": "aircraft"';
585
+							}
431 586
 						}
432 587
 						$output .= '},';
433 588
 						$output .= '"geometry": {';
@@ -495,7 +650,9 @@  discard block
 block discarded – undo
495 650
 			}
496 651
 */
497 652
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
498
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
653
+				if ($history == '' && isset($_COOKIE['history'])) {
654
+					$history = $_COOKIE['history'];
655
+				}
499 656
 				
500 657
 				if (
501 658
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -539,8 +696,11 @@  discard block
 block discarded – undo
539 696
 									$output_history .= ']}},';
540 697
 									$output .= $output_history;
541 698
 								}
542
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
543
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
699
+								if ($compress) {
700
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
701
+								} else {
702
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
703
+								}
544 704
 							}
545 705
 							$output_history .= '[';
546 706
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -559,9 +719,14 @@  discard block
 block discarded – undo
559 719
 							$prev_alt = $alt;
560 720
 						} else {
561 721
 							if ($d == false) {
562
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
563
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
564
-							} else $d = true;
722
+								if ($compress) {
723
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
724
+								} else {
725
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
726
+								}
727
+							} else {
728
+								$d = true;
729
+							}
565 730
 							$output_history .= '[';
566 731
 							$output_history .=  $spotter_history['longitude'].', ';
567 732
 							$output_history .=  $spotter_history['latitude'];
@@ -582,7 +747,9 @@  discard block
 block discarded – undo
582 747
 							$output_historyd = '[';
583 748
 							$output_historyd .=  $spotter_item['longitude'].', ';
584 749
 							$output_historyd .=  $spotter_item['latitude'];
585
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
750
+							if (isset($spotter_history['altitude'])) {
751
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
752
+							}
586 753
 							$output_historyd .= '],';
587 754
 							//$output_history = $output_historyd.$output_history;
588 755
 							$output_history = $output_history.$output_historyd;
@@ -604,8 +771,11 @@  discard block
 block discarded – undo
604 771
 				        && $spotter_item['arrival_airport'] != 'NA' 
605 772
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
606 773
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
607
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
608
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
774
+				    if ($compress) {
775
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
776
+				    } else {
777
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
778
+				    }
609 779
 				    if (isset($spotter_item['departure_airport_latitude'])) {
610 780
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
611 781
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -638,8 +808,11 @@  discard block
 block discarded – undo
638 808
 				    	    || (!isset($_COOKIE['MapRemainaingRoute']) && (!isset($globalMapRemainingRoute) 
639 809
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
640 810
 				    $havedata = false;
641
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
642
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
811
+				    if ($compress) {
812
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
813
+				    } else {
814
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
815
+				    }
643 816
 				    $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
644 817
 
645 818
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -654,7 +827,9 @@  discard block
 block discarded – undo
654 827
 				    }
655 828
 				    //$output_dest  = substr($output_dest, 0, -1);
656 829
 				    $output_dest .= ']}},';
657
-				    if ($havedata) $output .= $output_dest;
830
+				    if ($havedata) {
831
+				    	$output .= $output_dest;
832
+				    }
658 833
 				    unset($output_dest);
659 834
 				}
660 835
 			}
@@ -662,7 +837,9 @@  discard block
 block discarded – undo
662 837
 			$output .= ']';
663 838
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
664 839
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
665
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
840
+			if (isset($begindate)) {
841
+				$output .= '"archive_date": "'.$begindate.'",';
842
+			}
666 843
 			$output .= '"fc": "'.$j.'"';
667 844
 		} else {
668 845
 			$output .= '"features": ';
Please login to merge, or discard this patch.
header.php 1 patch
Braces   +73 added lines, -16 removed lines patch added patch discarded remove patch
@@ -3,10 +3,15 @@  discard block
 block discarded – undo
3 3
 //gets the page file and stores it in a variable
4 4
 $file_path = pathinfo($_SERVER['SCRIPT_NAME']);
5 5
 $current_page = $file_path['filename'];
6
-if ($globalTimezone == '') $globalTimezone = 'UTC';
6
+if ($globalTimezone == '') {
7
+	$globalTimezone = 'UTC';
8
+}
7 9
 date_default_timezone_set($globalTimezone);
8
-if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
9
-else $MapType = $globalMapProvider;
10
+if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') {
11
+	$MapType = $_COOKIE['MapType'];
12
+} else {
13
+	$MapType = $globalMapProvider;
14
+}
10 15
 if (isset($_GET['3d'])) {
11 16
 	setcookie('MapFormat','3d');
12 17
 } else if (isset($_GET['2d'])) {
@@ -240,7 +245,13 @@  discard block
 block discarded – undo
240 245
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
241 246
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
242 247
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
243
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
248
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) {
249
+	print '&latitude='.$latitude;
250
+}
251
+?><?php if(isset($longitude)) {
252
+	print '&longitude='.$longitude;
253
+}
254
+?>&<?php print time(); ?>"></script>
244 255
 <?php
245 256
 		if (!isset($type) || $type == 'aircraft') {
246 257
 ?>
@@ -310,7 +321,13 @@  discard block
 block discarded – undo
310 321
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
311 322
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
312 323
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
313
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
324
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) {
325
+	print '&latitude='.$latitude;
326
+}
327
+?><?php if(isset($longitude)) {
328
+	print '&longitude='.$longitude;
329
+}
330
+?>&<?php print time(); ?>"></script>
314 331
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
315 332
 <?php
316 333
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -391,7 +408,12 @@  discard block
 block discarded – undo
391 408
         <span class="icon-bar"></span>
392 409
       </button>
393 410
       <a href="<?php print $globalURL; ?>/search" class="navbar-toggle navbar-toggle-search"><i class="fa fa-search"></i></a>
394
-      <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
411
+      <a class="navbar-brand" href="<?php if ($globalURL == '') {
412
+	print '/';
413
+} else {
414
+	print $globalURL;
415
+}
416
+?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
395 417
     </div>
396 418
     <div class="collapse navbar-collapse">
397 419
 
@@ -417,7 +439,10 @@  discard block
 block discarded – undo
417 439
 <?php
418 440
     }
419 441
 ?>
420
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
442
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
443
+	echo 'right-';
444
+}
445
+?>caret"></b></a>
421 446
           <ul class="dropdown-menu">
422 447
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircrafts Types"); ?></a></li>
423 448
 <?php
@@ -488,8 +513,14 @@  discard block
 block discarded – undo
488 513
         </li>
489 514
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
490 515
       	<li><a href="<?php print $globalURL; ?>/statistics"><?php echo _("Statistics"); ?></a></li>
491
-        <li class="dropdown<?php if ($sub) echo '-submenu'; ?>">
492
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
516
+        <li class="dropdown<?php if ($sub) {
517
+	echo '-submenu';
518
+}
519
+?>">
520
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) {
521
+	echo 'right-';
522
+}
523
+?>caret"></b></a>
493 524
           <ul class="dropdown-menu">
494 525
           	<li><a href="<?php print $globalURL; ?>/tools/acars"><?php echo _("ACARS translator"); ?></a></li>
495 526
           	<li><a href="<?php print $globalURL; ?>/tools/metar"><?php echo _("METAR translator"); ?></a></li>
@@ -518,7 +549,10 @@  discard block
 block discarded – undo
518 549
 <?php
519 550
 	}
520 551
 ?>
521
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
552
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
553
+	echo 'right-';
554
+}
555
+?>caret"></b></a>
522 556
 		<ul class="dropdown-menu">
523 557
 		    <li><a href="<?php print $globalURL; ?>/marine/currently"><?php echo _("Current Activity"); ?></a></li>
524 558
 		    <li><a href="<?php print $globalURL; ?>/marine/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -550,7 +584,10 @@  discard block
 block discarded – undo
550 584
 <?php
551 585
 	}
552 586
 ?>
553
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
587
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
588
+	echo 'right-';
589
+}
590
+?>caret"></b></a>
554 591
 		<ul class="dropdown-menu">
555 592
 		    <li><a href="<?php print $globalURL; ?>/tracker/currently"><?php echo _("Current Activity"); ?></a></li>
556 593
 		    <li><a href="<?php print $globalURL; ?>/tracker/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -606,7 +643,9 @@  discard block
 block discarded – undo
606 643
   		        $alllang = $Language->getLanguages();
607 644
   		        foreach ($alllang as $key => $lang) {
608 645
   		            print '<option value="'.$key.'"';
609
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
646
+  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) {
647
+  		            	print ' selected ';
648
+  		            }
610 649
   		            print '>'.$lang[0].'</option>';
611 650
   		        }
612 651
   		    ?>
@@ -746,9 +785,24 @@  discard block
 block discarded – undo
746 785
 	$customid = $globalMapProvider;
747 786
 ?>
748 787
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
749
-        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
750
-        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
751
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
788
+        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
789
+	print $globalMapCustomLayer[$customid]['maxZoom'];
790
+} else {
791
+	print '18';
792
+}
793
+?>,
794
+        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
795
+	print $globalMapCustomLayer[$customid]['minZoom'];
796
+} else {
797
+	print '0';
798
+}
799
+?>,
800
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
801
+	print 'false';
802
+} else {
803
+	print 'true';
804
+}
805
+?>,
752 806
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
753 807
     }).addTo(map);
754 808
 <?php
@@ -771,4 +825,7 @@  discard block
 block discarded – undo
771 825
 
772 826
 ?>
773 827
 
774
-<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear">
828
+<section class="container main-content <?php if (strtolower($current_page) == 'index') {
829
+	print 'index ';
830
+}
831
+?>clear">
Please login to merge, or discard this patch.
require/class.TrackerImport.php 1 patch
Braces   +190 added lines, -65 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function checkAll() {
44 44
 	global $globalDebug;
45
-	if ($globalDebug) echo "Update last seen tracked data...\n";
45
+	if ($globalDebug) {
46
+		echo "Update last seen tracked data...\n";
47
+	}
46 48
 	foreach ($this->all_tracked as $key => $flight) {
47 49
 	    if (isset($this->all_tracked[$key]['id'])) {
48 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -55,12 +57,16 @@  discard block
 block discarded – undo
55 57
     public function del() {
56 58
 	global $globalDebug;
57 59
 	// Delete old infos
58
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
60
+	if ($globalDebug) {
61
+		echo 'Delete old values and update latest data...'."\n";
62
+	}
59 63
 	foreach ($this->all_tracked as $key => $flight) {
60 64
     	    if (isset($flight['lastupdate'])) {
61 65
         	if ($flight['lastupdate'] < (time()-3000)) {
62 66
             	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
67
+            		if ($globalDebug) {
68
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		}
64 70
 			/*
65 71
 			$TrackerLive = new TrackerLive();
66 72
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
@@ -70,7 +76,9 @@  discard block
 block discarded – undo
70 76
             		$Tracker = new Tracker($this->db);
71 77
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 78
 				$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
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
79
+				if ($globalDebug && $result != 'success') {
80
+					echo '!!! ERROR : '.$result."\n";
81
+				}
74 82
 			}
75 83
 			// Put in archive
76 84
 //			$Tracker->db = null;
@@ -83,7 +91,9 @@  discard block
 block discarded – undo
83 91
 
84 92
     public function add($line) {
85 93
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
94
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
95
+		$globalCoordMinChange = '0.02';
96
+	}
87 97
 	date_default_timezone_set('UTC');
88 98
 	$dataFound = false;
89 99
 	$send = false;
@@ -97,19 +107,29 @@  discard block
 block discarded – undo
97 107
 		// Increment message number
98 108
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99 109
 		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
110
+		    if (isset($line['source_name'])) {
111
+		    	$source = $line['source_name'];
112
+		    } else {
113
+		    	$source = '';
114
+		    }
115
+		    if ($source == '' || $line['format_source'] == 'aprs') {
116
+		    	$source = $line['format_source'];
117
+		    }
103 118
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104 119
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105 120
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
121
+		    } else {
122
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
123
+		    }
107 124
 		}
108 125
 		
109 126
 		
110 127
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
128
+	        if (!isset($line['id'])) {
129
+	        	$id = trim($line['ident']);
130
+	        } else {
131
+	        	$id = trim($line['id']);
132
+	        }
113 133
 		
114 134
 		if (!isset($this->all_tracked[$id])) {
115 135
 		    $this->all_tracked[$id] = array();
@@ -117,31 +137,46 @@  discard block
 block discarded – undo
117 137
 		    $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 138
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119 139
 		    if (!isset($line['id'])) {
120
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
140
+			if (!isset($globalDaemon)) {
141
+				$globalDaemon = TRUE;
142
+			}
121 143
 			$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
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
144
+		     } else {
145
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
146
+		     }
147
+		    if ($globalAllTracked !== FALSE) {
148
+		    	$dataFound = true;
149
+		    }
124 150
 		}
125 151
 		
126 152
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127 153
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 154
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129 155
 		    } else {
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
-				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";
156
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
157
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
158
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
159
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
160
+				}
132 161
 				return '';
133 162
 		    }
134 163
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
164
+			if ($globalDebug) {
165
+				echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
166
+			}
136 167
 			return '';
137 168
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
138
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
169
+			if ($globalDebug) {
170
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
171
+			}
139 172
 			return '';
140 173
 		} elseif (!isset($line['datetime'])) {
141 174
 			date_default_timezone_set('UTC');
142 175
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
143 176
 		} else {
144
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
177
+			if ($globalDebug) {
178
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
179
+			}
145 180
 			return '';
146 181
 		}
147 182
 		
@@ -153,11 +188,17 @@  discard block
 block discarded – undo
153 188
             		$Tracker = new Tracker($this->db);
154 189
             		$fromsource = NULL;
155 190
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
191
+			if ($globalDebug && $result != 'success') {
192
+				echo '!!! ERROR : '.$result."\n";
193
+			}
157 194
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
195
+			if ($globalDebugTimeElapsed) {
196
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
197
+			}
198
+		    }
199
+		    if (!isset($this->all_tracked[$id]['id'])) {
200
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159 201
 		    }
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 202
 		}
162 203
 
163 204
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -168,14 +209,21 @@  discard block
 block discarded – undo
168 209
 		    if ($distance > 100 && $distance < 10000) {
169 210
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 211
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
212
+			if ($speed < 1000) {
213
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
214
+			}
215
+  			if ($globalDebug) {
216
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
217
+  			}
173 218
 		    }
174 219
 		}
175 220
 
176 221
 	        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']);
178
-	    	    else unset($timediff);
222
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
223
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
224
+	    	    } else {
225
+	    	    	unset($timediff);
226
+	    	    }
179 227
 	    	    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 228
 			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 229
 			    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'])) {
@@ -183,20 +231,30 @@  discard block
 block discarded – undo
183 231
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 232
 				$this->all_tracked[$id]['putinarchive'] = true;
185 233
 				
186
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
234
+				if ($globalDebug) {
235
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
236
+				}
187 237
 				$timeelapsed = microtime(true);
188 238
 				$Tracker = new Tracker($this->db);
189 239
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
190
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
240
+				if (!empty($all_country)) {
241
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
242
+				}
191 243
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
244
+				if ($globalDebugTimeElapsed) {
245
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
246
+				}
193 247
 				$this->tmd = 0;
194
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
248
+				if ($globalDebug) {
249
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
250
+				}
195 251
 			    }
196 252
 			}
197 253
 
198 254
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
255
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
256
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
257
+				}
200 258
 				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 259
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 260
 				    $dataFound = true;
@@ -205,8 +263,12 @@  discard block
 block discarded – undo
205 263
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 264
 			}
207 265
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
266
+			    if ($line['longitude'] > 180) {
267
+			    	$line['longitude'] = $line['longitude'] - 360;
268
+			    }
269
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
270
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
271
+				}
210 272
 				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 273
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 274
 				    $dataFound = true;
@@ -226,7 +288,9 @@  discard block
 block discarded – undo
226 288
 		    }
227 289
 		}
228 290
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
291
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
292
+		    	$dataFound = true;
293
+		    }
230 294
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 295
 		}
232 296
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -246,7 +310,9 @@  discard block
 block discarded – undo
246 310
 
247 311
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 312
 		    //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;
313
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
314
+				$this->all_tracked[$id]['putinarchive'] = true;
315
+			}
250 316
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 317
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 318
 			//$dataFound = true;
@@ -258,15 +324,21 @@  discard block
 block discarded – undo
258 324
 		}
259 325
 		
260 326
 		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;
327
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
328
+		    	$this->all_tracked[$id]['putinarchive'] = true;
329
+		    }
262 330
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263 331
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264 332
 		    //$dataFound = true;
265 333
   		} 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 334
   		    $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 335
 		    $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
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
336
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
337
+		    	$this->all_tracked[$id]['putinarchive'] = true;
338
+		    }
339
+  		    if ($globalDebug) {
340
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
341
+  		    }
270 342
   		}
271 343
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 344
 
@@ -275,20 +347,31 @@  discard block
 block discarded – undo
275 347
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276 348
 		        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 349
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
350
+				if ($globalDebug) {
351
+					echo "Check if aircraft is already in DB...";
352
+				}
279 353
 				$timeelapsed = microtime(true);
280 354
 				$TrackerLive = new TrackerLive($this->db);
281 355
 				if (isset($line['id'])) {
282 356
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
357
+				    if ($globalDebugTimeElapsed) {
358
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
359
+				    }
284 360
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 361
 				    $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";
287
-				} else $recent_ident = '';
362
+				    if ($globalDebugTimeElapsed) {
363
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
364
+				    }
365
+				} else {
366
+					$recent_ident = '';
367
+				}
288 368
 				$TrackerLive->db=null;
289 369
 
290
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
370
+				if ($globalDebug && $recent_ident == '') {
371
+					echo " Not in DB.\n";
372
+				} elseif ($globalDebug && $recent_ident != '') {
373
+					echo " Already in DB.\n";
374
+				}
292 375
 			    } else {
293 376
 				$recent_ident = '';
294 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -296,27 +379,41 @@  discard block
 block discarded – undo
296 379
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297 380
 			    if($recent_ident == "")
298 381
 			    {
299
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
382
+				if ($globalDebug) {
383
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
384
+				}
300 385
 				//adds the spotter data for the archive
301 386
 				    $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')));
387
+				    if (!isset($this->all_tracked[$id]['id'])) {
388
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
389
+				    }
303 390
 				    $timeelapsed = microtime(true);
304 391
 				    $Tracker = new Tracker($this->db);
305 392
 				    $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 393
 				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
394
+				    if ($globalDebug && isset($result)) {
395
+				    	echo $result."\n";
396
+				    }
397
+				    if ($globalDebugTimeElapsed) {
398
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
+				    }
309 400
 				    
310 401
 				    
311 402
 				    // Add source stat in DB
312 403
 				    $Stats = new Stats($this->db);
313 404
 				    if (!empty($this->stats)) {
314
-					if ($globalDebug) echo 'Add source stats : ';
405
+					if ($globalDebug) {
406
+						echo 'Add source stats : ';
407
+					}
315 408
 				        foreach($this->stats as $date => $data) {
316 409
 					    foreach($data as $source => $sourced) {
317 410
 					        //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);
411
+				    	        if (isset($sourced['polar'])) {
412
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
413
+				    	        }
414
+				    	        if (isset($sourced['hist'])) {
415
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
416
+				    	        }
320 417
 				    		if (isset($sourced['msg'])) {
321 418
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 419
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -329,7 +426,9 @@  discard block
 block discarded – undo
329 426
 			    			unset($this->stats[$date]);
330 427
 			    		    }
331 428
 				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
429
+				    	if ($globalDebug) {
430
+				    		echo 'Done'."\n";
431
+				    	}
333 432
 
334 433
 				    }
335 434
 				    $Stats->db = null;
@@ -339,12 +438,16 @@  discard block
 block discarded – undo
339 438
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 439
 				//print_r($this->all_tracked[$id]);
341 440
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
441
+				    if ($globalDebug) {
442
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
443
+				    }
343 444
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 445
 				    $TrackerLive = new TrackerLive($this->db);
345 446
 				    $TrackerLive->deleteLiveTrackerData();
346 447
 				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
448
+				    if ($globalDebug) {
449
+				    	echo " Done\n";
450
+				    }
348 451
 				    $this->last_delete = time();
349 452
 				}
350 453
 			    } else {
@@ -367,19 +470,25 @@  discard block
 block discarded – undo
367 470
 
368 471
 		    if (!$ignoreImport) {
369 472
 			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
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
473
+				if ($globalDebug) {
474
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
475
+				}
371 476
 				$timeelapsed = microtime(true);
372 477
 				$TrackerLive = new TrackerLive($this->db);
373 478
 				$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 479
 				$TrackerLive->db = null;
375 480
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481
+				if ($globalDebugTimeElapsed) {
482
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
483
+				}
377 484
 
378 485
 				// Put statistics in $this->stats variable
379 486
 				
380 487
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
381 488
 					$source = $this->all_tracked[$id]['source_name'];
382
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
489
+					if ($source == '') {
490
+						$source = $this->all_tracked[$id]['format_source'];
491
+					}
383 492
 					if (!isset($this->source_location[$source])) {
384 493
 						$Location = new Source();
385 494
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -400,7 +509,9 @@  discard block
 block discarded – undo
400 509
 					$stats_heading = round($stats_heading/22.5);
401 510
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
402 511
 					$current_date = date('Y-m-d');
403
-					if ($stats_heading == 16) $stats_heading = 0;
512
+					if ($stats_heading == 16) {
513
+						$stats_heading = 0;
514
+					}
404 515
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 516
 						for ($i=0;$i<=15;$i++) {
406 517
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -418,7 +529,9 @@  discard block
 block discarded – undo
418 529
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 530
 						    end($this->stats[$current_date][$source]['hist']);
420 531
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
421
-						} else $mini = 0;
532
+						} else {
533
+							$mini = 0;
534
+						}
422 535
 						for ($i=$mini;$i<=$distance;$i+=10) {
423 536
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 537
 						}
@@ -429,19 +542,29 @@  discard block
 block discarded – undo
429 542
 				}
430 543
 
431 544
 				$this->all_tracked[$id]['lastupdate'] = time();
432
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
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";
545
+				if ($this->all_tracked[$id]['putinarchive']) {
546
+					$send = true;
547
+				}
548
+				if ($globalDebug) {
549
+					echo $result."\n";
550
+				}
551
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
552
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
553
+			}
435 554
 			//$this->del();
436 555
 			
437 556
 			
438 557
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
558
+			    if ($globalDebug) {
559
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
560
+			    }
440 561
 			    $TrackerLive = new TrackerLive($this->db);
441 562
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442 563
 			    $TrackerLive->db = null;
443 564
 			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
565
+			    if ($globalDebug) {
566
+			    	echo " Done\n";
567
+			    }
445 568
 			    $this->last_delete_hourly = time();
446 569
 			}
447 570
 			
@@ -449,7 +572,9 @@  discard block
 block discarded – undo
449 572
 		    //$ignoreImport = false;
450 573
 		}
451 574
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452
-		if ($send) return $this->all_tracked[$id];
575
+		if ($send) {
576
+			return $this->all_tracked[$id];
577
+		}
453 578
 	    }
454 579
 	}
455 580
     }
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Braces   +74 added lines, -25 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -76,8 +78,11 @@  discard block
 block discarded – undo
76 78
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77 79
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78 80
 		}
79
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81
+		if ($filter_query_where == '' && $where) {
82
+			$filter_query_where = ' WHERE';
83
+		} elseif ($filter_query_where != '' && $and) {
84
+			$filter_query_where .= ' AND';
85
+		}
81 86
 		if ($filter_query_where != '') {
82 87
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83 88
 		}
@@ -119,7 +124,9 @@  discard block
 block discarded – undo
119 124
 			}
120 125
 		}
121 126
 
122
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
127
+		if (!isset($globalLiveInterval)) {
128
+			$globalLiveInterval = '200';
129
+		}
123 130
 		if ($globalDBdriver == 'mysql') {
124 131
 			//$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 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
125 132
 			$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'.$filter_query.$orderby_query;
@@ -144,7 +151,9 @@  discard block
 block discarded – undo
144 151
 
145 152
 		$filter_query = $this->getFilter($filter,true,true);
146 153
 
147
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
154
+		if (!isset($globalLiveInterval)) {
155
+			$globalLiveInterval = '200';
156
+		}
148 157
 		if ($globalDBdriver == 'mysql') {
149 158
 			$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 
150 159
 			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'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
@@ -182,7 +191,9 @@  discard block
 block discarded – undo
182 191
 
183 192
 		$filter_query = $this->getFilter($filter,true,true);
184 193
 
185
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
+		if (!isset($globalLiveInterval)) {
195
+			$globalLiveInterval = '200';
196
+		}
186 197
 		if ($globalDBdriver == 'mysql') {
187 198
 			$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 199
 			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' 
@@ -215,7 +226,9 @@  discard block
 block discarded – undo
215 226
 		global $globalDBdriver, $globalLiveInterval;
216 227
 		$filter_query = $this->getFilter($filter,true,true);
217 228
 
218
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
229
+		if (!isset($globalLiveInterval)) {
230
+			$globalLiveInterval = '200';
231
+		}
219 232
 		if ($globalDBdriver == 'mysql') {
220 233
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
221 234
 		} else {
@@ -243,7 +256,9 @@  discard block
 block discarded – undo
243 256
 	{
244 257
 		global $globalDBdriver, $globalLiveInterval;
245 258
 		$Spotter = new Spotter($this->db);
246
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
259
+		if (!isset($globalLiveInterval)) {
260
+			$globalLiveInterval = '200';
261
+		}
247 262
 		$filter_query = $this->getFilter($filter);
248 263
 
249 264
 		if (is_array($coord)) {
@@ -251,7 +266,9 @@  discard block
 block discarded – undo
251 266
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
252 267
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
253 268
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
254
-		} else return array();
269
+		} else {
270
+			return array();
271
+		}
255 272
 		if ($globalDBdriver == 'mysql') {
256 273
 			$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;
257 274
 		} else {
@@ -271,7 +288,9 @@  discard block
 block discarded – undo
271 288
 	{
272 289
 		global $globalDBdriver, $globalLiveInterval;
273 290
 		$Spotter = new Spotter($this->db);
274
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
291
+		if (!isset($globalLiveInterval)) {
292
+			$globalLiveInterval = '200';
293
+		}
275 294
 		$filter_query = $this->getFilter($filter);
276 295
 
277 296
 		if (is_array($coord)) {
@@ -279,7 +298,9 @@  discard block
 block discarded – undo
279 298
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
280 299
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
281 300
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
282
-		} else return array();
301
+		} else {
302
+			return array();
303
+		}
283 304
 		if ($globalDBdriver == 'mysql') {
284 305
 			$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 306
 			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."
@@ -472,11 +493,15 @@  discard block
 block discarded – undo
472 493
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
473 494
 		if ($globalDBdriver == 'mysql') {
474 495
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
475
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
496
+			if ($liveinterval) {
497
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
498
+			}
476 499
 			$query .= ' ORDER BY date';
477 500
 		} else {
478 501
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
479
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
502
+			if ($liveinterval) {
503
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
504
+			}
480 505
 			$query .= ' ORDER BY date';
481 506
 		}
482 507
 
@@ -571,7 +596,9 @@  discard block
 block discarded – undo
571 596
 				$i++;
572 597
 				$j++;
573 598
 				if ($j == 30) {
574
-					if ($globalDebug) echo ".";
599
+					if ($globalDebug) {
600
+						echo ".";
601
+					}
575 602
 				    	try {
576 603
 						
577 604
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -818,7 +845,9 @@  discard block
 block discarded – undo
818 845
 			{
819 846
 				return false;
820 847
 			}
821
-		} else return '';
848
+		} else {
849
+			return '';
850
+		}
822 851
 
823 852
 		if ($longitude != '')
824 853
 		{
@@ -826,7 +855,9 @@  discard block
 block discarded – undo
826 855
 			{
827 856
 				return false;
828 857
 			}
829
-		} else return '';
858
+		} else {
859
+			return '';
860
+		}
830 861
 
831 862
 		if ($altitude != '')
832 863
 		{
@@ -834,7 +865,9 @@  discard block
 block discarded – undo
834 865
 			{
835 866
 				return false;
836 867
 			}
837
-		} else $altitude = 0;
868
+		} else {
869
+			$altitude = 0;
870
+		}
838 871
 
839 872
 		if ($heading != '')
840 873
 		{
@@ -842,7 +875,9 @@  discard block
 block discarded – undo
842 875
 			{
843 876
 				return false;
844 877
 			}
845
-		} else $heading = 0;
878
+		} else {
879
+			$heading = 0;
880
+		}
846 881
 
847 882
 		if ($groundspeed != '')
848 883
 		{
@@ -850,9 +885,13 @@  discard block
 block discarded – undo
850 885
 			{
851 886
 				return false;
852 887
 			}
853
-		} else $groundspeed = 0;
888
+		} else {
889
+			$groundspeed = 0;
890
+		}
854 891
 		date_default_timezone_set('UTC');
855
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
892
+		if ($date == '') {
893
+			$date = date("Y-m-d H:i:s", time());
894
+		}
856 895
 
857 896
         
858 897
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -868,12 +907,18 @@  discard block
 block discarded – undo
868 907
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
869 908
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
870 909
 
871
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
872
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
910
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
911
+            		$groundspeed = 0;
912
+            	}
913
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
914
+            		$heading = 0;
915
+            	}
873 916
             	
874 917
 		$query = '';
875 918
 		if ($globalArchive) {
876
-			if ($globalDebug) echo '-- Delete previous data -- ';
919
+			if ($globalDebug) {
920
+				echo '-- Delete previous data -- ';
921
+			}
877 922
 			$query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;';
878 923
 		}
879 924
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
@@ -892,10 +937,14 @@  discard block
 block discarded – undo
892 937
                 echo 'noarchive : '.$noarchive."\n";
893 938
                 */
894 939
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
895
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
940
+		    if ($globalDebug) {
941
+		    	echo '(Add to Tracker archive '.$famtrackid.' : ';
942
+		    }
896 943
 		    $TrackerArchive = new TrackerArchive($this->db);
897 944
 		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
898
-		    if ($globalDebug) echo $result.')';
945
+		    if ($globalDebug) {
946
+		    	echo $result.')';
947
+		    }
899 948
 		}
900 949
 
901 950
 		return "success";
Please login to merge, or discard this patch.