Completed
Push — master ( aa8319...e96b22 )
by Yannick
07:18
created
scripts/daemon-spotter.php 1 patch
Braces   +923 added lines, -317 removed lines patch added patch discarded remove patch
@@ -13,13 +13,17 @@  discard block
 block discarded – undo
13 13
 require_once(dirname(__FILE__).'/../require/class.SBS.php');
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
16
+if (isset($globalTracker) && $globalTracker) {
17
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+}
17 19
 if (isset($globalMarine) && $globalMarine) {
18 20
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
19 21
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 22
 }
21 23
 
22
-if (!isset($globalDebug)) $globalDebug = FALSE;
24
+if (!isset($globalDebug)) {
25
+	$globalDebug = FALSE;
26
+}
23 27
 
24 28
 // Check if schema is at latest version
25 29
 $Connection = new Connection();
@@ -54,35 +58,62 @@  discard block
 block discarded – undo
54 58
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 59
 if (isset($options['s'])) {
56 60
     $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
-    else $globalSources[] = array('host' => $options['s']);
59
-} elseif (isset($options['source'])) {
61
+    if (isset($options['format'])) {
62
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+    } else {
64
+    	$globalSources[] = array('host' => $options['s']);
65
+    }
66
+    } elseif (isset($options['source'])) {
60 67
     $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
-    else $globalSources[] = array('host' => $options['source']);
63
-}
68
+    if (isset($options['format'])) {
69
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
70
+    } else {
71
+    	$globalSources[] = array('host' => $options['source']);
72
+    }
73
+    }
64 74
 if (isset($options['aprsserverhost'])) {
65 75
 	$globalServerAPRS = TRUE;
66 76
 	$globalServerAPRShost = $options['aprsserverhost'];
67 77
 }
68
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
69
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
70
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
71
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
72
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
73
-if (isset($options['server'])) $globalServer = TRUE;
74
-if (isset($options['idsource'])) $id_source = $options['idsource'];
75
-else $id_source = 1;
78
+if (isset($options['aprsserverport'])) {
79
+	$globalServerAPRSport = $options['aprsserverport'];
80
+}
81
+if (isset($options['aprsserverssid'])) {
82
+	$globalServerAPRSssid = $options['aprsserverssid'];
83
+}
84
+if (isset($options['aprsserverpass'])) {
85
+	$globalServerAPRSpass = $options['aprsserverpass'];
86
+}
87
+if (isset($options['noaprsserver'])) {
88
+	$globalServerAPRS = FALSE;
89
+}
90
+if (isset($options['nodaemon'])) {
91
+	$globalDaemon = FALSE;
92
+}
93
+if (isset($options['server'])) {
94
+	$globalServer = TRUE;
95
+}
96
+if (isset($options['idsource'])) {
97
+	$id_source = $options['idsource'];
98
+} else {
99
+	$id_source = 1;
100
+}
76 101
 if (isset($globalServer) && $globalServer) {
77
-    if ($globalDebug) echo "Using Server Mode\n";
102
+    if ($globalDebug) {
103
+    	echo "Using Server Mode\n";
104
+    }
78 105
     $SI=new SpotterServer();
79 106
 /*
80 107
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 108
     $SI = new adsb2aprs();
82 109
     $SI->connect();
83 110
 */
84
-} else $SI=new SpotterImport($Connection->db);
85
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
111
+} else {
112
+	$SI=new SpotterImport($Connection->db);
113
+}
114
+if (isset($globalTracker) && $globalTracker) {
115
+	$TI = new TrackerImport($Connection->db);
116
+}
86 117
 if (isset($globalMarine) && $globalMarine) {
87 118
     $AIS = new AIS();
88 119
     $MI = new MarineImport($Connection->db);
@@ -104,7 +135,9 @@  discard block
 block discarded – undo
104 135
 }
105 136
 
106 137
 // let's try and connect
107
-if ($globalDebug) echo "Connecting...\n";
138
+if ($globalDebug) {
139
+	echo "Connecting...\n";
140
+}
108 141
 $use_aprs = false;
109 142
 $aprs_full = false;
110 143
 $reset = 0;
@@ -113,7 +146,9 @@  discard block
 block discarded – undo
113 146
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114 147
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115 148
     $reset++;
116
-    if ($globalDebug) echo 'Connect to all...'."\n";
149
+    if ($globalDebug) {
150
+    	echo 'Connect to all...'."\n";
151
+    }
117 152
     foreach ($hosts as $id => $value) {
118 153
 	$host = $value['host'];
119 154
 	$globalSources[$id]['last_exec'] = 0;
@@ -123,27 +158,37 @@  discard block
 block discarded – undo
123 158
         	//$formats[$id] = 'deltadbtxt';
124 159
         	$globalSources[$id]['format'] = 'deltadbtxt';
125 160
         	//$last_exec['deltadbtxt'] = 0;
126
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
161
+        	if ($globalDebug) {
162
+        		echo "Connect to deltadb source (".$host.")...\n";
163
+        	}
127 164
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
128 165
         	//$formats[$id] = 'vatsimtxt';
129 166
         	$globalSources[$id]['format'] = 'vatsimtxt';
130 167
         	//$last_exec['vatsimtxt'] = 0;
131
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
168
+        	if ($globalDebug) {
169
+        		echo "Connect to vatsim source (".$host.")...\n";
170
+        	}
132 171
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
133 172
         	//$formats[$id] = 'aircraftlistjson';
134 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
135 174
         	//$last_exec['aircraftlistjson'] = 0;
136
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
175
+        	if ($globalDebug) {
176
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
177
+        	}
137 178
     	    } else if (preg_match('/opensky/i',$host)) {
138 179
         	//$formats[$id] = 'aircraftlistjson';
139 180
         	$globalSources[$id]['format'] = 'opensky';
140 181
         	//$last_exec['aircraftlistjson'] = 0;
141
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
182
+        	if ($globalDebug) {
183
+        		echo "Connect to opensky source (".$host.")...\n";
184
+        	}
142 185
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
143 186
         	//$formats[$id] = 'radarvirtueljson';
144 187
         	$globalSources[$id]['format'] = 'radarvirtueljson';
145 188
         	//$last_exec['radarvirtueljson'] = 0;
146
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
189
+        	if ($globalDebug) {
190
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
191
+        	}
147 192
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
148 193
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149 194
         	    exit(0);
@@ -152,7 +197,9 @@  discard block
 block discarded – undo
152 197
         	//$formats[$id] = 'planeupdatefaa';
153 198
         	$globalSources[$id]['format'] = 'planeupdatefaa';
154 199
         	//$last_exec['planeupdatefaa'] = 0;
155
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
200
+        	if ($globalDebug) {
201
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
202
+        	}
156 203
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
157 204
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158 205
         	    exit(0);
@@ -161,26 +208,36 @@  discard block
 block discarded – undo
161 208
         	//$formats[$id] = 'phpvmacars';
162 209
         	$globalSources[$id]['format'] = 'phpvmacars';
163 210
         	//$last_exec['phpvmacars'] = 0;
164
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
211
+        	if ($globalDebug) {
212
+        		echo "Connect to phpvmacars source (".$host.")...\n";
213
+        	}
165 214
             } else if (preg_match('/VAM-json.php$/i',$host)) {
166 215
         	//$formats[$id] = 'phpvmacars';
167 216
         	$globalSources[$id]['format'] = 'vam';
168
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
217
+        	if ($globalDebug) {
218
+        		echo "Connect to Vam source (".$host.")...\n";
219
+        	}
169 220
             } else if (preg_match('/whazzup/i',$host)) {
170 221
         	//$formats[$id] = 'whazzup';
171 222
         	$globalSources[$id]['format'] = 'whazzup';
172 223
         	//$last_exec['whazzup'] = 0;
173
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
224
+        	if ($globalDebug) {
225
+        		echo "Connect to whazzup source (".$host.")...\n";
226
+        	}
174 227
             } else if (preg_match('/recentpireps/i',$host)) {
175 228
         	//$formats[$id] = 'pirepsjson';
176 229
         	$globalSources[$id]['format'] = 'pirepsjson';
177 230
         	//$last_exec['pirepsjson'] = 0;
178
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
231
+        	if ($globalDebug) {
232
+        		echo "Connect to pirepsjson source (".$host.")...\n";
233
+        	}
179 234
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
180 235
         	//$formats[$id] = 'fr24json';
181 236
         	$globalSources[$id]['format'] = 'fr24json';
182 237
         	//$last_exec['fr24json'] = 0;
183
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
238
+        	if ($globalDebug) {
239
+        		echo "Connect to fr24 source (".$host.")...\n";
240
+        	}
184 241
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
185 242
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186 243
         	    exit(0);
@@ -189,7 +246,9 @@  discard block
 block discarded – undo
189 246
         	//$formats[$id] = 'fr24json';
190 247
         	$globalSources[$id]['format'] = 'myshiptracking';
191 248
         	//$last_exec['fr24json'] = 0;
192
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
249
+        	if ($globalDebug) {
250
+        		echo "Connect to myshiptracking source (".$host.")...\n";
251
+        	}
193 252
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
194 253
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
195 254
         	    exit(0);
@@ -198,17 +257,24 @@  discard block
 block discarded – undo
198 257
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
199 258
         	//$formats[$id] = 'tsv';
200 259
         	$globalSources[$id]['format'] = 'tsv';
201
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
260
+        	if ($globalDebug) {
261
+        		echo "Connect to tsv source (".$host.")...\n";
262
+        	}
202 263
             }
203 264
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
204 265
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
205 266
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
206 267
     		    if ($idf !== false) {
207 268
     			$httpfeeds[$id] = $idf;
208
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
269
+        		if ($globalDebug) {
270
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
271
+        		}
272
+    		    } elseif ($globalDebug) {
273
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
209 274
     		    }
210
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
211
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
275
+    		} elseif ($globalDebug) {
276
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
277
+    		}
212 278
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
213 279
 	    $hostport = explode(':',$host);
214 280
 	    if (isset($hostport[1])) {
@@ -248,17 +314,25 @@  discard block
 block discarded – undo
248 314
         		//$formats[$id] = 'beast';
249 315
         		$globalSources[$id]['format'] = 'beast';
250 316
 		    //} else $formats[$id] = 'sbs';
251
-		    } else $globalSources[$id]['format'] = 'sbs';
317
+		    } else {
318
+		    	$globalSources[$id]['format'] = 'sbs';
319
+		    }
252 320
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
253 321
 		}
254
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
322
+		if ($globalDebug) {
323
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
324
+		}
255 325
             } else {
256
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
326
+		if ($globalDebug) {
327
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
328
+		}
257 329
     	    }
258 330
         }
259 331
     }
260 332
 }
261
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
333
+if (!isset($globalMinFetch)) {
334
+	$globalMinFetch = 15;
335
+}
262 336
 
263 337
 // Initialize all
264 338
 $status = array();
@@ -267,13 +341,19 @@  discard block
 block discarded – undo
267 341
 $formats = array();
268 342
 $last_exec = array();
269 343
 $time = time();
270
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
271
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
272
-else $timeout = 20;
344
+if (isset($globalSourcesTimeout)) {
345
+	$timeout = $globalSourcesTimeOut;
346
+} else if (isset($globalSBS1TimeOut)) {
347
+	$timeout = $globalSBS1TimeOut;
348
+} else {
349
+	$timeout = 20;
350
+}
273 351
 $errno = '';
274 352
 $errstr='';
275 353
 
276
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
354
+if (!isset($globalDaemon)) {
355
+	$globalDaemon = TRUE;
356
+}
277 357
 /* Initiate connections to all the hosts simultaneously */
278 358
 //connect_all($hosts);
279 359
 //connect_all($globalSources);
@@ -299,7 +379,9 @@  discard block
 block discarded – undo
299 379
     if (isset($source['format']) && $source['format'] == 'aprs') {
300 380
 	$aprs_connect = 0;
301 381
 	$use_aprs = true;
302
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
382
+	if (isset($source['port']) && $source['port'] == '10152') {
383
+		$aprs_full = true;
384
+	}
303 385
 	break;
304 386
     }
305 387
 }
@@ -310,25 +392,48 @@  discard block
 block discarded – undo
310 392
 	$aprs_connect = 0;
311 393
 	$aprs_keep = 120;
312 394
 	$aprs_last_tx = time();
313
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
314
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
315
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
316
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
317
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
318
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
319
-	if ($aprs_full) $aprs_filter = '';
320
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
321
-	else $aprs_pass = '-1';
395
+	if (isset($globalAPRSversion)) {
396
+		$aprs_version = $globalAPRSversion;
397
+	} else {
398
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
399
+	}
400
+	if (isset($globalAPRSssid)) {
401
+		$aprs_ssid = $globalAPRSssid;
402
+	} else {
403
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
404
+	}
405
+	if (isset($globalAPRSfilter)) {
406
+		$aprs_filter = $globalAPRSfilter;
407
+	} else {
408
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
409
+	}
410
+	if ($aprs_full) {
411
+		$aprs_filter = '';
412
+	}
413
+	if (isset($globalAPRSpass)) {
414
+		$aprs_pass = $globalAPRSpass;
415
+	} else {
416
+		$aprs_pass = '-1';
417
+	}
322 418
 
323
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
324
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
325
-}
419
+	if ($aprs_filter != '') {
420
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
421
+	} else {
422
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
423
+	}
424
+	}
326 425
 
327 426
 // connected - lets do some work
328
-if ($globalDebug) echo "Connected!\n";
427
+if ($globalDebug) {
428
+	echo "Connected!\n";
429
+}
329 430
 sleep(1);
330
-if ($globalDebug) echo "SCAN MODE \n\n";
331
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
431
+if ($globalDebug) {
432
+	echo "SCAN MODE \n\n";
433
+}
434
+if (!isset($globalCronEnd)) {
435
+	$globalCronEnd = 60;
436
+}
332 437
 $endtime = time()+$globalCronEnd;
333 438
 $i = 1;
334 439
 $tt = array();
@@ -342,10 +447,14 @@  discard block
 block discarded – undo
342 447
 
343 448
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
344 449
 while ($i > 0) {
345
-    if (!$globalDaemon) $i = $endtime-time();
450
+    if (!$globalDaemon) {
451
+    	$i = $endtime-time();
452
+    }
346 453
     // Delete old ATC
347 454
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
455
+	if ($globalDebug) {
456
+		echo 'Delete old ATC...'."\n";
457
+	}
349 458
         $ATC->deleteOldATC();
350 459
     }
351 460
     
@@ -353,10 +462,14 @@  discard block
 block discarded – undo
353 462
     if (count($last_exec) == count($globalSources)) {
354 463
 	$max = $globalMinFetch;
355 464
 	foreach ($last_exec as $last) {
356
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
465
+	    if ((time() - $last['last']) < $max) {
466
+	    	$max = time() - $last['last'];
467
+	    }
357 468
 	}
358 469
 	if ($max != $globalMinFetch) {
359
-	    if ($globalDebug) echo 'Sleeping...'."\n";
470
+	    if ($globalDebug) {
471
+	    	echo 'Sleeping...'."\n";
472
+	    }
360 473
 	    sleep($globalMinFetch-$max+2);
361 474
 	}
362 475
     }
@@ -365,11 +478,15 @@  discard block
 block discarded – undo
365 478
     //foreach ($formats as $id => $value) {
366 479
     foreach ($globalSources as $id => $value) {
367 480
 	date_default_timezone_set('UTC');
368
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
481
+	if (!isset($last_exec[$id]['last'])) {
482
+		$last_exec[$id]['last'] = 0;
483
+	}
369 484
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
370 485
 	    //$buffer = $Common->getData($hosts[$id]);
371 486
 	    $buffer = $Common->getData($value['host']);
372
-	    if ($buffer != '') $reset = 0;
487
+	    if ($buffer != '') {
488
+	    	$reset = 0;
489
+	    }
373 490
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374 491
 	    $buffer = explode('\n',$buffer);
375 492
 	    foreach ($buffer as $line) {
@@ -378,20 +495,41 @@  discard block
 block discarded – undo
378 495
 	            $data = array();
379 496
 	            $data['hex'] = $line[1]; // hex
380 497
 	            $data['ident'] = $line[2]; // ident
381
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
382
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
383
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
384
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
385
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
498
+	            if (isset($line[3])) {
499
+	            	$data['altitude'] = $line[3];
500
+	            }
501
+	            // altitude
502
+	            if (isset($line[4])) {
503
+	            	$data['speed'] = $line[4];
504
+	            }
505
+	            // speed
506
+	            if (isset($line[5])) {
507
+	            	$data['heading'] = $line[5];
508
+	            }
509
+	            // heading
510
+	            if (isset($line[6])) {
511
+	            	$data['latitude'] = $line[6];
512
+	            }
513
+	            // lat
514
+	            if (isset($line[7])) {
515
+	            	$data['longitude'] = $line[7];
516
+	            }
517
+	            // long
386 518
 	            $data['verticalrate'] = ''; // vertical rate
387 519
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
388 520
 	            $data['emergency'] = ''; // emergency
389 521
 		    $data['datetime'] = date('Y-m-d H:i:s');
390 522
 		    $data['format_source'] = 'deltadbtxt';
391 523
     		    $data['id_source'] = $id_source;
392
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
393
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
394
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
524
+		    if (isset($value['name']) && $value['name'] != '') {
525
+		    	$data['source_name'] = $value['name'];
526
+		    }
527
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
528
+		    	$data['noarchive'] = true;
529
+		    }
530
+		    if (isset($value['sourcestats'])) {
531
+		    	$data['sourcestats'] = $value['sourcestats'];
532
+		    }
395 533
     		    $SI->add($data);
396 534
 		    unset($data);
397 535
     		}
@@ -401,7 +539,9 @@  discard block
 block discarded – undo
401 539
 	    date_default_timezone_set('CET');
402 540
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
403 541
 	    date_default_timezone_set('UTC');
404
-	    if ($buffer != '') $reset = 0;
542
+	    if ($buffer != '') {
543
+	    	$reset = 0;
544
+	    }
405 545
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
406 546
 	    $buffer = explode('\n',$buffer);
407 547
 	    foreach ($buffer as $line) {
@@ -410,16 +550,36 @@  discard block
 block discarded – undo
410 550
 		    $add = false;
411 551
 		    $ais_data = $AIS->parse_line(trim($line));
412 552
 		    $data = array();
413
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
414
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
415
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
416
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
417
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
418
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
419
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
420
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
421
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
422
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
553
+		    if (isset($ais_data['ident'])) {
554
+		    	$data['ident'] = $ais_data['ident'];
555
+		    }
556
+		    if (isset($ais_data['mmsi'])) {
557
+		    	$data['mmsi'] = $ais_data['mmsi'];
558
+		    }
559
+		    if (isset($ais_data['speed'])) {
560
+		    	$data['speed'] = $ais_data['speed'];
561
+		    }
562
+		    if (isset($ais_data['heading'])) {
563
+		    	$data['heading'] = $ais_data['heading'];
564
+		    }
565
+		    if (isset($ais_data['latitude'])) {
566
+		    	$data['latitude'] = $ais_data['latitude'];
567
+		    }
568
+		    if (isset($ais_data['longitude'])) {
569
+		    	$data['longitude'] = $ais_data['longitude'];
570
+		    }
571
+		    if (isset($ais_data['status'])) {
572
+		    	$data['status'] = $ais_data['status'];
573
+		    }
574
+		    if (isset($ais_data['type'])) {
575
+		    	$data['type'] = $ais_data['type'];
576
+		    }
577
+		    if (isset($ais_data['imo'])) {
578
+		    	$data['imo'] = $ais_data['imo'];
579
+		    }
580
+		    if (isset($ais_data['callsign'])) {
581
+		    	$data['callsign'] = $ais_data['callsign'];
582
+		    }
423 583
 		    if (isset($ais_data['timestamp'])) {
424 584
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
425 585
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -433,8 +593,12 @@  discard block
 block discarded – undo
433 593
 		    $data['format_source'] = 'aisnmeatxt';
434 594
     		    $data['id_source'] = $id_source;
435 595
 		    //print_r($data);
436
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
437
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
596
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
597
+		    	$data['noarchive'] = true;
598
+		    }
599
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
600
+		    	$MI->add($data);
601
+		    }
438 602
 		    unset($data);
439 603
 		}
440 604
     	    }
@@ -454,20 +618,48 @@  discard block
 block discarded – undo
454 618
 			    if ($line != '') {
455 619
 				$ais_data = $AIS->parse_line(trim($line));
456 620
 				$data = array();
457
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
458
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
459
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
460
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
461
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
462
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
463
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
464
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
465
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
466
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
467
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
468
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
469
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
470
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
621
+				if (isset($ais_data['ident'])) {
622
+					$data['ident'] = $ais_data['ident'];
623
+				}
624
+				if (isset($ais_data['mmsi'])) {
625
+					$data['mmsi'] = $ais_data['mmsi'];
626
+				}
627
+				if (isset($ais_data['speed'])) {
628
+					$data['speed'] = $ais_data['speed'];
629
+				}
630
+				if (isset($ais_data['heading'])) {
631
+					$data['heading'] = $ais_data['heading'];
632
+				}
633
+				if (isset($ais_data['latitude'])) {
634
+					$data['latitude'] = $ais_data['latitude'];
635
+				}
636
+				if (isset($ais_data['longitude'])) {
637
+					$data['longitude'] = $ais_data['longitude'];
638
+				}
639
+				if (isset($ais_data['status'])) {
640
+					$data['status'] = $ais_data['status'];
641
+				}
642
+				if (isset($ais_data['statusid'])) {
643
+					$data['status_id'] = $ais_data['statusid'];
644
+				}
645
+				if (isset($ais_data['type'])) {
646
+					$data['type'] = $ais_data['type'];
647
+				}
648
+				if (isset($ais_data['typeid'])) {
649
+					$data['type_id'] = $ais_data['typeid'];
650
+				}
651
+				if (isset($ais_data['imo'])) {
652
+					$data['imo'] = $ais_data['imo'];
653
+				}
654
+				if (isset($ais_data['callsign'])) {
655
+					$data['callsign'] = $ais_data['callsign'];
656
+				}
657
+				if (isset($ais_data['destination'])) {
658
+					$data['arrival_code'] = $ais_data['destination'];
659
+				}
660
+				if (isset($ais_data['eta_ts'])) {
661
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
662
+				}
471 663
 				if (isset($ais_data['timestamp'])) {
472 664
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
473 665
 				} else {
@@ -475,18 +667,27 @@  discard block
 block discarded – undo
475 667
 				}
476 668
 				$data['format_source'] = 'aisnmeahttp';
477 669
 				$data['id_source'] = $id_source;
478
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
479
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
670
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
671
+					$data['noarchive'] = true;
672
+				}
673
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
674
+					$MI->add($data);
675
+				}
480 676
 				unset($data);
481 677
 			    }
482 678
 			}
483 679
 		    }
484 680
 		} else {
485 681
 		    $format = $value['format'];
486
-		    if (isset($tt[$format])) $tt[$format]++;
487
-		    else $tt[$format] = 0;
682
+		    if (isset($tt[$format])) {
683
+		    	$tt[$format]++;
684
+		    } else {
685
+		    	$tt[$format] = 0;
686
+		    }
488 687
 		    if ($tt[$format] > 30) {
489
-			if ($globalDebug) echo 'Reconnect...'."\n";
688
+			if ($globalDebug) {
689
+				echo 'Reconnect...'."\n";
690
+			}
490 691
 			sleep(2);
491 692
 			$sourceeen[] = $value;
492 693
 			connect_all($sourceeen);
@@ -516,7 +717,9 @@  discard block
 block discarded – undo
516 717
 			$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
517 718
 			$data['format_source'] = 'myshiptracking';
518 719
 			$data['id_source'] = $id_source;
519
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
720
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
721
+				$data['noarchive'] = true;
722
+			}
520 723
 			$MI->add($data);
521 724
 			unset($data);
522 725
 		    }
@@ -537,7 +740,9 @@  discard block
 block discarded – undo
537 740
 			    $data['callsign'] = $line['callsign'];
538 741
 			    $data['mmsi'] = $line['mmsi'];
539 742
 			    $data['speed'] = $line['sog'];
540
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
743
+			    if ($line['heading'] != '511') {
744
+			    	$data['heading'] = $line['heading'];
745
+			    }
541 746
 			    $data['latitude'] = $line['latitude'];
542 747
 			    $data['longitude'] = $line['longitude'];
543 748
 			    $data['type_id'] = $line['shiptype'];
@@ -545,7 +750,9 @@  discard block
 block discarded – undo
545 750
 			    $data['datetime'] = $line['time'];
546 751
 			    $data['format_source'] = 'boatbeaconapp';
547 752
 			    $data['id_source'] = $id_source;
548
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
753
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
754
+			    	$data['noarchive'] = true;
755
+			    }
549 756
 			    $MI->add($data);
550 757
 			    unset($data);
551 758
 			}
@@ -558,7 +765,9 @@  discard block
 block discarded – undo
558 765
 	    echo 'download...';
559 766
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
560 767
 	    echo 'done !'."\n";
561
-	    if ($buffer != '') $reset = 0;
768
+	    if ($buffer != '') {
769
+	    	$reset = 0;
770
+	    }
562 771
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
563 772
 	    $buffer = explode('\n',$buffer);
564 773
 	    foreach ($buffer as $line) {
@@ -583,7 +792,9 @@  discard block
 block discarded – undo
583 792
 		    //$data['etaTime'] = substr($line,135,5);
584 793
 		    $data['format_source'] = 'shipplotter';
585 794
     		    $data['id_source'] = $id_source;
586
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
795
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
796
+		    	$data['noarchive'] = true;
797
+		    }
587 798
 		    //print_r($data);
588 799
 		    echo 'Add...'."\n";
589 800
 		    $MI->add($data);
@@ -603,16 +814,28 @@  discard block
 block discarded – undo
603 814
     		    $line = explode(':', $line);
604 815
     		    if (count($line) > 30 && $line[0] != 'callsign') {
605 816
 			$data = array();
606
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
607
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
817
+			if (isset($line[37]) && $line[37] != '') {
818
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
819
+			} else {
820
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
821
+			}
608 822
 			$data['pilot_id'] = $line[1];
609 823
 			$data['pilot_name'] = $line[2];
610 824
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
611 825
 			$data['ident'] = $line[0]; // ident
612
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
826
+			if ($line[7] != '' && $line[7] != 0) {
827
+				$data['altitude'] = $line[7];
828
+			}
829
+			// altitude
613 830
 			$data['speed'] = $line[8]; // speed
614
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
615
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
831
+			if (isset($line[45])) {
832
+				$data['heading'] = $line[45];
833
+			}
834
+			// heading
835
+			elseif (isset($line[38])) {
836
+				$data['heading'] = $line[38];
837
+			}
838
+			// heading
616 839
 			$data['latitude'] = $line[5]; // lat
617 840
 	        	$data['longitude'] = $line[6]; // long
618 841
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -628,7 +851,9 @@  discard block
 block discarded – undo
628 851
 			$data['frequency'] = $line[4];
629 852
 			$data['type'] = $line[18];
630 853
 			$data['range'] = $line[19];
631
-			if (isset($line[35])) $data['info'] = $line[35];
854
+			if (isset($line[35])) {
855
+				$data['info'] = $line[35];
856
+			}
632 857
     			$data['id_source'] = $id_source;
633 858
 	    		//$data['arrival_airport_time'] = ;
634 859
 	    		if ($line[9] != '') {
@@ -642,25 +867,44 @@  discard block
 block discarded – undo
642 867
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
643 868
 	    		*/
644 869
 	    		$data['format_source'] = $value['format'];
645
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
646
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
647
-    			if ($line[3] == 'PILOT') $SI->add($data);
648
-			elseif ($line[3] == 'ATC') {
870
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
871
+				$data['noarchive'] = true;
872
+			}
873
+			if (isset($value['name']) && $value['name'] != '') {
874
+				$data['source_name'] = $value['name'];
875
+			}
876
+    			if ($line[3] == 'PILOT') {
877
+    				$SI->add($data);
878
+    			} elseif ($line[3] == 'ATC') {
649 879
 				//print_r($data);
650 880
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
651 881
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
652 882
 				$typec = substr($data['ident'],-3);
653
-				if ($typec == 'APP') $data['type'] = 'Approach';
654
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
655
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
656
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
657
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
658
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
659
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
660
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
661
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
662
-				if (!isset($data['source_name'])) $data['source_name'] = '';
663
-				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
883
+				if ($typec == 'APP') {
884
+					$data['type'] = 'Approach';
885
+				} elseif ($typec == 'TWR') {
886
+					$data['type'] = 'Tower';
887
+				} elseif ($typec == 'OBS') {
888
+					$data['type'] = 'Observer';
889
+				} elseif ($typec == 'GND') {
890
+					$data['type'] = 'Ground';
891
+				} elseif ($typec == 'DEL') {
892
+					$data['type'] = 'Delivery';
893
+				} elseif ($typec == 'DEP') {
894
+					$data['type'] = 'Departure';
895
+				} elseif ($typec == 'FSS') {
896
+					$data['type'] = 'Flight Service Station';
897
+				} elseif ($typec == 'CTR') {
898
+					$data['type'] = 'Control Radar or Centre';
899
+				} elseif ($data['type'] == '') {
900
+					$data['type'] = 'Observer';
901
+				}
902
+				if (!isset($data['source_name'])) {
903
+					$data['source_name'] = '';
904
+				}
905
+				if (isset($ATC)) {
906
+					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']);
907
+				}
664 908
 			}
665 909
     			unset($data);
666 910
     		    }
@@ -679,27 +923,61 @@  discard block
 block discarded – undo
679 923
 		foreach ($all_data['acList'] as $line) {
680 924
 		    $data = array();
681 925
 		    $data['hex'] = $line['Icao']; // hex
682
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
683
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
684
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
685
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
686
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
687
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
926
+		    if (isset($line['Call'])) {
927
+		    	$data['ident'] = $line['Call'];
928
+		    }
929
+		    // ident
930
+		    if (isset($line['Alt'])) {
931
+		    	$data['altitude'] = $line['Alt'];
932
+		    }
933
+		    // altitude
934
+		    if (isset($line['Spd'])) {
935
+		    	$data['speed'] = $line['Spd'];
936
+		    }
937
+		    // speed
938
+		    if (isset($line['Trak'])) {
939
+		    	$data['heading'] = $line['Trak'];
940
+		    }
941
+		    // heading
942
+		    if (isset($line['Lat'])) {
943
+		    	$data['latitude'] = $line['Lat'];
944
+		    }
945
+		    // lat
946
+		    if (isset($line['Long'])) {
947
+		    	$data['longitude'] = $line['Long'];
948
+		    }
949
+		    // long
688 950
 		    //$data['verticalrate'] = $line['']; // verticale rate
689
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
951
+		    if (isset($line['Sqk'])) {
952
+		    	$data['squawk'] = $line['Sqk'];
953
+		    }
954
+		    // squawk
690 955
 		    $data['emergency'] = ''; // emergency
691
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
956
+		    if (isset($line['Reg'])) {
957
+		    	$data['registration'] = $line['Reg'];
958
+		    }
692 959
 		    
693
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
694
-		    else $data['datetime'] = date('Y-m-d H:i:s');
960
+		    if (isset($line['PosTime'])) {
961
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
962
+		    } else {
963
+		    	$data['datetime'] = date('Y-m-d H:i:s');
964
+		    }
695 965
 		    
696 966
 		    //$data['datetime'] = date('Y-m-d H:i:s');
697
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
967
+		    if (isset($line['Type'])) {
968
+		    	$data['aircraft_icao'] = $line['Type'];
969
+		    }
698 970
 	    	    $data['format_source'] = 'aircraftlistjson';
699 971
 		    $data['id_source'] = $id_source;
700
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
701
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
702
-		    if (isset($data['latitude'])) $SI->add($data);
972
+		    if (isset($value['name']) && $value['name'] != '') {
973
+		    	$data['source_name'] = $value['name'];
974
+		    }
975
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
976
+		    	$data['noarchive'] = true;
977
+		    }
978
+		    if (isset($data['latitude'])) {
979
+		    	$SI->add($data);
980
+		    }
703 981
 		    unset($data);
704 982
 		}
705 983
 	    } elseif (is_array($all_data)) {
@@ -716,12 +994,19 @@  discard block
 block discarded – undo
716 994
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
717 995
 		    $data['squawk'] = $line['squawk']; // squawk
718 996
 		    $data['emergency'] = ''; // emergency
719
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
720
-		    else $data['datetime'] = date('Y-m-d H:i:s');
997
+		    if (isset($line['PosTime'])) {
998
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
999
+		    } else {
1000
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1001
+		    }
721 1002
 	    	    $data['format_source'] = 'aircraftlistjson';
722 1003
     		    $data['id_source'] = $id_source;
723
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
724
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1004
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1005
+		    	$data['noarchive'] = true;
1006
+		    }
1007
+		    if (isset($value['name']) && $value['name'] != '') {
1008
+		    	$data['source_name'] = $value['name'];
1009
+		    }
725 1010
 		    $SI->add($data);
726 1011
 		    unset($data);
727 1012
 		}
@@ -757,8 +1042,12 @@  discard block
 block discarded – undo
757 1042
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
758 1043
 	    	    $data['format_source'] = 'planeupdatefaa';
759 1044
     		    $data['id_source'] = $id_source;
760
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
761
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1045
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1046
+		    	$data['noarchive'] = true;
1047
+		    }
1048
+		    if (isset($value['name']) && $value['name'] != '') {
1049
+		    	$data['source_name'] = $value['name'];
1050
+		    }
762 1051
 		    $SI->add($data);
763 1052
 		    unset($data);
764 1053
 		}
@@ -787,7 +1076,9 @@  discard block
 block discarded – undo
787 1076
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
788 1077
 	    	    $data['format_source'] = 'opensky';
789 1078
     		    $data['id_source'] = $id_source;
790
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1079
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1080
+		    	$data['noarchive'] = true;
1081
+		    }
791 1082
 		    $SI->add($data);
792 1083
 		    unset($data);
793 1084
 		}
@@ -799,7 +1090,9 @@  discard block
 block discarded – undo
799 1090
 	    //$buffer = $Common->getData($hosts[$id]);
800 1091
 	    $buffer = $Common->getData($value['host']);
801 1092
 	    $all_data = json_decode($buffer,true);
802
-	    if (!empty($all_data)) $reset = 0;
1093
+	    if (!empty($all_data)) {
1094
+	    	$reset = 0;
1095
+	    }
803 1096
 	    foreach ($all_data as $key => $line) {
804 1097
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
805 1098
 		    $data = array();
@@ -820,8 +1113,12 @@  discard block
 block discarded – undo
820 1113
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
821 1114
 	    	    $data['format_source'] = 'fr24json';
822 1115
     		    $data['id_source'] = $id_source;
823
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
824
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1116
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1117
+		    	$data['noarchive'] = true;
1118
+		    }
1119
+		    if (isset($value['name']) && $value['name'] != '') {
1120
+		    	$data['source_name'] = $value['name'];
1121
+		    }
825 1122
 		    $SI->add($data);
826 1123
 		    unset($data);
827 1124
 		}
@@ -845,24 +1142,42 @@  discard block
 block discarded – undo
845 1142
 		    if (isset($line['inf'])) {
846 1143
 			$data = array();
847 1144
 			$data['hex'] = $line['inf']['ia'];
848
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1145
+			if (isset($line['inf']['cs'])) {
1146
+				$data['ident'] = $line['inf']['cs'];
1147
+			}
1148
+			//$line[13]
849 1149
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
850
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
851
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1150
+	    		if (isset($line['inf']['gs'])) {
1151
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1152
+	    		}
1153
+	    		// speed
1154
+	    		if (isset($line['inf']['tr'])) {
1155
+	    			$data['heading'] = $line['inf']['tr'];
1156
+	    		}
1157
+	    		// heading
852 1158
 	    		$data['latitude'] = $line['pt'][0]; // lat
853 1159
 	    		$data['longitude'] = $line['pt'][1]; // long
854 1160
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
855
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1161
+	    		if (isset($line['inf']['sq'])) {
1162
+	    			$data['squawk'] = $line['inf']['sq'];
1163
+	    		}
1164
+	    		// squawk
856 1165
 	    		//$data['aircraft_icao'] = $line[8];
857
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1166
+	    		if (isset($line['inf']['rc'])) {
1167
+	    			$data['registration'] = $line['inf']['rc'];
1168
+	    		}
858 1169
 			//$data['departure_airport_iata'] = $line[11];
859 1170
 			//$data['arrival_airport_iata'] = $line[12];
860 1171
 	    		//$data['emergency'] = ''; // emergency
861 1172
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
862 1173
 	    		$data['format_source'] = 'radarvirtueljson';
863 1174
     			$data['id_source'] = $id_source;
864
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
865
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1175
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1176
+				$data['noarchive'] = true;
1177
+			}
1178
+			if (isset($value['name']) && $value['name'] != '') {
1179
+				$data['source_name'] = $value['name'];
1180
+			}
866 1181
 			$SI->add($data);
867 1182
 			unset($data);
868 1183
 		    }
@@ -883,30 +1198,65 @@  discard block
 block discarded – undo
883 1198
 		    $data['id'] = $line['id'];
884 1199
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
885 1200
 		    $data['ident'] = $line['callsign']; // ident
886
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
887
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
888
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
889
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
890
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
891
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1201
+		    if (isset($line['pilotid'])) {
1202
+		    	$data['pilot_id'] = $line['pilotid'];
1203
+		    }
1204
+		    // pilot id
1205
+		    if (isset($line['name'])) {
1206
+		    	$data['pilot_name'] = $line['name'];
1207
+		    }
1208
+		    // pilot name
1209
+		    if (isset($line['alt'])) {
1210
+		    	$data['altitude'] = $line['alt'];
1211
+		    }
1212
+		    // altitude
1213
+		    if (isset($line['gs'])) {
1214
+		    	$data['speed'] = $line['gs'];
1215
+		    }
1216
+		    // speed
1217
+		    if (isset($line['heading'])) {
1218
+		    	$data['heading'] = $line['heading'];
1219
+		    }
1220
+		    // heading
1221
+		    if (isset($line['route'])) {
1222
+		    	$data['waypoints'] = $line['route'];
1223
+		    }
1224
+		    // route
892 1225
 		    $data['latitude'] = $line['lat']; // lat
893 1226
 		    $data['longitude'] = $line['lon']; // long
894 1227
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
895 1228
 		    //$data['squawk'] = $line['squawk']; // squawk
896 1229
 		    //$data['emergency'] = ''; // emergency
897
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
898
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
899
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1230
+		    if (isset($line['depicao'])) {
1231
+		    	$data['departure_airport_icao'] = $line['depicao'];
1232
+		    }
1233
+		    if (isset($line['deptime'])) {
1234
+		    	$data['departure_airport_time'] = $line['deptime'];
1235
+		    }
1236
+		    if (isset($line['arricao'])) {
1237
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1238
+		    }
900 1239
 		    //$data['arrival_airport_time'] = $line['arrtime'];
901
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
902
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
903
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
904
-		    else $data['info'] = '';
1240
+		    if (isset($line['aircraft'])) {
1241
+		    	$data['aircraft_icao'] = $line['aircraft'];
1242
+		    }
1243
+		    if (isset($line['transponder'])) {
1244
+		    	$data['squawk'] = $line['transponder'];
1245
+		    }
1246
+		    if (isset($line['atis'])) {
1247
+		    	$data['info'] = $line['atis'];
1248
+		    } else {
1249
+		    	$data['info'] = '';
1250
+		    }
905 1251
 		    $data['format_source'] = 'pireps';
906 1252
     		    $data['id_source'] = $id_source;
907 1253
 		    $data['datetime'] = date('Y-m-d H:i:s');
908
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
909
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1254
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1255
+		    	$data['noarchive'] = true;
1256
+		    }
1257
+		    if (isset($value['name']) && $value['name'] != '') {
1258
+		    	$data['source_name'] = $value['name'];
1259
+		    }
910 1260
 		    if ($line['icon'] == 'plane') {
911 1261
 			$SI->add($data);
912 1262
 		    //    print_r($data);
@@ -915,16 +1265,28 @@  discard block
 block discarded – undo
915 1265
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
916 1266
 			$typec = substr($data['ident'],-3);
917 1267
 			$data['type'] = '';
918
-			if ($typec == 'APP') $data['type'] = 'Approach';
919
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
920
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
921
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
922
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
923
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
924
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
925
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
926
-			else $data['type'] = 'Observer';
927
-			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']);
1268
+			if ($typec == 'APP') {
1269
+				$data['type'] = 'Approach';
1270
+			} elseif ($typec == 'TWR') {
1271
+				$data['type'] = 'Tower';
1272
+			} elseif ($typec == 'OBS') {
1273
+				$data['type'] = 'Observer';
1274
+			} elseif ($typec == 'GND') {
1275
+				$data['type'] = 'Ground';
1276
+			} elseif ($typec == 'DEL') {
1277
+				$data['type'] = 'Delivery';
1278
+			} elseif ($typec == 'DEP') {
1279
+				$data['type'] = 'Departure';
1280
+			} elseif ($typec == 'FSS') {
1281
+				$data['type'] = 'Flight Service Station';
1282
+			} elseif ($typec == 'CTR') {
1283
+				$data['type'] = 'Control Radar or Centre';
1284
+			} else {
1285
+				$data['type'] = 'Observer';
1286
+			}
1287
+			if (isset($ATC)) {
1288
+				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']);
1289
+			}
928 1290
 		    }
929 1291
 		    unset($data);
930 1292
 		}
@@ -934,7 +1296,9 @@  discard block
 block discarded – undo
934 1296
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
935 1297
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
936 1298
 	    //$buffer = $Common->getData($hosts[$id]);
937
-	    if ($globalDebug) echo 'Get Data...'."\n";
1299
+	    if ($globalDebug) {
1300
+	    	echo 'Get Data...'."\n";
1301
+	    }
938 1302
 	    $buffer = $Common->getData($value['host']);
939 1303
 	    $all_data = json_decode($buffer,true);
940 1304
 	    if ($buffer != '' && is_array($all_data)) {
@@ -942,10 +1306,16 @@  discard block
 block discarded – undo
942 1306
 		foreach ($all_data as $line) {
943 1307
 	    	    $data = array();
944 1308
 	    	    //$data['id'] = $line['id']; // id not usable
945
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1309
+	    	    if (isset($line['pilotid'])) {
1310
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1311
+	    	    }
946 1312
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
947
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
948
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1313
+	    	    if (isset($line['pilotname'])) {
1314
+	    	    	$data['pilot_name'] = $line['pilotname'];
1315
+	    	    }
1316
+	    	    if (isset($line['pilotid'])) {
1317
+	    	    	$data['pilot_id'] = $line['pilotid'];
1318
+	    	    }
949 1319
 	    	    $data['ident'] = $line['flightnum']; // ident
950 1320
 	    	    $data['altitude'] = $line['alt']; // altitude
951 1321
 	    	    $data['speed'] = $line['gs']; // speed
@@ -963,28 +1333,44 @@  discard block
 block discarded – undo
963 1333
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
964 1334
     		    $data['arrival_airport_time'] = $line['arrtime'];
965 1335
     		    $data['registration'] = $line['aircraft'];
966
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
967
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1336
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1337
+		    	$data['noarchive'] = true;
1338
+		    }
1339
+		    if (isset($line['route'])) {
1340
+		    	$data['waypoints'] = $line['route'];
1341
+		    }
1342
+		    // route
968 1343
 		    if (isset($line['aircraftname'])) {
969 1344
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
970 1345
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
971 1346
 	    		$aircraft_data = explode('-',$line['aircraftname']);
972
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
973
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
974
-	    		else {
1347
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1348
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1349
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1350
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1351
+	    		} else {
975 1352
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
976
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
977
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1353
+	    		    if (isset($aircraft_data[1])) {
1354
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1355
+	    		    } else {
1356
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1357
+	    		    }
978 1358
 	    		}
979 1359
 	    	    }
980
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1360
+    		    if (isset($line['route'])) {
1361
+    		    	$data['waypoints'] = $line['route'];
1362
+    		    }
981 1363
     		    $data['id_source'] = $id_source;
982 1364
 	    	    $data['format_source'] = 'phpvmacars';
983
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1365
+		    if (isset($value['name']) && $value['name'] != '') {
1366
+		    	$data['source_name'] = $value['name'];
1367
+		    }
984 1368
 		    $SI->add($data);
985 1369
 		    unset($data);
986 1370
 		}
987
-		if ($globalDebug) echo 'No more data...'."\n";
1371
+		if ($globalDebug) {
1372
+			echo 'No more data...'."\n";
1373
+		}
988 1374
 		unset($buffer);
989 1375
 		unset($all_data);
990 1376
 	    }
@@ -992,7 +1378,9 @@  discard block
 block discarded – undo
992 1378
     	    $last_exec[$id]['last'] = time();
993 1379
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
994 1380
 	    //$buffer = $Common->getData($hosts[$id]);
995
-	    if ($globalDebug) echo 'Get Data...'."\n";
1381
+	    if ($globalDebug) {
1382
+	    	echo 'Get Data...'."\n";
1383
+	    }
996 1384
 	    $buffer = $Common->getData($value['host']);
997 1385
 	    $all_data = json_decode($buffer,true);
998 1386
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1021,16 +1409,25 @@  discard block
 block discarded – undo
1021 1409
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1022 1410
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1023 1411
     		    //$data['registration'] = $line['aircraft'];
1024
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1412
+		    if (isset($line['route'])) {
1413
+		    	$data['waypoints'] = $line['route'];
1414
+		    }
1415
+		    // route
1025 1416
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1026 1417
     		    $data['id_source'] = $id_source;
1027 1418
 	    	    $data['format_source'] = 'vam';
1028
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1029
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1419
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1420
+		    	$data['noarchive'] = true;
1421
+		    }
1422
+		    if (isset($value['name']) && $value['name'] != '') {
1423
+		    	$data['source_name'] = $value['name'];
1424
+		    }
1030 1425
 		    $SI->add($data);
1031 1426
 		    unset($data);
1032 1427
 		}
1033
-		if ($globalDebug) echo 'No more data...'."\n";
1428
+		if ($globalDebug) {
1429
+			echo 'No more data...'."\n";
1430
+		}
1034 1431
 		unset($buffer);
1035 1432
 		unset($all_data);
1036 1433
 	    }
@@ -1038,7 +1435,9 @@  discard block
 block discarded – undo
1038 1435
     	    $last_exec[$id]['last'] = time();
1039 1436
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1040 1437
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1041
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1438
+	    if (function_exists('pcntl_fork')) {
1439
+	    	pcntl_signal_dispatch();
1440
+	    }
1042 1441
     	    //$last_exec[$id]['last'] = time();
1043 1442
 
1044 1443
 	    //$read = array( $sockets[$id] );
@@ -1046,7 +1445,9 @@  discard block
 block discarded – undo
1046 1445
 	    $write = NULL;
1047 1446
 	    $e = NULL;
1048 1447
 	    $n = socket_select($read, $write, $e, $timeout);
1049
-	    if ($e != NULL) var_dump($e);
1448
+	    if ($e != NULL) {
1449
+	    	var_dump($e);
1450
+	    }
1050 1451
 	    if ($n > 0) {
1051 1452
 		$reset = 0;
1052 1453
 		foreach ($read as $nb => $r) {
@@ -1067,12 +1468,16 @@  discard block
 block discarded – undo
1067 1468
 		    //$SI::del();
1068 1469
 		    if ($format == 'vrstcp') {
1069 1470
 			$buffer = explode('},{',$buffer);
1070
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1471
+		    } else {
1472
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1473
+		    }
1071 1474
 		    // SBS format is CSV format
1072 1475
 		    if ($buffer !== FALSE && $buffer != '') {
1073 1476
 			$tt[$format] = 0;
1074 1477
 			if ($format == 'acarssbs3') {
1075
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1478
+			    if ($globalDebug) {
1479
+			    	echo 'ACARS : '.$buffer."\n";
1480
+			    }
1076 1481
 			    $ACARS->add(trim($buffer));
1077 1482
 			    $ACARS->deleteLiveAcarsData();
1078 1483
 			} elseif ($format == 'raw') {
@@ -1081,28 +1486,64 @@  discard block
 block discarded – undo
1081 1486
 			    if (is_array($data)) {
1082 1487
 				$data['datetime'] = date('Y-m-d H:i:s');
1083 1488
 				$data['format_source'] = 'raw';
1084
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1085
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1086
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1087
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1489
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1490
+					$data['source_name'] = $globalSources[$nb]['name'];
1491
+				}
1492
+				if (isset($globalSources[$nb]['sourcestats'])) {
1493
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1494
+				}
1495
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1496
+					$data['noarchive'] = true;
1497
+				}
1498
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1499
+					$SI->add($data);
1500
+				}
1088 1501
 			    }
1089 1502
 			} elseif ($format == 'ais') {
1090 1503
 			    $ais_data = $AIS->parse_line(trim($buffer));
1091 1504
 			    $data = array();
1092
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1093
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1094
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1095
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1096
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1097
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1098
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1099
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1100
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1101
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1102
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1103
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1104
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1105
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1505
+			    if (isset($ais_data['ident'])) {
1506
+			    	$data['ident'] = $ais_data['ident'];
1507
+			    }
1508
+			    if (isset($ais_data['mmsi'])) {
1509
+			    	$data['mmsi'] = $ais_data['mmsi'];
1510
+			    }
1511
+			    if (isset($ais_data['speed'])) {
1512
+			    	$data['speed'] = $ais_data['speed'];
1513
+			    }
1514
+			    if (isset($ais_data['heading'])) {
1515
+			    	$data['heading'] = $ais_data['heading'];
1516
+			    }
1517
+			    if (isset($ais_data['latitude'])) {
1518
+			    	$data['latitude'] = $ais_data['latitude'];
1519
+			    }
1520
+			    if (isset($ais_data['longitude'])) {
1521
+			    	$data['longitude'] = $ais_data['longitude'];
1522
+			    }
1523
+			    if (isset($ais_data['status'])) {
1524
+			    	$data['status'] = $ais_data['status'];
1525
+			    }
1526
+			    if (isset($ais_data['statusid'])) {
1527
+			    	$data['status_id'] = $ais_data['statusid'];
1528
+			    }
1529
+			    if (isset($ais_data['type'])) {
1530
+			    	$data['type'] = $ais_data['type'];
1531
+			    }
1532
+			    if (isset($ais_data['imo'])) {
1533
+			    	$data['imo'] = $ais_data['imo'];
1534
+			    }
1535
+			    if (isset($ais_data['callsign'])) {
1536
+			    	$data['callsign'] = $ais_data['callsign'];
1537
+			    }
1538
+			    if (isset($ais_data['destination'])) {
1539
+			    	$data['arrival_code'] = $ais_data['destination'];
1540
+			    }
1541
+			    if (isset($ais_data['eta_ts'])) {
1542
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1543
+			    }
1544
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1545
+			    	$data['noarchive'] = true;
1546
+			    }
1106 1547
 
1107 1548
 			    if (isset($ais_data['timestamp'])) {
1108 1549
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1111,7 +1552,9 @@  discard block
 block discarded – undo
1111 1552
 			    }
1112 1553
 			    $data['format_source'] = 'aisnmea';
1113 1554
     			    $data['id_source'] = $id_source;
1114
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1555
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1556
+			    	$MI->add($data);
1557
+			    }
1115 1558
 			    unset($data);
1116 1559
                         } elseif ($format == 'flightgearsp') {
1117 1560
                     	    //echo $buffer."\n";
@@ -1129,12 +1572,18 @@  discard block
 block discarded – undo
1129 1572
 				$data['speed'] = round($line[5]*1.94384);
1130 1573
 				$data['datetime'] = date('Y-m-d H:i:s');
1131 1574
 				$data['format_source'] = 'flightgearsp';
1132
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1133
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1575
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1576
+					$data['noarchive'] = true;
1577
+				}
1578
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1579
+					$SI->add($data);
1580
+				}
1134 1581
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1135 1582
 			    }
1136 1583
                         } elseif ($format == 'acars') {
1137
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1584
+                    	    if ($globalDebug) {
1585
+                    	    	echo 'ACARS : '.$buffer."\n";
1586
+                    	    }
1138 1587
 			    $ACARS->add(trim($buffer));
1139 1588
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1140 1589
 			    $ACARS->deleteLiveAcarsData();
@@ -1155,8 +1604,12 @@  discard block
 block discarded – undo
1155 1604
 				    $aircraft_type = $line[10];
1156 1605
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1157 1606
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1158
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1159
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1607
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1608
+				    	$data['noarchive'] = true;
1609
+				    }
1610
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1611
+				    	$SI->add($data);
1612
+				    }
1160 1613
 				}
1161 1614
 			    }
1162 1615
 			} elseif ($format == 'beast') {
@@ -1166,28 +1619,62 @@  discard block
 block discarded – undo
1166 1619
 			    foreach($buffer as $all_data) {
1167 1620
 				$line = json_decode('{'.$all_data.'}',true);
1168 1621
 				$data = array();
1169
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1170
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1171
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1172
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1173
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1174
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1175
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1622
+				if (isset($line['Icao'])) {
1623
+					$data['hex'] = $line['Icao'];
1624
+				}
1625
+				// hex
1626
+				if (isset($line['Call'])) {
1627
+					$data['ident'] = $line['Call'];
1628
+				}
1629
+				// ident
1630
+				if (isset($line['Alt'])) {
1631
+					$data['altitude'] = $line['Alt'];
1632
+				}
1633
+				// altitude
1634
+				if (isset($line['Spd'])) {
1635
+					$data['speed'] = $line['Spd'];
1636
+				}
1637
+				// speed
1638
+				if (isset($line['Trak'])) {
1639
+					$data['heading'] = $line['Trak'];
1640
+				}
1641
+				// heading
1642
+				if (isset($line['Lat'])) {
1643
+					$data['latitude'] = $line['Lat'];
1644
+				}
1645
+				// lat
1646
+				if (isset($line['Long'])) {
1647
+					$data['longitude'] = $line['Long'];
1648
+				}
1649
+				// long
1176 1650
 				//$data['verticalrate'] = $line['']; // verticale rate
1177
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1651
+				if (isset($line['Sqk'])) {
1652
+					$data['squawk'] = $line['Sqk'];
1653
+				}
1654
+				// squawk
1178 1655
 				$data['emergency'] = ''; // emergency
1179
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1656
+				if (isset($line['Reg'])) {
1657
+					$data['registration'] = $line['Reg'];
1658
+				}
1180 1659
 				/*
1181 1660
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1182 1661
 				else $data['datetime'] = date('Y-m-d H:i:s');
1183 1662
 				*/
1184 1663
 				$data['datetime'] = date('Y-m-d H:i:s');
1185
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1664
+				if (isset($line['Type'])) {
1665
+					$data['aircraft_icao'] = $line['Type'];
1666
+				}
1186 1667
 		    		$data['format_source'] = 'vrstcp';
1187 1668
 				$data['id_source'] = $id_source;
1188
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1189
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1190
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1669
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1670
+					$data['noarchive'] = true;
1671
+				}
1672
+				if (isset($value['name']) && $value['name'] != '') {
1673
+					$data['source_name'] = $value['name'];
1674
+				}
1675
+				if (isset($data['latitude']) && isset($data['hex'])) {
1676
+					$SI->add($data);
1677
+				}
1191 1678
 				unset($data);
1192 1679
 			    }
1193 1680
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1200,22 +1687,46 @@  discard block
 block discarded – undo
1200 1687
     				$data['hex'] = $lined['hexid'];
1201 1688
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1202 1689
     				$data['datetime'] = date('Y-m-d H:i:s');;
1203
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1204
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1205
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1206
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1207
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1208
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1209
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1690
+    				if (isset($lined['ident'])) {
1691
+    					$data['ident'] = $lined['ident'];
1692
+    				}
1693
+    				if (isset($lined['lat'])) {
1694
+    					$data['latitude'] = $lined['lat'];
1695
+    				}
1696
+    				if (isset($lined['lon'])) {
1697
+    					$data['longitude'] = $lined['lon'];
1698
+    				}
1699
+    				if (isset($lined['speed'])) {
1700
+    					$data['speed'] = $lined['speed'];
1701
+    				}
1702
+    				if (isset($lined['squawk'])) {
1703
+    					$data['squawk'] = $lined['squawk'];
1704
+    				}
1705
+    				if (isset($lined['alt'])) {
1706
+    					$data['altitude'] = $lined['alt'];
1707
+    				}
1708
+    				if (isset($lined['heading'])) {
1709
+    					$data['heading'] = $lined['heading'];
1710
+    				}
1210 1711
     				$data['id_source'] = $id_source;
1211 1712
     				$data['format_source'] = 'tsv';
1212
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1213
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1214
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1215
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1713
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1714
+    					$data['source_name'] = $globalSources[$nb]['name'];
1715
+    				}
1716
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1717
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1718
+    				}
1719
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1720
+					$data['noarchive'] = true;
1721
+				}
1722
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1723
+    					$SI->add($data);
1724
+    				}
1216 1725
     				unset($lined);
1217 1726
     				unset($data);
1218
-    			    } else $error = true;
1727
+    			    } else {
1728
+    			    	$error = true;
1729
+    			    }
1219 1730
 			} elseif ($format == 'aprs' && $use_aprs) {
1220 1731
 			    if ($aprs_connect == 0) {
1221 1732
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1240,37 +1751,81 @@  discard block
 block discarded – undo
1240 1751
 				    $aprs_last_tx = time();
1241 1752
 				    $data = array();
1242 1753
 				    //print_r($line);
1243
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1244
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1245
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1246
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1247
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1248
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1249
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1250
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1251
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1754
+				    if (isset($line['address'])) {
1755
+				    	$data['hex'] = $line['address'];
1756
+				    }
1757
+				    if (isset($line['mmsi'])) {
1758
+				    	$data['mmsi'] = $line['mmsi'];
1759
+				    }
1760
+				    if (isset($line['imo'])) {
1761
+				    	$data['imo'] = $line['imo'];
1762
+				    }
1763
+				    if (isset($line['arrival_code'])) {
1764
+				    	$data['arrical_code'] = $line['arrival_code'];
1765
+				    }
1766
+				    if (isset($line['arrival_date'])) {
1767
+				    	$data['arrical_date'] = $line['arrival_date'];
1768
+				    }
1769
+				    if (isset($line['type_id'])) {
1770
+				    	$data['type_id'] = $line['typeid'];
1771
+				    }
1772
+				    if (isset($line['status_id'])) {
1773
+				    	$data['status_id'] = $line['statusid'];
1774
+				    }
1775
+				    if (isset($line['timestamp'])) {
1776
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1777
+				    } else {
1778
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1779
+				    }
1252 1780
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1253
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1781
+				    if (isset($line['ident'])) {
1782
+				    	$data['ident'] = $line['ident'];
1783
+				    }
1254 1784
 				    $data['latitude'] = $line['latitude'];
1255 1785
 				    $data['longitude'] = $line['longitude'];
1256 1786
 				    //$data['verticalrate'] = $line[16];
1257
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1258
-				    else $data['speed'] = 0;
1259
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1260
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1261
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1262
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1787
+				    if (isset($line['speed'])) {
1788
+				    	$data['speed'] = $line['speed'];
1789
+				    } else {
1790
+				    	$data['speed'] = 0;
1791
+				    }
1792
+				    if (isset($line['altitude'])) {
1793
+				    	$data['altitude'] = $line['altitude'];
1794
+				    }
1795
+				    if (isset($line['comment'])) {
1796
+				    	$data['comment'] = $line['comment'];
1797
+				    }
1798
+				    if (isset($line['symbol'])) {
1799
+				    	$data['type'] = $line['symbol'];
1800
+				    }
1801
+				    if (isset($line['heading'])) {
1802
+				    	$data['heading'] = $line['heading'];
1803
+				    }
1263 1804
 				    //else $data['heading'] = 0;
1264
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1265
-				    if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1266
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1805
+				    if (isset($line['stealth'])) {
1806
+				    	$data['aircraft_type'] = $line['stealth'];
1807
+				    }
1808
+				    if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) {
1809
+				    	$data['noarchive'] = true;
1810
+				    }
1811
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1812
+				    	$data['noarchive'] = true;
1813
+				    }
1267 1814
     				    $data['id_source'] = $id_source;
1268
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1269
-				    else $data['format_source'] = 'aprs';
1815
+    				    if (isset($line['format_source'])) {
1816
+    				    	$data['format_source'] = $line['format_source'];
1817
+    				    } else {
1818
+				    	$data['format_source'] = 'aprs';
1819
+				    }
1270 1820
 				    $data['source_name'] = $line['source'];
1271
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1272
-				    else $data['source_type'] = 'flarm';
1273
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1821
+				    if (isset($line['source_type'])) {
1822
+				    	$data['source_type'] = $line['source_type'];
1823
+				    } else {
1824
+				    	$data['source_type'] = 'flarm';
1825
+				    }
1826
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1827
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1828
+    				    }
1274 1829
 				    $currentdate = date('Y-m-d H:i:s');
1275 1830
 				    $aprsdate = strtotime($data['datetime']);
1276 1831
 				    // Accept data if time <= system time + 20s
@@ -1281,19 +1836,22 @@  discard block
 block discarded – undo
1281 1836
 					echo 'add...'."\n";
1282 1837
 					$send = $MI->add($data);
1283 1838
 				    } elseif (isset($line['stealth'])) {
1284
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1285
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1839
+					if ($line['stealth'] != 0) {
1840
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1841
+					} else {
1842
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1843
+					}
1286 1844
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1287 1845
 				    } 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') {
1288 1846
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1289
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1847
+					if (isset($globalTracker) && $globalTracker) {
1848
+						$send = $TI->add($data);
1849
+					}
1290 1850
 				    }
1291 1851
 				    unset($data);
1292
-				} 
1293
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1852
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1294 1853
 					echo '!! Weather Station not yet supported'."\n";
1295
-				}
1296
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
1854
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
1297 1855
 					echo '!! Car & Trucks not yet supported'."\n";
1298 1856
 				}
1299 1857
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
@@ -1326,26 +1884,45 @@  discard block
 block discarded – undo
1326 1884
     				$data['ground'] = $line[21];
1327 1885
     				$data['emergency'] = $line[19];
1328 1886
     				$data['format_source'] = 'sbs';
1329
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1330
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1331
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1887
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1888
+					$data['source_name'] = $globalSources[$nb]['name'];
1889
+				}
1890
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1891
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1892
+    				}
1893
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1894
+					$data['noarchive'] = true;
1895
+				}
1332 1896
     				$data['id_source'] = $id_source;
1333
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1334
-    				else $error = true;
1897
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1898
+    					$send = $SI->add($data);
1899
+    				} else {
1900
+    					$error = true;
1901
+    				}
1335 1902
     				unset($data);
1336
-    			    } else $error = true;
1903
+    			    } else {
1904
+    			    	$error = true;
1905
+    			    }
1337 1906
 			    if ($error) {
1338 1907
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1339
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1908
+					if ($globalDebug) {
1909
+						echo "Not a message. Ignoring... \n";
1910
+					}
1340 1911
 				} else {
1341
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1912
+					if ($globalDebug) {
1913
+						echo "Wrong line format. Ignoring... \n";
1914
+					}
1342 1915
 					if ($globalDebug) {
1343 1916
 						echo $buffer;
1344 1917
 						//print_r($line);
1345 1918
 					}
1346 1919
 					//socket_close($r);
1347
-					if ($globalDebug) echo "Reconnect after an error...\n";
1348
-					if ($format == 'aprs') $aprs_connect = 0;
1920
+					if ($globalDebug) {
1921
+						echo "Reconnect after an error...\n";
1922
+					}
1923
+					if ($format == 'aprs') {
1924
+						$aprs_connect = 0;
1925
+					}
1349 1926
 					$sourceer[$nb] = $globalSources[$nb];
1350 1927
 					connect_all($sourceer);
1351 1928
 					$sourceer = array();
@@ -1353,10 +1930,14 @@  discard block
 block discarded – undo
1353 1930
 			    }
1354 1931
 			}
1355 1932
 			// Sleep for xxx microseconds
1356
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1933
+			if (isset($globalSBSSleep)) {
1934
+				usleep($globalSBSSleep);
1935
+			}
1357 1936
 		    } else {
1358 1937
 			if ($format == 'flightgearmp') {
1359
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1938
+			    	if ($globalDebug) {
1939
+			    		echo "Reconnect FlightGear MP...";
1940
+			    	}
1360 1941
 				//@socket_close($r);
1361 1942
 				sleep($globalMinFetch);
1362 1943
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1365,10 +1946,15 @@  discard block
 block discarded – undo
1365 1946
 				break;
1366 1947
 				
1367 1948
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1368
-			    if (isset($tt[$format])) $tt[$format]++;
1369
-			    else $tt[$format] = 0;
1949
+			    if (isset($tt[$format])) {
1950
+			    	$tt[$format]++;
1951
+			    } else {
1952
+			    	$tt[$format] = 0;
1953
+			    }
1370 1954
 			    if ($tt[$format] > 30) {
1371
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1955
+				if ($globalDebug) {
1956
+					echo "ERROR : Reconnect ".$format."...";
1957
+				}
1372 1958
 				//@socket_close($r);
1373 1959
 				sleep(2);
1374 1960
 				$aprs_connect = 0;
@@ -1385,11 +1971,17 @@  discard block
 block discarded – undo
1385 1971
 	    } else {
1386 1972
 		$error = socket_strerror(socket_last_error());
1387 1973
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1388
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1389
-			if (isset($globalDebug)) echo "Restarting...\n";
1974
+			if ($globalDebug) {
1975
+				echo "ERROR : socket_select give this error ".$error . "\n";
1976
+			}
1977
+			if (isset($globalDebug)) {
1978
+				echo "Restarting...\n";
1979
+			}
1390 1980
 			// Restart the script if possible
1391 1981
 			if (is_array($sockets)) {
1392
-			    if ($globalDebug) echo "Shutdown all sockets...";
1982
+			    if ($globalDebug) {
1983
+			    	echo "Shutdown all sockets...";
1984
+			    }
1393 1985
 			    
1394 1986
 			    foreach ($sockets as $sock) {
1395 1987
 				@socket_shutdown($sock,2);
@@ -1397,22 +1989,36 @@  discard block
 block discarded – undo
1397 1989
 			    }
1398 1990
 			    
1399 1991
 			}
1400
-			if ($globalDebug) echo "Waiting...";
1992
+			if ($globalDebug) {
1993
+				echo "Waiting...";
1994
+			}
1401 1995
 			sleep(2);
1402 1996
 			$time = time();
1403 1997
 			//connect_all($hosts);
1404 1998
 			$aprs_connect = 0;
1405
-			if ($reset%5 == 0) sleep(20);
1406
-			if ($reset%10 == 0) sleep(100);
1407
-			if ($reset%20 == 0) sleep(200);
1408
-			if ($reset > 100) exit('Too many attempts...');
1409
-			if ($globalDebug) echo "Restart all connections...";
1999
+			if ($reset%5 == 0) {
2000
+				sleep(20);
2001
+			}
2002
+			if ($reset%10 == 0) {
2003
+				sleep(100);
2004
+			}
2005
+			if ($reset%20 == 0) {
2006
+				sleep(200);
2007
+			}
2008
+			if ($reset > 100) {
2009
+				exit('Too many attempts...');
2010
+			}
2011
+			if ($globalDebug) {
2012
+				echo "Restart all connections...";
2013
+			}
1410 2014
 			connect_all($globalSources);
1411 2015
 		}
1412 2016
 	    }
1413 2017
 	}
1414 2018
 	if ($globalDaemon === false) {
1415
-	    if ($globalDebug) echo 'Check all...'."\n";
2019
+	    if ($globalDebug) {
2020
+	    	echo 'Check all...'."\n";
2021
+	    }
1416 2022
 	    $SI->checkAll();
1417 2023
 	}
1418 2024
     }
Please login to merge, or discard this patch.
ident.php 1 patch
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,13 +1,20 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $ident = '';
4
-if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING);
5
-if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
4
+if (isset($_POST['ident'])) {
5
+	$ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING);
6
+}
7
+if (isset($_GET['ident'])) {
8
+	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
9
+}
6 10
 if ($ident != '')
7 11
 {
8
-	if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident);
9
-	else header('Location: '.$globalURL.'/ident/'.$ident);
10
-} else {
12
+	if (isset($_GET['marine'])) {
13
+		header('Location: '.$globalURL.'/marine/ident/'.$ident);
14
+	} else {
15
+		header('Location: '.$globalURL.'/ident/'.$ident);
16
+	}
17
+	} else {
11 18
 	header('Location: '.$globalURL);
12 19
 }
13 20
 ?>
14 21
\ No newline at end of file
Please login to merge, or discard this patch.
ident-detailed.php 1 patch
Braces   +22 added lines, -8 removed lines patch added patch discarded remove patch
@@ -118,8 +118,12 @@  discard block
 block discarded – undo
118 118
 	{
119 119
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['ident']);
120 120
 		$ident = $spotter_array[0]['ident'];
121
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
122
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
121
+		if (isset($spotter_array[0]['latitude'])) {
122
+			$latitude = $spotter_array[0]['latitude'];
123
+		}
124
+		if (isset($spotter_array[0]['longitude'])) {
125
+			$longitude = $spotter_array[0]['longitude'];
126
+		}
123 127
 		require_once('header.php');
124 128
 		if (isset($globalArchive) && $globalArchive && $type == 'aircraft') {
125 129
 			// Requirement for altitude graph
@@ -127,7 +131,9 @@  discard block
 block discarded – undo
127 131
 			$all_data = $SpotterArchive->getAltitudeSpeedArchiveSpotterDataById($spotter_array[0]['flightaware_id']);
128 132
 			if (isset($globalTimezone)) {
129 133
 				date_default_timezone_set($globalTimezone);
130
-			} else date_default_timezone_set('UTC');
134
+			} else {
135
+				date_default_timezone_set('UTC');
136
+			}
131 137
 			if (count($all_data) > 0) {
132 138
 				print '<div id="chart6" class="chart" width="100%"></div>
133 139
                     <script> 
@@ -174,14 +180,22 @@  discard block
 block discarded – undo
174 180
 		if (isset($spotter_array[0]['airline_icao'])) {
175 181
 			print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>'; 
176 182
 		}
177
-		if ($type == 'aircraft') print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>';
183
+		if ($type == 'aircraft') {
184
+			print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>';
185
+		}
178 186
 		print '</div>';
179 187
 	
180
-		if ($type == 'aircraft') include('ident-sub-menu.php');
188
+		if ($type == 'aircraft') {
189
+			include('ident-sub-menu.php');
190
+		}
181 191
 		print '<div class="table column">';
182
-		if ($type == 'aircraft') print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
183
-		elseif ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
184
-		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
192
+		if ($type == 'aircraft') {
193
+			print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
194
+		} elseif ($type == 'marine') {
195
+			print '<p>'.sprintf(_("The table below shows the detailed information of all vessels with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
196
+		} elseif ($type == 'tracker') {
197
+			print '<p>'.sprintf(_("The table below shows the detailed information of all trackers with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
198
+		}
185 199
 
186 200
 		include('table-output.php'); 
187 201
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
currently.php 1 patch
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	$limit_start = 0;
32 32
 	$limit_end = 25;
33 33
 	$absolute_difference = 25;
34
-}  else {
34
+} else {
35 35
 	$limit_explode = explode(",", $_GET['limit']);
36 36
 	$limit_start = $limit_explode[0];
37 37
 	$limit_end = $limit_explode[1];
@@ -50,20 +50,32 @@  discard block
 block discarded – undo
50 50
 print '</div>';
51 51
 
52 52
 print '<div class="table column">';
53
-if ($type == 'aircraft') print '<p>'._("The table below shows the detailed information of all current flights.").'</p>';
54
-elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>';
55
-elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>';
53
+if ($type == 'aircraft') {
54
+	print '<p>'._("The table below shows the detailed information of all current flights.").'</p>';
55
+} elseif ($type == 'marine') {
56
+	print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>';
57
+} elseif ($type == 'tracker') {
58
+	print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>';
59
+}
56 60
 
57 61
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
58 62
 if ($sort != '') {
59
-	if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort);
60
-	elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort);
61
-	elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort);
62
-} else {
63
-	if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference);
64
-	elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference);
65
-	elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference);
66
-}
63
+	if ($type == 'aircraft') {
64
+		$spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort);
65
+	} elseif ($type == 'marine') {
66
+		$spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort);
67
+	} elseif ($type == 'tracker') {
68
+		$spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort);
69
+	}
70
+	} else {
71
+	if ($type == 'aircraft') {
72
+		$spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference);
73
+	} elseif ($type == 'marine') {
74
+		$spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference);
75
+	} elseif ($type == 'tracker') {
76
+		$spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference);
77
+	}
78
+	}
67 79
 
68 80
 if (!empty($spotter_array))
69 81
 {
Please login to merge, or discard this patch.
date.php 1 patch
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,20 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $type = 'aircraft';
4
-if (isset($_GET['marine'])) $type = 'marine';
5
-elseif (isset($_GET['tracker'])) $type = 'tracker';
4
+if (isset($_GET['marine'])) {
5
+	$type = 'marine';
6
+} elseif (isset($_GET['tracker'])) {
7
+	$type = 'tracker';
8
+}
6 9
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
7
-if ($date == '') $date = date('Y-m-d');
8
-if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date);
9
-elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date);
10
-else header('Location: '.$globalURL.'/date/'.$date);
10
+if ($date == '') {
11
+	$date = date('Y-m-d');
12
+}
13
+if ($type == 'marine') {
14
+	header('Location: '.$globalURL.'/marine/date/'.$date);
15
+} elseif ($type == 'tracker') {
16
+	header('Location: '.$globalURL.'/tracker/date/'.$date);
17
+} else {
18
+	header('Location: '.$globalURL.'/date/'.$date);
19
+}
11 20
 ?>
12 21
\ No newline at end of file
Please login to merge, or discard this patch.
date-detailed.php 1 patch
Braces   +37 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		$limit_start = 0;
30 30
 		$limit_end = 25;
31 31
 		$absolute_difference = 25;
32
-	}  else {
32
+	} else {
33 33
 		$limit_explode = explode(",", $_GET['limit']);
34 34
 		$limit_start = $limit_explode[0];
35 35
 		$limit_end = $limit_explode[1];
@@ -46,21 +46,33 @@  discard block
 block discarded – undo
46 46
 	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
47 47
 	if ($sort != '') 
48 48
 	{
49
-		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort);
50
-		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort);
51
-		else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort);
49
+		if ($type == 'marine') {
50
+			$spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort);
51
+		} elseif ($type == 'tracker') {
52
+			$spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort);
53
+		} else {
54
+			$spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort);
55
+		}
52 56
 	} else {
53
-		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference);
54
-		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference);
55
-		else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference);
57
+		if ($type == 'marine') {
58
+			$spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference);
59
+		} elseif ($type == 'tracker') {
60
+			$spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference);
61
+		} else {
62
+			$spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference);
63
+		}
56 64
 	}
57 65
 	
58 66
 	if (!empty($spotter_array))
59 67
 	{
60 68
 		date_default_timezone_set($globalTimezone);
61
-		if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
62
-		elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
63
-		else $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
69
+		if ($type == 'marine') {
70
+			$title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
71
+		} elseif ($type == 'tracker') {
72
+			$title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
73
+		} else {
74
+			$title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
75
+		}
64 76
 
65 77
 		require_once('header.php');
66 78
 		print '<div class="select-item">';
@@ -78,15 +90,24 @@  discard block
 block discarded – undo
78 90
 		print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
79 91
 		print '<br />';
80 92
 		print '<div class="info column">';
81
-		if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
82
-		else print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
93
+		if ($type == 'marine') {
94
+			print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
95
+		} else {
96
+			print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
97
+		}
83 98
 		print '</div>';
84 99
 
85
-		if ($type == 'aircraft') include('date-sub-menu.php');
100
+		if ($type == 'aircraft') {
101
+			include('date-sub-menu.php');
102
+		}
86 103
 		print '<div class="table column">';
87
-		if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
88
-		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
89
-		else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
104
+		if ($type == 'marine') {
105
+			print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
106
+		} elseif ($type == 'tracker') {
107
+			print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
108
+		} else {
109
+			print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
110
+		}
90 111
  
91 112
 		include('table-output.php');
92 113
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
require/class.TrackerImport.php 1 patch
Braces   +158 added lines, -54 removed lines patch added patch discarded remove patch
@@ -44,7 +44,9 @@  discard block
 block discarded – undo
44 44
 
45 45
     public function checkAll() {
46 46
 	global $globalDebug;
47
-	if ($globalDebug) echo "Update last seen tracked data...\n";
47
+	if ($globalDebug) {
48
+		echo "Update last seen tracked data...\n";
49
+	}
48 50
 	foreach ($this->all_tracked as $key => $flight) {
49 51
 	    if (isset($this->all_tracked[$key]['id'])) {
50 52
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -57,12 +59,16 @@  discard block
 block discarded – undo
57 59
     public function del() {
58 60
 	global $globalDebug;
59 61
 	// Delete old infos
60
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
62
+	if ($globalDebug) {
63
+		echo 'Delete old values and update latest data...'."\n";
64
+	}
61 65
 	foreach ($this->all_tracked as $key => $flight) {
62 66
     	    if (isset($flight['lastupdate'])) {
63 67
         	if ($flight['lastupdate'] < (time()-3000)) {
64 68
             	    if (isset($this->all_tracked[$key]['id'])) {
65
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		if ($globalDebug) {
70
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
71
+            		}
66 72
 			/*
67 73
 			$TrackerLive = new TrackerLive();
68 74
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
@@ -72,7 +78,9 @@  discard block
 block discarded – undo
72 78
             		$Tracker = new Tracker($this->db);
73 79
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
74 80
 				$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']);
75
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
81
+				if ($globalDebug && $result != 'success') {
82
+					echo '!!! ERROR : '.$result."\n";
83
+				}
76 84
 			}
77 85
 			// Put in archive
78 86
 //			$Tracker->db = null;
@@ -85,7 +93,9 @@  discard block
 block discarded – undo
85 93
 
86 94
     public function add($line) {
87 95
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
88
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
96
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
97
+		$globalCoordMinChange = '0.02';
98
+	}
89 99
 	date_default_timezone_set('UTC');
90 100
 	$dataFound = false;
91 101
 	$send = false;
@@ -109,8 +119,11 @@  discard block
 block discarded – undo
109 119
 		*/
110 120
 		
111 121
 		$Common = new Common();
112
-	        if (!isset($line['id'])) $id = trim($line['ident']);
113
-	        else $id = trim($line['id']);
122
+	        if (!isset($line['id'])) {
123
+	        	$id = trim($line['ident']);
124
+	        } else {
125
+	        	$id = trim($line['id']);
126
+	        }
114 127
 		
115 128
 		if (!isset($this->all_tracked[$id])) {
116 129
 		    $this->all_tracked[$id] = array();
@@ -118,31 +131,46 @@  discard block
 block discarded – undo
118 131
 		    $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' => ''));
119 132
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
120 133
 		    if (!isset($line['id'])) {
121
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
134
+			if (!isset($globalDaemon)) {
135
+				$globalDaemon = TRUE;
136
+			}
122 137
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
123
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
124
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
138
+		     } else {
139
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
140
+		     }
141
+		    if ($globalAllTracked !== FALSE) {
142
+		    	$dataFound = true;
143
+		    }
125 144
 		}
126 145
 		
127 146
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
128 147
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
129 148
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
130 149
 		    } else {
131
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
132
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
150
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
151
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
152
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
153
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
154
+				}
133 155
 				return '';
134 156
 		    }
135 157
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
136
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
158
+			if ($globalDebug) {
159
+				echo "!!! Date is too old ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
160
+			}
137 161
 			return '';
138 162
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
139
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
163
+			if ($globalDebug) {
164
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
165
+			}
140 166
 			return '';
141 167
 		} elseif (!isset($line['datetime'])) {
142 168
 			date_default_timezone_set('UTC');
143 169
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
144 170
 		} else {
145
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
171
+			if ($globalDebug) {
172
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!";
173
+			}
146 174
 			return '';
147 175
 		}
148 176
 		
@@ -154,11 +182,17 @@  discard block
 block discarded – undo
154 182
             		$Tracker = new Tracker($this->db);
155 183
             		$fromsource = NULL;
156 184
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
157
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
185
+			if ($globalDebug && $result != 'success') {
186
+				echo '!!! ERROR : '.$result."\n";
187
+			}
158 188
 			$Tracker->db = null;
159
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
189
+			if ($globalDebugTimeElapsed) {
190
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
191
+			}
192
+		    }
193
+		    if (!isset($this->all_tracked[$id]['id'])) {
194
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
160 195
 		    }
161
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
162 196
 		}
163 197
 
164 198
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -169,14 +203,21 @@  discard block
 block discarded – undo
169 203
 		    if ($distance > 1000 && $distance < 10000) {
170 204
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
171 205
 			$speed = $speed*3.6;
172
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
173
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
206
+			if ($speed < 1000) {
207
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
208
+			}
209
+  			if ($globalDebug) {
210
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
211
+  			}
174 212
 		    }
175 213
 		}
176 214
 
177 215
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
178
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
179
-	    	    else unset($timediff);
216
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
217
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
218
+	    	    } else {
219
+	    	    	unset($timediff);
220
+	    	    }
180 221
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
181 222
 			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'])) {
182 223
 			    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'])) {
@@ -184,20 +225,30 @@  discard block
 block discarded – undo
184 225
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
185 226
 				$this->all_tracked[$id]['putinarchive'] = true;
186 227
 				
187
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
228
+				if ($globalDebug) {
229
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
230
+				}
188 231
 				$timeelapsed = microtime(true);
189 232
 				$Tracker = new Tracker($this->db);
190 233
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
191
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
234
+				if (!empty($all_country)) {
235
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
236
+				}
192 237
 				$Tracker->db = null;
193
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
238
+				if ($globalDebugTimeElapsed) {
239
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
240
+				}
194 241
 				$this->tmd = 0;
195
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
242
+				if ($globalDebug) {
243
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
244
+				}
196 245
 			    }
197 246
 			}
198 247
 
199 248
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
200
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
249
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
250
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
251
+				}
201 252
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
202 253
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
203 254
 				    $dataFound = true;
@@ -206,8 +257,12 @@  discard block
 block discarded – undo
206 257
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
207 258
 			}
208 259
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
209
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
210
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
260
+			    if ($line['longitude'] > 180) {
261
+			    	$line['longitude'] = $line['longitude'] - 360;
262
+			    }
263
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
264
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
265
+				}
211 266
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
212 267
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
213 268
 				    $dataFound = true;
@@ -225,7 +280,9 @@  discard block
 block discarded – undo
225 280
 		    }
226 281
 		}
227 282
 		if (isset($line['last_update']) && $line['last_update'] != '') {
228
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
283
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
284
+		    	$dataFound = true;
285
+		    }
229 286
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
230 287
 		}
231 288
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -245,7 +302,9 @@  discard block
 block discarded – undo
245 302
 
246 303
 		if (isset($line['altitude']) && $line['altitude'] != '') {
247 304
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
248
-			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;
305
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
306
+				$this->all_tracked[$id]['putinarchive'] = true;
307
+			}
249 308
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100)));
250 309
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
251 310
 			//$dataFound = true;
@@ -257,15 +316,21 @@  discard block
 block discarded – undo
257 316
 		}
258 317
 		
259 318
 		if (isset($line['heading']) && $line['heading'] != '') {
260
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
319
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
320
+		    	$this->all_tracked[$id]['putinarchive'] = true;
321
+		    }
261 322
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
262 323
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
263 324
 		    //$dataFound = true;
264 325
   		} 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']) {
265 326
   		    $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']);
266 327
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
267
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
268
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
328
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
329
+		    	$this->all_tracked[$id]['putinarchive'] = true;
330
+		    }
331
+  		    if ($globalDebug) {
332
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
333
+  		    }
269 334
   		}
270 335
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
271 336
 
@@ -274,20 +339,31 @@  discard block
 block discarded – undo
274 339
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
275 340
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
276 341
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
277
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
342
+				if ($globalDebug) {
343
+					echo "Check if aircraft is already in DB...";
344
+				}
278 345
 				$timeelapsed = microtime(true);
279 346
 				$TrackerLive = new TrackerLive($this->db);
280 347
 				if (isset($line['id'])) {
281 348
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
282
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
349
+				    if ($globalDebugTimeElapsed) {
350
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
351
+				    }
283 352
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
284 353
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
285
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
286
-				} else $recent_ident = '';
354
+				    if ($globalDebugTimeElapsed) {
355
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
356
+				    }
357
+				} else {
358
+					$recent_ident = '';
359
+				}
287 360
 				$TrackerLive->db=null;
288 361
 
289
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
290
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
362
+				if ($globalDebug && $recent_ident == '') {
363
+					echo " Not in DB.\n";
364
+				} elseif ($globalDebug && $recent_ident != '') {
365
+					echo " Already in DB.\n";
366
+				}
291 367
 			    } else {
292 368
 				$recent_ident = '';
293 369
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -295,16 +371,24 @@  discard block
 block discarded – undo
295 371
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
296 372
 			    if($recent_ident == "")
297 373
 			    {
298
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
374
+				if ($globalDebug) {
375
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
376
+				}
299 377
 				//adds the spotter data for the archive
300 378
 				    $highlight = '';
301
-				    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')));
379
+				    if (!isset($this->all_tracked[$id]['id'])) {
380
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
381
+				    }
302 382
 				    $timeelapsed = microtime(true);
303 383
 				    $Tracker = new Tracker($this->db);
304 384
 				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
305 385
 				    $Tracker->db = null;
306
-				    if ($globalDebug && isset($result)) echo $result."\n";
307
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
386
+				    if ($globalDebug && isset($result)) {
387
+				    	echo $result."\n";
388
+				    }
389
+				    if ($globalDebugTimeElapsed) {
390
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
391
+				    }
308 392
 				    
309 393
 				    /*
310 394
 				    // Add source stat in DB
@@ -338,12 +422,16 @@  discard block
 block discarded – undo
338 422
 				$this->all_tracked[$id]['addedTracker'] = 1;
339 423
 				//print_r($this->all_tracked[$id]);
340 424
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
341
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
425
+				    if ($globalDebug) {
426
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
427
+				    }
342 428
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
343 429
 				    $TrackerLive = new TrackerLive($this->db);
344 430
 				    $TrackerLive->deleteLiveTrackerData();
345 431
 				    $TrackerLive->db=null;
346
-				    if ($globalDebug) echo " Done\n";
432
+				    if ($globalDebug) {
433
+				    	echo " Done\n";
434
+				    }
347 435
 				    $this->last_delete = time();
348 436
 				}
349 437
 			    } else {
@@ -366,13 +454,17 @@  discard block
 block discarded – undo
366 454
 
367 455
 		    if (!$ignoreImport) {
368 456
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
369
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
457
+				if ($globalDebug) {
458
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
459
+				}
370 460
 				$timeelapsed = microtime(true);
371 461
 				$TrackerLive = new TrackerLive($this->db);
372 462
 				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
373 463
 				$TrackerLive->db = null;
374 464
 				$this->all_tracked[$id]['putinarchive'] = false;
375
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
465
+				if ($globalDebugTimeElapsed) {
466
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
467
+				}
376 468
 
377 469
 				// Put statistics in $this->stats variable
378 470
 				/*
@@ -429,19 +521,29 @@  discard block
 block discarded – undo
429 521
 				*/
430 522
 
431 523
 				$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";
524
+				if ($this->all_tracked[$id]['putinarchive']) {
525
+					$send = true;
526
+				}
527
+				if ($globalDebug) {
528
+					echo $result."\n";
529
+				}
530
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
531
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
532
+			}
435 533
 			//$this->del();
436 534
 			
437 535
 			
438 536
 			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...";
537
+			    if ($globalDebug) {
538
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
539
+			    }
440 540
 			    $TrackerLive = new TrackerLive($this->db);
441 541
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442 542
 			    $TrackerLive->db = null;
443 543
 			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
544
+			    if ($globalDebug) {
545
+			    	echo " Done\n";
546
+			    }
445 547
 			    $this->last_delete_hourly = time();
446 548
 			}
447 549
 			
@@ -449,7 +551,9 @@  discard block
 block discarded – undo
449 551
 		    //$ignoreImport = false;
450 552
 		}
451 553
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452
-		if ($send) return $this->all_tracked[$id];
554
+		if ($send) {
555
+			return $this->all_tracked[$id];
556
+		}
453 557
 	    }
454 558
 	}
455 559
     }
Please login to merge, or discard this patch.
latest.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	$limit_start = 0;
29 29
 	$limit_end = 25;
30 30
 	$absolute_difference = 25;
31
-}  else {
31
+} else {
32 32
 	$limit_explode = explode(",", $_GET['limit']);
33 33
 	$limit_start = $limit_explode[0];
34 34
 	$limit_end = $limit_explode[1];
@@ -47,9 +47,13 @@  discard block
 block discarded – undo
47 47
 print '<h1>'._("Latest Activity").'</h1>';
48 48
 print '</div>';
49 49
 print '<div class="table column">';
50
-if ($type == 'marine') print '<p>'._("The table below shows the detailed information of all recent vessels.").'</p>';
51
-elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>';
52
-else print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>';
50
+if ($type == 'marine') {
51
+	print '<p>'._("The table below shows the detailed information of all recent vessels.").'</p>';
52
+} elseif ($type == 'tracker') {
53
+	print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>';
54
+} else {
55
+	print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>';
56
+}
53 57
 
54 58
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
55 59
 $sql_begin = microtime(true);
Please login to merge, or discard this patch.
table-output.php 1 patch
Braces   +63 added lines, -23 removed lines patch added patch discarded remove patch
@@ -7,7 +7,9 @@  discard block
 block discarded – undo
7 7
 $showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop');
8 8
 $showDuration = $Common->multiKeyExists($spotter_array,'duration');
9 9
 
10
-if (!isset($type)) $type = 'aircraft';
10
+if (!isset($type)) {
11
+	$type = 'aircraft';
12
+}
11 13
 
12 14
 if (!isset($_GET['sort'])) 
13 15
 {
@@ -440,7 +442,9 @@  discard block
 block discarded – undo
440 442
 	if (isset($globalTimezone))
441 443
 	{
442 444
 		date_default_timezone_set($globalTimezone);
443
-	} else date_default_timezone_set('UTC');
445
+	} else {
446
+		date_default_timezone_set('UTC');
447
+	}
444 448
 	if ($showSpecial === true)
445 449
 	{
446 450
 		print '<tr class="special">'."\n";
@@ -455,7 +459,9 @@  discard block
 block discarded – undo
455 459
 			print '<tr class="active">';
456 460
 		} elseif (isset($spotter_item['spotted_registration'])) {
457 461
 			print '<tr class="info">';
458
-		} else print '<tr>';
462
+		} else {
463
+			print '<tr>';
464
+		}
459 465
 	}
460 466
 	if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive" || strtolower($current_page) == "currently" || strtolower($current_page) == "accident-latest" || strtolower($current_page) == "incident-latest" || strtolower($current_page) == "accident-detailed" || strtolower($current_page) == "incident-detailed") {
461 467
 		if ($type == 'aircraft') {
@@ -463,8 +469,9 @@  discard block
 block discarded – undo
463 469
 			{
464 470
 				print '<td class="aircraft_thumbnail">'."\n";
465 471
 				if ($spotter_item['image_source'] == 'planespotters') {
466
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
467
-					else {
472
+					if ($spotter_item['image_source_website'] != '') {
473
+						$image_src = $spotter_item['image_source_website'];
474
+					} else {
468 475
 						$planespotter_url_array = explode("_", $spotter_item['image']);
469 476
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
470 477
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -477,7 +484,9 @@  discard block
 block discarded – undo
477 484
 				} else {
478 485
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
479 486
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
480
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
487
+					} else {
488
+						$image_thumbnail = $spotter_item['image_thumbnail'];
489
+					}
481 490
 					if (isset($spotter_item['airline_name'])) {
482 491
 						print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
483 492
 					} else {
@@ -496,7 +505,9 @@  discard block
 block discarded – undo
496 505
 				print '<td class="aircraft_thumbnail">'."\n";
497 506
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
498 507
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
499
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
508
+				} else {
509
+					$image_thumbnail = $spotter_item['image_thumbnail'];
510
+				}
500 511
 				if (isset($spotter_item['airline_name'])) {
501 512
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
502 513
 				} else {
@@ -514,7 +525,9 @@  discard block
 block discarded – undo
514 525
 				print '<td class="aircraft_thumbnail">'."\n";
515 526
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
516 527
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
517
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
528
+				} else {
529
+					$image_thumbnail = $spotter_item['image_thumbnail'];
530
+				}
518 531
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
519 532
 				print '</td>'."\n";
520 533
 			} else {
@@ -565,8 +578,9 @@  discard block
 block discarded – undo
565 578
 				print '<td class="aircraft_thumbnail">'."\n";
566 579
 				//print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
567 580
 				if ($spotter_item['image_source'] == 'planespotters') {
568
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
569
-					else {
581
+					if ($spotter_item['image_source_website'] != '') {
582
+						$image_src = $spotter_item['image_source_website'];
583
+					} else {
570 584
 						$planespotter_url_array = explode("_", $spotter_array[0]['image']);
571 585
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
572 586
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -583,7 +597,9 @@  discard block
 block discarded – undo
583 597
 				} else {
584 598
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
585 599
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
586
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
600
+					} else {
601
+						$image_thumbnail = $spotter_item['image_thumbnail'];
602
+					}
587 603
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
588 604
 						print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
589 605
 					} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
@@ -616,7 +632,9 @@  discard block
 block discarded – undo
616 632
 				print '<td class="aircraft_thumbnail">'."\n";
617 633
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
618 634
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
619
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
635
+				} else {
636
+					$image_thumbnail = $spotter_item['image_thumbnail'];
637
+				}
620 638
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
621 639
 				print '</td>'."\n";
622 640
 			} else {
@@ -630,7 +648,9 @@  discard block
 block discarded – undo
630 648
 				print '<td class="aircraft_thumbnail">'."\n";
631 649
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
632 650
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
633
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
651
+				} else {
652
+					$image_thumbnail = $spotter_item['image_thumbnail'];
653
+				}
634 654
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
635 655
 				print '</td>'."\n";
636 656
 			} else {
@@ -783,15 +803,21 @@  discard block
 block discarded – undo
783 803
 			if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
784 804
 				if ($spotter_item['departure_airport_time'] > 2460) {
785 805
 					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
786
-				} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
806
+				} else {
807
+					$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
808
+				}
787 809
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
788 810
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
789
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
811
+				} else {
812
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
813
+				}
790 814
 				print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
791 815
 			} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
792 816
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
793 817
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
794
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
818
+				} else {
819
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
820
+				}
795 821
 				print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
796 822
 			} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
797 823
 				if ($spotter_item['departure_airport_time'] > 2460) {
@@ -813,7 +839,9 @@  discard block
 block discarded – undo
813 839
 						$longitude = $spotter_item['longitude'];
814 840
 					}
815 841
 					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
816
-				} else $distance = '';
842
+				} else {
843
+					$distance = '';
844
+				}
817 845
 				if ($distance != '') {
818 846
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
819 847
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
@@ -840,7 +868,9 @@  discard block
 block discarded – undo
840 868
 			} else {
841 869
 				if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) {
842 870
 					print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n";
843
-					if (!isset($Spotter)) $Spotter = new Spotter();
871
+					if (!isset($Spotter)) {
872
+						$Spotter = new Spotter();
873
+					}
844 874
 					$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
845 875
 					print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n";
846 876
 					print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
@@ -856,20 +886,28 @@  discard block
 block discarded – undo
856 886
 			if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
857 887
 				if ($spotter_item['arrival_airport_time'] > 2460) {
858 888
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
859
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
889
+				} else {
890
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
891
+				}
860 892
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
861 893
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
862
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
894
+				} else {
895
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
896
+				}
863 897
 				print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
864 898
 			} elseif (isset($spotter_item['real_arrival_airport_time'])) {
865 899
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
866 900
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
867
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
901
+				} else {
902
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
903
+				}
868 904
 				print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
869 905
 			} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
870 906
 				if ($spotter_item['arrival_airport_time'] > 2460) {
871 907
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
872
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
908
+				} else {
909
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
910
+				}
873 911
 				print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
874 912
 			}
875 913
 			if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
@@ -882,7 +920,9 @@  discard block
 block discarded – undo
882 920
 						$longitude = $spotter_item['longitude'];
883 921
 					}
884 922
 					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
885
-				} else $distance = '';
923
+				} else {
924
+					$distance = '';
925
+				}
886 926
 				if ($distance != '') {
887 927
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
888 928
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
Please login to merge, or discard this patch.