Completed
Push — master ( 76a3f8...0d46aa )
by Yannick
25:49
created
scripts/daemon-spotter.php 1 patch
Braces   +1025 added lines, -350 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,32 +211,46 @@  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('/blitzortung/i',$host)) {
180 231
         	$globalSources[$id]['format'] = 'blitzortung';
181
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
232
+        	if ($globalDebug) {
233
+        		echo "Connect to blitzortung source (".$host.")...\n";
234
+        	}
182 235
             } else if (preg_match('/airwhere/i',$host)) {
183 236
         	$globalSources[$id]['format'] = 'airwhere';
184
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
+        	if ($globalDebug) {
238
+        		echo "Connect to airwhere source (".$host.")...\n";
239
+        	}
185 240
             } else if (preg_match('/recentpireps/i',$host)) {
186 241
         	//$formats[$id] = 'pirepsjson';
187 242
         	$globalSources[$id]['format'] = 'pirepsjson';
188 243
         	//$last_exec['pirepsjson'] = 0;
189
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
244
+        	if ($globalDebug) {
245
+        		echo "Connect to pirepsjson source (".$host.")...\n";
246
+        	}
190 247
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
191 248
         	//$formats[$id] = 'fr24json';
192 249
         	$globalSources[$id]['format'] = 'fr24json';
193 250
         	//$last_exec['fr24json'] = 0;
194
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
251
+        	if ($globalDebug) {
252
+        		echo "Connect to fr24 source (".$host.")...\n";
253
+        	}
195 254
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
196 255
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
197 256
         	    exit(0);
@@ -200,7 +259,9 @@  discard block
 block discarded – undo
200 259
         	//$formats[$id] = 'fr24json';
201 260
         	$globalSources[$id]['format'] = 'myshiptracking';
202 261
         	//$last_exec['fr24json'] = 0;
203
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
262
+        	if ($globalDebug) {
263
+        		echo "Connect to myshiptracking source (".$host.")...\n";
264
+        	}
204 265
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
205 266
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
206 267
         	    exit(0);
@@ -209,17 +270,24 @@  discard block
 block discarded – undo
209 270
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
210 271
         	//$formats[$id] = 'tsv';
211 272
         	$globalSources[$id]['format'] = 'tsv';
212
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
273
+        	if ($globalDebug) {
274
+        		echo "Connect to tsv source (".$host.")...\n";
275
+        	}
213 276
             }
214 277
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
215 278
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
216 279
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
217 280
     		    if ($idf !== false) {
218 281
     			$httpfeeds[$id] = $idf;
219
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
+        		if ($globalDebug) {
283
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
284
+        		}
285
+    		    } elseif ($globalDebug) {
286
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
220 287
     		    }
221
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
222
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
288
+    		} elseif ($globalDebug) {
289
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
290
+    		}
223 291
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
224 292
 	    $hostport = explode(':',$host);
225 293
 	    if (isset($hostport[1])) {
@@ -259,17 +327,25 @@  discard block
 block discarded – undo
259 327
         		//$formats[$id] = 'beast';
260 328
         		$globalSources[$id]['format'] = 'beast';
261 329
 		    //} else $formats[$id] = 'sbs';
262
-		    } else $globalSources[$id]['format'] = 'sbs';
330
+		    } else {
331
+		    	$globalSources[$id]['format'] = 'sbs';
332
+		    }
263 333
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
264 334
 		}
265
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
335
+		if ($globalDebug) {
336
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
337
+		}
266 338
             } else {
267
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
339
+		if ($globalDebug) {
340
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
341
+		}
268 342
     	    }
269 343
         }
270 344
     }
271 345
 }
272
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
346
+if (!isset($globalMinFetch)) {
347
+	$globalMinFetch = 15;
348
+}
273 349
 
274 350
 // Initialize all
275 351
 $status = array();
@@ -278,13 +354,19 @@  discard block
 block discarded – undo
278 354
 $formats = array();
279 355
 $last_exec = array();
280 356
 $time = time();
281
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
282
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
283
-else $timeout = 20;
357
+if (isset($globalSourcesTimeout)) {
358
+	$timeout = $globalSourcesTimeOut;
359
+} else if (isset($globalSBS1TimeOut)) {
360
+	$timeout = $globalSBS1TimeOut;
361
+} else {
362
+	$timeout = 20;
363
+}
284 364
 $errno = '';
285 365
 $errstr='';
286 366
 
287
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
367
+if (!isset($globalDaemon)) {
368
+	$globalDaemon = TRUE;
369
+}
288 370
 /* Initiate connections to all the hosts simultaneously */
289 371
 //connect_all($hosts);
290 372
 //connect_all($globalSources);
@@ -313,7 +395,9 @@  discard block
 block discarded – undo
313 395
     if (isset($source['format']) && $source['format'] == 'aprs') {
314 396
 	$aprs_connect = 0;
315 397
 	$use_aprs = true;
316
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
398
+	if (isset($source['port']) && $source['port'] == '10152') {
399
+		$aprs_full = true;
400
+	}
317 401
 	break;
318 402
     }
319 403
 }
@@ -324,25 +408,48 @@  discard block
 block discarded – undo
324 408
 	$aprs_connect = 0;
325 409
 	$aprs_keep = 120;
326 410
 	$aprs_last_tx = time();
327
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
328
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
329
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
330
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
331
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
332
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
333
-	if ($aprs_full) $aprs_filter = '';
334
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
335
-	else $aprs_pass = '-1';
411
+	if (isset($globalAPRSversion)) {
412
+		$aprs_version = $globalAPRSversion;
413
+	} else {
414
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
415
+	}
416
+	if (isset($globalAPRSssid)) {
417
+		$aprs_ssid = $globalAPRSssid;
418
+	} else {
419
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
420
+	}
421
+	if (isset($globalAPRSfilter)) {
422
+		$aprs_filter = $globalAPRSfilter;
423
+	} else {
424
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
425
+	}
426
+	if ($aprs_full) {
427
+		$aprs_filter = '';
428
+	}
429
+	if (isset($globalAPRSpass)) {
430
+		$aprs_pass = $globalAPRSpass;
431
+	} else {
432
+		$aprs_pass = '-1';
433
+	}
336 434
 
337
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
338
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
339
-}
435
+	if ($aprs_filter != '') {
436
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
437
+	} else {
438
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
439
+	}
440
+	}
340 441
 
341 442
 // connected - lets do some work
342
-if ($globalDebug) echo "Connected!\n";
443
+if ($globalDebug) {
444
+	echo "Connected!\n";
445
+}
343 446
 sleep(1);
344
-if ($globalDebug) echo "SCAN MODE \n\n";
345
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
447
+if ($globalDebug) {
448
+	echo "SCAN MODE \n\n";
449
+}
450
+if (!isset($globalCronEnd)) {
451
+	$globalCronEnd = 60;
452
+}
346 453
 $endtime = time()+$globalCronEnd;
347 454
 $i = 1;
348 455
 $tt = array();
@@ -356,20 +463,28 @@  discard block
 block discarded – undo
356 463
 
357 464
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
358 465
 while ($i > 0) {
359
-    if (!$globalDaemon) $i = $endtime-time();
466
+    if (!$globalDaemon) {
467
+    	$i = $endtime-time();
468
+    }
360 469
     // Delete old ATC
361 470
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
362
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
471
+	if ($globalDebug) {
472
+		echo 'Delete old ATC...'."\n";
473
+	}
363 474
         $ATC->deleteOldATC();
364 475
     }
365 476
     
366 477
     if (count($last_exec) == count($globalSources)) {
367 478
 	$max = $globalMinFetch;
368 479
 	foreach ($last_exec as $last) {
369
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
480
+	    if ((time() - $last['last']) < $max) {
481
+	    	$max = time() - $last['last'];
482
+	    }
370 483
 	}
371 484
 	if ($max != $globalMinFetch) {
372
-	    if ($globalDebug) echo 'Sleeping...'."\n";
485
+	    if ($globalDebug) {
486
+	    	echo 'Sleeping...'."\n";
487
+	    }
373 488
 	    sleep($globalMinFetch-$max+2);
374 489
 	}
375 490
     }
@@ -378,11 +493,15 @@  discard block
 block discarded – undo
378 493
     //foreach ($formats as $id => $value) {
379 494
     foreach ($globalSources as $id => $value) {
380 495
 	date_default_timezone_set('UTC');
381
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
496
+	if (!isset($last_exec[$id]['last'])) {
497
+		$last_exec[$id]['last'] = 0;
498
+	}
382 499
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
383 500
 	    //$buffer = $Common->getData($hosts[$id]);
384 501
 	    $buffer = $Common->getData($value['host']);
385
-	    if ($buffer != '') $reset = 0;
502
+	    if ($buffer != '') {
503
+	    	$reset = 0;
504
+	    }
386 505
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
387 506
 	    $buffer = explode('\n',$buffer);
388 507
 	    foreach ($buffer as $line) {
@@ -391,20 +510,41 @@  discard block
 block discarded – undo
391 510
 	            $data = array();
392 511
 	            $data['hex'] = $line[1]; // hex
393 512
 	            $data['ident'] = $line[2]; // ident
394
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
395
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
396
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
397
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
398
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
513
+	            if (isset($line[3])) {
514
+	            	$data['altitude'] = $line[3];
515
+	            }
516
+	            // altitude
517
+	            if (isset($line[4])) {
518
+	            	$data['speed'] = $line[4];
519
+	            }
520
+	            // speed
521
+	            if (isset($line[5])) {
522
+	            	$data['heading'] = $line[5];
523
+	            }
524
+	            // heading
525
+	            if (isset($line[6])) {
526
+	            	$data['latitude'] = $line[6];
527
+	            }
528
+	            // lat
529
+	            if (isset($line[7])) {
530
+	            	$data['longitude'] = $line[7];
531
+	            }
532
+	            // long
399 533
 	            $data['verticalrate'] = ''; // vertical rate
400 534
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
401 535
 	            $data['emergency'] = ''; // emergency
402 536
 		    $data['datetime'] = date('Y-m-d H:i:s');
403 537
 		    $data['format_source'] = 'deltadbtxt';
404 538
     		    $data['id_source'] = $id_source;
405
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
406
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
407
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
539
+		    if (isset($value['name']) && $value['name'] != '') {
540
+		    	$data['source_name'] = $value['name'];
541
+		    }
542
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
543
+		    	$data['noarchive'] = true;
544
+		    }
545
+		    if (isset($value['sourcestats'])) {
546
+		    	$data['sourcestats'] = $value['sourcestats'];
547
+		    }
408 548
     		    $SI->add($data);
409 549
 		    unset($data);
410 550
     		}
@@ -414,7 +554,9 @@  discard block
 block discarded – undo
414 554
 	    date_default_timezone_set('CET');
415 555
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
416 556
 	    date_default_timezone_set('UTC');
417
-	    if ($buffer != '') $reset = 0;
557
+	    if ($buffer != '') {
558
+	    	$reset = 0;
559
+	    }
418 560
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
419 561
 	    $buffer = explode('\n',$buffer);
420 562
 	    foreach ($buffer as $line) {
@@ -423,16 +565,36 @@  discard block
 block discarded – undo
423 565
 		    $add = false;
424 566
 		    $ais_data = $AIS->parse_line(trim($line));
425 567
 		    $data = array();
426
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
427
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
428
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
429
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
430
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
431
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
432
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
433
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
434
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
435
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
568
+		    if (isset($ais_data['ident'])) {
569
+		    	$data['ident'] = $ais_data['ident'];
570
+		    }
571
+		    if (isset($ais_data['mmsi'])) {
572
+		    	$data['mmsi'] = $ais_data['mmsi'];
573
+		    }
574
+		    if (isset($ais_data['speed'])) {
575
+		    	$data['speed'] = $ais_data['speed'];
576
+		    }
577
+		    if (isset($ais_data['heading'])) {
578
+		    	$data['heading'] = $ais_data['heading'];
579
+		    }
580
+		    if (isset($ais_data['latitude'])) {
581
+		    	$data['latitude'] = $ais_data['latitude'];
582
+		    }
583
+		    if (isset($ais_data['longitude'])) {
584
+		    	$data['longitude'] = $ais_data['longitude'];
585
+		    }
586
+		    if (isset($ais_data['status'])) {
587
+		    	$data['status'] = $ais_data['status'];
588
+		    }
589
+		    if (isset($ais_data['type'])) {
590
+		    	$data['type'] = $ais_data['type'];
591
+		    }
592
+		    if (isset($ais_data['imo'])) {
593
+		    	$data['imo'] = $ais_data['imo'];
594
+		    }
595
+		    if (isset($ais_data['callsign'])) {
596
+		    	$data['callsign'] = $ais_data['callsign'];
597
+		    }
436 598
 		    if (isset($ais_data['timestamp'])) {
437 599
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
438 600
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -446,8 +608,12 @@  discard block
 block discarded – undo
446 608
 		    $data['format_source'] = 'aisnmeatxt';
447 609
     		    $data['id_source'] = $id_source;
448 610
 		    //print_r($data);
449
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
450
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
611
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
612
+		    	$data['noarchive'] = true;
613
+		    }
614
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
615
+		    	$MI->add($data);
616
+		    }
451 617
 		    unset($data);
452 618
 		}
453 619
     	    }
@@ -467,20 +633,48 @@  discard block
 block discarded – undo
467 633
 			    if ($line != '') {
468 634
 				$ais_data = $AIS->parse_line(trim($line));
469 635
 				$data = array();
470
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
471
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
472
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
473
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
474
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
475
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
476
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
477
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
478
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
479
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
480
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
481
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
482
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
483
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
636
+				if (isset($ais_data['ident'])) {
637
+					$data['ident'] = $ais_data['ident'];
638
+				}
639
+				if (isset($ais_data['mmsi'])) {
640
+					$data['mmsi'] = $ais_data['mmsi'];
641
+				}
642
+				if (isset($ais_data['speed'])) {
643
+					$data['speed'] = $ais_data['speed'];
644
+				}
645
+				if (isset($ais_data['heading'])) {
646
+					$data['heading'] = $ais_data['heading'];
647
+				}
648
+				if (isset($ais_data['latitude'])) {
649
+					$data['latitude'] = $ais_data['latitude'];
650
+				}
651
+				if (isset($ais_data['longitude'])) {
652
+					$data['longitude'] = $ais_data['longitude'];
653
+				}
654
+				if (isset($ais_data['status'])) {
655
+					$data['status'] = $ais_data['status'];
656
+				}
657
+				if (isset($ais_data['statusid'])) {
658
+					$data['status_id'] = $ais_data['statusid'];
659
+				}
660
+				if (isset($ais_data['type'])) {
661
+					$data['type'] = $ais_data['type'];
662
+				}
663
+				if (isset($ais_data['typeid'])) {
664
+					$data['type_id'] = $ais_data['typeid'];
665
+				}
666
+				if (isset($ais_data['imo'])) {
667
+					$data['imo'] = $ais_data['imo'];
668
+				}
669
+				if (isset($ais_data['callsign'])) {
670
+					$data['callsign'] = $ais_data['callsign'];
671
+				}
672
+				if (isset($ais_data['destination'])) {
673
+					$data['arrival_code'] = $ais_data['destination'];
674
+				}
675
+				if (isset($ais_data['eta_ts'])) {
676
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
677
+				}
484 678
 				if (isset($ais_data['timestamp'])) {
485 679
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
486 680
 				} else {
@@ -488,18 +682,27 @@  discard block
 block discarded – undo
488 682
 				}
489 683
 				$data['format_source'] = 'aisnmeahttp';
490 684
 				$data['id_source'] = $id_source;
491
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
492
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
685
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
686
+					$data['noarchive'] = true;
687
+				}
688
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
689
+					$MI->add($data);
690
+				}
493 691
 				unset($data);
494 692
 			    }
495 693
 			}
496 694
 		    }
497 695
 		} else {
498 696
 		    $format = $value['format'];
499
-		    if (isset($tt[$format])) $tt[$format]++;
500
-		    else $tt[$format] = 0;
697
+		    if (isset($tt[$format])) {
698
+		    	$tt[$format]++;
699
+		    } else {
700
+		    	$tt[$format] = 0;
701
+		    }
501 702
 		    if ($tt[$format] > 30) {
502
-			if ($globalDebug) echo 'Reconnect...'."\n";
703
+			if ($globalDebug) {
704
+				echo 'Reconnect...'."\n";
705
+			}
503 706
 			sleep(2);
504 707
 			$sourceeen[] = $value;
505 708
 			connect_all($sourceeen);
@@ -529,7 +732,9 @@  discard block
 block discarded – undo
529 732
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
530 733
 			    $data['format_source'] = 'myshiptracking';
531 734
 			    $data['id_source'] = $id_source;
532
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
735
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
736
+			    	$data['noarchive'] = true;
737
+			    }
533 738
 			    $MI->add($data);
534 739
 			    unset($data);
535 740
 			}
@@ -549,7 +754,9 @@  discard block
 block discarded – undo
549 754
 			    $data['callsign'] = $line['callsign'];
550 755
 			    $data['mmsi'] = $line['mmsi'];
551 756
 			    $data['speed'] = $line['sog'];
552
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
757
+			    if ($line['heading'] != '511') {
758
+			    	$data['heading'] = $line['heading'];
759
+			    }
553 760
 			    $data['latitude'] = $line['latitude'];
554 761
 			    $data['longitude'] = $line['longitude'];
555 762
 			    $data['type_id'] = $line['shiptype'];
@@ -557,7 +764,9 @@  discard block
 block discarded – undo
557 764
 			    $data['datetime'] = $line['time'];
558 765
 			    $data['format_source'] = 'boatbeaconapp';
559 766
 			    $data['id_source'] = $id_source;
560
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
767
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
768
+			    	$data['noarchive'] = true;
769
+			    }
561 770
 			    $MI->add($data);
562 771
 			    unset($data);
563 772
 			}
@@ -573,22 +782,44 @@  discard block
 block discarded – undo
573 782
 		if (isset($all_data['features'][0]['id'])) {
574 783
 		    foreach ($all_data['features'] as $line) {
575 784
 			$data = array();
576
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
577
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
578
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi'];
579
-			if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo'];
580
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
581
-			if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading'];
785
+			if (isset($line['properties']['name'])) {
786
+				$data['ident'] = $line['properties']['name'];
787
+			}
788
+			if (isset($line['properties']['callsign'])) {
789
+				$data['callsign'] = $line['properties']['callsign'];
790
+			}
791
+			if (isset($line['properties']['mmsi'])) {
792
+				$data['mmsi'] = $line['properties']['mmsi'];
793
+			}
794
+			if (isset($line['properties']['imo'])) {
795
+				$data['mmsi'] = $line['properties']['imo'];
796
+			}
797
+			if (isset($line['properties']['speed'])) {
798
+				$data['speed'] = $line['properties']['speed'];
799
+			}
800
+			if (isset($line['properties']['heading'])) {
801
+				$data['heading'] = $line['properties']['heading'];
802
+			}
582 803
 			$data['latitude'] = $line['geometry']['coordinates'][1];
583 804
 			$data['longitude'] = $line['geometry']['coordinates'][0];
584
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
585
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
586
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
805
+			if (isset($line['properties']['vesselType'])) {
806
+				$data['type'] = $line['properties']['vesselType'];
807
+			}
808
+			if (isset($line['properties']['destination'])) {
809
+				$data['arrival_code'] = $line['properties']['destination'];
810
+			}
811
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
812
+				$data['arrival_date'] = $line['properties']['eta'];
813
+			}
587 814
 			$data['format_source'] = 'boatnerd';
588 815
 			$data['id_source'] = $id_source;
589 816
 			$data['datetime'] = date('Y-m-d H:i:s');
590
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
591
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
817
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
818
+				$data['noarchive'] = true;
819
+			}
820
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
821
+				$MI->add($data);
822
+			}
592 823
 			unset($data);
593 824
 		    }
594 825
 		}
@@ -599,7 +830,9 @@  discard block
 block discarded – undo
599 830
 	    echo 'download...';
600 831
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
601 832
 	    echo 'done !'."\n";
602
-	    if ($buffer != '') $reset = 0;
833
+	    if ($buffer != '') {
834
+	    	$reset = 0;
835
+	    }
603 836
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
604 837
 	    $buffer = explode('\n',$buffer);
605 838
 	    foreach ($buffer as $line) {
@@ -624,7 +857,9 @@  discard block
 block discarded – undo
624 857
 		    //$data['etaTime'] = substr($line,135,5);
625 858
 		    $data['format_source'] = 'shipplotter';
626 859
     		    $data['id_source'] = $id_source;
627
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
860
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
861
+		    	$data['noarchive'] = true;
862
+		    }
628 863
 		    //print_r($data);
629 864
 		    echo 'Add...'."\n";
630 865
 		    $MI->add($data);
@@ -644,16 +879,28 @@  discard block
 block discarded – undo
644 879
     		    $line = explode(':', $line);
645 880
     		    if (count($line) > 30 && $line[0] != 'callsign') {
646 881
 			$data = array();
647
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
648
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
882
+			if (isset($line[37]) && $line[37] != '') {
883
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
884
+			} else {
885
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
886
+			}
649 887
 			$data['pilot_id'] = $line[1];
650 888
 			$data['pilot_name'] = $line[2];
651 889
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
652 890
 			$data['ident'] = $line[0]; // ident
653
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
891
+			if ($line[7] != '' && $line[7] != 0) {
892
+				$data['altitude'] = $line[7];
893
+			}
894
+			// altitude
654 895
 			$data['speed'] = $line[8]; // speed
655
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
656
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
896
+			if (isset($line[45])) {
897
+				$data['heading'] = $line[45];
898
+			}
899
+			// heading
900
+			elseif (isset($line[38])) {
901
+				$data['heading'] = $line[38];
902
+			}
903
+			// heading
657 904
 			$data['latitude'] = $line[5]; // lat
658 905
 	        	$data['longitude'] = $line[6]; // long
659 906
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -669,7 +916,9 @@  discard block
 block discarded – undo
669 916
 			$data['frequency'] = $line[4];
670 917
 			$data['type'] = $line[18];
671 918
 			$data['range'] = $line[19];
672
-			if (isset($line[35])) $data['info'] = $line[35];
919
+			if (isset($line[35])) {
920
+				$data['info'] = $line[35];
921
+			}
673 922
     			$data['id_source'] = $id_source;
674 923
 	    		//$data['arrival_airport_time'] = ;
675 924
 	    		if ($line[9] != '') {
@@ -683,27 +932,47 @@  discard block
 block discarded – undo
683 932
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
684 933
 	    		*/
685 934
 	    		$data['format_source'] = $value['format'];
686
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
687
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
688
-    			if ($line[3] == 'PILOT') $SI->add($data);
689
-			elseif ($line[3] == 'ATC') {
935
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
936
+				$data['noarchive'] = true;
937
+			}
938
+			if (isset($value['name']) && $value['name'] != '') {
939
+				$data['source_name'] = $value['name'];
940
+			}
941
+    			if ($line[3] == 'PILOT') {
942
+    				$SI->add($data);
943
+    			} elseif ($line[3] == 'ATC') {
690 944
 				//print_r($data);
691 945
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
692 946
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
693 947
 				$typec = substr($data['ident'],-3);
694
-				if ($typec == 'APP') $data['type'] = 'Approach';
695
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
696
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
697
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
698
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
699
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
700
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
701
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
702
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
703
-				if (!isset($data['source_name'])) $data['source_name'] = '';
948
+				if ($typec == 'APP') {
949
+					$data['type'] = 'Approach';
950
+				} elseif ($typec == 'TWR') {
951
+					$data['type'] = 'Tower';
952
+				} elseif ($typec == 'OBS') {
953
+					$data['type'] = 'Observer';
954
+				} elseif ($typec == 'GND') {
955
+					$data['type'] = 'Ground';
956
+				} elseif ($typec == 'DEL') {
957
+					$data['type'] = 'Delivery';
958
+				} elseif ($typec == 'DEP') {
959
+					$data['type'] = 'Departure';
960
+				} elseif ($typec == 'FSS') {
961
+					$data['type'] = 'Flight Service Station';
962
+				} elseif ($typec == 'CTR') {
963
+					$data['type'] = 'Control Radar or Centre';
964
+				} elseif ($data['type'] == '') {
965
+					$data['type'] = 'Observer';
966
+				}
967
+				if (!isset($data['source_name'])) {
968
+					$data['source_name'] = '';
969
+				}
704 970
 				if (isset($ATC)) {
705
-					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']);
706
-					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']);
971
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
972
+						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']);
973
+					} else {
974
+						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']);
975
+					}
707 976
 				}
708 977
 			}
709 978
     			unset($data);
@@ -725,14 +994,20 @@  discard block
 block discarded – undo
725 994
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
726 995
 			$data['latitude'] = (float)$line['pktLatitude'];
727 996
 			$data['longitude'] = (float)$line['pktLongitude'];
728
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
729
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
997
+			if ((float)$line['pktTrack'] != 0) {
998
+				$data['heading'] = (float)$line['pktTrack'];
999
+			}
1000
+			if ((int)$line['pktSpeed'] != 0) {
1001
+				$data['speed'] = (int)$line['pktSpeed'];
1002
+			}
730 1003
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
731 1004
 			$data['altitude_relative'] = 'AMSL';
732 1005
 			$data['pilot_id'] = (int)$line['pktPilotID'];
733 1006
 			$data['aircraft_icao'] = 'PARAGLIDER';
734 1007
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
735
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1008
+			if (isset($pilot_data[4])) {
1009
+				$data['pilot_name'] = $pilot_data[4];
1010
+			}
736 1011
 			$data['format_source'] = $value['format'];
737 1012
 			$SI->add($data);
738 1013
 			unset($data);
@@ -769,27 +1044,61 @@  discard block
 block discarded – undo
769 1044
 		foreach ($all_data['acList'] as $line) {
770 1045
 		    $data = array();
771 1046
 		    $data['hex'] = $line['Icao']; // hex
772
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
773
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
774
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
775
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
776
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
777
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1047
+		    if (isset($line['Call'])) {
1048
+		    	$data['ident'] = $line['Call'];
1049
+		    }
1050
+		    // ident
1051
+		    if (isset($line['Alt'])) {
1052
+		    	$data['altitude'] = $line['Alt'];
1053
+		    }
1054
+		    // altitude
1055
+		    if (isset($line['Spd'])) {
1056
+		    	$data['speed'] = $line['Spd'];
1057
+		    }
1058
+		    // speed
1059
+		    if (isset($line['Trak'])) {
1060
+		    	$data['heading'] = $line['Trak'];
1061
+		    }
1062
+		    // heading
1063
+		    if (isset($line['Lat'])) {
1064
+		    	$data['latitude'] = $line['Lat'];
1065
+		    }
1066
+		    // lat
1067
+		    if (isset($line['Long'])) {
1068
+		    	$data['longitude'] = $line['Long'];
1069
+		    }
1070
+		    // long
778 1071
 		    //$data['verticalrate'] = $line['']; // verticale rate
779
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1072
+		    if (isset($line['Sqk'])) {
1073
+		    	$data['squawk'] = $line['Sqk'];
1074
+		    }
1075
+		    // squawk
780 1076
 		    $data['emergency'] = ''; // emergency
781
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1077
+		    if (isset($line['Reg'])) {
1078
+		    	$data['registration'] = $line['Reg'];
1079
+		    }
782 1080
 		    
783
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
784
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1081
+		    if (isset($line['PosTime'])) {
1082
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1083
+		    } else {
1084
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1085
+		    }
785 1086
 		    
786 1087
 		    //$data['datetime'] = date('Y-m-d H:i:s');
787
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1088
+		    if (isset($line['Type'])) {
1089
+		    	$data['aircraft_icao'] = $line['Type'];
1090
+		    }
788 1091
 	    	    $data['format_source'] = 'aircraftlistjson';
789 1092
 		    $data['id_source'] = $id_source;
790
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
791
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
792
-		    if (isset($data['latitude'])) $SI->add($data);
1093
+		    if (isset($value['name']) && $value['name'] != '') {
1094
+		    	$data['source_name'] = $value['name'];
1095
+		    }
1096
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1097
+		    	$data['noarchive'] = true;
1098
+		    }
1099
+		    if (isset($data['latitude'])) {
1100
+		    	$SI->add($data);
1101
+		    }
793 1102
 		    unset($data);
794 1103
 		}
795 1104
 	    } elseif (is_array($all_data)) {
@@ -806,12 +1115,19 @@  discard block
 block discarded – undo
806 1115
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
807 1116
 		    $data['squawk'] = $line['squawk']; // squawk
808 1117
 		    $data['emergency'] = ''; // emergency
809
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
810
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1118
+		    if (isset($line['PosTime'])) {
1119
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1120
+		    } else {
1121
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1122
+		    }
811 1123
 	    	    $data['format_source'] = 'aircraftlistjson';
812 1124
     		    $data['id_source'] = $id_source;
813
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
814
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1125
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1126
+		    	$data['noarchive'] = true;
1127
+		    }
1128
+		    if (isset($value['name']) && $value['name'] != '') {
1129
+		    	$data['source_name'] = $value['name'];
1130
+		    }
815 1131
 		    $SI->add($data);
816 1132
 		    unset($data);
817 1133
 		}
@@ -847,8 +1163,12 @@  discard block
 block discarded – undo
847 1163
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
848 1164
 	    	    $data['format_source'] = 'planeupdatefaa';
849 1165
     		    $data['id_source'] = $id_source;
850
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
851
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1166
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1167
+		    	$data['noarchive'] = true;
1168
+		    }
1169
+		    if (isset($value['name']) && $value['name'] != '') {
1170
+		    	$data['source_name'] = $value['name'];
1171
+		    }
852 1172
 		    $SI->add($data);
853 1173
 		    unset($data);
854 1174
 		}
@@ -877,7 +1197,9 @@  discard block
 block discarded – undo
877 1197
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
878 1198
 	    	    $data['format_source'] = 'opensky';
879 1199
     		    $data['id_source'] = $id_source;
880
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1200
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1201
+		    	$data['noarchive'] = true;
1202
+		    }
881 1203
 		    $SI->add($data);
882 1204
 		    unset($data);
883 1205
 		}
@@ -889,7 +1211,9 @@  discard block
 block discarded – undo
889 1211
 	    //$buffer = $Common->getData($hosts[$id]);
890 1212
 	    $buffer = $Common->getData($value['host']);
891 1213
 	    $all_data = json_decode($buffer,true);
892
-	    if (!empty($all_data)) $reset = 0;
1214
+	    if (!empty($all_data)) {
1215
+	    	$reset = 0;
1216
+	    }
893 1217
 	    foreach ($all_data as $key => $line) {
894 1218
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
895 1219
 		    $data = array();
@@ -910,8 +1234,12 @@  discard block
 block discarded – undo
910 1234
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
911 1235
 	    	    $data['format_source'] = 'fr24json';
912 1236
     		    $data['id_source'] = $id_source;
913
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
914
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1237
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1238
+		    	$data['noarchive'] = true;
1239
+		    }
1240
+		    if (isset($value['name']) && $value['name'] != '') {
1241
+		    	$data['source_name'] = $value['name'];
1242
+		    }
915 1243
 		    $SI->add($data);
916 1244
 		    unset($data);
917 1245
 		}
@@ -935,24 +1263,42 @@  discard block
 block discarded – undo
935 1263
 		    if (isset($line['inf'])) {
936 1264
 			$data = array();
937 1265
 			$data['hex'] = $line['inf']['ia'];
938
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1266
+			if (isset($line['inf']['cs'])) {
1267
+				$data['ident'] = $line['inf']['cs'];
1268
+			}
1269
+			//$line[13]
939 1270
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
940
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
941
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1271
+	    		if (isset($line['inf']['gs'])) {
1272
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1273
+	    		}
1274
+	    		// speed
1275
+	    		if (isset($line['inf']['tr'])) {
1276
+	    			$data['heading'] = $line['inf']['tr'];
1277
+	    		}
1278
+	    		// heading
942 1279
 	    		$data['latitude'] = $line['pt'][0]; // lat
943 1280
 	    		$data['longitude'] = $line['pt'][1]; // long
944 1281
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
945
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1282
+	    		if (isset($line['inf']['sq'])) {
1283
+	    			$data['squawk'] = $line['inf']['sq'];
1284
+	    		}
1285
+	    		// squawk
946 1286
 	    		//$data['aircraft_icao'] = $line[8];
947
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1287
+	    		if (isset($line['inf']['rc'])) {
1288
+	    			$data['registration'] = $line['inf']['rc'];
1289
+	    		}
948 1290
 			//$data['departure_airport_iata'] = $line[11];
949 1291
 			//$data['arrival_airport_iata'] = $line[12];
950 1292
 	    		//$data['emergency'] = ''; // emergency
951 1293
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
952 1294
 	    		$data['format_source'] = 'radarvirtueljson';
953 1295
     			$data['id_source'] = $id_source;
954
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
955
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1296
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1297
+				$data['noarchive'] = true;
1298
+			}
1299
+			if (isset($value['name']) && $value['name'] != '') {
1300
+				$data['source_name'] = $value['name'];
1301
+			}
956 1302
 			$SI->add($data);
957 1303
 			unset($data);
958 1304
 		    }
@@ -973,30 +1319,65 @@  discard block
 block discarded – undo
973 1319
 		    $data['id'] = $line['id'];
974 1320
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
975 1321
 		    $data['ident'] = $line['callsign']; // ident
976
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
977
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
978
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
979
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
980
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
981
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1322
+		    if (isset($line['pilotid'])) {
1323
+		    	$data['pilot_id'] = $line['pilotid'];
1324
+		    }
1325
+		    // pilot id
1326
+		    if (isset($line['name'])) {
1327
+		    	$data['pilot_name'] = $line['name'];
1328
+		    }
1329
+		    // pilot name
1330
+		    if (isset($line['alt'])) {
1331
+		    	$data['altitude'] = $line['alt'];
1332
+		    }
1333
+		    // altitude
1334
+		    if (isset($line['gs'])) {
1335
+		    	$data['speed'] = $line['gs'];
1336
+		    }
1337
+		    // speed
1338
+		    if (isset($line['heading'])) {
1339
+		    	$data['heading'] = $line['heading'];
1340
+		    }
1341
+		    // heading
1342
+		    if (isset($line['route'])) {
1343
+		    	$data['waypoints'] = $line['route'];
1344
+		    }
1345
+		    // route
982 1346
 		    $data['latitude'] = $line['lat']; // lat
983 1347
 		    $data['longitude'] = $line['lon']; // long
984 1348
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
985 1349
 		    //$data['squawk'] = $line['squawk']; // squawk
986 1350
 		    //$data['emergency'] = ''; // emergency
987
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
988
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
989
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1351
+		    if (isset($line['depicao'])) {
1352
+		    	$data['departure_airport_icao'] = $line['depicao'];
1353
+		    }
1354
+		    if (isset($line['deptime'])) {
1355
+		    	$data['departure_airport_time'] = $line['deptime'];
1356
+		    }
1357
+		    if (isset($line['arricao'])) {
1358
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1359
+		    }
990 1360
 		    //$data['arrival_airport_time'] = $line['arrtime'];
991
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
992
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
993
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
994
-		    else $data['info'] = '';
1361
+		    if (isset($line['aircraft'])) {
1362
+		    	$data['aircraft_icao'] = $line['aircraft'];
1363
+		    }
1364
+		    if (isset($line['transponder'])) {
1365
+		    	$data['squawk'] = $line['transponder'];
1366
+		    }
1367
+		    if (isset($line['atis'])) {
1368
+		    	$data['info'] = $line['atis'];
1369
+		    } else {
1370
+		    	$data['info'] = '';
1371
+		    }
995 1372
 		    $data['format_source'] = 'pireps';
996 1373
     		    $data['id_source'] = $id_source;
997 1374
 		    $data['datetime'] = date('Y-m-d H:i:s');
998
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
999
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1375
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1376
+		    	$data['noarchive'] = true;
1377
+		    }
1378
+		    if (isset($value['name']) && $value['name'] != '') {
1379
+		    	$data['source_name'] = $value['name'];
1380
+		    }
1000 1381
 		    if ($line['icon'] == 'plane') {
1001 1382
 			$SI->add($data);
1002 1383
 		    //    print_r($data);
@@ -1005,16 +1386,28 @@  discard block
 block discarded – undo
1005 1386
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1006 1387
 			$typec = substr($data['ident'],-3);
1007 1388
 			$data['type'] = '';
1008
-			if ($typec == 'APP') $data['type'] = 'Approach';
1009
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
1010
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
1011
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
1012
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
1013
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
1014
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1015
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1016
-			else $data['type'] = 'Observer';
1017
-			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']);
1389
+			if ($typec == 'APP') {
1390
+				$data['type'] = 'Approach';
1391
+			} elseif ($typec == 'TWR') {
1392
+				$data['type'] = 'Tower';
1393
+			} elseif ($typec == 'OBS') {
1394
+				$data['type'] = 'Observer';
1395
+			} elseif ($typec == 'GND') {
1396
+				$data['type'] = 'Ground';
1397
+			} elseif ($typec == 'DEL') {
1398
+				$data['type'] = 'Delivery';
1399
+			} elseif ($typec == 'DEP') {
1400
+				$data['type'] = 'Departure';
1401
+			} elseif ($typec == 'FSS') {
1402
+				$data['type'] = 'Flight Service Station';
1403
+			} elseif ($typec == 'CTR') {
1404
+				$data['type'] = 'Control Radar or Centre';
1405
+			} else {
1406
+				$data['type'] = 'Observer';
1407
+			}
1408
+			if (isset($ATC)) {
1409
+				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']);
1410
+			}
1018 1411
 		    }
1019 1412
 		    unset($data);
1020 1413
 		}
@@ -1024,7 +1417,9 @@  discard block
 block discarded – undo
1024 1417
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1025 1418
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1026 1419
 	    //$buffer = $Common->getData($hosts[$id]);
1027
-	    if ($globalDebug) echo 'Get Data...'."\n";
1420
+	    if ($globalDebug) {
1421
+	    	echo 'Get Data...'."\n";
1422
+	    }
1028 1423
 	    $buffer = $Common->getData($value['host']);
1029 1424
 	    $all_data = json_decode($buffer,true);
1030 1425
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1032,10 +1427,16 @@  discard block
 block discarded – undo
1032 1427
 		foreach ($all_data as $line) {
1033 1428
 	    	    $data = array();
1034 1429
 	    	    //$data['id'] = $line['id']; // id not usable
1035
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1430
+	    	    if (isset($line['pilotid'])) {
1431
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1432
+	    	    }
1036 1433
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1037
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1038
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1434
+	    	    if (isset($line['pilotname'])) {
1435
+	    	    	$data['pilot_name'] = $line['pilotname'];
1436
+	    	    }
1437
+	    	    if (isset($line['pilotid'])) {
1438
+	    	    	$data['pilot_id'] = $line['pilotid'];
1439
+	    	    }
1039 1440
 	    	    $data['ident'] = $line['flightnum']; // ident
1040 1441
 	    	    $data['altitude'] = $line['alt']; // altitude
1041 1442
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1051,34 +1452,52 @@  discard block
 block discarded – undo
1051 1452
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1052 1453
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1053 1454
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1054
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1455
+	    	    } else {
1456
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1457
+	    	    }
1055 1458
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1056 1459
 	    	    $data['departure_airport_time'] = $line['deptime'];
1057 1460
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
1058 1461
     		    $data['arrival_airport_time'] = $line['arrtime'];
1059 1462
     		    $data['registration'] = $line['aircraft'];
1060
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1061
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1463
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1464
+		    	$data['noarchive'] = true;
1465
+		    }
1466
+		    if (isset($line['route'])) {
1467
+		    	$data['waypoints'] = $line['route'];
1468
+		    }
1469
+		    // route
1062 1470
 		    if (isset($line['aircraftname'])) {
1063 1471
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1064 1472
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1065 1473
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1066
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1067
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1068
-	    		else {
1474
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1475
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1476
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1477
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1478
+	    		} else {
1069 1479
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1070
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1071
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1480
+	    		    if (isset($aircraft_data[1])) {
1481
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1482
+	    		    } else {
1483
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1484
+	    		    }
1072 1485
 	    		}
1073 1486
 	    	    }
1074
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1487
+    		    if (isset($line['route'])) {
1488
+    		    	$data['waypoints'] = $line['route'];
1489
+    		    }
1075 1490
     		    $data['id_source'] = $id_source;
1076 1491
 	    	    $data['format_source'] = 'phpvmacars';
1077
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1492
+		    if (isset($value['name']) && $value['name'] != '') {
1493
+		    	$data['source_name'] = $value['name'];
1494
+		    }
1078 1495
 		    $SI->add($data);
1079 1496
 		    unset($data);
1080 1497
 		}
1081
-		if ($globalDebug) echo 'No more data...'."\n";
1498
+		if ($globalDebug) {
1499
+			echo 'No more data...'."\n";
1500
+		}
1082 1501
 		unset($buffer);
1083 1502
 		unset($all_data);
1084 1503
 	    }
@@ -1086,7 +1505,9 @@  discard block
 block discarded – undo
1086 1505
     	    $last_exec[$id]['last'] = time();
1087 1506
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1088 1507
 	    //$buffer = $Common->getData($hosts[$id]);
1089
-	    if ($globalDebug) echo 'Get Data...'."\n";
1508
+	    if ($globalDebug) {
1509
+	    	echo 'Get Data...'."\n";
1510
+	    }
1090 1511
 	    $buffer = $Common->getData($value['host']);
1091 1512
 	    $all_data = json_decode($buffer,true);
1092 1513
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1115,16 +1536,25 @@  discard block
 block discarded – undo
1115 1536
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1116 1537
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1117 1538
     		    //$data['registration'] = $line['aircraft'];
1118
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1539
+		    if (isset($line['route'])) {
1540
+		    	$data['waypoints'] = $line['route'];
1541
+		    }
1542
+		    // route
1119 1543
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1120 1544
     		    $data['id_source'] = $id_source;
1121 1545
 	    	    $data['format_source'] = 'vam';
1122
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1123
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1546
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1547
+		    	$data['noarchive'] = true;
1548
+		    }
1549
+		    if (isset($value['name']) && $value['name'] != '') {
1550
+		    	$data['source_name'] = $value['name'];
1551
+		    }
1124 1552
 		    $SI->add($data);
1125 1553
 		    unset($data);
1126 1554
 		}
1127
-		if ($globalDebug) echo 'No more data...'."\n";
1555
+		if ($globalDebug) {
1556
+			echo 'No more data...'."\n";
1557
+		}
1128 1558
 		unset($buffer);
1129 1559
 		unset($all_data);
1130 1560
 	    }
@@ -1132,7 +1562,9 @@  discard block
 block discarded – undo
1132 1562
     	    $last_exec[$id]['last'] = time();
1133 1563
     	} elseif ($value['format'] == 'blitzortung' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1134 1564
 	    //$buffer = $Common->getData($hosts[$id]);
1135
-	    if ($globalDebug) echo 'Get Data...'."\n";
1565
+	    if ($globalDebug) {
1566
+	    	echo 'Get Data...'."\n";
1567
+	    }
1136 1568
 	    $buffer = $Common->getData($value['host']);
1137 1569
 	    $all_data = json_decode($buffer,true);
1138 1570
 	    if ($buffer != '') {
@@ -1150,18 +1582,24 @@  discard block
 block discarded – undo
1150 1582
 			$data['id_source'] = $id_source;
1151 1583
 			$data['format_source'] = 'blitzortung';
1152 1584
 			$SI->add($data);
1153
-			if ($globalDebug) echo '☈ Lightning added'."\n";
1585
+			if ($globalDebug) {
1586
+				echo '☈ Lightning added'."\n";
1587
+			}
1154 1588
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1155 1589
 			unset($data);
1156 1590
 		    }
1157 1591
 		}
1158
-		if ($globalDebug) echo 'No more data...'."\n";
1592
+		if ($globalDebug) {
1593
+			echo 'No more data...'."\n";
1594
+		}
1159 1595
 		unset($buffer);
1160 1596
 	    }
1161 1597
 	    $last_exec[$id]['last'] = time();
1162 1598
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1163 1599
 	} 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') {
1164
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1600
+	    if (function_exists('pcntl_fork')) {
1601
+	    	pcntl_signal_dispatch();
1602
+	    }
1165 1603
     	    //$last_exec[$id]['last'] = time();
1166 1604
 
1167 1605
 	    //$read = array( $sockets[$id] );
@@ -1169,7 +1607,9 @@  discard block
 block discarded – undo
1169 1607
 	    $write = NULL;
1170 1608
 	    $e = NULL;
1171 1609
 	    $n = socket_select($read, $write, $e, $timeout);
1172
-	    if ($e != NULL) var_dump($e);
1610
+	    if ($e != NULL) {
1611
+	    	var_dump($e);
1612
+	    }
1173 1613
 	    if ($n > 0) {
1174 1614
 		$reset = 0;
1175 1615
 		foreach ($read as $nb => $r) {
@@ -1190,12 +1630,16 @@  discard block
 block discarded – undo
1190 1630
 		    //$SI::del();
1191 1631
 		    if ($format == 'vrstcp') {
1192 1632
 			$buffer = explode('},{',$buffer);
1193
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1633
+		    } else {
1634
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1635
+		    }
1194 1636
 		    // SBS format is CSV format
1195 1637
 		    if ($buffer !== FALSE && $buffer != '') {
1196 1638
 			$tt[$format] = 0;
1197 1639
 			if ($format == 'acarssbs3') {
1198
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1640
+			    if ($globalDebug) {
1641
+			    	echo 'ACARS : '.$buffer."\n";
1642
+			    }
1199 1643
 			    $ACARS->add(trim($buffer));
1200 1644
 			    $ACARS->deleteLiveAcarsData();
1201 1645
 			} elseif ($format == 'raw') {
@@ -1204,30 +1648,70 @@  discard block
 block discarded – undo
1204 1648
 			    if (is_array($data)) {
1205 1649
 				$data['datetime'] = date('Y-m-d H:i:s');
1206 1650
 				$data['format_source'] = 'raw';
1207
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1208
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1209
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1210
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1651
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1652
+					$data['source_name'] = $globalSources[$nb]['name'];
1653
+				}
1654
+				if (isset($globalSources[$nb]['sourcestats'])) {
1655
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1656
+				}
1657
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1658
+					$data['noarchive'] = true;
1659
+				}
1660
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1661
+					$SI->add($data);
1662
+				}
1211 1663
 			    }
1212 1664
 			} elseif ($format == 'ais') {
1213 1665
 			    $ais_data = $AIS->parse_line(trim($buffer));
1214 1666
 			    $data = array();
1215
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1216
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1217
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1218
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1219
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1220
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1221
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1222
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1223
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1224
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1225
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1226
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1227
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1228
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1229
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1230
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1667
+			    if (isset($ais_data['ident'])) {
1668
+			    	$data['ident'] = $ais_data['ident'];
1669
+			    }
1670
+			    if (isset($ais_data['mmsi'])) {
1671
+			    	$data['mmsi'] = $ais_data['mmsi'];
1672
+			    }
1673
+			    if (isset($ais_data['speed'])) {
1674
+			    	$data['speed'] = $ais_data['speed'];
1675
+			    }
1676
+			    if (isset($ais_data['heading'])) {
1677
+			    	$data['heading'] = $ais_data['heading'];
1678
+			    }
1679
+			    if (isset($ais_data['latitude'])) {
1680
+			    	$data['latitude'] = $ais_data['latitude'];
1681
+			    }
1682
+			    if (isset($ais_data['longitude'])) {
1683
+			    	$data['longitude'] = $ais_data['longitude'];
1684
+			    }
1685
+			    if (isset($ais_data['status'])) {
1686
+			    	$data['status'] = $ais_data['status'];
1687
+			    }
1688
+			    if (isset($ais_data['statusid'])) {
1689
+			    	$data['status_id'] = $ais_data['statusid'];
1690
+			    }
1691
+			    if (isset($ais_data['type'])) {
1692
+			    	$data['type'] = $ais_data['type'];
1693
+			    }
1694
+			    if (isset($ais_data['imo'])) {
1695
+			    	$data['imo'] = $ais_data['imo'];
1696
+			    }
1697
+			    if (isset($ais_data['callsign'])) {
1698
+			    	$data['callsign'] = $ais_data['callsign'];
1699
+			    }
1700
+			    if (isset($ais_data['destination'])) {
1701
+			    	$data['arrival_code'] = $ais_data['destination'];
1702
+			    }
1703
+			    if (isset($ais_data['eta_ts'])) {
1704
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1705
+			    }
1706
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1707
+			    	$data['noarchive'] = true;
1708
+			    }
1709
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1710
+			    	$data['source_name'] = $globalSources[$nb]['name'];
1711
+			    }
1712
+			    if (isset($globalSources[$nb]['sourcestats'])) {
1713
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1714
+			    }
1231 1715
 
1232 1716
 			    if (isset($ais_data['timestamp'])) {
1233 1717
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1236,7 +1720,9 @@  discard block
 block discarded – undo
1236 1720
 			    }
1237 1721
 			    $data['format_source'] = 'aisnmea';
1238 1722
     			    $data['id_source'] = $id_source;
1239
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1723
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1724
+			    	$MI->add($data);
1725
+			    }
1240 1726
 			    unset($data);
1241 1727
                         } elseif ($format == 'flightgearsp') {
1242 1728
                     	    //echo $buffer."\n";
@@ -1254,12 +1740,18 @@  discard block
 block discarded – undo
1254 1740
 				$data['speed'] = round($line[5]*1.94384);
1255 1741
 				$data['datetime'] = date('Y-m-d H:i:s');
1256 1742
 				$data['format_source'] = 'flightgearsp';
1257
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1258
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1743
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1744
+					$data['noarchive'] = true;
1745
+				}
1746
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1747
+					$SI->add($data);
1748
+				}
1259 1749
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1260 1750
 			    }
1261 1751
                         } elseif ($format == 'acars') {
1262
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1752
+                    	    if ($globalDebug) {
1753
+                    	    	echo 'ACARS : '.$buffer."\n";
1754
+                    	    }
1263 1755
 			    $ACARS->add(trim($buffer));
1264 1756
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1265 1757
 			    $ACARS->deleteLiveAcarsData();
@@ -1280,8 +1772,12 @@  discard block
 block discarded – undo
1280 1772
 				    $aircraft_type = $line[10];
1281 1773
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1282 1774
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1283
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1284
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1775
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1776
+				    	$data['noarchive'] = true;
1777
+				    }
1778
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1779
+				    	$SI->add($data);
1780
+				    }
1285 1781
 				}
1286 1782
 			    }
1287 1783
 			} elseif ($format == 'beast') {
@@ -1291,28 +1787,62 @@  discard block
 block discarded – undo
1291 1787
 			    foreach($buffer as $all_data) {
1292 1788
 				$line = json_decode('{'.$all_data.'}',true);
1293 1789
 				$data = array();
1294
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1295
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1296
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1297
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1298
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1299
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1300
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1790
+				if (isset($line['Icao'])) {
1791
+					$data['hex'] = $line['Icao'];
1792
+				}
1793
+				// hex
1794
+				if (isset($line['Call'])) {
1795
+					$data['ident'] = $line['Call'];
1796
+				}
1797
+				// ident
1798
+				if (isset($line['Alt'])) {
1799
+					$data['altitude'] = $line['Alt'];
1800
+				}
1801
+				// altitude
1802
+				if (isset($line['Spd'])) {
1803
+					$data['speed'] = $line['Spd'];
1804
+				}
1805
+				// speed
1806
+				if (isset($line['Trak'])) {
1807
+					$data['heading'] = $line['Trak'];
1808
+				}
1809
+				// heading
1810
+				if (isset($line['Lat'])) {
1811
+					$data['latitude'] = $line['Lat'];
1812
+				}
1813
+				// lat
1814
+				if (isset($line['Long'])) {
1815
+					$data['longitude'] = $line['Long'];
1816
+				}
1817
+				// long
1301 1818
 				//$data['verticalrate'] = $line['']; // verticale rate
1302
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1819
+				if (isset($line['Sqk'])) {
1820
+					$data['squawk'] = $line['Sqk'];
1821
+				}
1822
+				// squawk
1303 1823
 				$data['emergency'] = ''; // emergency
1304
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1824
+				if (isset($line['Reg'])) {
1825
+					$data['registration'] = $line['Reg'];
1826
+				}
1305 1827
 				/*
1306 1828
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1307 1829
 				else $data['datetime'] = date('Y-m-d H:i:s');
1308 1830
 				*/
1309 1831
 				$data['datetime'] = date('Y-m-d H:i:s');
1310
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1832
+				if (isset($line['Type'])) {
1833
+					$data['aircraft_icao'] = $line['Type'];
1834
+				}
1311 1835
 		    		$data['format_source'] = 'vrstcp';
1312 1836
 				$data['id_source'] = $id_source;
1313
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1314
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1315
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1837
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1838
+					$data['noarchive'] = true;
1839
+				}
1840
+				if (isset($value['name']) && $value['name'] != '') {
1841
+					$data['source_name'] = $value['name'];
1842
+				}
1843
+				if (isset($data['latitude']) && isset($data['hex'])) {
1844
+					$SI->add($data);
1845
+				}
1316 1846
 				unset($data);
1317 1847
 			    }
1318 1848
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1325,22 +1855,46 @@  discard block
 block discarded – undo
1325 1855
     				$data['hex'] = $lined['hexid'];
1326 1856
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1327 1857
     				$data['datetime'] = date('Y-m-d H:i:s');;
1328
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1329
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1330
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1331
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1332
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1333
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1334
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1858
+    				if (isset($lined['ident'])) {
1859
+    					$data['ident'] = $lined['ident'];
1860
+    				}
1861
+    				if (isset($lined['lat'])) {
1862
+    					$data['latitude'] = $lined['lat'];
1863
+    				}
1864
+    				if (isset($lined['lon'])) {
1865
+    					$data['longitude'] = $lined['lon'];
1866
+    				}
1867
+    				if (isset($lined['speed'])) {
1868
+    					$data['speed'] = $lined['speed'];
1869
+    				}
1870
+    				if (isset($lined['squawk'])) {
1871
+    					$data['squawk'] = $lined['squawk'];
1872
+    				}
1873
+    				if (isset($lined['alt'])) {
1874
+    					$data['altitude'] = $lined['alt'];
1875
+    				}
1876
+    				if (isset($lined['heading'])) {
1877
+    					$data['heading'] = $lined['heading'];
1878
+    				}
1335 1879
     				$data['id_source'] = $id_source;
1336 1880
     				$data['format_source'] = 'tsv';
1337
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1338
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1339
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1340
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1881
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1882
+    					$data['source_name'] = $globalSources[$nb]['name'];
1883
+    				}
1884
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1885
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1886
+    				}
1887
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1888
+					$data['noarchive'] = true;
1889
+				}
1890
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1891
+    					$SI->add($data);
1892
+    				}
1341 1893
     				unset($lined);
1342 1894
     				unset($data);
1343
-    			    } else $error = true;
1895
+    			    } else {
1896
+    			    	$error = true;
1897
+    			    }
1344 1898
 			} elseif ($format == 'aprs' && $use_aprs) {
1345 1899
 			    if ($aprs_connect == 0) {
1346 1900
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1365,59 +1919,117 @@  discard block
 block discarded – undo
1365 1919
 				    $aprs_last_tx = time();
1366 1920
 				    $data = array();
1367 1921
 				    //print_r($line);
1368
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1369
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1370
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1371
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1372
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1373
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1374
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1375
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1376
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1377
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1922
+				    if (isset($line['address'])) {
1923
+				    	$data['hex'] = $line['address'];
1924
+				    }
1925
+				    if (isset($line['mmsi'])) {
1926
+				    	$data['mmsi'] = $line['mmsi'];
1927
+				    }
1928
+				    if (isset($line['imo'])) {
1929
+				    	$data['imo'] = $line['imo'];
1930
+				    }
1931
+				    if (isset($line['squawk'])) {
1932
+				    	$data['squawk'] = $line['squawk'];
1933
+				    }
1934
+				    if (isset($line['arrival_code'])) {
1935
+				    	$data['arrical_code'] = $line['arrival_code'];
1936
+				    }
1937
+				    if (isset($line['arrival_date'])) {
1938
+				    	$data['arrical_date'] = $line['arrival_date'];
1939
+				    }
1940
+				    if (isset($line['type_id'])) {
1941
+				    	$data['type_id'] = $line['typeid'];
1942
+				    }
1943
+				    if (isset($line['status_id'])) {
1944
+				    	$data['status_id'] = $line['statusid'];
1945
+				    }
1946
+				    if (isset($line['timestamp'])) {
1947
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1948
+				    } else {
1949
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1950
+				    }
1378 1951
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1379
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1952
+				    if (isset($line['ident'])) {
1953
+				    	$data['ident'] = $line['ident'];
1954
+				    }
1380 1955
 				    $data['latitude'] = $line['latitude'];
1381 1956
 				    $data['longitude'] = $line['longitude'];
1382 1957
 				    //$data['verticalrate'] = $line[16];
1383
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1958
+				    if (isset($line['speed'])) {
1959
+				    	$data['speed'] = $line['speed'];
1960
+				    }
1384 1961
 				    //else $data['speed'] = 0;
1385
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1386
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1387
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1388
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1962
+				    if (isset($line['altitude'])) {
1963
+				    	$data['altitude'] = $line['altitude'];
1964
+				    }
1965
+				    if (isset($line['comment'])) {
1966
+				    	$data['comment'] = $line['comment'];
1967
+				    }
1968
+				    if (isset($line['symbol'])) {
1969
+				    	$data['type'] = $line['symbol'];
1970
+				    }
1971
+				    if (isset($line['heading'])) {
1972
+				    	$data['heading'] = $line['heading'];
1973
+				    }
1389 1974
 				    //else $data['heading'] = 0;
1390
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1975
+				    if (isset($line['stealth'])) {
1976
+				    	$data['aircraft_type'] = $line['stealth'];
1977
+				    }
1391 1978
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1392
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1393
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1394
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1395
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1979
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
1980
+				    	$data['noarchive'] = true;
1981
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
1982
+				    	$data['noarchive'] = false;
1983
+				    }
1984
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1985
+				    	$data['noarchive'] = true;
1986
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
1987
+				    	$data['noarchive'] = false;
1988
+				    }
1396 1989
     				    $data['id_source'] = $id_source;
1397
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1398
-				    else $data['format_source'] = 'aprs';
1990
+    				    if (isset($line['format_source'])) {
1991
+    				    	$data['format_source'] = $line['format_source'];
1992
+    				    } else {
1993
+				    	$data['format_source'] = 'aprs';
1994
+				    }
1399 1995
 				    $data['source_name'] = $line['source'];
1400
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1401
-				    else $data['source_type'] = 'flarm';
1402
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1996
+				    if (isset($line['source_type'])) {
1997
+				    	$data['source_type'] = $line['source_type'];
1998
+				    } else {
1999
+				    	$data['source_type'] = 'flarm';
2000
+				    }
2001
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2002
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2003
+    				    }
1403 2004
 				    $currentdate = date('Y-m-d H:i:s');
1404 2005
 				    $aprsdate = strtotime($data['datetime']);
1405
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2006
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2007
+				    	$data['altitude_relative'] = 'AMSL';
2008
+				    }
1406 2009
 				    // Accept data if time <= system time + 20s
1407 2010
 				    //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'])))) {
1408 2011
 				    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'])))) {
1409 2012
 					$send = $SI->add($data);
1410 2013
 				    } elseif ($data['source_type'] == 'ais') {
1411
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2014
+					if (isset($globalMarine) && $globalMarine) {
2015
+						$send = $MI->add($data);
2016
+					}
1412 2017
 				    } elseif (isset($line['stealth'])) {
1413
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1414
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2018
+					if ($line['stealth'] != 0) {
2019
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
2020
+					} else {
2021
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2022
+					}
1415 2023
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1416 2024
 					    //$line['symbol'] == 'Balloon' ||
1417 2025
 					    $line['symbol'] == 'Glider' || 
1418 2026
 					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1419
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1420
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2027
+					    if ($line['symbol'] == 'Ballon') {
2028
+					    	$data['aircraft_icao'] = 'BALL';
2029
+					    }
2030
+					    if ($line['symbol'] == 'Glider') {
2031
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2032
+					    }
1421 2033
 					    $send = $SI->add($data);
1422 2034
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1423 2035
 					    $line['symbol'] == 'Yacht (Sail)' || 
@@ -1448,9 +2060,13 @@  discard block
 block discarded – undo
1448 2060
 				    //} 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') {
1449 2061
 				//    } 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') {
1450 2062
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1451
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2063
+					if (isset($globalTracker) && $globalTracker) {
2064
+						$send = $TI->add($data);
2065
+					}
1452 2066
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1453
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2067
+					if (!isset($data['altitude'])) {
2068
+						$data['altitude'] = 0;
2069
+					}
1454 2070
 					$Source->deleteOldLocationByType('gs');
1455 2071
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1456 2072
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1459,7 +2075,9 @@  discard block
 block discarded – undo
1459 2075
 					}
1460 2076
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1461 2077
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1462
-					if ($globalDebug) echo '# Weather Station added'."\n";
2078
+					if ($globalDebug) {
2079
+						echo '# Weather Station added'."\n";
2080
+					}
1463 2081
 					$Source->deleteOldLocationByType('wx');
1464 2082
 					$weather_data = json_encode($line);
1465 2083
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1469,7 +2087,9 @@  discard block
 block discarded – undo
1469 2087
 					}
1470 2088
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1471 2089
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1472
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2090
+					if ($globalDebug) {
2091
+						echo '☈ Lightning added'."\n";
2092
+					}
1473 2093
 					$Source->deleteOldLocationByType('lightning');
1474 2094
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1475 2095
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1481,8 +2101,7 @@  discard block
 block discarded – undo
1481 2101
 				    	print_r($line);
1482 2102
 				    }
1483 2103
 				    unset($data);
1484
-				}
1485
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2104
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1486 2105
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1487 2106
 				}
1488 2107
 				/*
@@ -1491,7 +2110,9 @@  discard block
 block discarded – undo
1491 2110
 				}
1492 2111
 				*/
1493 2112
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1494
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2113
+				elseif ($line == true && $globalDebug) {
2114
+					echo '!! Failed : '.$buffer."!!\n";
2115
+				}
1495 2116
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1496 2117
 					$Source->deleteOldLocationByType('lightning');
1497 2118
 					$Source->deleteOldLocationByType('wx');
@@ -1527,26 +2148,45 @@  discard block
 block discarded – undo
1527 2148
     				$data['ground'] = $line[21];
1528 2149
     				$data['emergency'] = $line[19];
1529 2150
     				$data['format_source'] = 'sbs';
1530
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1531
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1532
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2151
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2152
+					$data['source_name'] = $globalSources[$nb]['name'];
2153
+				}
2154
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2155
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2156
+    				}
2157
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2158
+					$data['noarchive'] = true;
2159
+				}
1533 2160
     				$data['id_source'] = $id_source;
1534
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1535
-    				else $error = true;
2161
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2162
+    					$send = $SI->add($data);
2163
+    				} else {
2164
+    					$error = true;
2165
+    				}
1536 2166
     				unset($data);
1537
-    			    } else $error = true;
2167
+    			    } else {
2168
+    			    	$error = true;
2169
+    			    }
1538 2170
 			    if ($error) {
1539 2171
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1540
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2172
+					if ($globalDebug) {
2173
+						echo "Not a message. Ignoring... \n";
2174
+					}
1541 2175
 				} else {
1542
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2176
+					if ($globalDebug) {
2177
+						echo "Wrong line format. Ignoring... \n";
2178
+					}
1543 2179
 					if ($globalDebug) {
1544 2180
 						echo $buffer;
1545 2181
 						//print_r($line);
1546 2182
 					}
1547 2183
 					//socket_close($r);
1548
-					if ($globalDebug) echo "Reconnect after an error...\n";
1549
-					if ($format == 'aprs') $aprs_connect = 0;
2184
+					if ($globalDebug) {
2185
+						echo "Reconnect after an error...\n";
2186
+					}
2187
+					if ($format == 'aprs') {
2188
+						$aprs_connect = 0;
2189
+					}
1550 2190
 					$sourceer[$nb] = $globalSources[$nb];
1551 2191
 					connect_all($sourceer);
1552 2192
 					$sourceer = array();
@@ -1554,10 +2194,14 @@  discard block
 block discarded – undo
1554 2194
 			    }
1555 2195
 			}
1556 2196
 			// Sleep for xxx microseconds
1557
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2197
+			if (isset($globalSBSSleep)) {
2198
+				usleep($globalSBSSleep);
2199
+			}
1558 2200
 		    } else {
1559 2201
 			if ($format == 'flightgearmp') {
1560
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2202
+			    	if ($globalDebug) {
2203
+			    		echo "Reconnect FlightGear MP...";
2204
+			    	}
1561 2205
 				//@socket_close($r);
1562 2206
 				sleep($globalMinFetch);
1563 2207
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1566,10 +2210,15 @@  discard block
 block discarded – undo
1566 2210
 				break;
1567 2211
 				
1568 2212
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1569
-			    if (isset($tt[$format])) $tt[$format]++;
1570
-			    else $tt[$format] = 0;
2213
+			    if (isset($tt[$format])) {
2214
+			    	$tt[$format]++;
2215
+			    } else {
2216
+			    	$tt[$format] = 0;
2217
+			    }
1571 2218
 			    if ($tt[$format] > 30) {
1572
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2219
+				if ($globalDebug) {
2220
+					echo "ERROR : Reconnect ".$format."...";
2221
+				}
1573 2222
 				//@socket_close($r);
1574 2223
 				sleep(2);
1575 2224
 				$aprs_connect = 0;
@@ -1586,11 +2235,17 @@  discard block
 block discarded – undo
1586 2235
 	    } else {
1587 2236
 		$error = socket_strerror(socket_last_error());
1588 2237
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1589
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1590
-			if (isset($globalDebug)) echo "Restarting...\n";
2238
+			if ($globalDebug) {
2239
+				echo "ERROR : socket_select give this error ".$error . "\n";
2240
+			}
2241
+			if (isset($globalDebug)) {
2242
+				echo "Restarting...\n";
2243
+			}
1591 2244
 			// Restart the script if possible
1592 2245
 			if (is_array($sockets)) {
1593
-			    if ($globalDebug) echo "Shutdown all sockets...";
2246
+			    if ($globalDebug) {
2247
+			    	echo "Shutdown all sockets...";
2248
+			    }
1594 2249
 			    
1595 2250
 			    foreach ($sockets as $sock) {
1596 2251
 				@socket_shutdown($sock,2);
@@ -1598,25 +2253,45 @@  discard block
 block discarded – undo
1598 2253
 			    }
1599 2254
 			    
1600 2255
 			}
1601
-			if ($globalDebug) echo "Waiting...";
2256
+			if ($globalDebug) {
2257
+				echo "Waiting...";
2258
+			}
1602 2259
 			sleep(2);
1603 2260
 			$time = time();
1604 2261
 			//connect_all($hosts);
1605 2262
 			$aprs_connect = 0;
1606
-			if ($reset%5 == 0) sleep(20);
1607
-			if ($reset%10 == 0) sleep(100);
1608
-			if ($reset%20 == 0) sleep(200);
1609
-			if ($reset > 100) exit('Too many attempts...');
1610
-			if ($globalDebug) echo "Restart all connections...";
2263
+			if ($reset%5 == 0) {
2264
+				sleep(20);
2265
+			}
2266
+			if ($reset%10 == 0) {
2267
+				sleep(100);
2268
+			}
2269
+			if ($reset%20 == 0) {
2270
+				sleep(200);
2271
+			}
2272
+			if ($reset > 100) {
2273
+				exit('Too many attempts...');
2274
+			}
2275
+			if ($globalDebug) {
2276
+				echo "Restart all connections...";
2277
+			}
1611 2278
 			connect_all($globalSources);
1612 2279
 		}
1613 2280
 	    }
1614 2281
 	}
1615 2282
 	if ($globalDaemon === false) {
1616
-	    if ($globalDebug) echo 'Check all...'."\n";
1617
-	    if (isset($SI)) $SI->checkAll();
1618
-	    if (isset($TI)) $TI->checkAll();
1619
-	    if (isset($MI)) $MI->checkAll();
2283
+	    if ($globalDebug) {
2284
+	    	echo 'Check all...'."\n";
2285
+	    }
2286
+	    if (isset($SI)) {
2287
+	    	$SI->checkAll();
2288
+	    }
2289
+	    if (isset($TI)) {
2290
+	    	$TI->checkAll();
2291
+	    }
2292
+	    if (isset($MI)) {
2293
+	    	$MI->checkAll();
2294
+	    }
1620 2295
 	}
1621 2296
     }
1622 2297
 }
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +501 added lines, -134 removed lines patch added patch discarded remove patch
@@ -131,45 +131,72 @@  discard block
 block discarded – undo
131 131
 			</div>
132 132
 			<p>
133 133
 				<label for="dbhost">Database hostname</label>
134
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
134
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
135
+	print $globalDBhost;
136
+}
137
+?>" />
135 138
 			</p>
136 139
 			<p>
137 140
 				<label for="dbport">Database port</label>
138
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
141
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
142
+	print $globalDBport;
143
+}
144
+?>" />
139 145
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
140 146
 			</p>
141 147
 			<p>
142 148
 				<label for="dbname">Database name</label>
143
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
149
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
150
+	print $globalDBname;
151
+}
152
+?>" />
144 153
 			</p>
145 154
 			<p>
146 155
 				<label for="dbuser">Database user</label>
147
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
156
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
157
+	print $globalDBuser;
158
+}
159
+?>" />
148 160
 			</p>
149 161
 			<p>
150 162
 				<label for="dbuserpass">Database user password</label>
151
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
163
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
164
+	print $globalDBpass;
165
+}
166
+?>" />
152 167
 			</p>
153 168
 		</fieldset>
154 169
 		<fieldset id="site">
155 170
 			<legend>Site configuration</legend>
156 171
 			<p>
157 172
 				<label for="sitename">Site name</label>
158
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
173
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
174
+	print $globalName;
175
+}
176
+?>" />
159 177
 			</p>
160 178
 			<p>
161 179
 				<label for="siteurl">Site directory</label>
162
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
180
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
181
+	print $globalURL;
182
+}
183
+?>" />
163 184
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
164 185
 			</p>
165 186
 			<p>
166 187
 				<label for="timezone">Timezone</label>
167
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
188
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
189
+	print $globalTimezone;
190
+}
191
+?>" />
168 192
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
169 193
 			</p>
170 194
 			<p>
171 195
 				<label for="language">Language</label>
172
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
196
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
197
+	print $globalLanguage;
198
+}
199
+?>" />
173 200
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
174 201
 			</p>
175 202
 		</fieldset>
@@ -190,11 +217,17 @@  discard block
 block discarded – undo
190 217
 			<div id="mapbox_data">
191 218
 				<p>
192 219
 					<label for="mapboxid">Mapbox id</label>
193
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
220
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
221
+	print $globalMapboxId;
222
+}
223
+?>" />
194 224
 				</p>
195 225
 				<p>
196 226
 					<label for="mapboxtoken">Mapbox token</label>
197
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
227
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
228
+	print $globalMapboxToken;
229
+}
230
+?>" />
198 231
 				</p>
199 232
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
200 233
 			</div>
@@ -202,7 +235,10 @@  discard block
 block discarded – undo
202 235
 			<div id="google_data">
203 236
 				<p>
204 237
 					<label for="googlekey">Google API key</label>
205
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
238
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
239
+	print $globalGoogleAPIKey;
240
+}
241
+?>" />
206 242
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
207 243
 				</p>
208 244
 			</div>
@@ -210,7 +246,10 @@  discard block
 block discarded – undo
210 246
 			<div id="bing_data">
211 247
 				<p>
212 248
 					<label for="bingkey">Bing Map key</label>
213
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
249
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
250
+	print $globalBingMapKey;
251
+}
252
+?>" />
214 253
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
215 254
 				</p>
216 255
 			</div>
@@ -218,7 +257,10 @@  discard block
 block discarded – undo
218 257
 			<div id="mapquest_data">
219 258
 				<p>
220 259
 					<label for="mapquestkey">MapQuest key</label>
221
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
260
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
261
+	print $globalMapQuestKey;
262
+}
263
+?>" />
222 264
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
223 265
 				</p>
224 266
 			</div>
@@ -226,11 +268,17 @@  discard block
 block discarded – undo
226 268
 			<div id="here_data">
227 269
 				<p>
228 270
 					<label for="hereappid">Here App_Id</label>
229
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
271
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
272
+	print $globalHereappId;
273
+}
274
+?>" />
230 275
 				</p>
231 276
 				<p>
232 277
 					<label for="hereappcode">Here App_Code</label>
233
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
278
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
279
+	print $globalHereappCode;
280
+}
281
+?>" />
234 282
 				</p>
235 283
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
236 284
 			</div>
@@ -238,7 +286,10 @@  discard block
 block discarded – undo
238 286
 			<div id="openweathermap_data">
239 287
 				<p>
240 288
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
241
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
289
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
290
+	print $globalOpenWeatherMapKey;
291
+}
292
+?>" />
242 293
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
243 294
 				</p>
244 295
 			</div>
@@ -248,42 +299,86 @@  discard block
 block discarded – undo
248 299
 			<legend>Coverage area</legend>
249 300
 			<p>
250 301
 				<label for="latitudemax">The maximum latitude (north)</label>
251
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
302
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
303
+	print $globalLatitudeMax;
304
+}
305
+?>" />
252 306
 			</p>
253 307
 			<p>
254 308
 				<label for="latitudemin">The minimum latitude (south)</label>
255
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
309
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
310
+	print $globalLatitudeMin;
311
+}
312
+?>" />
256 313
 			</p>
257 314
 			<p>
258 315
 				<label for="longitudemax">The maximum longitude (west)</label>
259
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
316
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
317
+	print $globalLongitudeMax;
318
+}
319
+?>" />
260 320
 			</p>
261 321
 			<p>
262 322
 				<label for="longitudemin">The minimum longitude (east)</label>
263
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
323
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
324
+	print $globalLongitudeMin;
325
+}
326
+?>" />
264 327
 			</p>
265 328
 			<p>
266 329
 				<label for="latitudecenter">The latitude center</label>
267
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
330
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
331
+	print $globalCenterLatitude;
332
+}
333
+?>" />
268 334
 			</p>
269 335
 			<p>
270 336
 				<label for="longitudecenter">The longitude center</label>
271
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
337
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
338
+	print $globalCenterLongitude;
339
+}
340
+?>" />
272 341
 			</p>
273 342
 			<p>
274 343
 				<label for="livezoom">Default Zoom on live map</label>
275
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
344
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
345
+	print $globalLiveZoom;
346
+} else {
347
+	print '9';
348
+}
349
+?>" />
276 350
 			</p>
277 351
 			<p>
278 352
 				<label for="squawk_country">Country for squawk usage</label>
279 353
 				<select name="squawk_country" id="squawk_country">
280
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
281
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
282
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
283
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
284
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
285
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
286
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
354
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
355
+	print ' selected ';
356
+}
357
+?>>UK</option>
358
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
359
+	print ' selected ';
360
+}
361
+?>>NZ</option>
362
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
363
+	print ' selected ';
364
+}
365
+?>>US</option>
366
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
367
+	print ' selected ';
368
+}
369
+?>>AU</option>
370
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
371
+	print ' selected ';
372
+}
373
+?>>NL</option>
374
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
375
+	print ' selected ';
376
+}
377
+?>>FR</option>
378
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
379
+	print ' selected ';
380
+}
381
+?>>TR</option>
287 382
 				</select>
288 383
 			</p>
289 384
 		</fieldset>
@@ -292,15 +387,24 @@  discard block
 block discarded – undo
292 387
 			<p><i>Only put in DB flights that are inside a circle</i></p>
293 388
 			<p>
294 389
 				<label for="latitude">Center latitude</label>
295
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
390
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
391
+	echo $globalDistanceIgnore['latitude'];
392
+}
393
+?>" />
296 394
 			</p>
297 395
 			<p>
298 396
 				<label for="longitude">Center longitude</label>
299
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
397
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
398
+	echo $globalDistanceIgnore['longitude'];
399
+}
400
+?>" />
300 401
 			</p>
301 402
 			<p>
302 403
 				<label for="Distance">Distance (in km)</label>
303
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
404
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
405
+	echo $globalDistanceIgnore['distance'];
406
+}
407
+?>" />
304 408
 			</p>
305 409
 		</fieldset>
306 410
 		<fieldset id="sourceloc">
@@ -409,11 +513,17 @@  discard block
 block discarded – undo
409 513
 			<div id="flightaware_data">
410 514
 				<p>
411 515
 					<label for="flightawareusername">FlightAware username</label>
412
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
516
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
517
+	print $globalFlightAwareUsername;
518
+}
519
+?>" />
413 520
 				</p>
414 521
 				<p>
415 522
 					<label for="flightawarepassword">FlightAware password/API key</label>
416
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
523
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
524
+	print $globalFlightAwarePassword;
525
+}
526
+?>" />
417 527
 				</p>
418 528
 			</div>
419 529
 -->
@@ -455,7 +565,10 @@  discard block
 block discarded – undo
455 565
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
456 566
 								?>
457 567
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
458
-								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
568
+								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) {
569
+	print $source['port'];
570
+}
571
+?>" /></td>
459 572
 								<?php
460 573
 								    } else {
461 574
 									$hostport = explode(':',$source['host']);
@@ -474,33 +587,102 @@  discard block
 block discarded – undo
474 587
 								?>
475 588
 								<td>
476 589
 									<select name="format[]" id="format">
477
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
478
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
479
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
480
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
481
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
482
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
483
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
484
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
485
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
486
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
487
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
488
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
489
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
490
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
491
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
492
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
493
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
494
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
495
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
496
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
590
+										<option value="auto" <?php if (!isset($source['format'])) {
591
+	print 'selected';
592
+}
593
+?>>Auto</option>
594
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
595
+	print 'selected';
596
+}
597
+?>>SBS</option>
598
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
599
+	print 'selected';
600
+}
601
+?>>TSV</option>
602
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
603
+	print 'selected';
604
+}
605
+?>>Raw</option>
606
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
607
+	print 'selected';
608
+}
609
+?>>APRS</option>
610
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
611
+	print 'selected';
612
+}
613
+?>>Radarcape deltadb.txt</option>
614
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
615
+	print 'selected';
616
+}
617
+?>>Vatsim</option>
618
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
619
+	print 'selected';
620
+}
621
+?>>Virtual Radar Server AircraftList.json</option>
622
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
623
+	print 'selected';
624
+}
625
+?>>Virtual Radar Server TCP</option>
626
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
627
+	print 'selected';
628
+}
629
+?>>phpVMS</option>
630
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
631
+	print 'selected';
632
+}
633
+?>>Virtual Airlines Manager</option>
634
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
635
+	print 'selected';
636
+}
637
+?>>IVAO</option>
638
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
639
+	print 'selected';
640
+}
641
+?>>FlightGear Multiplayer</option>
642
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
643
+	print 'selected';
644
+}
645
+?>>FlightGear Singleplayer</option>
646
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
647
+	print 'selected';
648
+}
649
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
650
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
651
+	print 'selected';
652
+}
653
+?>>ACARS SBS-3 over TCP</option>
654
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
655
+	print 'selected';
656
+}
657
+?>>NMEA AIS over TCP</option>
658
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
659
+	print 'selected';
660
+}
661
+?>>AirWhere website</option>
662
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
663
+	print 'selected';
664
+}
665
+?>>HidnSeek Callback</option>
666
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
667
+	print 'selected';
668
+}
669
+?>>Blitzortung</option>
497 670
 									</select>
498 671
 								</td>
499 672
 								<td>
500
-									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
673
+									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
674
+	print $source['name'];
675
+}
676
+?>" />
501 677
 								</td>
502
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
503
-								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
678
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
679
+	print 'checked';
680
+}
681
+?> /></td>
682
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
683
+	print 'checked';
684
+}
685
+?> /></td>
504 686
 								<td>
505 687
 									<select name="timezones[]" id="timezones">
506 688
 								<?php
@@ -510,7 +692,9 @@  discard block
 block discarded – undo
510 692
 											print '<option selected>'.$timezones.'</option>';
511 693
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
512 694
 											print '<option selected>'.$timezones.'</option>';
513
-										} else print '<option>'.$timezones.'</option>';
695
+										} else {
696
+											print '<option>'.$timezones.'</option>';
697
+										}
514 698
 									}
515 699
 								?>
516 700
 									</select>
@@ -560,7 +744,9 @@  discard block
 block discarded – undo
560 744
 									foreach($timezonelist as $timezones){
561 745
 										if ($timezones == 'UTC') {
562 746
 											print '<option selected>'.$timezones.'</option>';
563
-										} else print '<option>'.$timezones.'</option>';
747
+										} else {
748
+											print '<option>'.$timezones.'</option>';
749
+										}
564 750
 									}
565 751
 								?>
566 752
 									</select>
@@ -583,11 +769,17 @@  discard block
 block discarded – undo
583 769
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
584 770
 					<p>
585 771
 						<label for="acarshost">ACARS UDP host</label>
586
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
772
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
773
+	print $globalACARSHost;
774
+}
775
+?>" />
587 776
 					</p>
588 777
 					<p>
589 778
 						<label for="acarsport">ACARS UDP port</label>
590
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
779
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
780
+	print $globalACARSPort;
781
+}
782
+?>" />
591 783
 					</p>
592 784
 				</fieldset>
593 785
 			</div>
@@ -667,13 +859,19 @@  discard block
 block discarded – undo
667 859
 			<div id="schedules_options">
668 860
 				<p>
669 861
 					<label for="britishairways">British Airways API Key</label>
670
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
862
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
863
+	print $globalBritishAirwaysKey;
864
+}
865
+?>" />
671 866
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
672 867
 				</p>
673 868
 				<!--
674 869
 				<p>
675 870
 					<label for="transavia">Transavia Test API Consumer Key</label>
676
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
871
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
872
+	print $globalTransaviaKey;
873
+}
874
+?>" />
677 875
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
678 876
 				</p>
679 877
 				-->
@@ -682,10 +880,16 @@  discard block
 block discarded – undo
682 880
 						<b>Lufthansa API Key</b>
683 881
 						<p>
684 882
 							<label for="lufthansakey">Key</label>
685
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
883
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
884
+	print $globalLufthansaKey['key'];
885
+}
886
+?>" />
686 887
 						</p><p>
687 888
 							<label for="lufthansasecret">Secret</label>
688
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
889
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
890
+	print $globalLufthansaKey['secret'];
891
+}
892
+?>" />
689 893
 						</p>
690 894
 					</div>
691 895
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -705,7 +909,10 @@  discard block
 block discarded – undo
705 909
 			</p>
706 910
 			<p>
707 911
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
708
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
912
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
913
+	print $globalNOTAMSource;
914
+}
915
+?>" />
709 916
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
710 917
 			</p>
711 918
 			<br />
@@ -721,14 +928,20 @@  discard block
 block discarded – undo
721 928
 			<div id="metarsrc">
722 929
 				<p>
723 930
 					<label for="metarsource">URL of your METAR source</label>
724
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
931
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
932
+	print $globalMETARurl;
933
+}
934
+?>" />
725 935
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
726 936
 				</p>
727 937
 			</div>
728 938
 			<br />
729 939
 			<p>
730 940
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
731
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
941
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
942
+	print $globalBitlyAccessToken;
943
+}
944
+?>" />
732 945
 			</p>
733 946
 			<br />
734 947
 			<p>
@@ -744,11 +957,26 @@  discard block
 block discarded – undo
744 957
 			<p>
745 958
 				<label for="geoid_source">Geoid Source</label>
746 959
 				<select name="geoid_source" id="geoid_source">
747
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
748
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
749
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
750
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
751
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
960
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
961
+	print ' selected="selected"';
962
+}
963
+?>>EGM96 15' (2.1MB)</option>
964
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
965
+	print ' selected="selected"';
966
+}
967
+?>>EGM96 5' (19MB)</option>
968
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
969
+	print ' selected="selected"';
970
+}
971
+?>>EGM2008 5' (19MB)</option>
972
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
973
+	print ' selected="selected"';
974
+}
975
+?>>EGM2008 2.5' (75MB)</option>
976
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
977
+	print ' selected="selected"';
978
+}
979
+?>>EGM2008 1' (470MB)</option>
752 980
 				</select>
753 981
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
754 982
 			</p>
@@ -766,7 +994,12 @@  discard block
 block discarded – undo
766 994
 			</p>
767 995
 			<p>
768 996
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
769
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
997
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
998
+	print $globalArchiveMonths;
999
+} else {
1000
+	echo '0';
1001
+}
1002
+?>" />
770 1003
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
771 1004
 			</p>
772 1005
 			<p>
@@ -776,12 +1009,22 @@  discard block
 block discarded – undo
776 1009
 			</p>
777 1010
 			<p>
778 1011
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
779
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
1012
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1013
+	print $globalArchiveKeepMonths;
1014
+} else {
1015
+	echo '0';
1016
+}
1017
+?>" />
780 1018
 				<p class="help-block">0 to disable</p>
781 1019
 			</p>
782 1020
 			<p>
783 1021
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
784
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
1022
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1023
+	print $globalArchiveKeepTrackMonths;
1024
+} else {
1025
+	echo '0';
1026
+}
1027
+?>" />
785 1028
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
786 1029
 			</p>
787 1030
 			<br />
@@ -791,7 +1034,12 @@  discard block
 block discarded – undo
791 1034
 				<p class="help-block">Uncheck if the script is running as cron job</p>
792 1035
 				<div id="cronends"> 
793 1036
 					<label for="cronend">Run script for xx seconds</label>
794
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1037
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1038
+	print $globalCronEnd;
1039
+} else {
1040
+	print '0';
1041
+}
1042
+?>" />
795 1043
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
796 1044
 				</div>
797 1045
 			</p>
@@ -844,15 +1092,30 @@  discard block
 block discarded – undo
844 1092
 			<br />
845 1093
 			<p>
846 1094
 				<label for="refresh">Show flights detected since xxx seconds</label>
847
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1095
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1096
+	echo $globalLiveInterval;
1097
+} else {
1098
+	echo '200';
1099
+}
1100
+?>" />
848 1101
 			</p>
849 1102
 			<p>
850 1103
 				<label for="maprefresh">Live map refresh (in seconds)</label>
851
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1104
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1105
+	echo $globalMapRefresh;
1106
+} else {
1107
+	echo '30';
1108
+}
1109
+?>" />
852 1110
 			</p>
853 1111
 			<p>
854 1112
 				<label for="mapidle">Map idle timeout (in minutes)</label>
855
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1113
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1114
+	echo $globalMapIdleTimeout;
1115
+} else {
1116
+	echo '30';
1117
+}
1118
+?>" />
856 1119
 				<p class="help-block">0 to disable</p>
857 1120
 			</p>
858 1121
 			<p>
@@ -867,12 +1130,20 @@  discard block
 block discarded – undo
867 1130
 			<br />
868 1131
 			<p>
869 1132
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
870
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1133
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1134
+	echo $globalClosestMinDist;
1135
+} else {
1136
+	echo '50';
1137
+}
1138
+?>" />
871 1139
 			</p>
872 1140
 			<br />
873 1141
 			<p>
874 1142
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
875
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1143
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1144
+	echo $globalAircraftSize;
1145
+}
1146
+?>" />
876 1147
 			</p>
877 1148
 			<br />
878 1149
 			<p>
@@ -885,7 +1156,12 @@  discard block
 block discarded – undo
885 1156
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
886 1157
 			?>
887 1158
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
888
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1159
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1160
+	echo $globalAircraftIconColor;
1161
+} else {
1162
+	echo '1a3151';
1163
+}
1164
+?>" />
889 1165
 			<?php
890 1166
 				if (!is_writable('../cache')) {
891 1167
 			?>
@@ -903,14 +1179,27 @@  discard block
 block discarded – undo
903 1179
 			<p>
904 1180
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
905 1181
 				<div class="range">
906
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
907
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1182
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1183
+	echo $globalAirportZoom;
1184
+} else {
1185
+	echo '7';
1186
+}
1187
+?>" />
1188
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1189
+	echo $globalAirportZoom;
1190
+} else {
1191
+	echo '7';
1192
+}
1193
+?></output>
908 1194
 				</div>
909 1195
 			</p>
910 1196
 			<br />
911 1197
 			<p>
912 1198
 				<label for="customcss">Custom CSS web path</label>
913
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1199
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1200
+	echo $globalCustomCSS;
1201
+}
1202
+?>" />
914 1203
 			</p>
915 1204
 		</fieldset>
916 1205
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -937,8 +1226,12 @@  discard block
 block discarded – undo
937 1226
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
938 1227
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
939 1228
 
940
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
941
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1229
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1230
+		$error .= 'Mysql driver for PDO must be loaded';
1231
+	}
1232
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1233
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1234
+	}
942 1235
 	
943 1236
 	$_SESSION['database_root'] = $dbroot;
944 1237
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1006,15 +1299,23 @@  discard block
 block discarded – undo
1006 1299
 	$source_city = $_POST['source_city'];
1007 1300
 	$source_country = $_POST['source_country'];
1008 1301
 	$source_ref = $_POST['source_ref'];
1009
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1010
-	else $source_id = array();
1302
+	if (isset($source_id)) {
1303
+		$source_id = $_POST['source_id'];
1304
+	} else {
1305
+		$source_id = array();
1306
+	}
1011 1307
 	
1012 1308
 	$sources = array();
1013 1309
 	foreach ($source_name as $keys => $name) {
1014
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1015
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1310
+	    if (isset($source_id[$keys])) {
1311
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1312
+	    } else {
1313
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1314
+	    }
1315
+	}
1316
+	if (count($sources) > 0) {
1317
+		$_SESSION['sources'] = $sources;
1016 1318
 	}
1017
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1018 1319
 
1019 1320
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1020 1321
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -1035,14 +1336,23 @@  discard block
 block discarded – undo
1035 1336
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1036 1337
 
1037 1338
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1038
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1039
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1339
+	if ($globalaircraft == 'aircraft') {
1340
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1341
+	} else {
1342
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1343
+	}
1040 1344
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1041
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1042
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1345
+	if ($globaltracker == 'tracker') {
1346
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1347
+	} else {
1348
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1349
+	}
1043 1350
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1044
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1045
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1351
+	if ($globalmarine == 'marine') {
1352
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1353
+	} else {
1354
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1355
+	}
1046 1356
 
1047 1357
 /*	
1048 1358
 	$globalSBS1Hosts = array();
@@ -1064,23 +1374,37 @@  discard block
 block discarded – undo
1064 1374
 	$name = $_POST['name'];
1065 1375
 	$format = $_POST['format'];
1066 1376
 	$timezones = $_POST['timezones'];
1067
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1068
-	else $sourcestats = array();
1069
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1070
-	else $noarchive = array();
1377
+	if (isset($_POST['sourcestats'])) {
1378
+		$sourcestats = $_POST['sourcestats'];
1379
+	} else {
1380
+		$sourcestats = array();
1381
+	}
1382
+	if (isset($_POST['noarchive'])) {
1383
+		$noarchive = $_POST['noarchive'];
1384
+	} else {
1385
+		$noarchive = array();
1386
+	}
1071 1387
 	$gSources = array();
1072 1388
 	$forcepilots = false;
1073 1389
 	foreach ($host as $key => $h) {
1074
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1075
-		else $cov = 'FALSE';
1076
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1077
-		else $arch = 'FALSE';
1390
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1391
+			$cov = 'TRUE';
1392
+		} else {
1393
+			$cov = 'FALSE';
1394
+		}
1395
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1396
+			$arch = 'TRUE';
1397
+		} else {
1398
+			$arch = 'FALSE';
1399
+		}
1078 1400
 		if (strpos($format[$key],'_callback')) {
1079 1401
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1080 1402
 		} elseif ($h != '' || $name[$key] != '') {
1081 1403
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1082 1404
 		}
1083
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1405
+		if ($format[$key] == 'airwhere') {
1406
+			$forcepilots = true;
1407
+		}
1084 1408
 	}
1085 1409
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1086 1410
 
@@ -1108,7 +1432,9 @@  discard block
 block discarded – undo
1108 1432
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1109 1433
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1110 1434
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1111
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1435
+	} else {
1436
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1437
+	}
1112 1438
 
1113 1439
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1114 1440
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1147,7 +1473,9 @@  discard block
 block discarded – undo
1147 1473
 
1148 1474
 	// Create in settings.php keys not yet configurable if not already here
1149 1475
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1150
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1476
+	if (!isset($globalDebug)) {
1477
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1478
+	}
1151 1479
 
1152 1480
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1153 1481
 	if ($resetyearstats == 'resetyearstats') {
@@ -1184,37 +1512,56 @@  discard block
 block discarded – undo
1184 1512
 	}
1185 1513
 */
1186 1514
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1187
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1188
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1189
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1190
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1515
+	if ($globalsbs == 'sbs') {
1516
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1517
+	} else {
1518
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1519
+	}
1520
+	if ($globalaprs == 'aprs') {
1521
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1522
+	} else {
1523
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1524
+	}
1191 1525
 	$va = false;
1192 1526
 	if ($globalivao == 'ivao') {
1193 1527
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1194 1528
 		$va = true;
1195
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1529
+	} else {
1530
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1531
+	}
1196 1532
 	if ($globalvatsim == 'vatsim') {
1197 1533
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1198 1534
 		$va = true;
1199
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1535
+	} else {
1536
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1537
+	}
1200 1538
 	if ($globalphpvms == 'phpvms') {
1201 1539
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1202 1540
 		$va = true;
1203
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1541
+	} else {
1542
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1543
+	}
1204 1544
 	if ($globalvam == 'vam') {
1205 1545
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1206 1546
 		$va = true;
1207
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1547
+	} else {
1548
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1549
+	}
1208 1550
 	if ($va) {
1209 1551
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1210
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1552
+	} else {
1553
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1554
+	}
1211 1555
 	if ($globalva == 'va' || $va) {
1212 1556
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1213 1557
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1214 1558
 	} else {
1215 1559
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1216
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1217
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1560
+		if ($forcepilots) {
1561
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1562
+		} else {
1563
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1564
+		}
1218 1565
 	}
1219 1566
 	
1220 1567
 	
@@ -1390,7 +1737,9 @@  discard block
 block discarded – undo
1390 1737
 		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1391 1738
 	}
1392 1739
 
1393
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1740
+	if (!isset($globalTransaction)) {
1741
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1742
+	}
1394 1743
 
1395 1744
 	// Set some defaults values...
1396 1745
 	if (!isset($globalAircraftImageSources)) {
@@ -1405,15 +1754,23 @@  discard block
 block discarded – undo
1405 1754
 
1406 1755
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1407 1756
 
1408
-	if ($error == '') settings::modify_settings($settings);
1409
-	if ($error == '') settings::comment_settings($settings_comment);
1757
+	if ($error == '') {
1758
+		settings::modify_settings($settings);
1759
+	}
1760
+	if ($error == '') {
1761
+		settings::comment_settings($settings_comment);
1762
+	}
1410 1763
 	if ($error != '') {
1411 1764
 		print '<div class="info column">'.$error.'</div>';
1412 1765
 		require('../footer.php');
1413 1766
 		exit;
1414 1767
 	} else {
1415
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1416
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1768
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1769
+			$_SESSION['waypoints'] = 1;
1770
+		}
1771
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1772
+			$_SESSION['owner'] = 1;
1773
+		}
1417 1774
 		if (isset($_POST['createdb'])) {
1418 1775
 			$_SESSION['install'] = 'database_create';
1419 1776
 		} else {
@@ -1449,10 +1806,18 @@  discard block
 block discarded – undo
1449 1806
 	$popw = false;
1450 1807
 	foreach ($_SESSION['done'] as $done) {
1451 1808
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1452
-	    if ($done == 'Create database') $pop = true;
1453
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1454
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1455
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1809
+	    if ($done == 'Create database') {
1810
+	    	$pop = true;
1811
+	    }
1812
+	    if ($_SESSION['install'] == 'database_create') {
1813
+	    	$pop = true;
1814
+	    }
1815
+	    if ($_SESSION['install'] == 'database_import') {
1816
+	    	$popi = true;
1817
+	    }
1818
+	    if ($_SESSION['install'] == 'waypoints') {
1819
+	    	$popw = true;
1820
+	    }
1456 1821
 	}
1457 1822
 	if ($pop) {
1458 1823
 	    sleep(5);
@@ -1463,7 +1828,9 @@  discard block
 block discarded – undo
1463 1828
 	} else if ($popw) {
1464 1829
 	    sleep(5);
1465 1830
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1466
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1831
+	} else {
1832
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1833
+	}
1467 1834
 	print '</div></ul>';
1468 1835
 	print '<div id="error"></div>';
1469 1836
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
location-data.php 1 patch
Braces   +34 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,9 +17,13 @@  discard block
 block discarded – undo
17 17
 date_default_timezone_set('UTC');
18 18
 
19 19
 print '<div class="top">';
20
-if ($spotter_item['name'] != '') print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>';
21
-elseif ($spotter_item['location_id'] != 0) print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>';
22
-else print '<div class="right"><div class="callsign-details"><div class="callsign"></div>';
20
+if ($spotter_item['name'] != '') {
21
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>';
22
+} elseif ($spotter_item['location_id'] != 0) {
23
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>';
24
+} else {
25
+	print '<div class="right"><div class="callsign-details"><div class="callsign"></div>';
26
+}
23 27
 print '</div>';
24 28
 
25 29
 print '</div></div>';
@@ -34,8 +38,12 @@  discard block
 block discarded – undo
34 38
 print $spotter_item['last_seen'].' UTC';
35 39
 print '</div>';
36 40
 
37
-if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
38
-if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
41
+if ($spotter_item['city'] != '') {
42
+	print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
43
+}
44
+if ($spotter_item['country'] !='') {
45
+	print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
46
+}
39 47
 print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>';
40 48
 /*
41 49
 if ($spotter_item['atc_range'] > 0) {
@@ -47,13 +55,27 @@  discard block
 block discarded – undo
47 55
 if ($spotter_item['type'] == 'wx') {
48 56
 	$weather = json_decode($spotter_item['description'],true);
49 57
 	//print_r($weather);
50
-	if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
51
-	if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>';
52
-	if (isset($weather['wind_gust'])) print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>';
53
-	if (isset($weather['humidity'])) print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>';
54
-	if (isset($weather['rain'])) print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>';
55
-	if (isset($weather['precipitation'])) print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>';
56
-	if (isset($weather['precipitation24h'])) print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>';
58
+	if (isset($weather['temp'])) {
59
+		print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
60
+	}
61
+	if (isset($weather['pressure'])) {
62
+		print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>';
63
+	}
64
+	if (isset($weather['wind_gust'])) {
65
+		print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>';
66
+	}
67
+	if (isset($weather['humidity'])) {
68
+		print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>';
69
+	}
70
+	if (isset($weather['rain'])) {
71
+		print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>';
72
+	}
73
+	if (isset($weather['precipitation'])) {
74
+		print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>';
75
+	}
76
+	if (isset($weather['precipitation24h'])) {
77
+		print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>';
78
+	}
57 79
 	$spotter_item['description'] = $weather['comment'];
58 80
 }
59 81
 print '</div>';
Please login to merge, or discard this patch.