Completed
Push — master ( d882c6...514564 )
by Yannick
47:57 queued 18:52
created
scripts/daemon-spotter.php 1 patch
Braces   +1135 added lines, -383 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();
@@ -59,66 +63,107 @@  discard block
 block discarded – undo
59 63
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 64
 if (isset($options['s'])) {
61 65
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
64
-} elseif (isset($options['source'])) {
66
+    if (isset($options['format'])) {
67
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
68
+    } else {
69
+    	$globalSources[] = array('host' => $options['s']);
70
+    }
71
+    } elseif (isset($options['source'])) {
65 72
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
68
-}
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['source']);
77
+    }
78
+    }
69 79
 if (isset($options['aprsserverhost'])) {
70 80
 	$globalServerAPRS = TRUE;
71 81
 	$globalServerAPRShost = $options['aprsserverhost'];
72 82
 }
73
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
74
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
75
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
76
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
83
+if (isset($options['aprsserverport'])) {
84
+	$globalServerAPRSport = $options['aprsserverport'];
85
+}
86
+if (isset($options['aprsserverssid'])) {
87
+	$globalServerAPRSssid = $options['aprsserverssid'];
88
+}
89
+if (isset($options['aprsserverpass'])) {
90
+	$globalServerAPRSpass = $options['aprsserverpass'];
91
+}
92
+if (isset($options['noaprsserver'])) {
93
+	$globalServerAPRS = FALSE;
94
+}
77 95
 if (isset($options['enable-aircraft'])) {
78
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
96
+	if ($globalDebug) {
97
+		echo 'Enable Aircraft mode'."\n";
98
+	}
79 99
 	$globalAircraft = TRUE; 
80 100
 }
81 101
 if (isset($options['disable-aircraft'])) {
82
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
102
+	if ($globalDebug) {
103
+		echo 'Disable Aircraft mode'."\n";
104
+	}
83 105
 	$globalAircraft = FALSE;
84 106
 }
85 107
 if (isset($options['enable-tracker'])) {
86
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
108
+	if ($globalDebug) {
109
+		echo 'Enable Tracker mode'."\n";
110
+	}
87 111
 	$globalTracker = TRUE; 
88 112
 }
89 113
 if (isset($options['disable-tracker'])) {
90
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
114
+	if ($globalDebug) {
115
+		echo 'Disable Tracker mode'."\n";
116
+	}
91 117
 	$globalTracker = FALSE;
92 118
 }
93 119
 if (isset($options['enable-marine'])) {
94
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
120
+	if ($globalDebug) {
121
+		echo 'Enable Marine mode'."\n";
122
+	}
95 123
 	$globalMarine = TRUE;
96 124
 }
97 125
 if (isset($options['disable-marine'])) {
98
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
126
+	if ($globalDebug) {
127
+		echo 'Disable Marine mode'."\n";
128
+	}
99 129
 	$globalMarine = FALSE;
100 130
 }
101
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
102
-if (isset($options['server'])) $globalServer = TRUE;
103
-if (isset($options['idsource'])) $id_source = $options['idsource'];
104
-else $id_source = 1;
131
+if (isset($options['nodaemon'])) {
132
+	$globalDaemon = FALSE;
133
+}
134
+if (isset($options['server'])) {
135
+	$globalServer = TRUE;
136
+}
137
+if (isset($options['idsource'])) {
138
+	$id_source = $options['idsource'];
139
+} else {
140
+	$id_source = 1;
141
+}
105 142
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
143
+    if ($globalDebug) {
144
+    	echo "Using Server Mode\n";
145
+    }
107 146
     $SI=new SpotterServer();
108 147
 /*
109 148
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 149
     $SI = new adsb2aprs();
111 150
     $SI->connect();
112 151
 */
113
-} else $SI=new SpotterImport($Connection->db);
152
+} else {
153
+	$SI=new SpotterImport($Connection->db);
154
+}
114 155
 
115
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
156
+if (isset($globalTracker) && $globalTracker) {
157
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
158
+}
116 159
 if (isset($globalMarine) && $globalMarine) {
117 160
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
118 161
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 162
 }
120 163
 
121
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
164
+if (isset($globalTracker) && $globalTracker) {
165
+	$TI = new TrackerImport($Connection->db);
166
+}
122 167
 if (isset($globalMarine) && $globalMarine) {
123 168
     $AIS = new AIS();
124 169
     $MI = new MarineImport($Connection->db);
@@ -143,7 +188,9 @@  discard block
 block discarded – undo
143 188
 }
144 189
 
145 190
 // let's try and connect
146
-if ($globalDebug) echo "Connecting...\n";
191
+if ($globalDebug) {
192
+	echo "Connecting...\n";
193
+}
147 194
 $use_aprs = false;
148 195
 $aprs_full = false;
149 196
 $reset = 0;
@@ -152,7 +199,9 @@  discard block
 block discarded – undo
152 199
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153 200
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154 201
     $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
202
+    if ($globalDebug) {
203
+    	echo 'Connect to all...'."\n";
204
+    }
156 205
     foreach ($hosts as $id => $value) {
157 206
 	$host = $value['host'];
158 207
 	$globalSources[$id]['last_exec'] = 0;
@@ -162,27 +211,37 @@  discard block
 block discarded – undo
162 211
         	//$formats[$id] = 'deltadbtxt';
163 212
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 213
         	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to deltadb source (".$host.")...\n";
216
+        	}
166 217
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167 218
         	//$formats[$id] = 'vatsimtxt';
168 219
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 220
         	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
221
+        	if ($globalDebug) {
222
+        		echo "Connect to vatsim source (".$host.")...\n";
223
+        	}
171 224
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172 225
         	//$formats[$id] = 'aircraftlistjson';
173 226
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 227
         	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
230
+        	}
176 231
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
177 232
         	//$formats[$id] = 'aircraftjson';
178 233
         	$globalSources[$id]['format'] = 'aircraftjson';
179 234
         	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
237
+        	}
181 238
     	    } else if (preg_match('/opensky/i',$host)) {
182 239
         	//$formats[$id] = 'aircraftlistjson';
183 240
         	$globalSources[$id]['format'] = 'opensky';
184 241
         	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
242
+        	if ($globalDebug) {
243
+        		echo "Connect to opensky source (".$host.")...\n";
244
+        	}
186 245
     	    /*
187 246
     	    // Disabled for now, site change source format
188 247
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -199,7 +258,9 @@  discard block
 block discarded – undo
199 258
         	//$formats[$id] = 'planeupdatefaa';
200 259
         	$globalSources[$id]['format'] = 'planeupdatefaa';
201 260
         	//$last_exec['planeupdatefaa'] = 0;
202
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
261
+        	if ($globalDebug) {
262
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
263
+        	}
203 264
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
204 265
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
205 266
         	    exit(0);
@@ -208,37 +269,53 @@  discard block
 block discarded – undo
208 269
         	//$formats[$id] = 'phpvmacars';
209 270
         	$globalSources[$id]['format'] = 'phpvmacars';
210 271
         	//$last_exec['phpvmacars'] = 0;
211
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
272
+        	if ($globalDebug) {
273
+        		echo "Connect to phpvmacars source (".$host.")...\n";
274
+        	}
212 275
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
213 276
         	//$formats[$id] = 'phpvmacars';
214 277
         	$globalSources[$id]['format'] = 'vaos';
215 278
         	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
279
+        	if ($globalDebug) {
280
+        		echo "Connect to vaos source (".$host.")...\n";
281
+        	}
217 282
             } else if (preg_match('/VAM-json.php$/i',$host)) {
218 283
         	//$formats[$id] = 'phpvmacars';
219 284
         	$globalSources[$id]['format'] = 'vam';
220
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
285
+        	if ($globalDebug) {
286
+        		echo "Connect to Vam source (".$host.")...\n";
287
+        	}
221 288
             } else if (preg_match('/whazzup/i',$host)) {
222 289
         	//$formats[$id] = 'whazzup';
223 290
         	$globalSources[$id]['format'] = 'whazzup';
224 291
         	//$last_exec['whazzup'] = 0;
225
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
292
+        	if ($globalDebug) {
293
+        		echo "Connect to whazzup source (".$host.")...\n";
294
+        	}
226 295
             } else if (preg_match('/blitzortung/i',$host)) {
227 296
         	$globalSources[$id]['format'] = 'blitzortung';
228
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
297
+        	if ($globalDebug) {
298
+        		echo "Connect to blitzortung source (".$host.")...\n";
299
+        	}
229 300
             } else if (preg_match('/airwhere/i',$host)) {
230 301
         	$globalSources[$id]['format'] = 'airwhere';
231
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
302
+        	if ($globalDebug) {
303
+        		echo "Connect to airwhere source (".$host.")...\n";
304
+        	}
232 305
             } else if (preg_match('/recentpireps/i',$host)) {
233 306
         	//$formats[$id] = 'pirepsjson';
234 307
         	$globalSources[$id]['format'] = 'pirepsjson';
235 308
         	//$last_exec['pirepsjson'] = 0;
236
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
309
+        	if ($globalDebug) {
310
+        		echo "Connect to pirepsjson source (".$host.")...\n";
311
+        	}
237 312
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
238 313
         	//$formats[$id] = 'fr24json';
239 314
         	$globalSources[$id]['format'] = 'fr24json';
240 315
         	//$last_exec['fr24json'] = 0;
241
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
316
+        	if ($globalDebug) {
317
+        		echo "Connect to fr24 source (".$host.")...\n";
318
+        	}
242 319
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
243 320
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
244 321
         	    exit(0);
@@ -247,7 +324,9 @@  discard block
 block discarded – undo
247 324
         	//$formats[$id] = 'fr24json';
248 325
         	$globalSources[$id]['format'] = 'myshiptracking';
249 326
         	//$last_exec['fr24json'] = 0;
250
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
327
+        	if ($globalDebug) {
328
+        		echo "Connect to myshiptracking source (".$host.")...\n";
329
+        	}
251 330
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
252 331
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
253 332
         	    exit(0);
@@ -256,16 +335,24 @@  discard block
 block discarded – undo
256 335
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
257 336
         	//$formats[$id] = 'tsv';
258 337
         	$globalSources[$id]['format'] = 'tsv';
259
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
338
+        	if ($globalDebug) {
339
+        		echo "Connect to tsv source (".$host.")...\n";
340
+        	}
260 341
             }
261 342
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
262 343
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
263 344
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
264 345
     		    if ($idf !== false) {
265 346
     			$httpfeeds[$id] = $idf;
266
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
267
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
268
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
347
+        		if ($globalDebug) {
348
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
349
+        		}
350
+    		    } elseif ($globalDebug) {
351
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
352
+    		    }
353
+    		} elseif ($globalDebug) {
354
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
355
+    		}
269 356
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
270 357
 	    $hostport = explode(':',$host);
271 358
 	    if (isset($hostport[1])) {
@@ -305,17 +392,25 @@  discard block
 block discarded – undo
305 392
         		//$formats[$id] = 'beast';
306 393
         		$globalSources[$id]['format'] = 'beast';
307 394
 		    //} else $formats[$id] = 'sbs';
308
-		    } else $globalSources[$id]['format'] = 'sbs';
395
+		    } else {
396
+		    	$globalSources[$id]['format'] = 'sbs';
397
+		    }
309 398
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
310 399
 		}
311
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
400
+		if ($globalDebug) {
401
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
402
+		}
312 403
             } else {
313
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
404
+		if ($globalDebug) {
405
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
406
+		}
314 407
     	    }
315 408
         }
316 409
     }
317 410
 }
318
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
411
+if (!isset($globalMinFetch)) {
412
+	$globalMinFetch = 15;
413
+}
319 414
 
320 415
 // Initialize all
321 416
 $status = array();
@@ -324,13 +419,19 @@  discard block
 block discarded – undo
324 419
 $formats = array();
325 420
 $last_exec = array();
326 421
 $time = time();
327
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
328
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
329
-else $timeout = 20;
422
+if (isset($globalSourcesTimeout)) {
423
+	$timeout = $globalSourcesTimeOut;
424
+} else if (isset($globalSBS1TimeOut)) {
425
+	$timeout = $globalSBS1TimeOut;
426
+} else {
427
+	$timeout = 20;
428
+}
330 429
 $errno = '';
331 430
 $errstr='';
332 431
 
333
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
432
+if (!isset($globalDaemon)) {
433
+	$globalDaemon = TRUE;
434
+}
334 435
 /* Initiate connections to all the hosts simultaneously */
335 436
 //connect_all($hosts);
336 437
 //connect_all($globalSources);
@@ -359,7 +460,9 @@  discard block
 block discarded – undo
359 460
     if (isset($source['format']) && $source['format'] == 'aprs') {
360 461
 	$aprs_connect = 0;
361 462
 	$use_aprs = true;
362
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
463
+	if (isset($source['port']) && $source['port'] == '10152') {
464
+		$aprs_full = true;
465
+	}
363 466
 	break;
364 467
     }
365 468
 }
@@ -370,25 +473,46 @@  discard block
 block discarded – undo
370 473
 	$aprs_connect = 0;
371 474
 	$aprs_keep = 120;
372 475
 	$aprs_last_tx = time();
373
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
374
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
375
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
376
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
377
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
378
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
379
-	if ($aprs_full) $aprs_filter = '';
380
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
381
-	else $aprs_pass = '-1';
476
+	if (isset($globalAPRSversion)) {
477
+		$aprs_version = $globalAPRSversion;
478
+	} else {
479
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
480
+	}
481
+	if (isset($globalAPRSssid)) {
482
+		$aprs_ssid = $globalAPRSssid;
483
+	} else {
484
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
485
+	}
486
+	if (isset($globalAPRSfilter)) {
487
+		$aprs_filter = $globalAPRSfilter;
488
+	} else {
489
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
490
+	}
491
+	if ($aprs_full) {
492
+		$aprs_filter = '';
493
+	}
494
+	if (isset($globalAPRSpass)) {
495
+		$aprs_pass = $globalAPRSpass;
496
+	} else {
497
+		$aprs_pass = '-1';
498
+	}
382 499
 
383
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
384
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
385
-}
500
+	if ($aprs_filter != '') {
501
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
502
+	} else {
503
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
504
+	}
505
+	}
386 506
 
387 507
 // connected - lets do some work
388 508
 //if ($globalDebug) echo "Connected!\n";
389 509
 sleep(1);
390
-if ($globalDebug) echo "SCAN MODE \n\n";
391
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
510
+if ($globalDebug) {
511
+	echo "SCAN MODE \n\n";
512
+}
513
+if (!isset($globalCronEnd)) {
514
+	$globalCronEnd = 60;
515
+}
392 516
 $endtime = time()+$globalCronEnd;
393 517
 $i = 1;
394 518
 $tt = array();
@@ -402,22 +526,32 @@  discard block
 block discarded – undo
402 526
 
403 527
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
404 528
 while ($i > 0) {
405
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
529
+    if (function_exists('pcntl_fork')) {
530
+    	pcntl_signal_dispatch();
531
+    }
406 532
 
407
-    if (!$globalDaemon) $i = $endtime-time();
533
+    if (!$globalDaemon) {
534
+    	$i = $endtime-time();
535
+    }
408 536
     // Delete old ATC
409 537
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
410
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
538
+	if ($globalDebug) {
539
+		echo 'Delete old ATC...'."\n";
540
+	}
411 541
         $ATC->deleteOldATC();
412 542
     }
413 543
     
414 544
     if (count($last_exec) == count($globalSources)) {
415 545
 	$max = $globalMinFetch;
416 546
 	foreach ($last_exec as $last) {
417
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
547
+	    if ((time() - $last['last']) < $max) {
548
+	    	$max = time() - $last['last'];
549
+	    }
418 550
 	}
419 551
 	if ($max < $globalMinFetch) {
420
-	    if ($globalDebug) echo 'Sleeping...'."\n";
552
+	    if ($globalDebug) {
553
+	    	echo 'Sleeping...'."\n";
554
+	    }
421 555
 	    sleep($globalMinFetch-$max+2);
422 556
 	}
423 557
     }
@@ -427,7 +561,9 @@  discard block
 block discarded – undo
427 561
     foreach ($globalSources as $id => $value) {
428 562
 	date_default_timezone_set('UTC');
429 563
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
430
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
564
+	if (!isset($last_exec[$id]['last'])) {
565
+		$last_exec[$id]['last'] = 0;
566
+	}
431 567
 	if ($value['format'] === 'deltadbtxt' && 
432 568
 	    (
433 569
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -436,7 +572,9 @@  discard block
 block discarded – undo
436 572
 	) {
437 573
 	    //$buffer = $Common->getData($hosts[$id]);
438 574
 	    $buffer = $Common->getData($value['host']);
439
-	    if ($buffer != '') $reset = 0;
575
+	    if ($buffer != '') {
576
+	    	$reset = 0;
577
+	    }
440 578
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
441 579
 	    $buffer = explode('\n',$buffer);
442 580
 	    foreach ($buffer as $line) {
@@ -445,20 +583,41 @@  discard block
 block discarded – undo
445 583
 	            $data = array();
446 584
 	            $data['hex'] = $line[1]; // hex
447 585
 	            $data['ident'] = $line[2]; // ident
448
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
449
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
450
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
451
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
452
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
586
+	            if (isset($line[3])) {
587
+	            	$data['altitude'] = $line[3];
588
+	            }
589
+	            // altitude
590
+	            if (isset($line[4])) {
591
+	            	$data['speed'] = $line[4];
592
+	            }
593
+	            // speed
594
+	            if (isset($line[5])) {
595
+	            	$data['heading'] = $line[5];
596
+	            }
597
+	            // heading
598
+	            if (isset($line[6])) {
599
+	            	$data['latitude'] = $line[6];
600
+	            }
601
+	            // lat
602
+	            if (isset($line[7])) {
603
+	            	$data['longitude'] = $line[7];
604
+	            }
605
+	            // long
453 606
 	            $data['verticalrate'] = ''; // vertical rate
454 607
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
455 608
 	            $data['emergency'] = ''; // emergency
456 609
 		    $data['datetime'] = date('Y-m-d H:i:s');
457 610
 		    $data['format_source'] = 'deltadbtxt';
458 611
     		    $data['id_source'] = $id_source;
459
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
460
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
461
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
612
+		    if (isset($value['name']) && $value['name'] != '') {
613
+		    	$data['source_name'] = $value['name'];
614
+		    }
615
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
616
+		    	$data['noarchive'] = true;
617
+		    }
618
+		    if (isset($value['sourcestats'])) {
619
+		    	$data['sourcestats'] = $value['sourcestats'];
620
+		    }
462 621
     		    $SI->add($data);
463 622
 		    unset($data);
464 623
     		}
@@ -473,7 +632,9 @@  discard block
 block discarded – undo
473 632
 	    date_default_timezone_set('CET');
474 633
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
475 634
 	    date_default_timezone_set('UTC');
476
-	    if ($buffer != '') $reset = 0;
635
+	    if ($buffer != '') {
636
+	    	$reset = 0;
637
+	    }
477 638
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
478 639
 	    $buffer = explode('\n',$buffer);
479 640
 	    foreach ($buffer as $line) {
@@ -482,18 +643,42 @@  discard block
 block discarded – undo
482 643
 		    $add = false;
483 644
 		    $ais_data = $AIS->parse_line(trim($line));
484 645
 		    $data = array();
485
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
486
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
487
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
488
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
489
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
490
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
491
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
492
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
493
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
494
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
495
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
496
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
646
+		    if (isset($ais_data['ident'])) {
647
+		    	$data['ident'] = $ais_data['ident'];
648
+		    }
649
+		    if (isset($ais_data['mmsi'])) {
650
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
651
+		    }
652
+		    if (isset($ais_data['speed'])) {
653
+		    	$data['speed'] = $ais_data['speed'];
654
+		    }
655
+		    if (isset($ais_data['heading'])) {
656
+		    	$data['heading'] = $ais_data['heading'];
657
+		    }
658
+		    if (isset($ais_data['latitude'])) {
659
+		    	$data['latitude'] = $ais_data['latitude'];
660
+		    }
661
+		    if (isset($ais_data['longitude'])) {
662
+		    	$data['longitude'] = $ais_data['longitude'];
663
+		    }
664
+		    if (isset($ais_data['status'])) {
665
+		    	$data['status'] = $ais_data['status'];
666
+		    }
667
+		    if (isset($ais_data['statusid'])) {
668
+		    	$data['status_id'] = $ais_data['statusid'];
669
+		    }
670
+		    if (isset($ais_data['type'])) {
671
+		    	$data['type'] = $ais_data['type'];
672
+		    }
673
+		    if (isset($ais_data['typeid'])) {
674
+		    	$data['type_id'] = $ais_data['typeid'];
675
+		    }
676
+		    if (isset($ais_data['imo'])) {
677
+		    	$data['imo'] = $ais_data['imo'];
678
+		    }
679
+		    if (isset($ais_data['callsign'])) {
680
+		    	$data['callsign'] = $ais_data['callsign'];
681
+		    }
497 682
 		    if (isset($ais_data['timestamp'])) {
498 683
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
499 684
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -507,8 +692,12 @@  discard block
 block discarded – undo
507 692
 		    $data['format_source'] = 'aisnmeatxt';
508 693
     		    $data['id_source'] = $id_source;
509 694
 		    //print_r($data);
510
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
511
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
695
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
696
+		    	$data['noarchive'] = true;
697
+		    }
698
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
699
+		    	$MI->add($data);
700
+		    }
512 701
 		    unset($data);
513 702
 		}
514 703
     	    }
@@ -531,20 +720,48 @@  discard block
 block discarded – undo
531 720
 			    if ($line != '') {
532 721
 				$ais_data = $AIS->parse_line(trim($line));
533 722
 				$data = array();
534
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
535
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
536
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
537
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
538
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
539
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
540
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
541
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
542
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
543
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
544
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
545
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
546
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
547
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
723
+				if (isset($ais_data['ident'])) {
724
+					$data['ident'] = $ais_data['ident'];
725
+				}
726
+				if (isset($ais_data['mmsi'])) {
727
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
728
+				}
729
+				if (isset($ais_data['speed'])) {
730
+					$data['speed'] = $ais_data['speed'];
731
+				}
732
+				if (isset($ais_data['heading'])) {
733
+					$data['heading'] = $ais_data['heading'];
734
+				}
735
+				if (isset($ais_data['latitude'])) {
736
+					$data['latitude'] = $ais_data['latitude'];
737
+				}
738
+				if (isset($ais_data['longitude'])) {
739
+					$data['longitude'] = $ais_data['longitude'];
740
+				}
741
+				if (isset($ais_data['status'])) {
742
+					$data['status'] = $ais_data['status'];
743
+				}
744
+				if (isset($ais_data['statusid'])) {
745
+					$data['status_id'] = $ais_data['statusid'];
746
+				}
747
+				if (isset($ais_data['type'])) {
748
+					$data['type'] = $ais_data['type'];
749
+				}
750
+				if (isset($ais_data['typeid'])) {
751
+					$data['type_id'] = $ais_data['typeid'];
752
+				}
753
+				if (isset($ais_data['imo'])) {
754
+					$data['imo'] = $ais_data['imo'];
755
+				}
756
+				if (isset($ais_data['callsign'])) {
757
+					$data['callsign'] = $ais_data['callsign'];
758
+				}
759
+				if (isset($ais_data['destination'])) {
760
+					$data['arrival_code'] = $ais_data['destination'];
761
+				}
762
+				if (isset($ais_data['eta_ts'])) {
763
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
764
+				}
548 765
 				if (isset($ais_data['timestamp'])) {
549 766
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
550 767
 				} else {
@@ -552,18 +769,27 @@  discard block
 block discarded – undo
552 769
 				}
553 770
 				$data['format_source'] = 'aisnmeahttp';
554 771
 				$data['id_source'] = $id_source;
555
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
556
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
772
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
773
+					$data['noarchive'] = true;
774
+				}
775
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
776
+					$MI->add($data);
777
+				}
557 778
 				unset($data);
558 779
 			    }
559 780
 			}
560 781
 		    }
561 782
 		} else {
562 783
 		    $format = $value['format'];
563
-		    if (isset($tt[$format])) $tt[$format]++;
564
-		    else $tt[$format] = 0;
784
+		    if (isset($tt[$format])) {
785
+		    	$tt[$format]++;
786
+		    } else {
787
+		    	$tt[$format] = 0;
788
+		    }
565 789
 		    if ($tt[$format] > 30) {
566
-			if ($globalDebug) echo 'Reconnect...'."\n";
790
+			if ($globalDebug) {
791
+				echo 'Reconnect...'."\n";
792
+			}
567 793
 			sleep(2);
568 794
 			//$sourceeen[] = $value;
569 795
 			//connect_all($sourceeen);
@@ -599,12 +825,18 @@  discard block
 block discarded – undo
599 825
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
600 826
 			    //$data['type_id'] = $line['TYPE'];
601 827
 			    $data['imo'] = $line['IMO'];
602
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
603
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
828
+			    if ($line['DEST'] != '') {
829
+			    	$data['arrival_code'] = $line['DEST'];
830
+			    }
831
+			    if ($line['ARV'] != '') {
832
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
833
+			    }
604 834
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
605 835
 			    $data['format_source'] = 'myshiptracking';
606 836
 			    $data['id_source'] = $id_source;
607
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
837
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
838
+			    	$data['noarchive'] = true;
839
+			    }
608 840
 			    $MI->add($data);
609 841
 			    unset($data);
610 842
 			}
@@ -629,7 +861,9 @@  discard block
 block discarded – undo
629 861
 			    $data['callsign'] = $line['callsign'];
630 862
 			    $data['mmsi'] = substr($line['mmsi'],-9);
631 863
 			    $data['speed'] = $line['sog'];
632
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
864
+			    if ($line['heading'] != '511') {
865
+			    	$data['heading'] = $line['heading'];
866
+			    }
633 867
 			    $data['latitude'] = $line['latitude'];
634 868
 			    $data['longitude'] = $line['longitude'];
635 869
 			    $data['type_id'] = $line['shiptype'];
@@ -637,7 +871,9 @@  discard block
 block discarded – undo
637 871
 			    $data['datetime'] = $line['time'];
638 872
 			    $data['format_source'] = 'boatbeaconapp';
639 873
 			    $data['id_source'] = $id_source;
640
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
874
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
875
+			    	$data['noarchive'] = true;
876
+			    }
641 877
 			    $MI->add($data);
642 878
 			    unset($data);
643 879
 			}
@@ -659,22 +895,44 @@  discard block
 block discarded – undo
659 895
 		    foreach ($all_data['features'] as $line) {
660 896
 			print_r($line);
661 897
 			$data = array();
662
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
663
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
664
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
665
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
666
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
667
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
898
+			if (isset($line['properties']['name'])) {
899
+				$data['ident'] = $line['properties']['name'];
900
+			}
901
+			if (isset($line['properties']['callsign'])) {
902
+				$data['callsign'] = $line['properties']['callsign'];
903
+			}
904
+			if (isset($line['properties']['mmsi'])) {
905
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
906
+			}
907
+			if (isset($line['properties']['imo'])) {
908
+				$data['imo'] = $line['properties']['imo'];
909
+			}
910
+			if (isset($line['properties']['speed'])) {
911
+				$data['speed'] = $line['properties']['speed'];
912
+			}
913
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
914
+				$data['heading'] = $line['properties']['heading'];
915
+			}
668 916
 			$data['latitude'] = $line['geometry']['coordinates'][1];
669 917
 			$data['longitude'] = $line['geometry']['coordinates'][0];
670
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
671
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
672
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
918
+			if (isset($line['properties']['vesselType'])) {
919
+				$data['type'] = $line['properties']['vesselType'];
920
+			}
921
+			if (isset($line['properties']['destination'])) {
922
+				$data['arrival_code'] = $line['properties']['destination'];
923
+			}
924
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
925
+				$data['arrival_date'] = $line['properties']['eta'];
926
+			}
673 927
 			$data['format_source'] = 'boatnerd';
674 928
 			$data['id_source'] = $id_source;
675 929
 			$data['datetime'] = date('Y-m-d H:i:s');
676
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
677
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
930
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
931
+				$data['noarchive'] = true;
932
+			}
933
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
934
+				$MI->add($data);
935
+			}
678 936
 			unset($data);
679 937
 		    }
680 938
 		}
@@ -691,7 +949,9 @@  discard block
 block discarded – undo
691 949
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
692 950
 	    echo 'done !'."\n";
693 951
 	    // FIXME: Need more work
694
-	    if ($buffer != '') $reset = 0;
952
+	    if ($buffer != '') {
953
+	    	$reset = 0;
954
+	    }
695 955
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
696 956
 	    $buffer = explode('\n',$buffer);
697 957
 	    foreach ($buffer as $line) {
@@ -717,7 +977,9 @@  discard block
 block discarded – undo
717 977
 		    //$data['etaTime'] = substr($line,135,5);
718 978
 		    $data['format_source'] = 'shipplotter';
719 979
     		    $data['id_source'] = $id_source;
720
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
980
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
981
+		    	$data['noarchive'] = true;
982
+		    }
721 983
 		    //print_r($data);
722 984
 		    echo 'Add...'."\n";
723 985
 		    $MI->add($data);
@@ -751,16 +1013,28 @@  discard block
 block discarded – undo
751 1013
     		    $line = explode(':', $line);
752 1014
     		    if (count($line) > 30 && $line[0] != 'callsign') {
753 1015
 			$data = array();
754
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
755
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1016
+			if (isset($line[37]) && $line[37] != '') {
1017
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1018
+			} else {
1019
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1020
+			}
756 1021
 			$data['pilot_id'] = $line[1];
757 1022
 			$data['pilot_name'] = $line[2];
758 1023
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
759 1024
 			$data['ident'] = $line[0]; // ident
760
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1025
+			if ($line[7] != '' && $line[7] != 0) {
1026
+				$data['altitude'] = $line[7];
1027
+			}
1028
+			// altitude
761 1029
 			$data['speed'] = $line[8]; // speed
762
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
763
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1030
+			if (isset($line[45])) {
1031
+				$data['heading'] = $line[45];
1032
+			}
1033
+			// heading
1034
+			elseif (isset($line[38])) {
1035
+				$data['heading'] = $line[38];
1036
+			}
1037
+			// heading
764 1038
 			$data['latitude'] = $line[5]; // lat
765 1039
 	        	$data['longitude'] = $line[6]; // long
766 1040
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -776,7 +1050,9 @@  discard block
 block discarded – undo
776 1050
 			$data['frequency'] = $line[4];
777 1051
 			$data['type'] = $line[18];
778 1052
 			$data['range'] = $line[19];
779
-			if (isset($line[35])) $data['info'] = $line[35];
1053
+			if (isset($line[35])) {
1054
+				$data['info'] = $line[35];
1055
+			}
780 1056
     			$data['id_source'] = $id_source;
781 1057
 	    		//$data['arrival_airport_time'] = ;
782 1058
 	    		if ($line[9] != '') {
@@ -790,27 +1066,47 @@  discard block
 block discarded – undo
790 1066
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
791 1067
 	    		*/
792 1068
 	    		$data['format_source'] = $value['format'];
793
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
794
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
795
-    			if ($line[3] === 'PILOT') $SI->add($data);
796
-			elseif ($line[3] === 'ATC') {
1069
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1070
+				$data['noarchive'] = true;
1071
+			}
1072
+			if (isset($value['name']) && $value['name'] != '') {
1073
+				$data['source_name'] = $value['name'];
1074
+			}
1075
+    			if ($line[3] === 'PILOT') {
1076
+    				$SI->add($data);
1077
+    			} elseif ($line[3] === 'ATC') {
797 1078
 				//print_r($data);
798 1079
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
799 1080
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
800 1081
 				$typec = substr($data['ident'],-3);
801
-				if ($typec === 'APP') $data['type'] = 'Approach';
802
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
803
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
804
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
805
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
806
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
807
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
808
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
809
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
810
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1082
+				if ($typec === 'APP') {
1083
+					$data['type'] = 'Approach';
1084
+				} elseif ($typec === 'TWR') {
1085
+					$data['type'] = 'Tower';
1086
+				} elseif ($typec === 'OBS') {
1087
+					$data['type'] = 'Observer';
1088
+				} elseif ($typec === 'GND') {
1089
+					$data['type'] = 'Ground';
1090
+				} elseif ($typec === 'DEL') {
1091
+					$data['type'] = 'Delivery';
1092
+				} elseif ($typec === 'DEP') {
1093
+					$data['type'] = 'Departure';
1094
+				} elseif ($typec === 'FSS') {
1095
+					$data['type'] = 'Flight Service Station';
1096
+				} elseif ($typec === 'CTR') {
1097
+					$data['type'] = 'Control Radar or Centre';
1098
+				} elseif ($data['type'] === '') {
1099
+					$data['type'] = 'Observer';
1100
+				}
1101
+				if (!isset($data['source_name'])) {
1102
+					$data['source_name'] = '';
1103
+				}
811 1104
 				if (isset($ATC)) {
812
-					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']);
813
-					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']);
1105
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1106
+						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']);
1107
+					} else {
1108
+						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']);
1109
+					}
814 1110
 				}
815 1111
 			}
816 1112
     			unset($data);
@@ -837,14 +1133,20 @@  discard block
 block discarded – undo
837 1133
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
838 1134
 			$data['latitude'] = (float)$line['pktLatitude'];
839 1135
 			$data['longitude'] = (float)$line['pktLongitude'];
840
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
841
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1136
+			if ((float)$line['pktTrack'] != 0) {
1137
+				$data['heading'] = (float)$line['pktTrack'];
1138
+			}
1139
+			if ((int)$line['pktSpeed'] != 0) {
1140
+				$data['speed'] = (int)$line['pktSpeed'];
1141
+			}
842 1142
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
843 1143
 			$data['altitude_relative'] = 'AMSL';
844 1144
 			$data['pilot_id'] = (int)$line['pktPilotID'];
845 1145
 			$data['aircraft_icao'] = 'PARAGLIDER';
846 1146
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
847
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1147
+			if (isset($pilot_data[4])) {
1148
+				$data['pilot_name'] = $pilot_data[4];
1149
+			}
848 1150
 			$data['format_source'] = $value['format'];
849 1151
 			$SI->add($data);
850 1152
 			unset($data);
@@ -892,25 +1194,59 @@  discard block
 block discarded – undo
892 1194
 		    foreach ($all_data['acList'] as $line) {
893 1195
 			$data = array();
894 1196
 			$data['hex'] = $line['Icao']; // hex
895
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
896
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
897
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
898
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
899
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
900
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1197
+			if (isset($line['Call'])) {
1198
+				$data['ident'] = $line['Call'];
1199
+			}
1200
+			// ident
1201
+			if (isset($line['Alt'])) {
1202
+				$data['altitude'] = $line['Alt'];
1203
+			}
1204
+			// altitude
1205
+			if (isset($line['Spd'])) {
1206
+				$data['speed'] = $line['Spd'];
1207
+			}
1208
+			// speed
1209
+			if (isset($line['Trak'])) {
1210
+				$data['heading'] = $line['Trak'];
1211
+			}
1212
+			// heading
1213
+			if (isset($line['Lat'])) {
1214
+				$data['latitude'] = $line['Lat'];
1215
+			}
1216
+			// lat
1217
+			if (isset($line['Long'])) {
1218
+				$data['longitude'] = $line['Long'];
1219
+			}
1220
+			// long
901 1221
 			//$data['verticalrate'] = $line['']; // verticale rate
902
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1222
+			if (isset($line['Sqk'])) {
1223
+				$data['squawk'] = $line['Sqk'];
1224
+			}
1225
+			// squawk
903 1226
 			$data['emergency'] = ''; // emergency
904
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
905
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
906
-			else $data['datetime'] = date('Y-m-d H:i:s');
1227
+			if (isset($line['Reg'])) {
1228
+				$data['registration'] = $line['Reg'];
1229
+			}
1230
+			if (isset($line['PosTime'])) {
1231
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1232
+			} else {
1233
+				$data['datetime'] = date('Y-m-d H:i:s');
1234
+			}
907 1235
 			//$data['datetime'] = date('Y-m-d H:i:s');
908
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1236
+			if (isset($line['Type'])) {
1237
+				$data['aircraft_icao'] = $line['Type'];
1238
+			}
909 1239
 			$data['format_source'] = 'aircraftlistjson';
910 1240
 			$data['id_source'] = $id_source;
911
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
912
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
913
-			if (isset($data['latitude'])) $SI->add($data);
1241
+			if (isset($value['name']) && $value['name'] != '') {
1242
+				$data['source_name'] = $value['name'];
1243
+			}
1244
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1245
+				$data['noarchive'] = true;
1246
+			}
1247
+			if (isset($data['latitude'])) {
1248
+				$SI->add($data);
1249
+			}
914 1250
 			unset($data);
915 1251
 		    }
916 1252
 		} elseif (is_array($all_data)) {
@@ -927,17 +1263,26 @@  discard block
 block discarded – undo
927 1263
 			$data['verticalrate'] = $line['vrt']; // verticale rate
928 1264
 			$data['squawk'] = $line['squawk']; // squawk
929 1265
 			$data['emergency'] = ''; // emergency
930
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
931
-			else $data['datetime'] = date('Y-m-d H:i:s');
1266
+			if (isset($line['PosTime'])) {
1267
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1268
+			} else {
1269
+				$data['datetime'] = date('Y-m-d H:i:s');
1270
+			}
932 1271
 			$data['format_source'] = 'aircraftlistjson';
933 1272
 			$data['id_source'] = $id_source;
934
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
935
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1273
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1274
+				$data['noarchive'] = true;
1275
+			}
1276
+			if (isset($value['name']) && $value['name'] != '') {
1277
+				$data['source_name'] = $value['name'];
1278
+			}
936 1279
 			$SI->add($data);
937 1280
 			unset($data);
938 1281
 		    }
939 1282
 		}
940
-	    } elseif ($globalDebug) echo 'No data'."\n";
1283
+	    } elseif ($globalDebug) {
1284
+	    	echo 'No data'."\n";
1285
+	    }
941 1286
     	    //$last_exec['aircraftlistjson'] = time();
942 1287
     	    $last_exec[$id]['last'] = time();
943 1288
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -973,8 +1318,12 @@  discard block
 block discarded – undo
973 1318
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
974 1319
 	    	    $data['format_source'] = 'planeupdatefaa';
975 1320
     		    $data['id_source'] = $id_source;
976
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
977
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1321
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1322
+		    	$data['noarchive'] = true;
1323
+		    }
1324
+		    if (isset($value['name']) && $value['name'] != '') {
1325
+		    	$data['source_name'] = $value['name'];
1326
+		    }
978 1327
 		    $SI->add($data);
979 1328
 		    unset($data);
980 1329
 		}
@@ -1008,7 +1357,9 @@  discard block
 block discarded – undo
1008 1357
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1009 1358
 		    $data['format_source'] = 'opensky';
1010 1359
 		    $data['id_source'] = $id_source;
1011
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1360
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1361
+		    	$data['noarchive'] = true;
1362
+		    }
1012 1363
 		    $SI->add($data);
1013 1364
 		    unset($data);
1014 1365
 		}
@@ -1027,22 +1378,51 @@  discard block
 block discarded – undo
1027 1378
 		$reset = 0;
1028 1379
 		foreach ($all_data['aircraft'] as $key => $line) {
1029 1380
 		    $data = array();
1030
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1031
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1032
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1033
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1034
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1035
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1036
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1037
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1038
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1381
+		    if (isset($line['hex'])) {
1382
+		    	$data['hex'] = $line['hex'];
1383
+		    }
1384
+		    // hex
1385
+		    if (isset($line['flight'])) {
1386
+		    	$data['ident'] = trim($line['flight']);
1387
+		    }
1388
+		    // ident
1389
+		    if (isset($line['altitude'])) {
1390
+		    	$data['altitude'] = $line['altitude'];
1391
+		    }
1392
+		    // altitude
1393
+		    if (isset($line['speed'])) {
1394
+		    	$data['speed'] = $line['speed'];
1395
+		    }
1396
+		    // speed
1397
+		    if (isset($line['track'])) {
1398
+		    	$data['heading'] = $line['track'];
1399
+		    }
1400
+		    // heading
1401
+		    if (isset($line['lat'])) {
1402
+		    	$data['latitude'] = $line['lat'];
1403
+		    }
1404
+		    // lat
1405
+		    if (isset($line['lon'])) {
1406
+		    	$data['longitude'] = $line['lon'];
1407
+		    }
1408
+		    // long
1409
+		    if (isset($line['vert_rate'])) {
1410
+		    	$data['verticalrate'] = $line['vert_rate'];
1411
+		    }
1412
+		    // verticale rate
1413
+		    if (isset($line['squawk'])) {
1414
+		    	$data['squawk'] = $line['squawk'];
1415
+		    }
1416
+		    // squawk
1039 1417
 		    //$data['emergency'] = ''; // emergency
1040 1418
 		    //$data['registration'] = $line[2];
1041 1419
 		    //$data['aircraft_icao'] = $line[0];
1042 1420
 		    $data['datetime'] = date('Y-m-d H:i:s');
1043 1421
 		    $data['format_source'] = 'aircraftjson';
1044 1422
 		    $data['id_source'] = $id_source;
1045
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1423
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1424
+		    	$data['noarchive'] = true;
1425
+		    }
1046 1426
 		    $SI->add($data);
1047 1427
 		    unset($data);
1048 1428
 		}
@@ -1059,7 +1439,9 @@  discard block
 block discarded – undo
1059 1439
 	    //$buffer = $Common->getData($hosts[$id]);
1060 1440
 	    $buffer = $Common->getData($value['host']);
1061 1441
 	    $all_data = json_decode($buffer,true);
1062
-	    if (!empty($all_data)) $reset = 0;
1442
+	    if (!empty($all_data)) {
1443
+	    	$reset = 0;
1444
+	    }
1063 1445
 	    foreach ($all_data as $key => $line) {
1064 1446
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1065 1447
 		    $data = array();
@@ -1080,8 +1462,12 @@  discard block
 block discarded – undo
1080 1462
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1081 1463
 	    	    $data['format_source'] = 'fr24json';
1082 1464
     		    $data['id_source'] = $id_source;
1083
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1084
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1465
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1466
+		    	$data['noarchive'] = true;
1467
+		    }
1468
+		    if (isset($value['name']) && $value['name'] != '') {
1469
+		    	$data['source_name'] = $value['name'];
1470
+		    }
1085 1471
 		    $SI->add($data);
1086 1472
 		    unset($data);
1087 1473
 		}
@@ -1110,24 +1496,42 @@  discard block
 block discarded – undo
1110 1496
 		    if (isset($line['inf'])) {
1111 1497
 			$data = array();
1112 1498
 			$data['hex'] = $line['inf']['ia'];
1113
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1499
+			if (isset($line['inf']['cs'])) {
1500
+				$data['ident'] = $line['inf']['cs'];
1501
+			}
1502
+			//$line[13]
1114 1503
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1115
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1116
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1504
+	    		if (isset($line['inf']['gs'])) {
1505
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1506
+	    		}
1507
+	    		// speed
1508
+	    		if (isset($line['inf']['tr'])) {
1509
+	    			$data['heading'] = $line['inf']['tr'];
1510
+	    		}
1511
+	    		// heading
1117 1512
 	    		$data['latitude'] = $line['pt'][0]; // lat
1118 1513
 	    		$data['longitude'] = $line['pt'][1]; // long
1119 1514
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1120
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1515
+	    		if (isset($line['inf']['sq'])) {
1516
+	    			$data['squawk'] = $line['inf']['sq'];
1517
+	    		}
1518
+	    		// squawk
1121 1519
 	    		//$data['aircraft_icao'] = $line[8];
1122
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1520
+	    		if (isset($line['inf']['rc'])) {
1521
+	    			$data['registration'] = $line['inf']['rc'];
1522
+	    		}
1123 1523
 			//$data['departure_airport_iata'] = $line[11];
1124 1524
 			//$data['arrival_airport_iata'] = $line[12];
1125 1525
 	    		//$data['emergency'] = ''; // emergency
1126 1526
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1127 1527
 	    		$data['format_source'] = 'radarvirtueljson';
1128 1528
     			$data['id_source'] = $id_source;
1129
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1130
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1529
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1530
+				$data['noarchive'] = true;
1531
+			}
1532
+			if (isset($value['name']) && $value['name'] != '') {
1533
+				$data['source_name'] = $value['name'];
1534
+			}
1131 1535
 			$SI->add($data);
1132 1536
 			unset($data);
1133 1537
 		    }
@@ -1153,30 +1557,65 @@  discard block
 block discarded – undo
1153 1557
 		    $data['id'] = $line['id'];
1154 1558
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1155 1559
 		    $data['ident'] = $line['callsign']; // ident
1156
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1157
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1158
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1159
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1160
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1161
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1560
+		    if (isset($line['pilotid'])) {
1561
+		    	$data['pilot_id'] = $line['pilotid'];
1562
+		    }
1563
+		    // pilot id
1564
+		    if (isset($line['name'])) {
1565
+		    	$data['pilot_name'] = $line['name'];
1566
+		    }
1567
+		    // pilot name
1568
+		    if (isset($line['alt'])) {
1569
+		    	$data['altitude'] = $line['alt'];
1570
+		    }
1571
+		    // altitude
1572
+		    if (isset($line['gs'])) {
1573
+		    	$data['speed'] = $line['gs'];
1574
+		    }
1575
+		    // speed
1576
+		    if (isset($line['heading'])) {
1577
+		    	$data['heading'] = $line['heading'];
1578
+		    }
1579
+		    // heading
1580
+		    if (isset($line['route'])) {
1581
+		    	$data['waypoints'] = $line['route'];
1582
+		    }
1583
+		    // route
1162 1584
 		    $data['latitude'] = $line['lat']; // lat
1163 1585
 		    $data['longitude'] = $line['lon']; // long
1164 1586
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1165 1587
 		    //$data['squawk'] = $line['squawk']; // squawk
1166 1588
 		    //$data['emergency'] = ''; // emergency
1167
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1168
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1169
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1589
+		    if (isset($line['depicao'])) {
1590
+		    	$data['departure_airport_icao'] = $line['depicao'];
1591
+		    }
1592
+		    if (isset($line['deptime'])) {
1593
+		    	$data['departure_airport_time'] = $line['deptime'];
1594
+		    }
1595
+		    if (isset($line['arricao'])) {
1596
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1597
+		    }
1170 1598
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1171
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1172
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1173
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1174
-		    else $data['info'] = '';
1599
+		    if (isset($line['aircraft'])) {
1600
+		    	$data['aircraft_icao'] = $line['aircraft'];
1601
+		    }
1602
+		    if (isset($line['transponder'])) {
1603
+		    	$data['squawk'] = $line['transponder'];
1604
+		    }
1605
+		    if (isset($line['atis'])) {
1606
+		    	$data['info'] = $line['atis'];
1607
+		    } else {
1608
+		    	$data['info'] = '';
1609
+		    }
1175 1610
 		    $data['format_source'] = 'pireps';
1176 1611
     		    $data['id_source'] = $id_source;
1177 1612
 		    $data['datetime'] = date('Y-m-d H:i:s');
1178
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1179
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1613
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1614
+		    	$data['noarchive'] = true;
1615
+		    }
1616
+		    if (isset($value['name']) && $value['name'] != '') {
1617
+		    	$data['source_name'] = $value['name'];
1618
+		    }
1180 1619
 		    if ($line['icon'] === 'plane') {
1181 1620
 			$SI->add($data);
1182 1621
 		    //    print_r($data);
@@ -1185,16 +1624,28 @@  discard block
 block discarded – undo
1185 1624
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1186 1625
 			$typec = substr($data['ident'],-3);
1187 1626
 			$data['type'] = '';
1188
-			if ($typec === 'APP') $data['type'] = 'Approach';
1189
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1190
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1191
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1192
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1193
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1194
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1195
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1196
-			else $data['type'] = 'Observer';
1197
-			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']);
1627
+			if ($typec === 'APP') {
1628
+				$data['type'] = 'Approach';
1629
+			} elseif ($typec === 'TWR') {
1630
+				$data['type'] = 'Tower';
1631
+			} elseif ($typec === 'OBS') {
1632
+				$data['type'] = 'Observer';
1633
+			} elseif ($typec === 'GND') {
1634
+				$data['type'] = 'Ground';
1635
+			} elseif ($typec === 'DEL') {
1636
+				$data['type'] = 'Delivery';
1637
+			} elseif ($typec === 'DEP') {
1638
+				$data['type'] = 'Departure';
1639
+			} elseif ($typec === 'FSS') {
1640
+				$data['type'] = 'Flight Service Station';
1641
+			} elseif ($typec === 'CTR') {
1642
+				$data['type'] = 'Control Radar or Centre';
1643
+			} else {
1644
+				$data['type'] = 'Observer';
1645
+			}
1646
+			if (isset($ATC)) {
1647
+				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']);
1648
+			}
1198 1649
 		    }
1199 1650
 		    unset($data);
1200 1651
 		}
@@ -1209,7 +1660,9 @@  discard block
 block discarded – undo
1209 1660
 	    )
1210 1661
 	) {
1211 1662
 	    //$buffer = $Common->getData($hosts[$id]);
1212
-	    if ($globalDebug) echo 'Get Data...'."\n";
1663
+	    if ($globalDebug) {
1664
+	    	echo 'Get Data...'."\n";
1665
+	    }
1213 1666
 	    $buffer = $Common->getData($value['host']);
1214 1667
 	    $all_data = json_decode($buffer,true);
1215 1668
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1217,10 +1670,16 @@  discard block
 block discarded – undo
1217 1670
 		foreach ($all_data as $line) {
1218 1671
 	    	    $data = array();
1219 1672
 	    	    //$data['id'] = $line['id']; // id not usable
1220
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1673
+	    	    if (isset($line['pilotid'])) {
1674
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1675
+	    	    }
1221 1676
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1222
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1223
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1677
+	    	    if (isset($line['pilotname'])) {
1678
+	    	    	$data['pilot_name'] = $line['pilotname'];
1679
+	    	    }
1680
+	    	    if (isset($line['pilotid'])) {
1681
+	    	    	$data['pilot_id'] = $line['pilotid'];
1682
+	    	    }
1224 1683
 	    	    $data['ident'] = $line['flightnum']; // ident
1225 1684
 	    	    $data['altitude'] = $line['alt']; // altitude
1226 1685
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1236,7 +1695,9 @@  discard block
 block discarded – undo
1236 1695
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1237 1696
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1238 1697
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1239
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1698
+	    	    } else {
1699
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1700
+	    	    }
1240 1701
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1241 1702
 	    	    $data['departure_airport_time'] = $line['deptime'];
1242 1703
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1244,29 +1705,47 @@  discard block
 block discarded – undo
1244 1705
     		    if (isset($line['registration'])) {
1245 1706
     			$data['registration'] = $line['registration'];
1246 1707
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1247
-    		    } else $data['registration'] = $line['aircraft'];
1248
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1249
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1708
+    		    } else {
1709
+    		    	$data['registration'] = $line['aircraft'];
1710
+    		    }
1711
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1712
+		    	$data['noarchive'] = true;
1713
+		    }
1714
+		    if (isset($line['route'])) {
1715
+		    	$data['waypoints'] = $line['route'];
1716
+		    }
1717
+		    // route
1250 1718
 		    if (isset($line['aircraftname'])) {
1251 1719
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1252 1720
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1253 1721
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1254
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1255
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1256
-	    		else {
1722
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1723
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1724
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1725
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1726
+	    		} else {
1257 1727
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1258
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1259
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1728
+	    		    if (isset($aircraft_data[1])) {
1729
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1730
+	    		    } else {
1731
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1732
+	    		    }
1260 1733
 	    		}
1261 1734
 	    	    }
1262
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1735
+    		    if (isset($line['route'])) {
1736
+    		    	$data['waypoints'] = $line['route'];
1737
+    		    }
1263 1738
     		    $data['id_source'] = $id_source;
1264 1739
 	    	    $data['format_source'] = 'phpvmacars';
1265
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1740
+		    if (isset($value['name']) && $value['name'] != '') {
1741
+		    	$data['source_name'] = $value['name'];
1742
+		    }
1266 1743
 		    $SI->add($data);
1267 1744
 		    unset($data);
1268 1745
 		}
1269
-		if ($globalDebug) echo 'No more data...'."\n";
1746
+		if ($globalDebug) {
1747
+			echo 'No more data...'."\n";
1748
+		}
1270 1749
 		unset($buffer);
1271 1750
 		unset($all_data);
1272 1751
 	    }
@@ -1279,7 +1758,9 @@  discard block
 block discarded – undo
1279 1758
 	    )
1280 1759
 	) {
1281 1760
 	    //$buffer = $Common->getData($hosts[$id]);
1282
-	    if ($globalDebug) echo 'Get Data...'."\n";
1761
+	    if ($globalDebug) {
1762
+	    	echo 'Get Data...'."\n";
1763
+	    }
1283 1764
 	    $buffer = $Common->getData($value['host']);
1284 1765
 	    $all_data = json_decode($buffer,true);
1285 1766
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1290,10 +1771,16 @@  discard block
 block discarded – undo
1290 1771
 	    	    //$data['id'] = $line['id']; // id not usable
1291 1772
 	    	    $data['id'] = $line['id'];
1292 1773
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1293
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1294
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1774
+	    	    if (isset($line['user']['username'])) {
1775
+	    	    	$data['pilot_name'] = $line['user']['username'];
1776
+	    	    }
1777
+	    	    if (isset($line['user_id'])) {
1778
+	    	    	$data['pilot_id'] = $line['user_id'];
1779
+	    	    }
1295 1780
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1296
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1781
+	    	    if (is_numeric($data['ident'])) {
1782
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1783
+	    	    }
1297 1784
 	    	    $data['altitude'] = $line['altitude']; // altitude
1298 1785
 	    	    $data['speed'] = $line['groundspeed']; // speed
1299 1786
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1306,7 +1793,9 @@  discard block
 block discarded – undo
1306 1793
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1307 1794
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1308 1795
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1309
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1796
+	    	    } else {
1797
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1798
+	    	    }
1310 1799
 	    	    
1311 1800
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1312 1801
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1314,17 +1803,26 @@  discard block
 block discarded – undo
1314 1803
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1315 1804
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1316 1805
 
1317
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1318
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1806
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1807
+		    	$data['noarchive'] = true;
1808
+		    }
1809
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
1810
+		    	$data['waypoints'] = $line['bid']['route'];
1811
+		    }
1812
+		    // route
1319 1813
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1320 1814
 
1321 1815
     		    $data['id_source'] = $id_source;
1322 1816
 	    	    $data['format_source'] = 'vaos';
1323
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1817
+		    if (isset($value['name']) && $value['name'] != '') {
1818
+		    	$data['source_name'] = $value['name'];
1819
+		    }
1324 1820
 		    $SI->add($data);
1325 1821
 		    unset($data);
1326 1822
 		}
1327
-		if ($globalDebug) echo 'No more data...'."\n";
1823
+		if ($globalDebug) {
1824
+			echo 'No more data...'."\n";
1825
+		}
1328 1826
 		unset($buffer);
1329 1827
 		unset($all_data);
1330 1828
 	    }
@@ -1337,7 +1835,9 @@  discard block
 block discarded – undo
1337 1835
 	    )
1338 1836
 	) {
1339 1837
 	    //$buffer = $Common->getData($hosts[$id]);
1340
-	    if ($globalDebug) echo 'Get Data...'."\n";
1838
+	    if ($globalDebug) {
1839
+	    	echo 'Get Data...'."\n";
1840
+	    }
1341 1841
 	    $buffer = $Common->getData($value['host']);
1342 1842
 	    $all_data = json_decode($buffer,true);
1343 1843
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1366,16 +1866,25 @@  discard block
 block discarded – undo
1366 1866
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1367 1867
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1368 1868
     		    //$data['registration'] = $line['aircraft'];
1369
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1869
+		    if (isset($line['route'])) {
1870
+		    	$data['waypoints'] = $line['route'];
1871
+		    }
1872
+		    // route
1370 1873
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1371 1874
     		    $data['id_source'] = $id_source;
1372 1875
 	    	    $data['format_source'] = 'vam';
1373
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1374
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1876
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1877
+		    	$data['noarchive'] = true;
1878
+		    }
1879
+		    if (isset($value['name']) && $value['name'] != '') {
1880
+		    	$data['source_name'] = $value['name'];
1881
+		    }
1375 1882
 		    $SI->add($data);
1376 1883
 		    unset($data);
1377 1884
 		}
1378
-		if ($globalDebug) echo 'No more data...'."\n";
1885
+		if ($globalDebug) {
1886
+			echo 'No more data...'."\n";
1887
+		}
1379 1888
 		unset($buffer);
1380 1889
 		unset($all_data);
1381 1890
 	    }
@@ -1388,7 +1897,9 @@  discard block
 block discarded – undo
1388 1897
 	    )
1389 1898
 	) {
1390 1899
 	    //$buffer = $Common->getData($hosts[$id]);
1391
-	    if ($globalDebug) echo 'Get Data...'."\n";
1900
+	    if ($globalDebug) {
1901
+	    	echo 'Get Data...'."\n";
1902
+	    }
1392 1903
 	    $buffer = $Common->getData($value['host']);
1393 1904
 	    $all_data = json_decode($buffer,true);
1394 1905
 	    if ($buffer != '') {
@@ -1406,12 +1917,16 @@  discard block
 block discarded – undo
1406 1917
 			$data['id_source'] = $id_source;
1407 1918
 			$data['format_source'] = 'blitzortung';
1408 1919
 			$SI->add($data);
1409
-			if ($globalDebug) echo '☈ Lightning added'."\n";
1920
+			if ($globalDebug) {
1921
+				echo '☈ Lightning added'."\n";
1922
+			}
1410 1923
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1411 1924
 			unset($data);
1412 1925
 		    }
1413 1926
 		}
1414
-		if ($globalDebug) echo 'No more data...'."\n";
1927
+		if ($globalDebug) {
1928
+			echo 'No more data...'."\n";
1929
+		}
1415 1930
 		unset($buffer);
1416 1931
 	    }
1417 1932
 	    $last_exec[$id]['last'] = time();
@@ -1423,7 +1938,9 @@  discard block
 block discarded – undo
1423 1938
 	    $write = NULL;
1424 1939
 	    $e = NULL;
1425 1940
 	    $n = socket_select($read, $write, $e, $timeout);
1426
-	    if ($e != NULL) var_dump($e);
1941
+	    if ($e != NULL) {
1942
+	    	var_dump($e);
1943
+	    }
1427 1944
 	    if ($n > 0) {
1428 1945
 		$reset = 0;
1429 1946
 		foreach ($read as $nb => $r) {
@@ -1445,13 +1962,17 @@  discard block
 block discarded – undo
1445 1962
 		    if ($buffer !== FALSE) {
1446 1963
 			if ($format === 'vrstcp') {
1447 1964
 			    $buffer = explode('},{',$buffer);
1448
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1965
+			} else {
1966
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1967
+			}
1449 1968
 		    }
1450 1969
 		    // SBS format is CSV format
1451 1970
 		    if ($buffer !== FALSE && $buffer !== '') {
1452 1971
 			$tt[$format] = 0;
1453 1972
 			if ($format === 'acarssbs3') {
1454
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1973
+			    if ($globalDebug) {
1974
+			    	echo 'ACARS : '.$buffer."\n";
1975
+			    }
1455 1976
 			    $ACARS->add(trim($buffer));
1456 1977
 			    $ACARS->deleteLiveAcarsData();
1457 1978
 			} elseif ($format === 'raw') {
@@ -1460,30 +1981,70 @@  discard block
 block discarded – undo
1460 1981
 			    if (is_array($data)) {
1461 1982
 				$data['datetime'] = date('Y-m-d H:i:s');
1462 1983
 				$data['format_source'] = 'raw';
1463
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1464
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1465
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1466
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1984
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1985
+					$data['source_name'] = $globalSources[$nb]['name'];
1986
+				}
1987
+				if (isset($globalSources[$nb]['sourcestats'])) {
1988
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1989
+				}
1990
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1991
+					$data['noarchive'] = true;
1992
+				}
1993
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1994
+					$SI->add($data);
1995
+				}
1467 1996
 			    }
1468 1997
 			} elseif ($format === 'ais') {
1469 1998
 			    $ais_data = $AIS->parse_line(trim($buffer));
1470 1999
 			    $data = array();
1471
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1472
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1473
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1474
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1475
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1476
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1477
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1478
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1479
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1480
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1481
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1482
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1483
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1484
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1485
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1486
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2000
+			    if (isset($ais_data['ident'])) {
2001
+			    	$data['ident'] = $ais_data['ident'];
2002
+			    }
2003
+			    if (isset($ais_data['mmsi'])) {
2004
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2005
+			    }
2006
+			    if (isset($ais_data['speed'])) {
2007
+			    	$data['speed'] = $ais_data['speed'];
2008
+			    }
2009
+			    if (isset($ais_data['heading'])) {
2010
+			    	$data['heading'] = $ais_data['heading'];
2011
+			    }
2012
+			    if (isset($ais_data['latitude'])) {
2013
+			    	$data['latitude'] = $ais_data['latitude'];
2014
+			    }
2015
+			    if (isset($ais_data['longitude'])) {
2016
+			    	$data['longitude'] = $ais_data['longitude'];
2017
+			    }
2018
+			    if (isset($ais_data['status'])) {
2019
+			    	$data['status'] = $ais_data['status'];
2020
+			    }
2021
+			    if (isset($ais_data['statusid'])) {
2022
+			    	$data['status_id'] = $ais_data['statusid'];
2023
+			    }
2024
+			    if (isset($ais_data['type'])) {
2025
+			    	$data['type'] = $ais_data['type'];
2026
+			    }
2027
+			    if (isset($ais_data['imo'])) {
2028
+			    	$data['imo'] = $ais_data['imo'];
2029
+			    }
2030
+			    if (isset($ais_data['callsign'])) {
2031
+			    	$data['callsign'] = $ais_data['callsign'];
2032
+			    }
2033
+			    if (isset($ais_data['destination'])) {
2034
+			    	$data['arrival_code'] = $ais_data['destination'];
2035
+			    }
2036
+			    if (isset($ais_data['eta_ts'])) {
2037
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2038
+			    }
2039
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2040
+			    	$data['noarchive'] = true;
2041
+			    }
2042
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2043
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2044
+			    }
2045
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2046
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2047
+			    }
1487 2048
 
1488 2049
 			    if (isset($ais_data['timestamp'])) {
1489 2050
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1492,7 +2053,9 @@  discard block
 block discarded – undo
1492 2053
 			    }
1493 2054
 			    $data['format_source'] = 'aisnmea';
1494 2055
     			    $data['id_source'] = $id_source;
1495
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2056
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2057
+			    	$MI->add($data);
2058
+			    }
1496 2059
 			    unset($data);
1497 2060
                         } elseif ($format === 'flightgearsp') {
1498 2061
                     	    //echo $buffer."\n";
@@ -1510,12 +2073,18 @@  discard block
 block discarded – undo
1510 2073
 				$data['speed'] = round($line[5]*1.94384);
1511 2074
 				$data['datetime'] = date('Y-m-d H:i:s');
1512 2075
 				$data['format_source'] = 'flightgearsp';
1513
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1514
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2076
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2077
+					$data['noarchive'] = true;
2078
+				}
2079
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2080
+					$SI->add($data);
2081
+				}
1515 2082
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1516 2083
 			    }
1517 2084
                         } elseif ($format === 'acars') {
1518
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2085
+                    	    if ($globalDebug) {
2086
+                    	    	echo 'ACARS : '.$buffer."\n";
2087
+                    	    }
1519 2088
 			    $ACARS->add(trim($buffer));
1520 2089
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1521 2090
 			    $ACARS->deleteLiveAcarsData();
@@ -1536,8 +2105,12 @@  discard block
 block discarded – undo
1536 2105
 				    $aircraft_type = $line[10];
1537 2106
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1538 2107
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1539
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1540
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2108
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2109
+				    	$data['noarchive'] = true;
2110
+				    }
2111
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2112
+				    	$SI->add($data);
2113
+				    }
1541 2114
 				}
1542 2115
 			    }
1543 2116
 			} elseif ($format === 'beast') {
@@ -1547,28 +2120,62 @@  discard block
 block discarded – undo
1547 2120
 			    foreach($buffer as $all_data) {
1548 2121
 				$line = json_decode('{'.$all_data.'}',true);
1549 2122
 				$data = array();
1550
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1551
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1552
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1553
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1554
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1555
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1556
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2123
+				if (isset($line['Icao'])) {
2124
+					$data['hex'] = $line['Icao'];
2125
+				}
2126
+				// hex
2127
+				if (isset($line['Call'])) {
2128
+					$data['ident'] = $line['Call'];
2129
+				}
2130
+				// ident
2131
+				if (isset($line['Alt'])) {
2132
+					$data['altitude'] = $line['Alt'];
2133
+				}
2134
+				// altitude
2135
+				if (isset($line['Spd'])) {
2136
+					$data['speed'] = $line['Spd'];
2137
+				}
2138
+				// speed
2139
+				if (isset($line['Trak'])) {
2140
+					$data['heading'] = $line['Trak'];
2141
+				}
2142
+				// heading
2143
+				if (isset($line['Lat'])) {
2144
+					$data['latitude'] = $line['Lat'];
2145
+				}
2146
+				// lat
2147
+				if (isset($line['Long'])) {
2148
+					$data['longitude'] = $line['Long'];
2149
+				}
2150
+				// long
1557 2151
 				//$data['verticalrate'] = $line['']; // verticale rate
1558
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2152
+				if (isset($line['Sqk'])) {
2153
+					$data['squawk'] = $line['Sqk'];
2154
+				}
2155
+				// squawk
1559 2156
 				$data['emergency'] = ''; // emergency
1560
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2157
+				if (isset($line['Reg'])) {
2158
+					$data['registration'] = $line['Reg'];
2159
+				}
1561 2160
 				/*
1562 2161
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1563 2162
 				else $data['datetime'] = date('Y-m-d H:i:s');
1564 2163
 				*/
1565 2164
 				$data['datetime'] = date('Y-m-d H:i:s');
1566
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2165
+				if (isset($line['Type'])) {
2166
+					$data['aircraft_icao'] = $line['Type'];
2167
+				}
1567 2168
 		    		$data['format_source'] = 'vrstcp';
1568 2169
 				$data['id_source'] = $id_source;
1569
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1570
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1571
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2170
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2171
+					$data['noarchive'] = true;
2172
+				}
2173
+				if (isset($value['name']) && $value['name'] != '') {
2174
+					$data['source_name'] = $value['name'];
2175
+				}
2176
+				if (isset($data['latitude']) && isset($data['hex'])) {
2177
+					$SI->add($data);
2178
+				}
1572 2179
 				unset($data);
1573 2180
 			    }
1574 2181
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1581,22 +2188,46 @@  discard block
 block discarded – undo
1581 2188
     				$data['hex'] = $lined['hexid'];
1582 2189
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1583 2190
     				$data['datetime'] = date('Y-m-d H:i:s');;
1584
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1585
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1586
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1587
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1588
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1589
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1590
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2191
+    				if (isset($lined['ident'])) {
2192
+    					$data['ident'] = $lined['ident'];
2193
+    				}
2194
+    				if (isset($lined['lat'])) {
2195
+    					$data['latitude'] = $lined['lat'];
2196
+    				}
2197
+    				if (isset($lined['lon'])) {
2198
+    					$data['longitude'] = $lined['lon'];
2199
+    				}
2200
+    				if (isset($lined['speed'])) {
2201
+    					$data['speed'] = $lined['speed'];
2202
+    				}
2203
+    				if (isset($lined['squawk'])) {
2204
+    					$data['squawk'] = $lined['squawk'];
2205
+    				}
2206
+    				if (isset($lined['alt'])) {
2207
+    					$data['altitude'] = $lined['alt'];
2208
+    				}
2209
+    				if (isset($lined['heading'])) {
2210
+    					$data['heading'] = $lined['heading'];
2211
+    				}
1591 2212
     				$data['id_source'] = $id_source;
1592 2213
     				$data['format_source'] = 'tsv';
1593
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1594
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1595
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1596
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2214
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2215
+    					$data['source_name'] = $globalSources[$nb]['name'];
2216
+    				}
2217
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2218
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2219
+    				}
2220
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2221
+					$data['noarchive'] = true;
2222
+				}
2223
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2224
+    					$SI->add($data);
2225
+    				}
1597 2226
     				unset($lined);
1598 2227
     				unset($data);
1599
-    			    } else $error = true;
2228
+    			    } else {
2229
+    			    	$error = true;
2230
+    			    }
1600 2231
 			} elseif ($format === 'aprs' && $use_aprs) {
1601 2232
 			    if ($aprs_connect === 0) {
1602 2233
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1622,63 +2253,121 @@  discard block
 block discarded – undo
1622 2253
 				    $aprs_last_tx = time();
1623 2254
 				    $data = array();
1624 2255
 				    //print_r($line);
1625
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1626
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1627
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1628
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1629
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1630
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1631
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1632
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1633
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1634
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2256
+				    if (isset($line['address'])) {
2257
+				    	$data['hex'] = $line['address'];
2258
+				    }
2259
+				    if (isset($line['mmsi'])) {
2260
+				    	$data['mmsi'] = $line['mmsi'];
2261
+				    }
2262
+				    if (isset($line['imo'])) {
2263
+				    	$data['imo'] = $line['imo'];
2264
+				    }
2265
+				    if (isset($line['squawk'])) {
2266
+				    	$data['squawk'] = $line['squawk'];
2267
+				    }
2268
+				    if (isset($line['arrival_code'])) {
2269
+				    	$data['arrival_code'] = $line['arrival_code'];
2270
+				    }
2271
+				    if (isset($line['arrival_date'])) {
2272
+				    	$data['arrival_date'] = $line['arrival_date'];
2273
+				    }
2274
+				    if (isset($line['typeid'])) {
2275
+				    	$data['type_id'] = $line['typeid'];
2276
+				    }
2277
+				    if (isset($line['statusid'])) {
2278
+				    	$data['status_id'] = $line['statusid'];
2279
+				    }
2280
+				    if (isset($line['timestamp'])) {
2281
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2282
+				    } else {
2283
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2284
+				    }
1635 2285
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1636
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2286
+				    if (isset($line['ident'])) {
2287
+				    	$data['ident'] = $line['ident'];
2288
+				    }
1637 2289
 				    $data['latitude'] = $line['latitude'];
1638 2290
 				    $data['longitude'] = $line['longitude'];
1639 2291
 				    //$data['verticalrate'] = $line[16];
1640
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2292
+				    if (isset($line['speed'])) {
2293
+				    	$data['speed'] = $line['speed'];
2294
+				    }
1641 2295
 				    //else $data['speed'] = 0;
1642
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1643
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1644
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2296
+				    if (isset($line['altitude'])) {
2297
+				    	$data['altitude'] = $line['altitude'];
2298
+				    }
2299
+				    if (isset($line['comment'])) {
2300
+				    	$data['comment'] = $line['comment'];
2301
+				    }
2302
+				    if (isset($line['symbol'])) {
2303
+				    	$data['type'] = $line['symbol'];
2304
+				    }
1645 2305
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1646 2306
 				    
1647
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2307
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2308
+				    	$data['heading'] = $line['heading'];
2309
+				    }
1648 2310
 				    //else echo 'No heading...'."\n";
1649 2311
 				    //else $data['heading'] = 0;
1650
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2312
+				    if (isset($line['stealth'])) {
2313
+				    	$data['aircraft_type'] = $line['stealth'];
2314
+				    }
1651 2315
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1652
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1653
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1654
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1655
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2316
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2317
+				    	$data['noarchive'] = true;
2318
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2319
+				    	$data['noarchive'] = false;
2320
+				    }
2321
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2322
+				    	$data['noarchive'] = true;
2323
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2324
+				    	$data['noarchive'] = false;
2325
+				    }
1656 2326
     				    $data['id_source'] = $id_source;
1657
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1658
-				    else $data['format_source'] = 'aprs';
2327
+    				    if (isset($line['format_source'])) {
2328
+    				    	$data['format_source'] = $line['format_source'];
2329
+    				    } else {
2330
+				    	$data['format_source'] = 'aprs';
2331
+				    }
1659 2332
 				    $data['source_name'] = $line['source'];
1660
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1661
-				    else $data['source_type'] = 'flarm';
1662
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2333
+				    if (isset($line['source_type'])) {
2334
+				    	$data['source_type'] = $line['source_type'];
2335
+				    } else {
2336
+				    	$data['source_type'] = 'flarm';
2337
+				    }
2338
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2339
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2340
+    				    }
1663 2341
 				    $currentdate = date('Y-m-d H:i:s');
1664 2342
 				    $aprsdate = strtotime($data['datetime']);
1665
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2343
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2344
+				    	$data['altitude_relative'] = 'AMSL';
2345
+				    }
1666 2346
 				    // Accept data if time <= system time + 20s
1667 2347
 				    //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'])))) {
1668 2348
 				    if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1669 2349
 					$send = $SI->add($data);
1670 2350
 				    } elseif ($data['source_type'] === 'ais') {
1671 2351
 					$data['type'] = '';
1672
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2352
+					if (isset($globalMarine) && $globalMarine) {
2353
+						$send = $MI->add($data);
2354
+					}
1673 2355
 				    } elseif (isset($line['stealth'])) {
1674
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1675
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2356
+					if ($line['stealth'] != 0) {
2357
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
2358
+					} else {
2359
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2360
+					}
1676 2361
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1677 2362
 					    //$line['symbol'] === 'Balloon' ||
1678 2363
 					    $line['symbol'] === 'Glider' || 
1679 2364
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1680
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1681
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2365
+					    if ($line['symbol'] === 'Ballon') {
2366
+					    	$data['aircraft_icao'] = 'BALL';
2367
+					    }
2368
+					    if ($line['symbol'] === 'Glider') {
2369
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2370
+					    }
1682 2371
 					    $send = $SI->add($data);
1683 2372
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1684 2373
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1709,9 +2398,13 @@  discard block
 block discarded – undo
1709 2398
 				    //} 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') {
1710 2399
 				//    } 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') {
1711 2400
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1712
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2401
+					if (isset($globalTracker) && $globalTracker) {
2402
+						$send = $TI->add($data);
2403
+					}
1713 2404
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1714
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2405
+					if (!isset($data['altitude'])) {
2406
+						$data['altitude'] = 0;
2407
+					}
1715 2408
 					$Source->deleteOldLocationByType('gs');
1716 2409
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1717 2410
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1720,7 +2413,9 @@  discard block
 block discarded – undo
1720 2413
 					}
1721 2414
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1722 2415
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1723
-					if ($globalDebug) echo '# Weather Station added'."\n";
2416
+					if ($globalDebug) {
2417
+						echo '# Weather Station added'."\n";
2418
+					}
1724 2419
 					$Source->deleteOldLocationByType('wx');
1725 2420
 					$weather_data = json_encode($line);
1726 2421
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1730,7 +2425,9 @@  discard block
 block discarded – undo
1730 2425
 					}
1731 2426
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1732 2427
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1733
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2428
+					if ($globalDebug) {
2429
+						echo '☈ Lightning added'."\n";
2430
+					}
1734 2431
 					$Source->deleteOldLocationByType('lightning');
1735 2432
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1736 2433
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1742,8 +2439,7 @@  discard block
 block discarded – undo
1742 2439
 				    	print_r($line);
1743 2440
 				    }
1744 2441
 				    unset($data);
1745
-				}
1746
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2442
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1747 2443
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1748 2444
 				}
1749 2445
 				/*
@@ -1752,7 +2448,9 @@  discard block
 block discarded – undo
1752 2448
 				}
1753 2449
 				*/
1754 2450
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1755
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2451
+				elseif ($line === true && $globalDebug) {
2452
+					echo '!! Failed : '.$buffer."!!\n";
2453
+				}
1756 2454
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1757 2455
 					$Source->deleteOldLocationByType('lightning');
1758 2456
 					$Source->deleteOldLocationByType('wx');
@@ -1788,26 +2486,45 @@  discard block
 block discarded – undo
1788 2486
     				$data['ground'] = $line[21];
1789 2487
     				$data['emergency'] = $line[19];
1790 2488
     				$data['format_source'] = 'sbs';
1791
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1792
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1793
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2489
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2490
+					$data['source_name'] = $globalSources[$nb]['name'];
2491
+				}
2492
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2493
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2494
+    				}
2495
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2496
+					$data['noarchive'] = true;
2497
+				}
1794 2498
     				$data['id_source'] = $id_source;
1795
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1796
-    				else $error = true;
2499
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2500
+    					$send = $SI->add($data);
2501
+    				} else {
2502
+    					$error = true;
2503
+    				}
1797 2504
     				unset($data);
1798
-    			    } else $error = true;
2505
+    			    } else {
2506
+    			    	$error = true;
2507
+    			    }
1799 2508
 			    if ($error) {
1800 2509
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1801
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2510
+					if ($globalDebug) {
2511
+						echo "Not a message. Ignoring... \n";
2512
+					}
1802 2513
 				} else {
1803
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2514
+					if ($globalDebug) {
2515
+						echo "Wrong line format. Ignoring... \n";
2516
+					}
1804 2517
 					if ($globalDebug) {
1805 2518
 						echo $buffer;
1806 2519
 						//print_r($line);
1807 2520
 					}
1808 2521
 					//socket_close($r);
1809
-					if ($globalDebug) echo "Reconnect after an error...\n";
1810
-					if ($format === 'aprs') $aprs_connect = 0;
2522
+					if ($globalDebug) {
2523
+						echo "Reconnect after an error...\n";
2524
+					}
2525
+					if ($format === 'aprs') {
2526
+						$aprs_connect = 0;
2527
+					}
1811 2528
 					$sourceer[$nb] = $globalSources[$nb];
1812 2529
 					connect_all($sourceer);
1813 2530
 					$sourceer = array();
@@ -1815,10 +2532,14 @@  discard block
 block discarded – undo
1815 2532
 			    }
1816 2533
 			}
1817 2534
 			// Sleep for xxx microseconds
1818
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2535
+			if (isset($globalSBSSleep)) {
2536
+				usleep($globalSBSSleep);
2537
+			}
1819 2538
 		    } else {
1820 2539
 			if ($format === 'flightgearmp') {
1821
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2540
+			    	if ($globalDebug) {
2541
+			    		echo "Reconnect FlightGear MP...";
2542
+			    	}
1822 2543
 				//@socket_close($r);
1823 2544
 				sleep($globalMinFetch);
1824 2545
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1827,10 +2548,15 @@  discard block
 block discarded – undo
1827 2548
 				break;
1828 2549
 				
1829 2550
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1830
-			    if (isset($tt[$format])) $tt[$format]++;
1831
-			    else $tt[$format] = 0;
2551
+			    if (isset($tt[$format])) {
2552
+			    	$tt[$format]++;
2553
+			    } else {
2554
+			    	$tt[$format] = 0;
2555
+			    }
1832 2556
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
1833
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2557
+				if ($globalDebug) {
2558
+					echo "ERROR : Reconnect ".$format."...";
2559
+				}
1834 2560
 				//@socket_close($r);
1835 2561
 				sleep(2);
1836 2562
 				$aprs_connect = 0;
@@ -1848,11 +2574,17 @@  discard block
 block discarded – undo
1848 2574
 	    } else {
1849 2575
 		$error = socket_strerror(socket_last_error());
1850 2576
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1851
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1852
-			if (isset($globalDebug)) echo "Restarting...\n";
2577
+			if ($globalDebug) {
2578
+				echo "ERROR : socket_select give this error ".$error . "\n";
2579
+			}
2580
+			if (isset($globalDebug)) {
2581
+				echo "Restarting...\n";
2582
+			}
1853 2583
 			// Restart the script if possible
1854 2584
 			if (is_array($sockets)) {
1855
-			    if ($globalDebug) echo "Shutdown all sockets...";
2585
+			    if ($globalDebug) {
2586
+			    	echo "Shutdown all sockets...";
2587
+			    }
1856 2588
 			    
1857 2589
 			    foreach ($sockets as $sock) {
1858 2590
 				@socket_shutdown($sock,2);
@@ -1860,25 +2592,45 @@  discard block
 block discarded – undo
1860 2592
 			    }
1861 2593
 			    
1862 2594
 			}
1863
-			if ($globalDebug) echo "Waiting...";
2595
+			if ($globalDebug) {
2596
+				echo "Waiting...";
2597
+			}
1864 2598
 			sleep(2);
1865 2599
 			$time = time();
1866 2600
 			//connect_all($hosts);
1867 2601
 			$aprs_connect = 0;
1868
-			if ($reset%5 === 0) sleep(20);
1869
-			if ($reset%10 === 0) sleep(100);
1870
-			if ($reset%20 === 0) sleep(200);
1871
-			if ($reset > 100) exit('Too many attempts...');
1872
-			if ($globalDebug) echo "Restart all connections...";
2602
+			if ($reset%5 === 0) {
2603
+				sleep(20);
2604
+			}
2605
+			if ($reset%10 === 0) {
2606
+				sleep(100);
2607
+			}
2608
+			if ($reset%20 === 0) {
2609
+				sleep(200);
2610
+			}
2611
+			if ($reset > 100) {
2612
+				exit('Too many attempts...');
2613
+			}
2614
+			if ($globalDebug) {
2615
+				echo "Restart all connections...";
2616
+			}
1873 2617
 			connect_all($globalSources);
1874 2618
 		}
1875 2619
 	    }
1876 2620
 	}
1877 2621
 	if ($globalDaemon === false) {
1878
-	    if ($globalDebug) echo 'Check all...'."\n";
1879
-	    if (isset($SI)) $SI->checkAll();
1880
-	    if (isset($TI)) $TI->checkAll();
1881
-	    if (isset($MI)) $MI->checkAll();
2622
+	    if ($globalDebug) {
2623
+	    	echo 'Check all...'."\n";
2624
+	    }
2625
+	    if (isset($SI)) {
2626
+	    	$SI->checkAll();
2627
+	    }
2628
+	    if (isset($TI)) {
2629
+	    	$TI->checkAll();
2630
+	    }
2631
+	    if (isset($MI)) {
2632
+	    	$MI->checkAll();
2633
+	    }
1882 2634
 	}
1883 2635
     }
1884 2636
 }
Please login to merge, or discard this patch.
require/class.TrackerImport.php 1 patch
Braces   +190 added lines, -65 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function checkAll() {
44 44
 	global $globalDebug;
45
-	if ($globalDebug) echo "Update last seen tracked data...\n";
45
+	if ($globalDebug) {
46
+		echo "Update last seen tracked data...\n";
47
+	}
46 48
 	foreach ($this->all_tracked as $key => $flight) {
47 49
 	    if (isset($this->all_tracked[$key]['id'])) {
48 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -55,12 +57,16 @@  discard block
 block discarded – undo
55 57
     public function del() {
56 58
 	global $globalDebug;
57 59
 	// Delete old infos
58
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
60
+	if ($globalDebug) {
61
+		echo 'Delete old values and update latest data...'."\n";
62
+	}
59 63
 	foreach ($this->all_tracked as $key => $flight) {
60 64
     	    if (isset($flight['lastupdate'])) {
61 65
         	if ($flight['lastupdate'] < (time()-3000)) {
62 66
             	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
67
+            		if ($globalDebug) {
68
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		}
64 70
 			/*
65 71
 			$TrackerLive = new TrackerLive();
66 72
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
@@ -70,7 +76,9 @@  discard block
 block discarded – undo
70 76
             		$Tracker = new Tracker($this->db);
71 77
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 78
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
79
+				if ($globalDebug && $result != 'success') {
80
+					echo '!!! ERROR : '.$result."\n";
81
+				}
74 82
 			}
75 83
 			// Put in archive
76 84
 //			$Tracker->db = null;
@@ -83,7 +91,9 @@  discard block
 block discarded – undo
83 91
 
84 92
     public function add($line) {
85 93
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86
-	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015';
94
+	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') {
95
+		$globalCoordMinChangeTracker = '0.015';
96
+	}
87 97
 	date_default_timezone_set('UTC');
88 98
 	$dataFound = false;
89 99
 	$send = false;
@@ -97,19 +107,29 @@  discard block
 block discarded – undo
97 107
 		// Increment message number
98 108
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99 109
 		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
110
+		    if (isset($line['source_name'])) {
111
+		    	$source = $line['source_name'];
112
+		    } else {
113
+		    	$source = '';
114
+		    }
115
+		    if ($source == '' || $line['format_source'] == 'aprs') {
116
+		    	$source = $line['format_source'];
117
+		    }
103 118
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104 119
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105 120
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
121
+		    } else {
122
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
123
+		    }
107 124
 		}
108 125
 		
109 126
 		
110 127
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
128
+	        if (!isset($line['id'])) {
129
+	        	$id = trim($line['ident']);
130
+	        } else {
131
+	        	$id = trim($line['id']);
132
+	        }
113 133
 		
114 134
 		if (!isset($this->all_tracked[$id])) {
115 135
 		    $this->all_tracked[$id] = array();
@@ -117,31 +137,46 @@  discard block
 block discarded – undo
117 137
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118 138
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119 139
 		    if (!isset($line['id'])) {
120
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
140
+			if (!isset($globalDaemon)) {
141
+				$globalDaemon = TRUE;
142
+			}
121 143
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
144
+		     } else {
145
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
146
+		     }
147
+		    if ($globalAllTracked !== FALSE) {
148
+		    	$dataFound = true;
149
+		    }
124 150
 		}
125 151
 		
126 152
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127 153
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 154
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129 155
 		    } else {
130
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
156
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
157
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
158
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
159
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
160
+				}
132 161
 				return '';
133 162
 		    }
134 163
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
164
+			if ($globalDebug) {
165
+				echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
166
+			}
136 167
 			return '';
137 168
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
138
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
169
+			if ($globalDebug) {
170
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
171
+			}
139 172
 			return '';
140 173
 		} elseif (!isset($line['datetime'])) {
141 174
 			date_default_timezone_set('UTC');
142 175
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
143 176
 		} else {
144
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
177
+			if ($globalDebug) {
178
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
179
+			}
145 180
 			return '';
146 181
 		}
147 182
 		
@@ -153,11 +188,17 @@  discard block
 block discarded – undo
153 188
             		$Tracker = new Tracker($this->db);
154 189
             		$fromsource = NULL;
155 190
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
191
+			if ($globalDebug && $result != 'success') {
192
+				echo '!!! ERROR : '.$result."\n";
193
+			}
157 194
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
195
+			if ($globalDebugTimeElapsed) {
196
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
197
+			}
198
+		    }
199
+		    if (!isset($this->all_tracked[$id]['id'])) {
200
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159 201
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 202
 		}
162 203
 
163 204
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -168,14 +209,21 @@  discard block
 block discarded – undo
168 209
 		    if ($distance > 100 && $distance < 10000) {
169 210
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 211
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
212
+			if ($speed < 1000) {
213
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
214
+			}
215
+  			if ($globalDebug) {
216
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
217
+  			}
173 218
 		    }
174 219
 		}
175 220
 
176 221
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
222
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
223
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
224
+	    	    } else {
225
+	    	    	unset($timediff);
226
+	    	    }
179 227
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 228
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181 229
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
@@ -183,20 +231,30 @@  discard block
 block discarded – undo
183 231
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 232
 				$this->all_tracked[$id]['putinarchive'] = true;
185 233
 				
186
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
234
+				if ($globalDebug) {
235
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
236
+				}
187 237
 				$timeelapsed = microtime(true);
188 238
 				$Tracker = new Tracker($this->db);
189 239
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
190
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
240
+				if (!empty($all_country)) {
241
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
242
+				}
191 243
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
244
+				if ($globalDebugTimeElapsed) {
245
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
246
+				}
193 247
 				$this->tmd = 0;
194
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
248
+				if ($globalDebug) {
249
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
250
+				}
195 251
 			    }
196 252
 			}
197 253
 
198 254
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
255
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
256
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
257
+				}
200 258
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 259
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 260
 				    $dataFound = true;
@@ -205,8 +263,12 @@  discard block
 block discarded – undo
205 263
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 264
 			}
207 265
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
266
+			    if ($line['longitude'] > 180) {
267
+			    	$line['longitude'] = $line['longitude'] - 360;
268
+			    }
269
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
270
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
271
+				}
210 272
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 273
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 274
 				    $dataFound = true;
@@ -226,7 +288,9 @@  discard block
 block discarded – undo
226 288
 		    }
227 289
 		}
228 290
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
291
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
292
+		    	$dataFound = true;
293
+		    }
230 294
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 295
 		}
232 296
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -246,7 +310,9 @@  discard block
 block discarded – undo
246 310
 
247 311
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 312
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
313
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
314
+				$this->all_tracked[$id]['putinarchive'] = true;
315
+			}
250 316
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 317
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 318
 			//$dataFound = true;
@@ -258,15 +324,21 @@  discard block
 block discarded – undo
258 324
 		}
259 325
 		
260 326
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
327
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
328
+		    	$this->all_tracked[$id]['putinarchive'] = true;
329
+		    }
262 330
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263 331
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264 332
 		    //$dataFound = true;
265 333
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266 334
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267 335
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
336
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
337
+		    	$this->all_tracked[$id]['putinarchive'] = true;
338
+		    }
339
+  		    if ($globalDebug) {
340
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
341
+  		    }
270 342
   		}
271 343
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 344
 
@@ -275,20 +347,31 @@  discard block
 block discarded – undo
275 347
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276 348
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 349
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
350
+				if ($globalDebug) {
351
+					echo "Check if aircraft is already in DB...";
352
+				}
279 353
 				$timeelapsed = microtime(true);
280 354
 				$TrackerLive = new TrackerLive($this->db);
281 355
 				if (isset($line['id'])) {
282 356
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
357
+				    if ($globalDebugTimeElapsed) {
358
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
359
+				    }
284 360
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 361
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287
-				} else $recent_ident = '';
362
+				    if ($globalDebugTimeElapsed) {
363
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
364
+				    }
365
+				} else {
366
+					$recent_ident = '';
367
+				}
288 368
 				$TrackerLive->db=null;
289 369
 
290
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
370
+				if ($globalDebug && $recent_ident == '') {
371
+					echo " Not in DB.\n";
372
+				} elseif ($globalDebug && $recent_ident != '') {
373
+					echo " Already in DB.\n";
374
+				}
292 375
 			    } else {
293 376
 				$recent_ident = '';
294 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -296,27 +379,41 @@  discard block
 block discarded – undo
296 379
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297 380
 			    if($recent_ident == "")
298 381
 			    {
299
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
382
+				if ($globalDebug) {
383
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
384
+				}
300 385
 				//adds the spotter data for the archive
301 386
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
387
+				    if (!isset($this->all_tracked[$id]['id'])) {
388
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
389
+				    }
303 390
 				    $timeelapsed = microtime(true);
304 391
 				    $Tracker = new Tracker($this->db);
305 392
 				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306 393
 				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
394
+				    if ($globalDebug && isset($result)) {
395
+				    	echo $result."\n";
396
+				    }
397
+				    if ($globalDebugTimeElapsed) {
398
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
+				    }
309 400
 				    
310 401
 				    
311 402
 				    // Add source stat in DB
312 403
 				    $Stats = new Stats($this->db);
313 404
 				    if (!empty($this->stats)) {
314
-					if ($globalDebug) echo 'Add source stats : ';
405
+					if ($globalDebug) {
406
+						echo 'Add source stats : ';
407
+					}
315 408
 				        foreach($this->stats as $date => $data) {
316 409
 					    foreach($data as $source => $sourced) {
317 410
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
411
+				    	        if (isset($sourced['polar'])) {
412
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
413
+				    	        }
414
+				    	        if (isset($sourced['hist'])) {
415
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
416
+				    	        }
320 417
 				    		if (isset($sourced['msg'])) {
321 418
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 419
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -329,7 +426,9 @@  discard block
 block discarded – undo
329 426
 			    			unset($this->stats[$date]);
330 427
 			    		    }
331 428
 				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
429
+				    	if ($globalDebug) {
430
+				    		echo 'Done'."\n";
431
+				    	}
333 432
 
334 433
 				    }
335 434
 				    $Stats->db = null;
@@ -339,12 +438,16 @@  discard block
 block discarded – undo
339 438
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 439
 				//print_r($this->all_tracked[$id]);
341 440
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
441
+				    if ($globalDebug) {
442
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
443
+				    }
343 444
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 445
 				    $TrackerLive = new TrackerLive($this->db);
345 446
 				    $TrackerLive->deleteLiveTrackerData();
346 447
 				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
448
+				    if ($globalDebug) {
449
+				    	echo " Done\n";
450
+				    }
348 451
 				    $this->last_delete = time();
349 452
 				}
350 453
 			    } else {
@@ -367,19 +470,25 @@  discard block
 block discarded – undo
367 470
 
368 471
 		    if (!$ignoreImport) {
369 472
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
473
+				if ($globalDebug) {
474
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
475
+				}
371 476
 				$timeelapsed = microtime(true);
372 477
 				$TrackerLive = new TrackerLive($this->db);
373 478
 				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
374 479
 				$TrackerLive->db = null;
375 480
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481
+				if ($globalDebugTimeElapsed) {
482
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
483
+				}
377 484
 
378 485
 				// Put statistics in $this->stats variable
379 486
 				
380 487
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
381 488
 					$source = $this->all_tracked[$id]['source_name'];
382
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
489
+					if ($source == '') {
490
+						$source = $this->all_tracked[$id]['format_source'];
491
+					}
383 492
 					if (!isset($this->source_location[$source])) {
384 493
 						$Location = new Source($this->db);
385 494
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -400,7 +509,9 @@  discard block
 block discarded – undo
400 509
 					$stats_heading = round($stats_heading/22.5);
401 510
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
402 511
 					$current_date = date('Y-m-d');
403
-					if ($stats_heading == 16) $stats_heading = 0;
512
+					if ($stats_heading == 16) {
513
+						$stats_heading = 0;
514
+					}
404 515
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 516
 						for ($i=0;$i<=15;$i++) {
406 517
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -418,7 +529,9 @@  discard block
 block discarded – undo
418 529
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 530
 						    end($this->stats[$current_date][$source]['hist']);
420 531
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
421
-						} else $mini = 0;
532
+						} else {
533
+							$mini = 0;
534
+						}
422 535
 						for ($i=$mini;$i<=$distance;$i+=10) {
423 536
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 537
 						}
@@ -429,19 +542,29 @@  discard block
 block discarded – undo
429 542
 				}
430 543
 
431 544
 				$this->all_tracked[$id]['lastupdate'] = time();
432
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433
-				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
545
+				if ($this->all_tracked[$id]['putinarchive']) {
546
+					$send = true;
547
+				}
548
+				if ($globalDebug) {
549
+					echo $result."\n";
550
+				}
551
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
552
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
553
+			}
435 554
 			//$this->del();
436 555
 			
437 556
 			
438 557
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
558
+			    if ($globalDebug) {
559
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
560
+			    }
440 561
 			    $TrackerLive = new TrackerLive($this->db);
441 562
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442 563
 			    $TrackerLive->db = null;
443 564
 			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
565
+			    if ($globalDebug) {
566
+			    	echo " Done\n";
567
+			    }
445 568
 			    $this->last_delete_hourly = time();
446 569
 			}
447 570
 			
@@ -449,7 +572,9 @@  discard block
 block discarded – undo
449 572
 		    //$ignoreImport = false;
450 573
 		}
451 574
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452
-		if ($send) return $this->all_tracked[$id];
575
+		if ($send) {
576
+			return $this->all_tracked[$id];
577
+		}
453 578
 	    }
454 579
 	}
455 580
     }
Please login to merge, or discard this patch.
require/class.TrackerArchive.php 1 patch
Braces   +42 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 	public function __construct($dbc = null) {
7 7
 		$Connection = new Connection($dbc);
8 8
 		$this->db = $Connection->db;
9
-		if ($this->db === null) die('Error: No DB connection. (TrackerArchive)');
9
+		if ($this->db === null) {
10
+			die('Error: No DB connection. (TrackerArchive)');
11
+		}
10 12
 	}
11 13
 
12 14
 	/**
@@ -27,7 +29,9 @@  discard block
 block discarded – undo
27 29
 		if (isset($filter[0]['source'])) {
28 30
 			$filters = array_merge($filters,$filter);
29 31
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
31 35
 		$filter_query_join = '';
32 36
 		$filter_query_where = '';
33 37
 		foreach($filters as $flt) {
@@ -73,8 +77,11 @@  discard block
 block discarded – undo
73 77
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
74 78
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
75 79
 		}
76
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
77
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
80
+		if ($filter_query_where == '' && $where) {
81
+			$filter_query_where = ' WHERE';
82
+		} elseif ($filter_query_where != '' && $and) {
83
+			$filter_query_where .= ' AND';
84
+		}
78 85
 		if ($filter_query_where != '') {
79 86
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
80 87
 		}
@@ -88,9 +95,14 @@  discard block
 block discarded – undo
88 95
 		if ($over_country == '') {
89 96
 			$Tracker = new Tracker($this->db);
90 97
 			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude);
91
-			if (!empty($data_country)) $country = $data_country['iso2'];
92
-			else $country = '';
93
-		} else $country = $over_country;
98
+			if (!empty($data_country)) {
99
+				$country = $data_country['iso2'];
100
+			} else {
101
+				$country = '';
102
+			}
103
+		} else {
104
+			$country = $over_country;
105
+		}
94 106
 		// Route is not added in tracker_archive
95 107
 		$query  = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
96 108
 		    VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
@@ -168,8 +180,11 @@  discard block
 block discarded – undo
168 180
 	{
169 181
                 date_default_timezone_set('UTC');
170 182
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
171
-                if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
-                else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
183
+                if ($date == '') {
184
+                	$query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
185
+                } else {
186
+                	$query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
187
+                }
173 188
 
174 189
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
175 190
 
@@ -593,7 +608,9 @@  discard block
 block discarded – undo
593 608
 		    $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
594 609
 		    $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
595 610
 		    $translate = $Translation->ident2icao($q_item);
596
-		    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
611
+		    if ($translate != $q_item) {
612
+		    	$additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
613
+		    }
597 614
 		    $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
598 615
 		    $additional_query .= ")";
599 616
 		}
@@ -811,7 +828,9 @@  discard block
 block discarded – undo
811 828
 		date_default_timezone_set($globalTimezone);
812 829
 		$datetime = new DateTime();
813 830
 		$offset = $datetime->format('P');
814
-	    } else $offset = '+00:00';
831
+	    } else {
832
+	    	$offset = '+00:00';
833
+	    }
815 834
 
816 835
 
817 836
 	    if ($date_array[1] != "")
@@ -1087,9 +1106,13 @@  discard block
 block discarded – undo
1087 1106
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1088 1107
 			}
1089 1108
 		}
1090
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1109
+                if ($sincedate != '') {
1110
+                	$query .= "AND date > '".$sincedate."' ";
1111
+                }
1091 1112
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1092
-	if ($limit) $query .= " LIMIT 0,10";
1113
+	if ($limit) {
1114
+		$query .= " LIMIT 0,10";
1115
+	}
1093 1116
       
1094 1117
 	
1095 1118
 	$sth = $this->db->prepare($query);
@@ -1133,9 +1156,13 @@  discard block
 block discarded – undo
1133 1156
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1134 1157
 			}
1135 1158
 		}
1136
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1159
+                if ($sincedate != '') {
1160
+                	$query .= "AND s.date > '".$sincedate."' ";
1161
+                }
1137 1162
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1138
-	if ($limit) $query .= " LIMIT 0,10";
1163
+	if ($limit) {
1164
+		$query .= " LIMIT 0,10";
1165
+	}
1139 1166
       
1140 1167
 	
1141 1168
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Braces   +114 added lines, -39 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (TrackerLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (TrackerLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -77,8 +81,11 @@  discard block
 block discarded – undo
77 81
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78 82
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
79 83
 		}
80
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
84
+		if ($filter_query_where == '' && $where) {
85
+			$filter_query_where = ' WHERE';
86
+		} elseif ($filter_query_where != '' && $and) {
87
+			$filter_query_where .= ' AND';
88
+		}
82 89
 		if ($filter_query_where != '') {
83 90
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
84 91
 		}
@@ -120,7 +127,9 @@  discard block
 block discarded – undo
120 127
 			}
121 128
 		}
122 129
 
123
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
130
+		if (!isset($globalLiveInterval)) {
131
+			$globalLiveInterval = '200';
132
+		}
124 133
 		if ($globalDBdriver == 'mysql') {
125 134
 			//$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
126 135
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -145,7 +154,9 @@  discard block
 block discarded – undo
145 154
 
146 155
 		$filter_query = $this->getFilter($filter,true,true);
147 156
 
148
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
157
+		if (!isset($globalLiveInterval)) {
158
+			$globalLiveInterval = '200';
159
+		}
149 160
 		if ($globalDBdriver == 'mysql') {
150 161
 			$query  = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
151 162
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
@@ -190,50 +201,74 @@  discard block
 block discarded – undo
190 201
 		}
191 202
 		$filter_query = $this->getFilter($filter,true,true);
192 203
 
193
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
-		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300';
204
+		if (!isset($globalLiveInterval)) {
205
+			$globalLiveInterval = '200';
206
+		}
207
+		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') {
208
+			$globalMap3DTrackersLimit = '300';
209
+		}
195 210
 		if ($globalDBdriver == 'mysql') {
196 211
 			if (isset($globalArchive) && $globalArchive) {
197 212
 				$query  = "SELECT * FROM (
198 213
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
199 214
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
200
-				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
215
+				if ($usecoord) {
216
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
217
+				}
201 218
 				$query .= "UNION
202 219
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
203 220
 					FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
204
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
221
+				if ($usecoord) {
222
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
223
+				}
205 224
 				$query .= ") AS tracker
206 225
 				    WHERE latitude <> '0' AND longitude <> '0' 
207 226
 				    ORDER BY famtrackid, date";
208
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
227
+				if ($limit) {
228
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
229
+				}
209 230
 			} else {
210 231
 				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
211 232
 				    FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
212
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
233
+				if ($usecoord) {
234
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
235
+				}
213 236
 				$query .= "AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
214 237
 				    ORDER BY tracker_live.famtrackid, tracker_live.date";
215
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
238
+				if ($limit) {
239
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
240
+				}
216 241
 			}
217 242
 		} else {
218 243
 			if (isset($globalArchive) && $globalArchive) {
219 244
 				$query  = "SELECT * FROM (
220 245
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
221 246
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
222
-				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
247
+				if ($usecoord) {
248
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
249
+				}
223 250
 				$query .= "UNION
224 251
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
225 252
 					FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date";
226
-				if ($usecoord) $query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
253
+				if ($usecoord) {
254
+					$query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
255
+				}
227 256
 				$query .= ") AS tracker
228 257
 				    WHERE latitude <> '0' AND longitude <> '0' 
229 258
 				    ORDER BY famtrackid, date";
230
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
259
+				if ($limit) {
260
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
261
+				}
231 262
 			} else {
232 263
 				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
233 264
 				    FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' ";
234
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
265
+				if ($usecoord) {
266
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
267
+				}
235 268
 				$query .= "ORDER BY tracker_live.famtrackid, tracker_live.date";
236
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
269
+				if ($limit) {
270
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
271
+				}
237 272
 			}
238 273
 		}
239 274
 
@@ -259,7 +294,9 @@  discard block
 block discarded – undo
259 294
 		global $globalDBdriver, $globalLiveInterval;
260 295
 		$filter_query = $this->getFilter($filter,true,true);
261 296
 
262
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
297
+		if (!isset($globalLiveInterval)) {
298
+			$globalLiveInterval = '200';
299
+		}
263 300
 		if ($globalDBdriver == 'mysql') {
264 301
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
265 302
 		} else {
@@ -287,7 +324,9 @@  discard block
 block discarded – undo
287 324
 	{
288 325
 		global $globalDBdriver, $globalLiveInterval;
289 326
 		$Tracker = new Tracker($this->db);
290
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
327
+		if (!isset($globalLiveInterval)) {
328
+			$globalLiveInterval = '200';
329
+		}
291 330
 		$filter_query = $this->getFilter($filter);
292 331
 
293 332
 		if (is_array($coord)) {
@@ -295,7 +334,9 @@  discard block
 block discarded – undo
295 334
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
296 335
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
297 336
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
298
-		} else return array();
337
+		} else {
338
+			return array();
339
+		}
299 340
 		if ($globalDBdriver == 'mysql') {
300 341
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
301 342
 		} else {
@@ -315,7 +356,9 @@  discard block
 block discarded – undo
315 356
 	{
316 357
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
317 358
 		$Tracker = new Tracker($this->db);
318
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
359
+		if (!isset($globalLiveInterval)) {
360
+			$globalLiveInterval = '200';
361
+		}
319 362
 		$filter_query = $this->getFilter($filter,true,true);
320 363
 
321 364
 		if (is_array($coord)) {
@@ -323,7 +366,9 @@  discard block
 block discarded – undo
323 366
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324 367
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
325 368
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
326
-		} else return array();
369
+		} else {
370
+			return array();
371
+		}
327 372
 		/*
328 373
 		if ($globalDBdriver == 'mysql') {
329 374
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
@@ -557,13 +602,19 @@  discard block
 block discarded – undo
557 602
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
558 603
 		if ($globalDBdriver == 'mysql') {
559 604
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
560
-			if ($liveinterval === true) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
561
-			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'";
605
+			if ($liveinterval === true) {
606
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
607
+			} elseif ($liveinterval !== false) {
608
+				$query .= " AND date <= '".date('c',$liveinterval)."'";
609
+			}
562 610
 			$query .= ' ORDER BY date';
563 611
 		} else {
564 612
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
565
-			if ($liveinterval === true) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
566
-			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'";
613
+			if ($liveinterval === true) {
614
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
615
+			} elseif ($liveinterval !== false) {
616
+				$query .= " AND date <= '".date('c',$liveinterval)."'";
617
+			}
567 618
 			$query .= ' ORDER BY date';
568 619
 		}
569 620
 
@@ -658,7 +709,9 @@  discard block
 block discarded – undo
658 709
 				$i++;
659 710
 				$j++;
660 711
 				if ($j == 30) {
661
-					if ($globalDebug) echo ".";
712
+					if ($globalDebug) {
713
+						echo ".";
714
+					}
662 715
 				    	try {
663 716
 						
664 717
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -905,7 +958,9 @@  discard block
 block discarded – undo
905 958
 			{
906 959
 				return false;
907 960
 			}
908
-		} else return '';
961
+		} else {
962
+			return '';
963
+		}
909 964
 
910 965
 		if ($longitude != '')
911 966
 		{
@@ -913,7 +968,9 @@  discard block
 block discarded – undo
913 968
 			{
914 969
 				return false;
915 970
 			}
916
-		} else return '';
971
+		} else {
972
+			return '';
973
+		}
917 974
 
918 975
 		if ($altitude != '')
919 976
 		{
@@ -921,7 +978,9 @@  discard block
 block discarded – undo
921 978
 			{
922 979
 				return false;
923 980
 			}
924
-		} else $altitude = 0;
981
+		} else {
982
+			$altitude = 0;
983
+		}
925 984
 
926 985
 		if ($heading != '')
927 986
 		{
@@ -929,7 +988,9 @@  discard block
 block discarded – undo
929 988
 			{
930 989
 				return false;
931 990
 			}
932
-		} else $heading = 0;
991
+		} else {
992
+			$heading = 0;
993
+		}
933 994
 
934 995
 		if ($groundspeed != '')
935 996
 		{
@@ -937,9 +998,13 @@  discard block
 block discarded – undo
937 998
 			{
938 999
 				return false;
939 1000
 			}
940
-		} else $groundspeed = 0;
1001
+		} else {
1002
+			$groundspeed = 0;
1003
+		}
941 1004
 		date_default_timezone_set('UTC');
942
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1005
+		if ($date == '') {
1006
+			$date = date("Y-m-d H:i:s", time());
1007
+		}
943 1008
 
944 1009
         
945 1010
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -955,12 +1020,18 @@  discard block
 block discarded – undo
955 1020
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
956 1021
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
957 1022
 
958
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
959
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1023
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1024
+            		$groundspeed = 0;
1025
+            	}
1026
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1027
+            		$heading = 0;
1028
+            	}
960 1029
             	
961 1030
 		$query = '';
962 1031
 		if ($globalArchive) {
963
-			if ($globalDebug) echo '-- Delete previous data -- ';
1032
+			if ($globalDebug) {
1033
+				echo '-- Delete previous data -- ';
1034
+			}
964 1035
 			$query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;';
965 1036
 		}
966 1037
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
@@ -979,10 +1050,14 @@  discard block
 block discarded – undo
979 1050
                 echo 'noarchive : '.$noarchive."\n";
980 1051
                 */
981 1052
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
982
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
1053
+		    if ($globalDebug) {
1054
+		    	echo '(Add to Tracker archive '.$famtrackid.' : ';
1055
+		    }
983 1056
 		    $TrackerArchive = new TrackerArchive($this->db);
984 1057
 		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
985
-		    if ($globalDebug) echo $result.')';
1058
+		    if ($globalDebug) {
1059
+		    	echo $result.')';
1060
+		    }
986 1061
 		}
987 1062
 
988 1063
 		return "success";
Please login to merge, or discard this patch.
live-geojson.php 1 patch
Braces   +318 added lines, -129 removed lines patch added patch discarded remove patch
@@ -56,28 +56,55 @@  discard block
 block discarded – undo
56 56
 }
57 57
 header('Content-Type: text/javascript');
58 58
 
59
-if (!isset($globalJsonCompress)) $compress = true;
60
-else $compress = $globalJsonCompress;
59
+if (!isset($globalJsonCompress)) {
60
+	$compress = true;
61
+} else {
62
+	$compress = $globalJsonCompress;
63
+}
61 64
 
62 65
 $from_archive = false;
63 66
 $min = true;
64 67
 $allhistory = false;
65 68
 $filter['source'] = array();
66
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
69
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
71
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
72
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
69
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
70
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
71
+}
72
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
73
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
74
+}
75
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
76
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
77
+}
78
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
79
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
80
+}
81
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
82
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
83
+}
84
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
85
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
86
+}
87
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') {
88
+	$filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
89
+}
90
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
91
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
92
+}
93
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
94
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
95
+}
96
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
97
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
98
+}
99
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
100
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
101
+}
77 102
 
78 103
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
79 104
 	$min = true;
80
-} else $min = false;
105
+} else {
106
+	$min = false;
107
+}
81 108
 
82 109
 $spotter_array = array();
83 110
 
@@ -188,24 +215,38 @@  discard block
 block discarded – undo
188 215
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
189 216
 		}
190 217
 	}
191
-	if ($flightcnt == '') $flightcnt = 0;
192
-} else $flightcnt = 0;
218
+	if ($flightcnt == '') {
219
+		$flightcnt = 0;
220
+	}
221
+	} else {
222
+	$flightcnt = 0;
223
+}
193 224
 
194 225
 $sqltime = round(microtime(true)-$begintime,2);
195 226
 
196 227
 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
197
-if ($currenttime != '') $currenttime = round($currenttime/1000);
228
+if ($currenttime != '') {
229
+	$currenttime = round($currenttime/1000);
230
+}
198 231
 
199
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
200
-else $usenextlatlon = true;
201
-if ($usenextlatlon === false) $currenttime = '';
232
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
233
+	$usenextlatlon = false;
234
+} else {
235
+	$usenextlatlon = true;
236
+}
237
+if ($usenextlatlon === false) {
238
+	$currenttime = '';
239
+}
202 240
 $j = 0;
203 241
 $prev_flightaware_id = '';
204 242
 $aircrafts_shadow = array();
205 243
 $output = '{';
206 244
 	$output .= '"type": "FeatureCollection",';
207
-		if ($min) $output .= '"minimal": "true",';
208
-		else $output .= '"minimal": "false",';
245
+		if ($min) {
246
+			$output .= '"minimal": "true",';
247
+		} else {
248
+			$output .= '"minimal": "false",';
249
+		}
209 250
 		//$output .= '"fc": "'.$flightcnt.'",';
210 251
 		$output .= '"sqt": "'.$sqltime.'",';
211 252
 
@@ -250,18 +291,29 @@  discard block
 block discarded – undo
250 291
 						}
251 292
 						$output .= '"properties": {';
252 293
 						if (isset($spotter_item['flightaware_id'])) {
253
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
254
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
294
+							if ($compress) {
295
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
296
+							} else {
297
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
298
+							}
255 299
 						} elseif (isset($spotter_item['famtrackid'])) {
256
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
257
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
300
+							if ($compress) {
301
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
302
+							} else {
303
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
304
+							}
258 305
 						} elseif (isset($spotter_item['fammarine_id'])) {
259
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
260
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
306
+							if ($compress) {
307
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
308
+							} else {
309
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
310
+							}
261 311
 						}
262 312
 							$output .= '"fc": "'.$flightcnt.'",';
263 313
 							$output .= '"sqt": "'.$sqltime.'",';
264
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
314
+							if (isset($begindate)) {
315
+								$output .= '"archive_date": "'.$begindate.'",';
316
+							}
265 317
 
266 318
 /*
267 319
 							if ($min) $output .= '"minimal": "true",';
@@ -269,14 +321,22 @@  discard block
 block discarded – undo
269 321
 */
270 322
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
271 323
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
272
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
273
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
324
+							if ($compress) {
325
+								$output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
326
+							} else {
327
+								$output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
328
+							}
274 329
 							//"
275 330
 						} else {
276
-							if ($compress) $output .= '"c": "NA",';
277
-							else $output .= '"callsign": "NA",';
331
+							if ($compress) {
332
+								$output .= '"c": "NA",';
333
+							} else {
334
+								$output .= '"callsign": "NA",';
335
+							}
336
+						}
337
+						if (isset($spotter_item['registration'])) {
338
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
278 339
 						}
279
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
280 340
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
281 341
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
282 342
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -289,16 +349,23 @@  discard block
 block discarded – undo
289 349
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
290 350
 						}
291 351
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
292
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
293
-							else {
352
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
353
+								$spotter_item['aircraft_shadow'] = '';
354
+							} else {
294 355
 								$aircraft_icao = $spotter_item['aircraft_icao'];
295
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
296
-								else {
356
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
357
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
358
+								} else {
297 359
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
298
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
299
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
300
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
301
-									else $spotter_item['aircraft_shadow'] = '';
360
+									if (count($aircraft_info) > 0) {
361
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
362
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
363
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
364
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
365
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
366
+									} else {
367
+										$spotter_item['aircraft_shadow'] = '';
368
+									}
302 369
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
303 370
 								}
304 371
 							}
@@ -306,73 +373,139 @@  discard block
 block discarded – undo
306 373
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
307 374
 							if ($tracker) {
308 375
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
309
-									if ($compress) $output .= '"as": "ambulance.png",';
310
-									else $output .= '"aircraft_shadow": "ambulance.png",';
376
+									if ($compress) {
377
+										$output .= '"as": "ambulance.png",';
378
+									} else {
379
+										$output .= '"aircraft_shadow": "ambulance.png",';
380
+									}
311 381
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
312
-									if ($compress) $output .= '"as": "police.png",';
313
-									else $output .= '"aircraft_shadow": "police.png",';
382
+									if ($compress) {
383
+										$output .= '"as": "police.png",';
384
+									} else {
385
+										$output .= '"aircraft_shadow": "police.png",';
386
+									}
314 387
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
315
-									if ($compress) $output .= '"as": "ship.png",';
316
-									else $output .= '"aircraft_shadow": "ship.png",';
388
+									if ($compress) {
389
+										$output .= '"as": "ship.png",';
390
+									} else {
391
+										$output .= '"aircraft_shadow": "ship.png",';
392
+									}
317 393
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
318
-									if ($compress) $output .= '"as": "ship.png",';
319
-									else $output .= '"aircraft_shadow": "ship.png",';
394
+									if ($compress) {
395
+										$output .= '"as": "ship.png",';
396
+									} else {
397
+										$output .= '"aircraft_shadow": "ship.png",';
398
+									}
320 399
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
321
-									if ($compress) $output .= '"as": "ship.png",';
322
-									else $output .= '"aircraft_shadow": "ship.png",';
400
+									if ($compress) {
401
+										$output .= '"as": "ship.png",';
402
+									} else {
403
+										$output .= '"aircraft_shadow": "ship.png",';
404
+									}
323 405
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
324
-									if ($compress) $output .= '"as": "truck.png",';
325
-									else $output .= '"aircraft_shadow": "truck.png",';
406
+									if ($compress) {
407
+										$output .= '"as": "truck.png",';
408
+									} else {
409
+										$output .= '"aircraft_shadow": "truck.png",';
410
+									}
326 411
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
327
-									if ($compress) $output .= '"as": "truck.png",';
328
-									else $output .= '"aircraft_shadow": "truck.png",';
412
+									if ($compress) {
413
+										$output .= '"as": "truck.png",';
414
+									} else {
415
+										$output .= '"aircraft_shadow": "truck.png",';
416
+									}
329 417
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
330
-									if ($compress) $output .= '"as": "aircraft.png",';
331
-									else $output .= '"aircraft_shadow": "aircraft.png",';
418
+									if ($compress) {
419
+										$output .= '"as": "aircraft.png",';
420
+									} else {
421
+										$output .= '"aircraft_shadow": "aircraft.png",';
422
+									}
332 423
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
333
-									if ($compress) $output .= '"as": "aircraft.png",';
334
-									else $output .= '"aircraft_shadow": "aircraft.png",';
424
+									if ($compress) {
425
+										$output .= '"as": "aircraft.png",';
426
+									} else {
427
+										$output .= '"aircraft_shadow": "aircraft.png",';
428
+									}
335 429
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
336
-									if ($compress) $output .= '"as": "helico.png",';
337
-									else $output .= '"aircraft_shadow": "helico.png",';
430
+									if ($compress) {
431
+										$output .= '"as": "helico.png",';
432
+									} else {
433
+										$output .= '"aircraft_shadow": "helico.png",';
434
+									}
338 435
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
339
-									if ($compress) $output .= '"as": "rail.png",';
340
-									else $output .= '"aircraft_shadow": "rail.png",';
436
+									if ($compress) {
437
+										$output .= '"as": "rail.png",';
438
+									} else {
439
+										$output .= '"aircraft_shadow": "rail.png",';
440
+									}
341 441
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
342
-									if ($compress) $output .= '"as": "firetruck.png",';
343
-									else $output .= '"aircraft_shadow": "firetruck.png",';
442
+									if ($compress) {
443
+										$output .= '"as": "firetruck.png",';
444
+									} else {
445
+										$output .= '"aircraft_shadow": "firetruck.png",';
446
+									}
344 447
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
345
-									if ($compress) $output .= '"as": "bus.png",';
346
-									else $output .= '"aircraft_shadow": "bus.png",';
448
+									if ($compress) {
449
+										$output .= '"as": "bus.png",';
450
+									} else {
451
+										$output .= '"aircraft_shadow": "bus.png",';
452
+									}
347 453
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
348
-									if ($compress) $output .= '"as": "phone.png",';
349
-									else $output .= '"aircraft_shadow": "phone.png",';
454
+									if ($compress) {
455
+										$output .= '"as": "phone.png",';
456
+									} else {
457
+										$output .= '"aircraft_shadow": "phone.png",';
458
+									}
350 459
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
351
-									if ($compress) $output .= '"as": "jogger.png",';
352
-									else $output .= '"aircraft_shadow": "jogger.png",';
460
+									if ($compress) {
461
+										$output .= '"as": "jogger.png",';
462
+									} else {
463
+										$output .= '"aircraft_shadow": "jogger.png",';
464
+									}
353 465
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
354
-									if ($compress) $output .= '"as": "bike.png",';
355
-									else $output .= '"aircraft_shadow": "bike.png",';
466
+									if ($compress) {
467
+										$output .= '"as": "bike.png",';
468
+									} else {
469
+										$output .= '"aircraft_shadow": "bike.png",';
470
+									}
356 471
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
357
-									if ($compress) $output .= '"as": "motorcycle.png",';
358
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
472
+									if ($compress) {
473
+										$output .= '"as": "motorcycle.png",';
474
+									} else {
475
+										$output .= '"aircraft_shadow": "motorcycle.png",';
476
+									}
359 477
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
360
-									if ($compress) $output .= '"as": "balloon.png",';
361
-									else $output .= '"aircraft_shadow": "balloon.png",';
478
+									if ($compress) {
479
+										$output .= '"as": "balloon.png",';
480
+									} else {
481
+										$output .= '"aircraft_shadow": "balloon.png",';
482
+									}
362 483
 								} else {
363
-									if ($compress) $output .= '"as": "car.png",';
364
-									else $output .= '"aircraft_shadow": "car.png",';
484
+									if ($compress) {
485
+										$output .= '"as": "car.png",';
486
+									} else {
487
+										$output .= '"aircraft_shadow": "car.png",';
488
+									}
365 489
 								}
366 490
 							} elseif ($marine) {
367
-								if ($compress) $output .= '"as": "ship.png",';
368
-								else $output .= '"aircraft_shadow": "ship.png",';
491
+								if ($compress) {
492
+									$output .= '"as": "ship.png",';
493
+								} else {
494
+									$output .= '"aircraft_shadow": "ship.png",';
495
+								}
369 496
 							} else {
370
-								if ($compress) $output .= '"as": "default.png",';
371
-								else $output .= '"aircraft_shadow": "default.png",';
497
+								if ($compress) {
498
+									$output .= '"as": "default.png",';
499
+								} else {
500
+									$output .= '"aircraft_shadow": "default.png",';
501
+								}
372 502
 							}
373 503
 						} else {
374
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
375
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
504
+							if ($compress) {
505
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
506
+							} else {
507
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
508
+							}
376 509
 						}
377 510
 						if (isset($spotter_item['airline_name'])) {
378 511
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -380,8 +513,11 @@  discard block
 block discarded – undo
380 513
 							$output .= '"airline_name": "NA",';
381 514
 						}
382 515
 						if (isset($spotter_item['departure_airport'])) {
383
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
384
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
516
+							if ($compress) {
517
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
518
+							} else {
519
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
520
+							}
385 521
 						}
386 522
 						if (isset($spotter_item['departure_airport_city'])) {
387 523
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -393,8 +529,11 @@  discard block
 block discarded – undo
393 529
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
394 530
 						}
395 531
 						if (isset($spotter_item['arrival_airport'])) {
396
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
397
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
532
+							if ($compress) {
533
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
534
+							} else {
535
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
536
+							}
398 537
 						}
399 538
 						if (isset($spotter_item['arrival_airport_city'])) {
400 539
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -413,8 +552,11 @@  discard block
 block discarded – undo
413 552
 						}
414 553
 						
415 554
 						if (isset($spotter_item['altitude'])) {
416
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
417
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
555
+							if ($compress) {
556
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
557
+							} else {
558
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
559
+							}
418 560
 						}
419 561
 						
420 562
 						$heading = $spotter_item['heading'];
@@ -438,19 +580,24 @@  discard block
 block discarded – undo
438 580
 							}
439 581
 						}
440 582
 						
441
-						if ($compress)$output .= '"h": "'.$heading.'",';
442
-						else $output .= '"heading": "'.$heading.'",';
583
+						if ($compress) {
584
+							$output .= '"h": "'.$heading.'",';
585
+						} else {
586
+							$output .= '"heading": "'.$heading.'",';
587
+						}
443 588
 						if ($currenttime != '') {
444 589
 							if (strtotime($spotter_item['date']) < $currenttime) {
445 590
 								if (isset($archivespeed)) {
446 591
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
447 592
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
448
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
449
-									else {
593
+									if (!isset($idistance) || $fdistance < $idistance) {
594
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
595
+									} else {
450 596
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
451 597
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
452
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
453
-										else {
598
+										if (!isset($idistance) || $fdistance < $idistance) {
599
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
600
+										} else {
454 601
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
455 602
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
456 603
 										}
@@ -458,12 +605,14 @@  discard block
 block discarded – undo
458 605
 								} elseif ($usenextlatlon) {
459 606
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
460 607
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
461
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
462
-									else {
608
+									if (!isset($idistance) || $fdistance < $idistance) {
609
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
610
+									} else {
463 611
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
464 612
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
465
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
466
-										else {
613
+										if (!isset($idistance) || $fdistance < $idistance) {
614
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
615
+										} else {
467 616
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
468 617
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
469 618
 										}
@@ -502,7 +651,9 @@  discard block
 block discarded – undo
502 651
 							}
503 652
 						}
504 653
 
505
-						if (!$min) $output .= '"image": "'.$image.'",';
654
+						if (!$min) {
655
+							$output .= '"image": "'.$image.'",';
656
+						}
506 657
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
507 658
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
508 659
 						}
@@ -510,8 +661,11 @@  discard block
 block discarded – undo
510 661
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
511 662
 						}
512 663
 						if (isset($spotter_item['squawk'])) {
513
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
514
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
664
+							if ($compress) {
665
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
666
+							} else {
667
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
668
+							}
515 669
 						}
516 670
 						if (isset($spotter_item['squawk_usage'])) {
517 671
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -530,14 +684,23 @@  discard block
 block discarded – undo
530 684
 						}
531 685
 						// type when not aircraft ?
532 686
 						if (isset($spotter_item['type'])) {
533
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
534
-							else $output .= '"type": "'.$spotter_item['type'].'"';
687
+							if ($compress) {
688
+								$output .= '"t": "'.$spotter_item['type'].'"';
689
+							} else {
690
+								$output .= '"type": "'.$spotter_item['type'].'"';
691
+							}
535 692
 						} elseif ($marine) {
536
-							if ($compress) $output .= '"t": "ship"';
537
-							else $output .= '"type": "ship"';
693
+							if ($compress) {
694
+								$output .= '"t": "ship"';
695
+							} else {
696
+								$output .= '"type": "ship"';
697
+							}
538 698
 						} else {
539
-							if ($compress) $output .= '"t": "aircraft"';
540
-							else $output .= '"type": "aircraft"';
699
+							if ($compress) {
700
+								$output .= '"t": "aircraft"';
701
+							} else {
702
+								$output .= '"type": "aircraft"';
703
+							}
541 704
 						}
542 705
 						$output .= '},';
543 706
 						$output .= '"geometry": {';
@@ -545,15 +708,19 @@  discard block
 block discarded – undo
545 708
 								$output .= '"coordinates": [';
546 709
 								if ($currenttime != '') {
547 710
 									if (strtotime($spotter_item['date']) < $currenttime) {
548
-										if (!isset($archivespeed)) $archivespeed = 1;
711
+										if (!isset($archivespeed)) {
712
+											$archivespeed = 1;
713
+										}
549 714
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
550 715
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
551
-										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
552
-										else {
716
+										if (!isset($idistance) || $fdistance < $idistance) {
717
+											$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
718
+										} else {
553 719
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
554 720
 											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
555
-											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
556
-											else {
721
+											if (!isset($idistance) || $fdistance < $idistance) {
722
+												$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
723
+											} else {
557 724
 												$output .= $spotter_item['longitude'].', ';
558 725
 												$output .= $spotter_item['latitude'];
559 726
 											}
@@ -631,7 +798,9 @@  discard block
 block discarded – undo
631 798
 			}
632 799
 */
633 800
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
634
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
801
+				if ($history == '' && isset($_COOKIE['history'])) {
802
+					$history = $_COOKIE['history'];
803
+				}
635 804
 				
636 805
 				if (
637 806
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -697,8 +866,11 @@  discard block
 block discarded – undo
697 866
 									$output_history .= ']}},';
698 867
 									$output .= $output_history;
699 868
 								}
700
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
701
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
869
+								if ($compress) {
870
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
871
+								} else {
872
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
873
+								}
702 874
 							}
703 875
 							$output_history .= '[';
704 876
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -719,10 +891,15 @@  discard block
 block discarded – undo
719 891
 							if ($d == false) {
720 892
 								if ($compress) {
721 893
 									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",';
722
-									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
723
-									elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
894
+									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') {
895
+										$output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
896
+									} elseif (isset($spotter_history_array[0]['mapmatching_engine'])) {
897
+										$output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
898
+									}
724 899
 									$output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": [';
725
-								} else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
900
+								} else {
901
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
902
+								}
726 903
 								$d = true;
727 904
 							}
728 905
 							$output_history .= '[';
@@ -745,7 +922,9 @@  discard block
 block discarded – undo
745 922
 							$output_historyd = '[';
746 923
 							$output_historyd .=  $spotter_item['longitude'].', ';
747 924
 							$output_historyd .=  $spotter_item['latitude'];
748
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
925
+							if (isset($spotter_history['altitude'])) {
926
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
927
+							}
749 928
 							$output_historyd .= '],';
750 929
 							//$output_history = $output_historyd.$output_history;
751 930
 							$output_history = $output_history.$output_historyd;
@@ -772,8 +951,11 @@  discard block
 block discarded – undo
772 951
 				        && $spotter_item['arrival_airport'] != 'NA' 
773 952
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
774 953
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
775
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
776
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
954
+				    if ($compress) {
955
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
956
+				    } else {
957
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
958
+				    }
777 959
 				    if (isset($spotter_item['departure_airport_latitude'])) {
778 960
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
779 961
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -806,8 +988,11 @@  discard block
 block discarded – undo
806 988
 				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
807 989
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
808 990
 				    $havedata = false;
809
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
810
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
991
+				    if ($compress) {
992
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
993
+				    } else {
994
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
995
+				    }
811 996
 				    $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
812 997
 
813 998
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -822,7 +1007,9 @@  discard block
 block discarded – undo
822 1007
 				    }
823 1008
 				    //$output_dest  = substr($output_dest, 0, -1);
824 1009
 				    $output_dest .= ']}},';
825
-				    if ($havedata) $output .= $output_dest;
1010
+				    if ($havedata) {
1011
+				    	$output .= $output_dest;
1012
+				    }
826 1013
 				    unset($output_dest);
827 1014
 				}
828 1015
 			}
@@ -830,7 +1017,9 @@  discard block
 block discarded – undo
830 1017
 			$output .= ']';
831 1018
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
832 1019
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
833
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
1020
+			if (isset($begindate)) {
1021
+				$output .= '"archive_date": "'.$begindate.'",';
1022
+			}
834 1023
 			$output .= '"fc": "'.$j.'"';
835 1024
 		} else {
836 1025
 			$output .= '"features": ';
Please login to merge, or discard this patch.
header.php 1 patch
Braces   +90 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,12 +6,19 @@  discard block
 block discarded – undo
6 6
 //gets the page file and stores it in a variable
7 7
 $file_path = pathinfo($_SERVER['SCRIPT_NAME']);
8 8
 $current_page = $file_path['filename'];
9
-if ($globalTimezone == '') $globalTimezone = 'UTC';
9
+if ($globalTimezone == '') {
10
+	$globalTimezone = 'UTC';
11
+}
10 12
 date_default_timezone_set($globalTimezone);
11
-if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
12
-else $MapType = $globalMapProvider;
13
+if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') {
14
+	$MapType = $_COOKIE['MapType'];
15
+} else {
16
+	$MapType = $globalMapProvider;
17
+}
13 18
 
14
-if (isset($globalMapOffline) && $globalMapOffline) $MapType = 'offline';
19
+if (isset($globalMapOffline) && $globalMapOffline) {
20
+	$MapType = 'offline';
21
+}
15 22
 
16 23
 if (isset($_GET['3d'])) {
17 24
 	setcookie('MapFormat','3d');
@@ -219,7 +226,10 @@  discard block
 block discarded – undo
219 226
 <?php
220 227
 //		}
221 228
 ?>
222
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) print '&tsk='.$tsk; ?>"></script>
229
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) {
230
+	print '&tsk='.$tsk;
231
+}
232
+?>"></script>
223 233
 <?php
224 234
 		if (!isset($globalAircraft) || $globalAircraft) {
225 235
 ?>
@@ -264,7 +274,13 @@  discard block
 block discarded – undo
264 274
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
265 275
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
266 276
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
267
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
277
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) {
278
+	print '&latitude='.$latitude;
279
+}
280
+?><?php if(isset($longitude)) {
281
+	print '&longitude='.$longitude;
282
+}
283
+?>&<?php print time(); ?>"></script>
268 284
 <?php
269 285
 		if (!isset($type) || $type == 'aircraft') {
270 286
 ?>
@@ -337,7 +353,13 @@  discard block
 block discarded – undo
337 353
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
338 354
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
339 355
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
340
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
356
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) {
357
+	print '&latitude='.$latitude;
358
+}
359
+?><?php if(isset($longitude)) {
360
+	print '&longitude='.$longitude;
361
+}
362
+?>&<?php print time(); ?>"></script>
341 363
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
342 364
 <?php
343 365
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -418,7 +440,12 @@  discard block
 block discarded – undo
418 440
         <span class="icon-bar"></span>
419 441
       </button>
420 442
       <a href="<?php print $globalURL; ?>/search" class="navbar-toggle search"><i class="fa fa-search"></i></a>
421
-      <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
443
+      <a class="navbar-brand" href="<?php if ($globalURL == '') {
444
+	print '/';
445
+} else {
446
+	print $globalURL;
447
+}
448
+?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
422 449
     </div>
423 450
     <div class="collapse navbar-collapse">
424 451
 
@@ -473,7 +500,10 @@  discard block
 block discarded – undo
473 500
 	}
474 501
 ?>
475 502
 
476
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
503
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
504
+	echo 'right-';
505
+}
506
+?>caret"></b></a>
477 507
           <ul class="dropdown-menu">
478 508
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircrafts Types"); ?></a></li>
479 509
 <?php
@@ -544,8 +574,14 @@  discard block
 block discarded – undo
544 574
         </li>
545 575
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
546 576
       	<li><a href="<?php print $globalURL; ?>/statistics"><?php echo _("Statistics"); ?></a></li>
547
-        <li class="dropdown<?php if ($sub) echo '-submenu'; ?>">
548
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
577
+        <li class="dropdown<?php if ($sub) {
578
+	echo '-submenu';
579
+}
580
+?>">
581
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) {
582
+	echo 'right-';
583
+}
584
+?>caret"></b></a>
549 585
           <ul class="dropdown-menu">
550 586
           	<li><a href="<?php print $globalURL; ?>/tools/acars"><?php echo _("ACARS translator"); ?></a></li>
551 587
           	<li><a href="<?php print $globalURL; ?>/tools/metar"><?php echo _("METAR translator"); ?></a></li>
@@ -589,7 +625,10 @@  discard block
 block discarded – undo
589 625
 <?php
590 626
 	}
591 627
 ?>
592
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
628
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
629
+	echo 'right-';
630
+}
631
+?>caret"></b></a>
593 632
 		<ul class="dropdown-menu">
594 633
 		    <li><a href="<?php print $globalURL; ?>/marine/currently"><?php echo _("Current Activity"); ?></a></li>
595 634
 		    <li><a href="<?php print $globalURL; ?>/marine/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -630,7 +669,10 @@  discard block
 block discarded – undo
630 669
 <?php
631 670
 	}
632 671
 ?>
633
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
672
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
673
+	echo 'right-';
674
+}
675
+?>caret"></b></a>
634 676
 		<ul class="dropdown-menu">
635 677
 		    <li><a href="<?php print $globalURL; ?>/tracker/currently"><?php echo _("Current Activity"); ?></a></li>
636 678
 		    <li><a href="<?php print $globalURL; ?>/tracker/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -673,7 +715,10 @@  discard block
 block discarded – undo
673 715
 ?>
674 716
 
675 717
 <!--
676
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
718
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
719
+	echo 'right-';
720
+}
721
+?>caret"></b></a>
677 722
 		<ul class="dropdown-menu">
678 723
 		    <li><a href="<?php print $globalURL; ?>/satellite/currently"><?php echo _("Current Activity"); ?></a></li>
679 724
 		    <li><a href="<?php print $globalURL; ?>/satellite/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -730,7 +775,9 @@  discard block
 block discarded – undo
730 775
   		        $alllang = $Language->getLanguages();
731 776
   		        foreach ($alllang as $key => $lang) {
732 777
   		            print '<option value="'.$key.'"';
733
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
778
+  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) {
779
+  		            	print ' selected ';
780
+  		            }
734 781
   		            print '>'.$lang[0].'</option>';
735 782
   		        }
736 783
   		    ?>
@@ -878,9 +925,24 @@  discard block
 block discarded – undo
878 925
 	$customid = $globalMapProvider;
879 926
 ?>
880 927
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
881
-        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
882
-        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
883
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
928
+        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
929
+	print $globalMapCustomLayer[$customid]['maxZoom'];
930
+} else {
931
+	print '18';
932
+}
933
+?>,
934
+        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
935
+	print $globalMapCustomLayer[$customid]['minZoom'];
936
+} else {
937
+	print '0';
938
+}
939
+?>,
940
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
941
+	print 'false';
942
+} else {
943
+	print 'true';
944
+}
945
+?>,
884 946
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
885 947
     }).addTo(map);
886 948
 <?php
@@ -895,7 +957,12 @@  discard block
 block discarded – undo
895 957
         maxZoom: 5,
896 958
         tms : true,
897 959
         zindex : 3,
898
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
960
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
961
+	print 'false';
962
+} else {
963
+	print 'true';
964
+}
965
+?>,
899 966
         attribution: 'Natural Earth'
900 967
     }).addTo(map);
901 968
 <?php
@@ -918,4 +985,7 @@  discard block
 block discarded – undo
918 985
 
919 986
 ?>
920 987
 
921
-<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear">
988
+<section class="container main-content <?php if (strtolower($current_page) == 'index') {
989
+	print 'index ';
990
+}
991
+?>clear">
Please login to merge, or discard this patch.
js/map.2d.js.php 1 patch
Braces   +109 added lines, -27 removed lines patch added patch discarded remove patch
@@ -4,10 +4,15 @@  discard block
 block discarded – undo
4 4
 
5 5
 setcookie("MapFormat",'2d');
6 6
 
7
-if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = '';
7
+if (!isset($globalOpenWeatherMapKey)) {
8
+	$globalOpenWeatherMapKey = '';
9
+}
8 10
 // Compressed GeoJson is used if true
9
-if (!isset($globalJsonCompress)) $compress = true;
10
-else $compress = $globalJsonCompress;
11
+if (!isset($globalJsonCompress)) {
12
+	$compress = true;
13
+} else {
14
+	$compress = $globalJsonCompress;
15
+}
11 16
 if (isset($_GET['archive'])) {
12 17
 	$archive = true;
13 18
 	//$archiveupdatetime = 50;
@@ -18,8 +23,11 @@  discard block
 block discarded – undo
18 23
 	//$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10));
19 24
 	//$lastupd = 20;
20 25
 	$lastupd = $_GET['archivespeed']*$archiveupdatetime;
21
-	if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
22
-	else $enddate = time();
26
+	if (isset($_GET['enddate']) && $_GET['enddate'] != '') {
27
+		$enddate = $_GET['enddate'];
28
+	} else {
29
+		$enddate = time();
30
+	}
23 31
 	setcookie("archive_begin",$begindate);
24 32
 	setcookie("archive_end",$enddate);
25 33
 	setcookie("archive_update",$lastupd);
@@ -107,7 +115,17 @@  discard block
 block discarded – undo
107 115
 	}
108 116
 
109 117
 	//create the map
110
-	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom);
118
+	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) {
119
+	print $latitude;
120
+} else {
121
+	print $globalCenterLatitude;
122
+}
123
+?>,<?php if (isset($longitude)) {
124
+	print $longitude;
125
+} else {
126
+	print $globalCenterLongitude;
127
+}
128
+?>], zoom);
111 129
 <?php
112 130
 	} else {
113 131
 		if ((isset($globalCenterLatitude) && $globalCenterLatitude != '' && isset($globalCenterLongitude) && $globalCenterLongitude != '') || isset($_COOKIE['lastcentercoord'])) {
@@ -133,9 +151,21 @@  discard block
 block discarded – undo
133 151
 	     || navigator.userAgent.match(/BlackBerry/i)
134 152
 	     || navigator.userAgent.match(/Windows Phone/i))
135 153
 	{
136
-		var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) print $viewzoom-1; elseif (isset($viewzoom)) print $viewzoom; else print '8'; ?>;
154
+		var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) {
155
+	print $viewzoom-1;
156
+} elseif (isset($viewzoom)) {
157
+	print $viewzoom;
158
+} else {
159
+	print '8';
160
+}
161
+?>;
137 162
 	} else {
138
-		var zoom = <?php if (isset($viewzoom)) print $viewzoom; else print '9'; ?>;
163
+		var zoom = <?php if (isset($viewzoom)) {
164
+	print $viewzoom;
165
+} else {
166
+	print '9';
167
+}
168
+?>;
139 169
 	}
140 170
 
141 171
 	//create the map
@@ -161,16 +191,27 @@  discard block
 block discarded – undo
161 191
 	bounds = L.latLngBounds(southWest,northEast);
162 192
 	//a few title layers
163 193
 <?php
164
-	if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType'];
165
-	else $MapType = $globalMapProvider;
194
+	if (isset($_COOKIE['MapType'])) {
195
+		$MapType = $_COOKIE['MapType'];
196
+	} else {
197
+		$MapType = $globalMapProvider;
198
+	}
166 199
 
167 200
 	if ($MapType == 'Mapbox') {
168
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
169
-		else $MapBoxId = $_COOKIE['MapTypeId'];
170
-?>
201
+		if ($_COOKIE['MapTypeId'] == 'default') {
202
+			$MapBoxId = $globalMapboxId;
203
+		} else {
204
+			$MapBoxId = $_COOKIE['MapTypeId'];
205
+		}
206
+		?>
171 207
 	L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
172 208
 	    maxZoom: 18,
173
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
209
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
210
+	print 'false';
211
+} else {
212
+	print 'true';
213
+}
214
+?>,
174 215
 	    attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
175 216
 	    id: '<?php print $MapBoxId; ?>',
176 217
 	    token: '<?php print $globalMapboxToken; ?>'
@@ -189,7 +230,12 @@  discard block
 block discarded – undo
189 230
 ?>
190 231
 	L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
191 232
 	    maxZoom: 18,
192
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
233
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
234
+	print 'false';
235
+} else {
236
+	print 'true';
237
+}
238
+?>,
193 239
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
194 240
 	      '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>'
195 241
 	}).addTo(map);
@@ -235,20 +281,26 @@  discard block
 block discarded – undo
235 281
 	map.addLayer(yandexLayer);
236 282
 <?php
237 283
 	} elseif ($MapType == 'Bing-Aerial') {
238
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
239
-?>
284
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
285
+			setcookie('MapType','OpenStreetMap');
286
+		}
287
+		?>
240 288
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
241 289
 	map.addLayer(bingLayer);
242 290
 <?php
243 291
 	} elseif ($MapType == 'Bing-Hybrid') {
244
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
245
-?>
292
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
293
+			setcookie('MapType','OpenStreetMap');
294
+		}
295
+		?>
246 296
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
247 297
 	map.addLayer(bingLayer);
248 298
 <?php
249 299
 	} elseif ($MapType == 'Bing-Road') {
250
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
251
-?>
300
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
301
+			setcookie('MapType','OpenStreetMap');
302
+		}
303
+		?>
252 304
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
253 305
 	map.addLayer(bingLayer);
254 306
 <?php
@@ -277,7 +329,12 @@  discard block
 block discarded – undo
277 329
 	    maxZoom: 5,
278 330
 	    tms : true,
279 331
 	    zindex : 3,
280
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
332
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
333
+	print 'false';
334
+} else {
335
+	print 'true';
336
+}
337
+?>,
281 338
 	    attribution: 'Natural Earth'
282 339
 	}).addTo(map);
283 340
 <?php
@@ -285,9 +342,24 @@  discard block
 block discarded – undo
285 342
 		$customid = $MapType;
286 343
 ?>
287 344
 	L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
288
-	    maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
289
-	    minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
290
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
345
+	    maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
346
+	print $globalMapCustomLayer[$customid]['maxZoom'];
347
+} else {
348
+	print '18';
349
+}
350
+?>,
351
+	    minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
352
+	print $globalMapCustomLayer[$customid]['minZoom'];
353
+} else {
354
+	print '0';
355
+}
356
+?>,
357
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
358
+	print 'false';
359
+} else {
360
+	print 'true';
361
+}
362
+?>,
291 363
 	    attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
292 364
 	}).addTo(map);
293 365
 
@@ -327,7 +399,12 @@  discard block
 block discarded – undo
327 399
 		}
328 400
 	} elseif ($globalBounding == 'circle') {
329 401
 ?>
330
-	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{
402
+	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) {
403
+	print $globalBoundingCircleSize;
404
+} else {
405
+	print '70000';
406
+}
407
+?>,{
331 408
 	    color: '#92C7D1',
332 409
 	    fillColor: '#92C7D1',
333 410
 	    fillOpacity: 0.3,
@@ -419,7 +496,12 @@  discard block
 block discarded – undo
419 496
 		createCookie('lastcentercoord',map.getCenter().lat+','+map.getCenter().lng+','+map.getZoom(),2);
420 497
 	});
421 498
 update_locationsLayer();
422
-setInterval(function(){if (noTimeout) update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
499
+setInterval(function(){if (noTimeout) update_locationsLayer()},<?php if (isset($globalMapRefresh)) {
500
+	print $globalMapRefresh*1000*2;
501
+} else {
502
+	print '60000';
503
+}
504
+?>);
423 505
 
424 506
 <?php
425 507
     // Add support for custom json via $globalMapJson
Please login to merge, or discard this patch.
index.php 1 patch
Braces   +477 added lines, -120 removed lines patch added patch discarded remove patch
@@ -49,7 +49,10 @@  discard block
 block discarded – undo
49 49
 <?php
50 50
     if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
51 51
 ?>
52
-<script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) print '?tsk='.$tsk; ?>"></script>
52
+<script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) {
53
+	print '?tsk='.$tsk;
54
+}
55
+?>"></script>
53 56
 <?php
54 57
 	if (!isset($globalAircraft) || $globalAircraft) {
55 58
 ?>
@@ -163,11 +166,26 @@  discard block
 block discarded – undo
163 166
 				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam();" /><?php echo _("Display NOTAM"); ?></label></div></li>
164 167
 				<li><?php echo _("NOTAM scope:"); ?>
165 168
 					<select class="selectpicker" onchange="notamscope(this);">
166
-						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option>
167
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option>
168
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option>
169
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option>
170
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option>
169
+						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') {
170
+	print ' selected';
171
+}
172
+?>>All</option>
173
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') {
174
+	print ' selected';
175
+}
176
+?>>Airport/Enroute warning</option>
177
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') {
178
+	print ' selected';
179
+}
180
+?>>Airport warning</option>
181
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') {
182
+	print ' selected';
183
+}
184
+?>>Navigation warning</option>
185
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') {
186
+	print ' selected';
187
+}
188
+?>>Enroute warning</option>
171 189
 					</select
172 190
 				</li>
173 191
 			</ul>
@@ -195,7 +213,12 @@  discard block
 block discarded – undo
195 213
 		        <div class="form-group">
196 214
 			    <label>From (UTC):</label>
197 215
 		            <div class='input-group date' id='datetimepicker1'>
198
-            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required />
216
+            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) {
217
+	print $_POST['start_date'];
218
+} elseif (isset($_COOKIE['archive_begin'])) {
219
+	print date("m/d/Y h:i a",$_COOKIE['archive_begin']);
220
+}
221
+?>" required />
199 222
 		                <span class="input-group-addon">
200 223
             			    <span class="glyphicon glyphicon-calendar"></span>
201 224
 		                </span>
@@ -204,7 +227,12 @@  discard block
 block discarded – undo
204 227
 		        <div class="form-group">
205 228
 			    <label>To (UTC):</label>
206 229
 		            <div class='input-group date' id='datetimepicker2'>
207
-		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" />
230
+		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) {
231
+	print $_POST['end_date'];
232
+} elseif (isset($_COOKIE['archive_end'])) {
233
+	print date("m/d/Y h:i a",$_COOKIE['archive_end']);
234
+}
235
+?>" />
208 236
             			<span class="input-group-addon">
209 237
 		                    <span class="glyphicon glyphicon-calendar"></span>
210 238
             			</span>
@@ -229,8 +257,20 @@  discard block
 block discarded – undo
229 257
 			</script>
230 258
 		    <li><?php echo _("Playback speed:"); ?>
231 259
 			<div class="range">
232
-			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) print $_POST['archivespeed']; elseif (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>">
233
-			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output>
260
+			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) {
261
+	print $_POST['archivespeed'];
262
+} elseif (isset($_COOKIE['archive_speed'])) {
263
+	print $_COOKIE['archive_speed'];
264
+} else {
265
+	print '1';
266
+}
267
+?>">
268
+			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) {
269
+	print $_COOKIE['archive_speed'];
270
+} else {
271
+	print '1';
272
+}
273
+?></output>
234 274
 			</div>
235 275
 		    </li>
236 276
 		    <li><input type="submit" name="archive" value="Show archive" class="btn btn-primary" /></li>
@@ -252,25 +292,43 @@  discard block
 block discarded – undo
252 292
 		    <li><?php echo _("Type of Map:"); ?>
253 293
 			<select  class="selectpicker" onchange="mapType(this);">
254 294
 			    <?php
255
-				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
256
-				else $MapType = $_COOKIE['MapType'];
295
+				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') {
296
+					$MapType = $globalMapProvider;
297
+				} else {
298
+					$MapType = $_COOKIE['MapType'];
299
+				}
257 300
 			    ?>
258 301
 			    <?php
259 302
 				if (isset($globalMapOffline) && $globalMapOffline === TRUE) {
260 303
 			    ?>
261
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
304
+			    <option value="offline"<?php if ($MapType == 'offline') {
305
+	print ' selected';
306
+}
307
+?>>Natural Earth (local)</option>
262 308
 			    <?php
263 309
 				} else {
264 310
 				    if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
265 311
 			    ?>
266
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
312
+			    <option value="offline"<?php if ($MapType == 'offline') {
313
+	print ' selected';
314
+}
315
+?>>Natural Earth (local)</option>
267 316
 			    <?php
268 317
 				    }
269 318
 				    if (isset($globalBingMapKey) && $globalBingMapKey != '') {
270 319
 			    ?>
271
-			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
272
-			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
273
-			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
320
+			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') {
321
+	print ' selected';
322
+}
323
+?>>Bing-Aerial</option>
324
+			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') {
325
+	print ' selected';
326
+}
327
+?>>Bing-Hybrid</option>
328
+			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') {
329
+	print ' selected';
330
+}
331
+?>>Bing-Road</option>
274 332
 			    <?php
275 333
 				    }
276 334
 			    ?>
@@ -280,58 +338,139 @@  discard block
 block discarded – undo
280 338
 			    <?php
281 339
 					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
282 340
 			    ?>
283
-			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
284
-			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
285
-			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
341
+			    <option value="Here-Aerial"<?php if ($MapType == 'Here') {
342
+	print ' selected';
343
+}
344
+?>>Here-Aerial</option>
345
+			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') {
346
+	print ' selected';
347
+}
348
+?>>Here-Hybrid</option>
349
+			    <option value="Here-Road"<?php if ($MapType == 'Here') {
350
+	print ' selected';
351
+}
352
+?>>Here-Road</option>
286 353
 			    <?php
287 354
 					}
288 355
 			    ?>
289 356
 			    <?php
290 357
 					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
291 358
 			    ?>
292
-			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
293
-			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
294
-			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
295
-			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
359
+			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') {
360
+	print ' selected';
361
+}
362
+?>>Google Roadmap</option>
363
+			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') {
364
+	print ' selected';
365
+}
366
+?>>Google Satellite</option>
367
+			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') {
368
+	print ' selected';
369
+}
370
+?>>Google Hybrid</option>
371
+			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') {
372
+	print ' selected';
373
+}
374
+?>>Google Terrain</option>
296 375
 			    <?php
297 376
 					}
298 377
 			    ?>
299 378
 			    <?php
300 379
 					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
301 380
 			    ?>
302
-			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
303
-			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
304
-			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
381
+			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') {
382
+	print ' selected';
383
+}
384
+?>>MapQuest-OSM</option>
385
+			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') {
386
+	print ' selected';
387
+}
388
+?>>MapQuest-Aerial</option>
389
+			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') {
390
+	print ' selected';
391
+}
392
+?>>MapQuest-Hybrid</option>
305 393
 			    <?php
306 394
 					}
307 395
 			    ?>
308
-			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
309
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth</option>
396
+			    <option value="Yandex"<?php if ($MapType == 'Yandex') {
397
+	print ' selected';
398
+}
399
+?>>Yandex</option>
400
+			    <option value="offline"<?php if ($MapType == 'offline') {
401
+	print ' selected';
402
+}
403
+?>>Natural Earth</option>
310 404
 			    <?php
311 405
 				    }
312 406
 			    ?>
313 407
 			    <?php
314 408
 				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
315
-					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
316
-					else $MapBoxId = $_COOKIE['MapTypeId'];
409
+					if (!isset($_COOKIE['MapTypeId'])) {
410
+						$MapBoxId = 'default';
411
+					} else {
412
+						$MapBoxId = $_COOKIE['MapTypeId'];
413
+					}
317 414
 			    ?>
318
-			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') print ' selected'; ?>>Mapbox GL</option>
319
-			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
320
-			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
321
-			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
322
-			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option>
323
-			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option>
324
-			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option>
325
-			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option>
326
-			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option>
327
-			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option>
328
-			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option>
329
-			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
330
-			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
415
+			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') {
416
+	print ' selected';
417
+}
418
+?>>Mapbox GL</option>
419
+			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') {
420
+	print ' selected';
421
+}
422
+?>>Mapbox default</option>
423
+			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') {
424
+	print ' selected';
425
+}
426
+?>>Mapbox streets</option>
427
+			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') {
428
+	print ' selected';
429
+}
430
+?>>Mapbox light</option>
431
+			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') {
432
+	print ' selected';
433
+}
434
+?>>Mapbox dark</option>
435
+			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') {
436
+	print ' selected';
437
+}
438
+?>>Mapbox satellite</option>
439
+			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') {
440
+	print ' selected';
441
+}
442
+?>>Mapbox streets-satellite</option>
443
+			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') {
444
+	print ' selected';
445
+}
446
+?>>Mapbox streets-basic</option>
447
+			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') {
448
+	print ' selected';
449
+}
450
+?>>Mapbox comic</option>
451
+			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') {
452
+	print ' selected';
453
+}
454
+?>>Mapbox outdoors</option>
455
+			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') {
456
+	print ' selected';
457
+}
458
+?>>Mapbox pencil</option>
459
+			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') {
460
+	print ' selected';
461
+}
462
+?>>Mapbox pirates</option>
463
+			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') {
464
+	print ' selected';
465
+}
466
+?>>Mapbox emerald</option>
331 467
 			    <?php
332 468
 				    }
333 469
 			    ?>
334
-			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
470
+			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') {
471
+	print ' selected';
472
+}
473
+?>>OpenStreetMap</option>
335 474
 			    <?php
336 475
 				}
337 476
 			    ?>
@@ -342,10 +481,22 @@  discard block
 block discarded – undo
342 481
 ?>
343 482
 		    <li><?php echo _("Type of Terrain:"); ?>
344 483
 			<select  class="selectpicker" onchange="terrainType(this);">
345
-			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
346
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
347
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
348
-			    <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') print ' selected';?>>ArticDEM</option>
484
+			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
485
+	print ' selected';
486
+}
487
+?>>stk terrain</option>
488
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') {
489
+	print ' selected';
490
+}
491
+?>>ellipsoid</option>
492
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') {
493
+	print ' selected';
494
+}
495
+?>>vr terrain</option>
496
+			    <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') {
497
+	print ' selected';
498
+}
499
+?>>ArticDEM</option>
349 500
 			</select>
350 501
 		    </li>
351 502
 <?php
@@ -354,42 +505,84 @@  discard block
 block discarded – undo
354 505
 <?php
355 506
     if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
356 507
 ?>
357
-		    <li><div class="checkbox"><label><input type="checkbox" name="display2dbuildings" value="1" onclick="clickDisplay2DBuildings(this)" <?php if (isset($_COOKIE['Map2DBuildings']) && $_COOKIE['Map2DBuildings'] == 'true') print 'checked'; ?> ><?php echo _("Display 2.5D buidings on map"); ?></label></div></li>
508
+		    <li><div class="checkbox"><label><input type="checkbox" name="display2dbuildings" value="1" onclick="clickDisplay2DBuildings(this)" <?php if (isset($_COOKIE['Map2DBuildings']) && $_COOKIE['Map2DBuildings'] == 'true') {
509
+	print 'checked';
510
+}
511
+?> ><?php echo _("Display 2.5D buidings on map"); ?></label></div></li>
358 512
 
359 513
 <?php
360 514
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
361 515
 ?>
362
-		    <!--<li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>-->
363
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) print 'checked'; ?> ><?php echo _("Display flight path"); ?></label></div></li>
364
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
365
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightremainingroute" value="1" onclick="clickFlightRemainingRoute(this)" <?php if ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == 'true') || (!isset($_COOKIE['MapRemainingRoute']) && isset($globalMapRemainingRoute) && $globalMapRemainingRoute)) print 'checked'; ?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li>
366
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
516
+		    <!--<li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') {
517
+	print 'checked';
518
+}
519
+?> ><?php echo _("Display flight info as popup"); ?></label></div></li>-->
520
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) {
521
+	print 'checked';
522
+}
523
+?> ><?php echo _("Display flight path"); ?></label></div></li>
524
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)) {
525
+	print 'checked';
526
+}
527
+?> ><?php echo _("Display flight route on click"); ?></label></div></li>
528
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightremainingroute" value="1" onclick="clickFlightRemainingRoute(this)" <?php if ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == 'true') || (!isset($_COOKIE['MapRemainingRoute']) && isset($globalMapRemainingRoute) && $globalMapRemainingRoute)) {
529
+	print 'checked';
530
+}
531
+?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li>
532
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) {
533
+	print 'checked';
534
+}
535
+?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
367 536
 <?php
368 537
 	} elseif (!isset($globalTracker) || $globalTracker === TRUE) {
369 538
 ?>
370
-		    <li><div class="checkbox"><label><input type="checkbox" name="mapmatching" value="1" onclick="clickMapMatching(this)" <?php if ((isset($_COOKIE['mapmatching']) && $_COOKIE['mapmatching'] == 'true') || (!isset($_COOKIE['mapmatching']) && isset($globalMapMatching) && $globalMapMatching)) print 'checked'; ?> ><?php echo _("Enable map matching"); ?></label></div></li>
539
+		    <li><div class="checkbox"><label><input type="checkbox" name="mapmatching" value="1" onclick="clickMapMatching(this)" <?php if ((isset($_COOKIE['mapmatching']) && $_COOKIE['mapmatching'] == 'true') || (!isset($_COOKIE['mapmatching']) && isset($globalMapMatching) && $globalMapMatching)) {
540
+	print 'checked';
541
+}
542
+?> ><?php echo _("Enable map matching"); ?></label></div></li>
371 543
 <?php
372 544
 	}
373 545
 	if (isset($globalSatellite) && $globalSatellite === TRUE) {
374 546
 ?>
375
-		    <li><div class="checkbox"><label><input type="checkbox" name="satelliteestimation" value="1" onclick="clickSatelliteEstimation(this)" <?php if ((isset($_COOKIE['satelliteestimation']) && $_COOKIE['satelliteestimation'] == 'true') || (!isset($_COOKIE['satelliteestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['satelliteestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Satellites animate between updates"); ?></label></div></li>
547
+		    <li><div class="checkbox"><label><input type="checkbox" name="satelliteestimation" value="1" onclick="clickSatelliteEstimation(this)" <?php if ((isset($_COOKIE['satelliteestimation']) && $_COOKIE['satelliteestimation'] == 'true') || (!isset($_COOKIE['satelliteestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['satelliteestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) {
548
+	print 'checked';
549
+}
550
+?> ><?php echo _("Satellites animate between updates"); ?></label></div></li>
376 551
 <?php
377 552
 	}
378 553
     }
379 554
 ?>
380
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
381
-		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li>
382
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayweatherstation" value="1" onclick="clickDisplayWeatherStation(this)" <?php if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) print 'checked'; ?> ><?php echo _("Display weather station on map"); ?></label></div></li>
383
-		    <li><div class="checkbox"><label><input type="checkbox" name="displaylightning" value="1" onclick="clickDisplayLightning(this)" <?php if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) print 'checked'; ?> ><?php echo _("Display lightning on map"); ?></label></div></li>
555
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) {
556
+	print 'checked';
557
+}
558
+?> ><?php echo _("Display airports on map"); ?></label></div></li>
559
+		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) {
560
+	print 'checked';
561
+}
562
+?> ><?php echo _("Display ground station on map"); ?></label></div></li>
563
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayweatherstation" value="1" onclick="clickDisplayWeatherStation(this)" <?php if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) {
564
+	print 'checked';
565
+}
566
+?> ><?php echo _("Display weather station on map"); ?></label></div></li>
567
+		    <li><div class="checkbox"><label><input type="checkbox" name="displaylightning" value="1" onclick="clickDisplayLightning(this)" <?php if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) {
568
+	print 'checked';
569
+}
570
+?> ><?php echo _("Display lightning on map"); ?></label></div></li>
384 571
 <?php
385 572
 	if (isset($globalFires)) {
386 573
 ?>
387
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayfires" value="1" onclick="clickDisplayFires(this)" <?php if ((isset($_COOKIE['show_Fires']) && $_COOKIE['show_Fires'] == 'true') || (!isset($_COOKIE['show_Fires']) && (isset($globalMapFires) && $globalMapFires === TRUE))) print 'checked'; ?> ><?php echo _("Display fires on map"); ?></label></div></li>
574
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayfires" value="1" onclick="clickDisplayFires(this)" <?php if ((isset($_COOKIE['show_Fires']) && $_COOKIE['show_Fires'] == 'true') || (!isset($_COOKIE['show_Fires']) && (isset($globalMapFires) && $globalMapFires === TRUE))) {
575
+	print 'checked';
576
+}
577
+?> ><?php echo _("Display fires on map"); ?></label></div></li>
388 578
 <?php
389 579
 	}
390 580
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
391 581
 ?>
392
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
582
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) {
583
+	print 'checked';
584
+}
585
+?> ><?php echo _("Show mini-map"); ?></label></div></li>
393 586
 <?php
394 587
     }
395 588
     if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
@@ -402,17 +595,25 @@  discard block
 block discarded – undo
402 595
 			if (function_exists('array_column')) {
403 596
 			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
404 597
 		    ?>
405
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
598
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
599
+	print 'checked';
600
+}
601
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
406 602
 		    <?php
407 603
 			    }
408 604
 			} elseif (isset($globalSources)) {
409 605
 			    $dispolar = false;
410 606
 			    foreach ($globalSources as $testsource) {
411
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
607
+			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) {
608
+			        	$dispolar = true;
609
+			        }
412 610
 			    }
413 611
 			    if ($dispolar) {
414 612
 		    ?>
415
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
613
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
614
+	print 'checked';
615
+}
616
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
416 617
 		    <?php
417 618
 			    }
418 619
 		        }
@@ -425,12 +626,22 @@  discard block
 block discarded – undo
425 626
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
426 627
 		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
427 628
 		    ?>
428
-		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
629
+		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') {
630
+	print 'checked';
631
+}
632
+?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
429 633
 		    <?php 
430 634
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
431 635
 		    ?>
432 636
 		    <li><?php echo _("Aircraft icon color:"); ?>
433
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
637
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
638
+	print $_COOKIE['IconColor'];
639
+} elseif (isset($globalAircraftIconColor)) {
640
+	print $globalAircraftIconColor;
641
+} else {
642
+	print '1a3151';
643
+}
644
+?>">
434 645
 		    </li>
435 646
 		    <?php
436 647
 				}
@@ -442,7 +653,14 @@  discard block
 block discarded – undo
442 653
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
443 654
 		    ?>
444 655
 		    <li><?php echo _("Marine icon color:"); ?>
445
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
656
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
657
+	print $_COOKIE['MarineIconColor'];
658
+} elseif (isset($globalMarineIconColor)) {
659
+	print $globalMarineIconColor;
660
+} else {
661
+	print '1a3151';
662
+}
663
+?>">
446 664
 		    </li>
447 665
 		    <?php
448 666
 			    }
@@ -453,7 +671,14 @@  discard block
 block discarded – undo
453 671
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
454 672
 		    ?>
455 673
 		    <li><?php echo _("Tracker icon color:"); ?>
456
-			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print '1a3151'; ?>">
674
+			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) {
675
+	print $_COOKIE['TrackerIconColor'];
676
+} elseif (isset($globalTrackerIconColor)) {
677
+	print $globalTrackerIconColor;
678
+} else {
679
+	print '1a3151';
680
+}
681
+?>">
457 682
 		    </li>
458 683
 		    <?php
459 684
 			    }
@@ -464,8 +689,22 @@  discard block
 block discarded – undo
464 689
 		    ?>
465 690
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
466 691
 			<div class="range">
467
-			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
468
-			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output>
692
+			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) {
693
+	print $_COOKIE['AirportZoom'];
694
+} elseif (isset($globalAirportZoom)) {
695
+	print $globalAirportZoom;
696
+} else {
697
+	print '7';
698
+}
699
+?>">
700
+			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) {
701
+	print $_COOKIE['AirportZoom'];
702
+} elseif (isset($globalAirportZoom)) {
703
+	print $globalAirportZoom;
704
+} else {
705
+	print '7';
706
+}
707
+?></output>
469 708
 			</div>
470 709
 		    </li>
471 710
 		    <?php
@@ -477,10 +716,23 @@  discard block
 block discarded – undo
477 716
 <?php
478 717
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
479 718
 ?>
480
-		    <li><input type="checkbox" name="useliveries" value="1" onclick="useLiveries(this)" <?php if (isset($_COOKIE['UseLiveries']) && $_COOKIE['UseLiveries'] == 'true') print 'checked'; ?> ><?php echo _("Use airlines liveries"); ?></li>
481
-		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Aircraft color"); ?></li>
719
+		    <li><input type="checkbox" name="useliveries" value="1" onclick="useLiveries(this)" <?php if (isset($_COOKIE['UseLiveries']) && $_COOKIE['UseLiveries'] == 'true') {
720
+	print 'checked';
721
+}
722
+?> ><?php echo _("Use airlines liveries"); ?></li>
723
+		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') {
724
+	print 'checked';
725
+}
726
+?> ><?php echo _("Force Aircraft color"); ?></li>
482 727
 		    <li><?php echo _("Aircraft icon color:"); ?>
483
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print 'ff0000'; ?>">
728
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
729
+	print $_COOKIE['IconColor'];
730
+} elseif (isset($globalAircraftIconColor)) {
731
+	print $globalAircraftIconColor;
732
+} else {
733
+	print 'ff0000';
734
+}
735
+?>">
484 736
 		    </li>
485 737
 <?php
486 738
 	}
@@ -488,9 +740,19 @@  discard block
 block discarded – undo
488 740
 <?php
489 741
 	if (isset($globalMarine) && $globalMarine === TRUE) {
490 742
 ?>
491
-		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="MarineiconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Marine color"); ?></li>
743
+		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="MarineiconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') {
744
+	print 'checked';
745
+}
746
+?> ><?php echo _("Force Marine color"); ?></li>
492 747
 		    <li><?php echo _("Marine icon color:"); ?>
493
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print 'ff0000'; ?>">
748
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
749
+	print $_COOKIE['MarineIconColor'];
750
+} elseif (isset($globalMarineIconColor)) {
751
+	print $globalMarineIconColor;
752
+} else {
753
+	print 'ff0000';
754
+}
755
+?>">
494 756
 		    </li>
495 757
 <?php
496 758
 	}
@@ -498,9 +760,19 @@  discard block
 block discarded – undo
498 760
 <?php
499 761
 	if (isset($globalTracker) && $globalTracker === TRUE) {
500 762
 ?>
501
-		    <li><input type="checkbox" name="trackercolorforce" value="1" onclick="TrackericonColorForce(this)" <?php if (isset($_COOKIE['TrackerIconColorForce']) && $_COOKIE['TrackerIconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Tracker color"); ?></li>
763
+		    <li><input type="checkbox" name="trackercolorforce" value="1" onclick="TrackericonColorForce(this)" <?php if (isset($_COOKIE['TrackerIconColorForce']) && $_COOKIE['TrackerIconColorForce'] == 'true') {
764
+	print 'checked';
765
+}
766
+?> ><?php echo _("Force Tracker color"); ?></li>
502 767
 		    <li><?php echo _("Tracker icon color:"); ?>
503
-			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print 'ff0000'; ?>">
768
+			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) {
769
+	print $_COOKIE['TrackerIconColor'];
770
+} elseif (isset($globalTrackerIconColor)) {
771
+	print $globalTrackerIconColor;
772
+} else {
773
+	print 'ff0000';
774
+}
775
+?>">
504 776
 		    </li>
505 777
 <?php
506 778
 	}
@@ -508,22 +780,46 @@  discard block
 block discarded – undo
508 780
 ?>
509 781
 		    <li><?php echo _("Distance unit:"); ?>
510 782
 			<select class="selectpicker" onchange="unitdistance(this);">
511
-			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
512
-			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option>
513
-			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option>
783
+			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
784
+	echo ' selected';
785
+}
786
+?>>km</option>
787
+			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
788
+	echo ' selected';
789
+}
790
+?>>nm</option>
791
+			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
792
+	echo ' selected';
793
+}
794
+?>>mi</option>
514 795
 		        </select>
515 796
 		    </li>
516 797
 		    <li><?php echo _("Altitude unit:"); ?>
517 798
 			<select class="selectpicker" onchange="unitaltitude(this);">
518
-			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option>
519
-			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option>
799
+			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) {
800
+	echo ' selected';
801
+}
802
+?>>m</option>
803
+			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
804
+	echo ' selected';
805
+}
806
+?>>feet</option>
520 807
 		        </select>
521 808
 		    </li>
522 809
 		    <li><?php echo _("Speed unit:"); ?>
523 810
 			<select class="selectpicker" onchange="unitspeed(this);">
524
-			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) echo ' selected'; ?>>km/h</option>
525
-			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option>
526
-			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option>
811
+			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) {
812
+	echo ' selected';
813
+}
814
+?>>km/h</option>
815
+			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
816
+	echo ' selected';
817
+}
818
+?>>mph</option>
819
+			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
820
+	echo ' selected';
821
+}
822
+?>>knots</option>
527 823
 		        </select>
528 824
 		    </li>
529 825
 
@@ -541,9 +837,18 @@  discard block
 block discarded – undo
541 837
 		    <?php
542 838
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
543 839
 		    ?>
544
-			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
545
-			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
546
-			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
840
+			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) {
841
+	print 'checked';
842
+}
843
+?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
844
+			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) {
845
+	print 'checked';
846
+}
847
+?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
848
+			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) {
849
+	print 'checked';
850
+}
851
+?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
547 852
 		    <?php
548 853
 			}
549 854
 		    ?>
@@ -551,10 +856,16 @@  discard block
 block discarded – undo
551 856
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
552 857
 		    ?>
553 858
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
554
-			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
859
+			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) {
860
+	print 'checked';
861
+}
862
+?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
555 863
 			<?php } ?>
556 864
 			<?php if (isset($globalAPRS) && $globalAPRS) { ?>
557
-			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) print 'checked'; ?> ><?php echo _("Display APRS data"); ?></label></div></li>
865
+			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) {
866
+	print 'checked';
867
+}
868
+?> ><?php echo _("Display APRS data"); ?></label></div></li>
558 869
 			<?php } ?>
559 870
 		    <?php
560 871
 			}
@@ -571,7 +882,9 @@  discard block
 block discarded – undo
571 882
 				}
572 883
 				foreach($allairlinenames as $airline) {
573 884
 					$airline_name = $airline['airline_name'];
574
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
885
+					if (strlen($airline_name) > 30) {
886
+						$airline_name = substr($airline_name,0,30).'...';
887
+					}
575 888
 					if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) {
576 889
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
577 890
 					} else {
@@ -589,7 +902,10 @@  discard block
 block discarded – undo
589 902
 		    <li><?php echo _("Display alliance:"); ?>
590 903
 		    <br/>
591 904
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
592
-			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
905
+			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') {
906
+	echo ' selected';
907
+}
908
+?>><?php echo _("All"); ?></option>
593 909
 			    <?php
594 910
 				foreach($allalliancenames as $alliance) {
595 911
 					$alliance_name = $alliance['alliance'];
@@ -648,10 +964,22 @@  discard block
 block discarded – undo
648 964
 		    ?>
649 965
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
650 966
 			<select class="selectpicker" onchange="airlinestype(this);">
651
-			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
652
-			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option>
653
-			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option>
654
-			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option>
967
+			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') {
968
+	echo ' selected';
969
+}
970
+?>><?php echo _("All"); ?></option>
971
+			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') {
972
+	echo ' selected';
973
+}
974
+?>><?php echo _("Passenger"); ?></option>
975
+			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') {
976
+	echo ' selected';
977
+}
978
+?>><?php echo _("Cargo"); ?></option>
979
+			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') {
980
+	echo ' selected';
981
+}
982
+?>><?php echo _("Military"); ?></option>
655 983
 			</select>
656 984
 		    </li>
657 985
 		    <?php
@@ -665,14 +993,20 @@  discard block
 block discarded – undo
665 993
 		    ?>
666 994
 		    <li>
667 995
 			<?php echo _("Display vessels with MMSI:"); ?>
668
-			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) print $_COOKIE['filter_mmsi']; ?>" />
996
+			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) {
997
+	print $_COOKIE['filter_mmsi'];
998
+}
999
+?>" />
669 1000
 		    </li>
670 1001
 		    <?php
671 1002
 			}
672 1003
 		    ?>
673 1004
 		    <li>
674 1005
 			<?php echo _("Display with ident:"); ?>
675
-			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
1006
+			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) {
1007
+	print $_COOKIE['filter_ident'];
1008
+}
1009
+?>" />
676 1010
 		    </li>
677 1011
 		</ul>
678 1012
 	    </form>
@@ -688,7 +1022,10 @@  discard block
 block discarded – undo
688 1022
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
689 1023
 	    <form>
690 1024
 		<ul>
691
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if ((isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') || !isset($_COOKIE['displayiss'])) print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
1025
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if ((isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') || !isset($_COOKIE['displayiss'])) {
1026
+	print 'checked';
1027
+}
1028
+?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
692 1029
 		    <li><?php echo _("Type:"); ?>
693 1030
 			<select class="selectpicker" multiple onchange="sattypes(this);">
694 1031
 			    <?php
@@ -696,25 +1033,45 @@  discard block
 block discarded – undo
696 1033
 				$types = $Satellite->get_tle_types();
697 1034
 				foreach ($types as $type) {
698 1035
 					$type_name = $type['tle_type'];
699
-					if ($type_name == 'musson') $type_name = 'Russian LEO Navigation';
700
-					else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System';
701
-					else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System';
702
-					else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational';
703
-					else if ($type_name == 'gps-ops') $type_name = 'GPS Operational';
704
-					else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System';
705
-					else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System';
706
-					else if ($type_name == 'sarsat') $type_name = 'Search & Rescue';
707
-					else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring';
708
-					else if ($type_name == 'resource') $type_name = 'Earth Resources';
709
-					else if ($type_name == 'stations') $type_name = 'Space Stations';
710
-					else if ($type_name == 'geo') $type_name = 'Geostationary';
711
-					else if ($type_name == 'amateur') $type_name = 'Amateur Radio';
712
-					else if ($type_name == 'x-comm') $type_name = 'Experimental';
713
-					else if ($type_name == 'other-comm') $type_name = 'Other Comm';
714
-					else if ($type_name == 'science') $type_name = 'Space & Earth Science';
715
-					else if ($type_name == 'military') $type_name = 'Miscellaneous Military';
716
-					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
717
-					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
1036
+					if ($type_name == 'musson') {
1037
+						$type_name = 'Russian LEO Navigation';
1038
+					} else if ($type_name == 'nnss') {
1039
+						$type_name = 'Navi Navigation Satellite System';
1040
+					} else if ($type_name == 'sbas') {
1041
+						$type_name = 'Satellite-Based Augmentation System';
1042
+					} else if ($type_name == 'glo-ops') {
1043
+						$type_name = 'Glonass Operational';
1044
+					} else if ($type_name == 'gps-ops') {
1045
+						$type_name = 'GPS Operational';
1046
+					} else if ($type_name == 'argos') {
1047
+						$type_name = 'ARGOS Data Collection System';
1048
+					} else if ($type_name == 'tdrss') {
1049
+						$type_name = 'Tracking and Data Relay Satellite System';
1050
+					} else if ($type_name == 'sarsat') {
1051
+						$type_name = 'Search & Rescue';
1052
+					} else if ($type_name == 'dmc') {
1053
+						$type_name = 'Disaster Monitoring';
1054
+					} else if ($type_name == 'resource') {
1055
+						$type_name = 'Earth Resources';
1056
+					} else if ($type_name == 'stations') {
1057
+						$type_name = 'Space Stations';
1058
+					} else if ($type_name == 'geo') {
1059
+						$type_name = 'Geostationary';
1060
+					} else if ($type_name == 'amateur') {
1061
+						$type_name = 'Amateur Radio';
1062
+					} else if ($type_name == 'x-comm') {
1063
+						$type_name = 'Experimental';
1064
+					} else if ($type_name == 'other-comm') {
1065
+						$type_name = 'Other Comm';
1066
+					} else if ($type_name == 'science') {
1067
+						$type_name = 'Space & Earth Science';
1068
+					} else if ($type_name == 'military') {
1069
+						$type_name = 'Miscellaneous Military';
1070
+					} else if ($type_name == 'radar') {
1071
+						$type_name = 'Radar Calibration';
1072
+					} else if ($type_name == 'tle-new') {
1073
+						$type_name = 'Last 30 days launches';
1074
+					}
718 1075
 					
719 1076
 					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
720 1077
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +592 added lines, -159 removed lines patch added patch discarded remove patch
@@ -4,11 +4,19 @@  discard block
 block discarded – undo
4 4
 if (isset($_SESSION['error'])) {
5 5
 	header('Content-Encoding: none;');
6 6
 	echo 'Error : '.$_SESSION['error'].' - Resetting install... You need to fix the problem and run install again.';
7
-	if (isset($_SESSION['error'])) unset($_SESSION['error']);
8
-	if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']);
9
-	if (isset($_SESSION['next'])) unset($_SESSION['next']);
10
-	if (isset($_SESSION['install'])) unset($_SESSION['install']);
11
-}
7
+	if (isset($_SESSION['error'])) {
8
+		unset($_SESSION['error']);
9
+	}
10
+	if (isset($_SESSION['errorlst'])) {
11
+		unset($_SESSION['errorlst']);
12
+	}
13
+	if (isset($_SESSION['next'])) {
14
+		unset($_SESSION['next']);
15
+	}
16
+	if (isset($_SESSION['install'])) {
17
+		unset($_SESSION['install']);
18
+	}
19
+	}
12 20
 /*
13 21
 if (isset($_SESSION['errorlst'])) {
14 22
 	header('Content-Encoding: none;');
@@ -159,31 +167,49 @@  discard block
 block discarded – undo
159 167
 			</div>
160 168
 			<p>
161 169
 				<label for="dbhost">Database hostname</label>
162
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
170
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
171
+	print $globalDBhost;
172
+}
173
+?>" />
163 174
 			</p>
164 175
 			<p>
165 176
 				<label for="dbport">Database port</label>
166
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
177
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
178
+	print $globalDBport;
179
+}
180
+?>" />
167 181
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
168 182
 			</p>
169 183
 			<p>
170 184
 				<label for="dbname">Database name</label>
171
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
185
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
186
+	print $globalDBname;
187
+}
188
+?>" />
172 189
 			</p>
173 190
 			<p>
174 191
 				<label for="dbuser">Database user</label>
175
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
192
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
193
+	print $globalDBuser;
194
+}
195
+?>" />
176 196
 			</p>
177 197
 			<p>
178 198
 				<label for="dbuserpass">Database user password</label>
179
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
199
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
200
+	print $globalDBpass;
201
+}
202
+?>" />
180 203
 			</p>
181 204
 		</fieldset>
182 205
 		<fieldset id="site">
183 206
 			<legend>Site configuration</legend>
184 207
 			<p>
185 208
 				<label for="sitename">Site name</label>
186
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
209
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
210
+	print $globalName;
211
+}
212
+?>" />
187 213
 			</p>
188 214
 			<p>
189 215
 				<label for="siteurl">Site directory</label>
@@ -196,18 +222,27 @@  discard block
 block discarded – undo
196 222
 					}
197 223
 				    }
198 224
 				?>
199
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
225
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
226
+	print $globalURL;
227
+}
228
+?>" />
200 229
 				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
201 230
 				<p class="help-block">Can be empty</p>
202 231
 			</p>
203 232
 			<p>
204 233
 				<label for="timezone">Timezone</label>
205
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
234
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
235
+	print $globalTimezone;
236
+}
237
+?>" />
206 238
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
207 239
 			</p>
208 240
 			<p>
209 241
 				<label for="language">Language</label>
210
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
242
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
243
+	print $globalLanguage;
244
+}
245
+?>" />
211 246
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
212 247
 			</p>
213 248
 		</fieldset>
@@ -227,11 +262,17 @@  discard block
 block discarded – undo
227 262
 			<div id="mapbox_data">
228 263
 				<p>
229 264
 					<label for="mapboxid">Mapbox id</label>
230
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
265
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
266
+	print $globalMapboxId;
267
+}
268
+?>" />
231 269
 				</p>
232 270
 				<p>
233 271
 					<label for="mapboxtoken">Mapbox token</label>
234
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
272
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
273
+	print $globalMapboxToken;
274
+}
275
+?>" />
235 276
 				</p>
236 277
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
237 278
 			</div>
@@ -239,7 +280,10 @@  discard block
 block discarded – undo
239 280
 			<div id="google_data">
240 281
 				<p>
241 282
 					<label for="googlekey">Google API key</label>
242
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
283
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
284
+	print $globalGoogleAPIKey;
285
+}
286
+?>" />
243 287
 					<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>
244 288
 				</p>
245 289
 			</div>
@@ -247,7 +291,10 @@  discard block
 block discarded – undo
247 291
 			<div id="bing_data">
248 292
 				<p>
249 293
 					<label for="bingkey">Bing Map key</label>
250
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
294
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
295
+	print $globalBingMapKey;
296
+}
297
+?>" />
251 298
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
252 299
 				</p>
253 300
 			</div>
@@ -255,7 +302,10 @@  discard block
 block discarded – undo
255 302
 			<div id="mapquest_data">
256 303
 				<p>
257 304
 					<label for="mapquestkey">MapQuest key</label>
258
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
305
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
306
+	print $globalMapQuestKey;
307
+}
308
+?>" />
259 309
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
260 310
 				</p>
261 311
 			</div>
@@ -263,11 +313,17 @@  discard block
 block discarded – undo
263 313
 			<div id="here_data">
264 314
 				<p>
265 315
 					<label for="hereappid">Here App_Id</label>
266
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
316
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
317
+	print $globalHereappId;
318
+}
319
+?>" />
267 320
 				</p>
268 321
 				<p>
269 322
 					<label for="hereappcode">Here App_Code</label>
270
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
323
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
324
+	print $globalHereappCode;
325
+}
326
+?>" />
271 327
 				</p>
272 328
 				<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>
273 329
 			</div>
@@ -275,7 +331,10 @@  discard block
 block discarded – undo
275 331
 			<div id="openweathermap_data">
276 332
 				<p>
277 333
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
278
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
334
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
335
+	print $globalOpenWeatherMapKey;
336
+}
337
+?>" />
279 338
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
280 339
 				</p>
281 340
 			</div>
@@ -304,42 +363,86 @@  discard block
 block discarded – undo
304 363
 			<legend>Coverage area</legend>
305 364
 			<p>
306 365
 				<label for="latitudemax">The maximum latitude (north)</label>
307
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
366
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
367
+	print $globalLatitudeMax;
368
+}
369
+?>" />
308 370
 			</p>
309 371
 			<p>
310 372
 				<label for="latitudemin">The minimum latitude (south)</label>
311
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
373
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
374
+	print $globalLatitudeMin;
375
+}
376
+?>" />
312 377
 			</p>
313 378
 			<p>
314 379
 				<label for="longitudemax">The maximum longitude (west)</label>
315
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
380
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
381
+	print $globalLongitudeMax;
382
+}
383
+?>" />
316 384
 			</p>
317 385
 			<p>
318 386
 				<label for="longitudemin">The minimum longitude (east)</label>
319
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
387
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
388
+	print $globalLongitudeMin;
389
+}
390
+?>" />
320 391
 			</p>
321 392
 			<p>
322 393
 				<label for="latitudecenter">The latitude center</label>
323
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
394
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
395
+	print $globalCenterLatitude;
396
+}
397
+?>" />
324 398
 			</p>
325 399
 			<p>
326 400
 				<label for="longitudecenter">The longitude center</label>
327
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
401
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
402
+	print $globalCenterLongitude;
403
+}
404
+?>" />
328 405
 			</p>
329 406
 			<p>
330 407
 				<label for="livezoom">Default Zoom on live map</label>
331
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
408
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
409
+	print $globalLiveZoom;
410
+} else {
411
+	print '9';
412
+}
413
+?>" />
332 414
 			</p>
333 415
 			<p>
334 416
 				<label for="squawk_country">Country for squawk usage</label>
335 417
 				<select name="squawk_country" id="squawk_country">
336
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
337
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
338
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
339
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
340
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
341
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
342
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
418
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
419
+	print ' selected ';
420
+}
421
+?>>UK</option>
422
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
423
+	print ' selected ';
424
+}
425
+?>>NZ</option>
426
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
427
+	print ' selected ';
428
+}
429
+?>>US</option>
430
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
431
+	print ' selected ';
432
+}
433
+?>>AU</option>
434
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
435
+	print ' selected ';
436
+}
437
+?>>NL</option>
438
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
439
+	print ' selected ';
440
+}
441
+?>>FR</option>
442
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
443
+	print ' selected ';
444
+}
445
+?>>TR</option>
343 446
 				</select>
344 447
 			</p>
345 448
 		</fieldset>
@@ -348,15 +451,24 @@  discard block
 block discarded – undo
348 451
 			<p><i>Only put in DB flights that are inside a circle</i></p>
349 452
 			<p>
350 453
 				<label for="latitude">Center latitude</label>
351
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
454
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
455
+	echo $globalDistanceIgnore['latitude'];
456
+}
457
+?>" />
352 458
 			</p>
353 459
 			<p>
354 460
 				<label for="longitude">Center longitude</label>
355
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
461
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
462
+	echo $globalDistanceIgnore['longitude'];
463
+}
464
+?>" />
356 465
 			</p>
357 466
 			<p>
358 467
 				<label for="Distance">Distance (in km)</label>
359
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
468
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
469
+	echo $globalDistanceIgnore['distance'];
470
+}
471
+?>" />
360 472
 			</p>
361 473
 		</fieldset>
362 474
 		<fieldset id="sourceloc">
@@ -472,11 +584,17 @@  discard block
 block discarded – undo
472 584
 			<div id="flightaware_data">
473 585
 				<p>
474 586
 					<label for="flightawareusername">FlightAware username</label>
475
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
587
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
588
+	print $globalFlightAwareUsername;
589
+}
590
+?>" />
476 591
 				</p>
477 592
 				<p>
478 593
 					<label for="flightawarepassword">FlightAware password/API key</label>
479
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
594
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
595
+	print $globalFlightAwarePassword;
596
+}
597
+?>" />
480 598
 				</p>
481 599
 			</div>
482 600
 -->
@@ -518,7 +636,10 @@  discard block
 block discarded – undo
518 636
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
519 637
 								?>
520 638
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
521
-								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
639
+								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) {
640
+	print $source['port'];
641
+}
642
+?>" /></td>
522 643
 								<?php
523 644
 								    } else {
524 645
 									$hostport = explode(':',$source['host']);
@@ -537,35 +658,110 @@  discard block
 block discarded – undo
537 658
 								?>
538 659
 								<td>
539 660
 									<select name="format[]" id="format">
540
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
541
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
542
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
543
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
544
-										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option>
545
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
546
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
547
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
548
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
549
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
550
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
551
-										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option>
552
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
553
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
554
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
555
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
556
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
557
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
558
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
559
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
560
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
561
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
661
+										<option value="auto" <?php if (!isset($source['format'])) {
662
+	print 'selected';
663
+}
664
+?>>Auto</option>
665
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
666
+	print 'selected';
667
+}
668
+?>>SBS</option>
669
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
670
+	print 'selected';
671
+}
672
+?>>TSV</option>
673
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
674
+	print 'selected';
675
+}
676
+?>>Raw</option>
677
+										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') {
678
+	print 'selected';
679
+}
680
+?>>Dump1090 aircraft.json</option>
681
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
682
+	print 'selected';
683
+}
684
+?>>APRS</option>
685
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
686
+	print 'selected';
687
+}
688
+?>>Radarcape deltadb.txt</option>
689
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
690
+	print 'selected';
691
+}
692
+?>>Vatsim</option>
693
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
694
+	print 'selected';
695
+}
696
+?>>Virtual Radar Server AircraftList.json</option>
697
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
698
+	print 'selected';
699
+}
700
+?>>Virtual Radar Server TCP</option>
701
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
702
+	print 'selected';
703
+}
704
+?>>phpVMS</option>
705
+										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
706
+	print 'selected';
707
+}
708
+?>>Virtual Airline Operations System (VAOS)</option>
709
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
710
+	print 'selected';
711
+}
712
+?>>Virtual Airlines Manager</option>
713
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
714
+	print 'selected';
715
+}
716
+?>>IVAO</option>
717
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
718
+	print 'selected';
719
+}
720
+?>>FlightGear Multiplayer</option>
721
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
722
+	print 'selected';
723
+}
724
+?>>FlightGear Singleplayer</option>
725
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
726
+	print 'selected';
727
+}
728
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
729
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
730
+	print 'selected';
731
+}
732
+?>>ACARS SBS-3 over TCP</option>
733
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
734
+	print 'selected';
735
+}
736
+?>>NMEA AIS over TCP</option>
737
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
738
+	print 'selected';
739
+}
740
+?>>AirWhere website</option>
741
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
742
+	print 'selected';
743
+}
744
+?>>HidnSeek Callback</option>
745
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
746
+	print 'selected';
747
+}
748
+?>>Blitzortung</option>
562 749
 									</select>
563 750
 								</td>
564 751
 								<td>
565
-									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
752
+									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
753
+	print $source['name'];
754
+}
755
+?>" />
566 756
 								</td>
567
-								<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>
568
-								<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>
757
+								<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']) {
758
+	print 'checked';
759
+}
760
+?> /></td>
761
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
762
+	print 'checked';
763
+}
764
+?> /></td>
569 765
 								<td>
570 766
 									<select name="timezones[]" id="timezones">
571 767
 								<?php
@@ -575,7 +771,9 @@  discard block
 block discarded – undo
575 771
 											print '<option selected>'.$timezones.'</option>';
576 772
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
577 773
 											print '<option selected>'.$timezones.'</option>';
578
-										} else print '<option>'.$timezones.'</option>';
774
+										} else {
775
+											print '<option>'.$timezones.'</option>';
776
+										}
579 777
 									}
580 778
 								?>
581 779
 									</select>
@@ -627,7 +825,9 @@  discard block
 block discarded – undo
627 825
 									foreach($timezonelist as $timezones){
628 826
 										if ($timezones == 'UTC') {
629 827
 											print '<option selected>'.$timezones.'</option>';
630
-										} else print '<option>'.$timezones.'</option>';
828
+										} else {
829
+											print '<option>'.$timezones.'</option>';
830
+										}
631 831
 									}
632 832
 								?>
633 833
 									</select>
@@ -652,11 +852,17 @@  discard block
 block discarded – undo
652 852
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
653 853
 					<p>
654 854
 						<label for="acarshost">ACARS UDP host</label>
655
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
855
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
856
+	print $globalACARSHost;
857
+}
858
+?>" />
656 859
 					</p>
657 860
 					<p>
658 861
 						<label for="acarsport">ACARS UDP port</label>
659
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
862
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
863
+	print $globalACARSPort;
864
+}
865
+?>" />
660 866
 					</p>
661 867
 				</fieldset>
662 868
 			</div>
@@ -682,17 +888,38 @@  discard block
 block discarded – undo
682 888
 				    <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td>
683 889
 				    <td>
684 890
 					<select name="newslang[]">
685
-					    <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option>
686
-					    <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option>
891
+					    <option value="en"<?php if ($lng == 'en') {
892
+	print ' selected';
893
+}
894
+?>>English</option>
895
+					    <option value="fr"<?php if ($lng == 'fr') {
896
+	print ' selected';
897
+}
898
+?>>French</option>
687 899
 					</select>
688 900
 				    </td>
689 901
 				    <td>
690 902
 					<select name="newstype[]">
691
-					    <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option>
692
-					    <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option>
693
-					    <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option>
694
-					    <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option>
695
-					    <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option>
903
+					    <option value="global"<?php if ($type == 'global') {
904
+	print ' selected';
905
+}
906
+?>>Global</option>
907
+					    <option value="aircraft"<?php if ($type == 'aircraft') {
908
+	print ' selected';
909
+}
910
+?>>Aircraft</option>
911
+					    <option value="marine"<?php if ($type == 'marine') {
912
+	print ' selected';
913
+}
914
+?>>Marine</option>
915
+					    <option value="tracker"<?php if ($type == 'tracker') {
916
+	print ' selected';
917
+}
918
+?>>Tracker</option>
919
+					    <option value="satellite"<?php if ($type == 'Satellite') {
920
+	print ' selected';
921
+}
922
+?>>Satellite</option>
696 923
 					</select>
697 924
 				    </td>
698 925
 				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
@@ -825,13 +1052,19 @@  discard block
 block discarded – undo
825 1052
 			<div id="schedules_options">
826 1053
 				<p>
827 1054
 					<label for="britishairways">British Airways API Key</label>
828
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
1055
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
1056
+	print $globalBritishAirwaysKey;
1057
+}
1058
+?>" />
829 1059
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
830 1060
 				</p>
831 1061
 				<!--
832 1062
 				<p>
833 1063
 					<label for="transavia">Transavia Test API Consumer Key</label>
834
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
1064
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
1065
+	print $globalTransaviaKey;
1066
+}
1067
+?>" />
835 1068
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
836 1069
 				</p>
837 1070
 				-->
@@ -840,10 +1073,16 @@  discard block
 block discarded – undo
840 1073
 						<b>Lufthansa API Key</b>
841 1074
 						<p>
842 1075
 							<label for="lufthansakey">Key</label>
843
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
1076
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
1077
+	print $globalLufthansaKey['key'];
1078
+}
1079
+?>" />
844 1080
 						</p><p>
845 1081
 							<label for="lufthansasecret">Secret</label>
846
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
1082
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
1083
+	print $globalLufthansaKey['secret'];
1084
+}
1085
+?>" />
847 1086
 						</p>
848 1087
 					</div>
849 1088
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -853,11 +1092,17 @@  discard block
 block discarded – undo
853 1092
 						<b>FlightAware API Key</b>
854 1093
 						<p>
855 1094
 							<label for="flightawareusername">Username</label>
856
-							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
1095
+							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
1096
+	print $globalFlightAwareUsername;
1097
+}
1098
+?>" />
857 1099
 						</p>
858 1100
 						<p>
859 1101
 							<label for="flightawarepassword">API key</label>
860
-							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
1102
+							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
1103
+	print $globalFlightAwarePassword;
1104
+}
1105
+?>" />
861 1106
 						</p>
862 1107
 					</div>
863 1108
 					<p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p>
@@ -874,10 +1119,22 @@  discard block
 block discarded – undo
874 1119
 				<p>
875 1120
 					<label for="mapmatchingsource">Map Matching source</label>
876 1121
 					<select name="mapmatchingsource" id="mapmatchingsource">
877
-						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option>
878
-						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option>
879
-						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') print 'selected="selected" '; ?>>OSMR</option>
880
-						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option>
1122
+						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) {
1123
+	print 'selected="selected" ';
1124
+}
1125
+?>>FlightAirMap Map Matching</option>
1126
+						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') {
1127
+	print 'selected="selected" ';
1128
+}
1129
+?>>GraphHopper</option>
1130
+						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') {
1131
+	print 'selected="selected" ';
1132
+}
1133
+?>>OSMR</option>
1134
+						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') {
1135
+	print 'selected="selected" ';
1136
+}
1137
+?>>Mapbox</option>
881 1138
 					</select>
882 1139
 					<p class="help-block">Mapbox need the API Key defined in map section.</p>
883 1140
 					<p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p>
@@ -885,7 +1142,10 @@  discard block
 block discarded – undo
885 1142
 				<br />
886 1143
 				<p>
887 1144
 					<label for="graphhopper">GraphHopper API Key</label>
888
-					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" />
1145
+					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) {
1146
+	print $globalGraphHopperKey;
1147
+}
1148
+?>" />
889 1149
 					<p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p>
890 1150
 				</p>
891 1151
 			</div>
@@ -903,7 +1163,10 @@  discard block
 block discarded – undo
903 1163
 			</p>
904 1164
 			<p>
905 1165
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
906
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
1166
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
1167
+	print $globalNOTAMSource;
1168
+}
1169
+?>" />
907 1170
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
908 1171
 			</p>
909 1172
 			<br />
@@ -919,14 +1182,20 @@  discard block
 block discarded – undo
919 1182
 			<div id="metarsrc">
920 1183
 				<p>
921 1184
 					<label for="metarsource">URL of your METAR source</label>
922
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
1185
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
1186
+	print $globalMETARurl;
1187
+}
1188
+?>" />
923 1189
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
924 1190
 				</p>
925 1191
 			</div>
926 1192
 			<br />
927 1193
 			<p>
928 1194
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
929
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
1195
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
1196
+	print $globalBitlyAccessToken;
1197
+}
1198
+?>" />
930 1199
 			</p>
931 1200
 			<br />
932 1201
 			<p>
@@ -942,11 +1211,26 @@  discard block
 block discarded – undo
942 1211
 			<p>
943 1212
 				<label for="geoid_source">Geoid Source</label>
944 1213
 				<select name="geoid_source" id="geoid_source">
945
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
946
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
947
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
948
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
949
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
1214
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
1215
+	print ' selected="selected"';
1216
+}
1217
+?>>EGM96 15' (2.1MB)</option>
1218
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
1219
+	print ' selected="selected"';
1220
+}
1221
+?>>EGM96 5' (19MB)</option>
1222
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
1223
+	print ' selected="selected"';
1224
+}
1225
+?>>EGM2008 5' (19MB)</option>
1226
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
1227
+	print ' selected="selected"';
1228
+}
1229
+?>>EGM2008 2.5' (75MB)</option>
1230
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
1231
+	print ' selected="selected"';
1232
+}
1233
+?>>EGM2008 1' (470MB)</option>
950 1234
 				</select>
951 1235
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
952 1236
 			</p>
@@ -968,7 +1252,12 @@  discard block
 block discarded – undo
968 1252
 			</p>
969 1253
 			<p>
970 1254
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
971
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1255
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
1256
+	print $globalArchiveMonths;
1257
+} else {
1258
+	echo '1';
1259
+}
1260
+?>" />
972 1261
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
973 1262
 			</p>
974 1263
 			<p>
@@ -978,12 +1267,22 @@  discard block
 block discarded – undo
978 1267
 			</p>
979 1268
 			<p>
980 1269
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
981
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1270
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1271
+	print $globalArchiveKeepMonths;
1272
+} else {
1273
+	echo '1';
1274
+}
1275
+?>" />
982 1276
 				<p class="help-block">0 to disable</p>
983 1277
 			</p>
984 1278
 			<p>
985 1279
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
986
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1280
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1281
+	print $globalArchiveKeepTrackMonths;
1282
+} else {
1283
+	echo '1';
1284
+}
1285
+?>" />
987 1286
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
988 1287
 			</p>
989 1288
 			<br />
@@ -993,7 +1292,12 @@  discard block
 block discarded – undo
993 1292
 				<p class="help-block">Uncheck if the script is running as cron job. You should always run it as daemon when it's possible.</p>
994 1293
 				<div id="cronends"> 
995 1294
 					<label for="cronend">Run script for xx seconds</label>
996
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1295
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1296
+	print $globalCronEnd;
1297
+} else {
1298
+	print '0';
1299
+}
1300
+?>" />
997 1301
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
998 1302
 				</div>
999 1303
 			</p>
@@ -1046,20 +1350,40 @@  discard block
 block discarded – undo
1046 1350
 			<br />
1047 1351
 			<p>
1048 1352
 				<label for="refresh">Show flights detected since xxx seconds</label>
1049
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1353
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1354
+	echo $globalLiveInterval;
1355
+} else {
1356
+	echo '200';
1357
+}
1358
+?>" />
1050 1359
 			</p>
1051 1360
 			<p>
1052 1361
 				<label for="maprefresh">Live map refresh (in seconds)</label>
1053
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1362
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1363
+	echo $globalMapRefresh;
1364
+} else {
1365
+	echo '30';
1366
+}
1367
+?>" />
1054 1368
 			</p>
1055 1369
 			<p>
1056 1370
 				<label for="mapidle">Map idle timeout (in minutes)</label>
1057
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1371
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1372
+	echo $globalMapIdleTimeout;
1373
+} else {
1374
+	echo '30';
1375
+}
1376
+?>" />
1058 1377
 				<p class="help-block">0 to disable</p>
1059 1378
 			</p>
1060 1379
 			<p>
1061 1380
 				<label for="minfetch">HTTP/file source fetch every xxx seconds</label>
1062
-				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" />
1381
+				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) {
1382
+	echo $globalMinFetch;
1383
+} else {
1384
+	echo '20';
1385
+}
1386
+?>" />
1063 1387
 			</p>
1064 1388
 			<p>
1065 1389
 				<label for="bbox">Only display flights that we can see on screen (bounding box)</label>
@@ -1073,12 +1397,20 @@  discard block
 block discarded – undo
1073 1397
 			<br />
1074 1398
 			<p>
1075 1399
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
1076
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1400
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1401
+	echo $globalClosestMinDist;
1402
+} else {
1403
+	echo '50';
1404
+}
1405
+?>" />
1077 1406
 			</p>
1078 1407
 			<br />
1079 1408
 			<p>
1080 1409
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1081
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1410
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1411
+	echo $globalAircraftSize;
1412
+}
1413
+?>" />
1082 1414
 			</p>
1083 1415
 			<br />
1084 1416
 			<p>
@@ -1097,7 +1429,12 @@  discard block
 block discarded – undo
1097 1429
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
1098 1430
 			?>
1099 1431
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1100
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1432
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1433
+	echo $globalAircraftIconColor;
1434
+} else {
1435
+	echo '1a3151';
1436
+}
1437
+?>" />
1101 1438
 			<?php
1102 1439
 				if (!is_writable('../cache')) {
1103 1440
 			?>
@@ -1115,14 +1452,27 @@  discard block
 block discarded – undo
1115 1452
 			<p>
1116 1453
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
1117 1454
 				<div class="range">
1118
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
1119
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1455
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1456
+	echo $globalAirportZoom;
1457
+} else {
1458
+	echo '7';
1459
+}
1460
+?>" />
1461
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1462
+	echo $globalAirportZoom;
1463
+} else {
1464
+	echo '7';
1465
+}
1466
+?></output>
1120 1467
 				</div>
1121 1468
 			</p>
1122 1469
 			<br />
1123 1470
 			<p>
1124 1471
 				<label for="customcss">Custom CSS web path</label>
1125
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1472
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1473
+	echo $globalCustomCSS;
1474
+}
1475
+?>" />
1126 1476
 			</p>
1127 1477
 		</fieldset>
1128 1478
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -1149,8 +1499,12 @@  discard block
 block discarded – undo
1149 1499
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1150 1500
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1151 1501
 
1152
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1153
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1502
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1503
+		$error .= 'Mysql driver for PDO must be loaded';
1504
+	}
1505
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1506
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1507
+	}
1154 1508
 	
1155 1509
 	$_SESSION['database_root'] = $dbroot;
1156 1510
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1218,15 +1572,23 @@  discard block
 block discarded – undo
1218 1572
 	$source_city = $_POST['source_city'];
1219 1573
 	$source_country = $_POST['source_country'];
1220 1574
 	$source_ref = $_POST['source_ref'];
1221
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1222
-	else $source_id = array();
1575
+	if (isset($source_id)) {
1576
+		$source_id = $_POST['source_id'];
1577
+	} else {
1578
+		$source_id = array();
1579
+	}
1223 1580
 	
1224 1581
 	$sources = array();
1225 1582
 	foreach ($source_name as $keys => $name) {
1226
-	    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]);
1227
-	    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]);
1583
+	    if (isset($source_id[$keys])) {
1584
+	    	$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]);
1585
+	    } else {
1586
+	    	$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]);
1587
+	    }
1588
+	}
1589
+	if (count($sources) > 0) {
1590
+		$_SESSION['sources'] = $sources;
1228 1591
 	}
1229
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1230 1592
 
1231 1593
 	$newsurl = $_POST['newsurl'];
1232 1594
 	$newslng = $_POST['newslang'];
@@ -1239,7 +1601,9 @@  discard block
 block discarded – undo
1239 1601
 		$lng = $newslng[$newskey];
1240 1602
 		if (isset($newsfeeds[$type][$lng])) {
1241 1603
 		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1242
-		} else $newsfeeds[$type][$lng] = array($url);
1604
+		} else {
1605
+			$newsfeeds[$type][$lng] = array($url);
1606
+		}
1243 1607
 	    }
1244 1608
 	}
1245 1609
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
@@ -1263,17 +1627,29 @@  discard block
 block discarded – undo
1263 1627
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1264 1628
 
1265 1629
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1266
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1267
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1630
+	if ($globalaircraft == 'aircraft') {
1631
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1632
+	} else {
1633
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1634
+	}
1268 1635
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1269
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1270
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1636
+	if ($globaltracker == 'tracker') {
1637
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1638
+	} else {
1639
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1640
+	}
1271 1641
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1272
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1273
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1642
+	if ($globalmarine == 'marine') {
1643
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1644
+	} else {
1645
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1646
+	}
1274 1647
 	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1275
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1276
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1648
+	if ($globalsatellite == 'satellite') {
1649
+		$settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1650
+	} else {
1651
+		$settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1652
+	}
1277 1653
 
1278 1654
 /*	
1279 1655
 	$globalSBS1Hosts = array();
@@ -1295,23 +1671,37 @@  discard block
 block discarded – undo
1295 1671
 	$name = $_POST['name'];
1296 1672
 	$format = $_POST['format'];
1297 1673
 	$timezones = $_POST['timezones'];
1298
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1299
-	else $sourcestats = array();
1300
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1301
-	else $noarchive = array();
1674
+	if (isset($_POST['sourcestats'])) {
1675
+		$sourcestats = $_POST['sourcestats'];
1676
+	} else {
1677
+		$sourcestats = array();
1678
+	}
1679
+	if (isset($_POST['noarchive'])) {
1680
+		$noarchive = $_POST['noarchive'];
1681
+	} else {
1682
+		$noarchive = array();
1683
+	}
1302 1684
 	$gSources = array();
1303 1685
 	$forcepilots = false;
1304 1686
 	foreach ($host as $key => $h) {
1305
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1306
-		else $cov = 'FALSE';
1307
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1308
-		else $arch = 'FALSE';
1687
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1688
+			$cov = 'TRUE';
1689
+		} else {
1690
+			$cov = 'FALSE';
1691
+		}
1692
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1693
+			$arch = 'TRUE';
1694
+		} else {
1695
+			$arch = 'FALSE';
1696
+		}
1309 1697
 		if (strpos($format[$key],'_callback')) {
1310 1698
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1311 1699
 		} elseif ($h != '' || $name[$key] != '') {
1312 1700
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1313 1701
 		}
1314
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1702
+		if ($format[$key] == 'airwhere') {
1703
+			$forcepilots = true;
1704
+		}
1315 1705
 	}
1316 1706
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1317 1707
 
@@ -1342,7 +1732,9 @@  discard block
 block discarded – undo
1342 1732
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1343 1733
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1344 1734
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1345
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1735
+	} else {
1736
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1737
+	}
1346 1738
 
1347 1739
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1348 1740
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1383,7 +1775,9 @@  discard block
 block discarded – undo
1383 1775
 
1384 1776
 	// Create in settings.php keys not yet configurable if not already here
1385 1777
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1386
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1778
+	if (!isset($globalDebug)) {
1779
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1780
+	}
1387 1781
 
1388 1782
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1389 1783
 	if ($resetyearstats == 'resetyearstats') {
@@ -1426,37 +1820,56 @@  discard block
 block discarded – undo
1426 1820
 	}
1427 1821
 */
1428 1822
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1429
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1430
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1431
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1432
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1823
+	if ($globalsbs == 'sbs') {
1824
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1825
+	} else {
1826
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1827
+	}
1828
+	if ($globalaprs == 'aprs') {
1829
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1830
+	} else {
1831
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1832
+	}
1433 1833
 	$va = false;
1434 1834
 	if ($globalivao == 'ivao') {
1435 1835
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1436 1836
 		$va = true;
1437
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1837
+	} else {
1838
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1839
+	}
1438 1840
 	if ($globalvatsim == 'vatsim') {
1439 1841
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1440 1842
 		$va = true;
1441
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1843
+	} else {
1844
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1845
+	}
1442 1846
 	if ($globalphpvms == 'phpvms') {
1443 1847
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1444 1848
 		$va = true;
1445
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1849
+	} else {
1850
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1851
+	}
1446 1852
 	if ($globalvam == 'vam') {
1447 1853
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1448 1854
 		$va = true;
1449
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1855
+	} else {
1856
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1857
+	}
1450 1858
 	if ($va) {
1451 1859
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1452
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1860
+	} else {
1861
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1862
+	}
1453 1863
 	if ($globalva == 'va' || $va) {
1454 1864
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1455 1865
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1456 1866
 	} else {
1457 1867
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1458
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1459
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1868
+		if ($forcepilots) {
1869
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1870
+		} else {
1871
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1872
+		}
1460 1873
 	}
1461 1874
 	
1462 1875
 	
@@ -1679,7 +2092,9 @@  discard block
 block discarded – undo
1679 2092
 	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1680 2093
 	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1681 2094
 
1682
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2095
+	if (!isset($globalTransaction)) {
2096
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2097
+	}
1683 2098
 
1684 2099
 	// Set some defaults values...
1685 2100
 	if (!isset($globalAircraftImageSources)) {
@@ -1694,15 +2109,23 @@  discard block
 block discarded – undo
1694 2109
 
1695 2110
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1696 2111
 
1697
-	if ($error == '') settings::modify_settings($settings);
1698
-	if ($error == '') settings::comment_settings($settings_comment);
2112
+	if ($error == '') {
2113
+		settings::modify_settings($settings);
2114
+	}
2115
+	if ($error == '') {
2116
+		settings::comment_settings($settings_comment);
2117
+	}
1699 2118
 	if ($error != '') {
1700 2119
 		print '<div class="info column">'.$error.'</div>';
1701 2120
 		require('../footer.php');
1702 2121
 		exit;
1703 2122
 	} else {
1704
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1705
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
2123
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
2124
+			$_SESSION['waypoints'] = 1;
2125
+		}
2126
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
2127
+			$_SESSION['owner'] = 1;
2128
+		}
1706 2129
 		if (isset($_POST['createdb'])) {
1707 2130
 			$_SESSION['install'] = 'database_create';
1708 2131
 		} else {
@@ -1739,10 +2162,18 @@  discard block
 block discarded – undo
1739 2162
 	$popw = false;
1740 2163
 	foreach ($_SESSION['done'] as $done) {
1741 2164
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1742
-	    if ($done == 'Create database') $pop = true;
1743
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1744
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1745
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
2165
+	    if ($done == 'Create database') {
2166
+	    	$pop = true;
2167
+	    }
2168
+	    if ($_SESSION['install'] == 'database_create') {
2169
+	    	$pop = true;
2170
+	    }
2171
+	    if ($_SESSION['install'] == 'database_import') {
2172
+	    	$popi = true;
2173
+	    }
2174
+	    if ($_SESSION['install'] == 'waypoints') {
2175
+	    	$popw = true;
2176
+	    }
1746 2177
 	}
1747 2178
 	if ($pop) {
1748 2179
 	    sleep(5);
@@ -1753,7 +2184,9 @@  discard block
 block discarded – undo
1753 2184
 	} else if ($popw) {
1754 2185
 	    sleep(5);
1755 2186
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1756
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2187
+	} else {
2188
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2189
+	}
1757 2190
 	print '</div></ul>';
1758 2191
 	print '<div id="error"></div>';
1759 2192
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.