Completed
Push — master ( e40365...d4de89 )
by Yannick
30:56
created
owner-detailed.php 1 patch
Braces   +23 added lines, -8 removed lines patch added patch discarded remove patch
@@ -45,8 +45,12 @@  discard block
 block discarded – undo
45 45
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
46 46
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
47 47
 	$filter = array();
48
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
49
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
48
+	if ($year != '') {
49
+		$filter = array_merge($filter,array('year' => $year));
50
+	}
51
+	if ($month != '') {
52
+		$filter = array_merge($filter,array('month' => $month));
53
+	}
50 54
 	if ($sort != '') 
51 55
 	{
52 56
 		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -64,8 +68,12 @@  discard block
 block discarded – undo
64 68
 	{
65 69
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']);
66 70
 		//$ident = $spotter_array[0]['ident'];
67
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
68
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
71
+		if (isset($spotter_array[0]['latitude'])) {
72
+			$latitude = $spotter_array[0]['latitude'];
73
+		}
74
+		if (isset($spotter_array[0]['longitude'])) {
75
+			$longitude = $spotter_array[0]['longitude'];
76
+		}
69 77
 		require_once('header.php');
70 78
 		/*
71 79
 		if (isset($globalArchive) && $globalArchive) {
@@ -120,9 +128,14 @@  discard block
 block discarded – undo
120 128
 		print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
121 129
 		//print '<div><span class="label">'._("Owner").'</span>'.$spotter_array[0]['aircraft_owner'].'</div>';
122 130
 		$Stats = new Stats();
123
-		if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner);
124
-		else $flights = 0;
125
-		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter);
131
+		if ($year == '' && $month == '') {
132
+			$flights = $Stats->getStatsOwner($owner);
133
+		} else {
134
+			$flights = 0;
135
+		}
136
+		if ($flights == 0) {
137
+			$flights = $Spotter->countFlightsByOwner($owner,$filter);
138
+		}
126 139
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
127 140
 		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter));
128 141
 		print '<div><span class="label">'._("Aircraft type").'</span>'.$aircraft_type.'</div>';
@@ -133,7 +146,9 @@  discard block
 block discarded – undo
133 146
 		$airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter));
134 147
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
135 148
 		$duration = $Spotter->getFlightDurationByOwner($owner,$filter);
136
-		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
149
+		if ($duration != '0') {
150
+			print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
151
+		}
137 152
 		print '</div>';
138 153
 	
139 154
 		include('owner-sub-menu.php');
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Braces   +1190 added lines, -399 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -59,66 +63,107 @@  discard block
 block discarded – undo
59 63
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 64
 if (isset($options['s'])) {
61 65
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
64
-} elseif (isset($options['source'])) {
66
+    if (isset($options['format'])) {
67
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
68
+    } else {
69
+    	$globalSources[] = array('host' => $options['s']);
70
+    }
71
+    } elseif (isset($options['source'])) {
65 72
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
68
-}
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['source']);
77
+    }
78
+    }
69 79
 if (isset($options['aprsserverhost'])) {
70 80
 	$globalServerAPRS = TRUE;
71 81
 	$globalServerAPRShost = $options['aprsserverhost'];
72 82
 }
73
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
74
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
75
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
76
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
83
+if (isset($options['aprsserverport'])) {
84
+	$globalServerAPRSport = $options['aprsserverport'];
85
+}
86
+if (isset($options['aprsserverssid'])) {
87
+	$globalServerAPRSssid = $options['aprsserverssid'];
88
+}
89
+if (isset($options['aprsserverpass'])) {
90
+	$globalServerAPRSpass = $options['aprsserverpass'];
91
+}
92
+if (isset($options['noaprsserver'])) {
93
+	$globalServerAPRS = FALSE;
94
+}
77 95
 if (isset($options['enable-aircraft'])) {
78
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
96
+	if ($globalDebug) {
97
+		echo 'Enable Aircraft mode'."\n";
98
+	}
79 99
 	$globalAircraft = TRUE; 
80 100
 }
81 101
 if (isset($options['disable-aircraft'])) {
82
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
102
+	if ($globalDebug) {
103
+		echo 'Disable Aircraft mode'."\n";
104
+	}
83 105
 	$globalAircraft = FALSE;
84 106
 }
85 107
 if (isset($options['enable-tracker'])) {
86
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
108
+	if ($globalDebug) {
109
+		echo 'Enable Tracker mode'."\n";
110
+	}
87 111
 	$globalTracker = TRUE; 
88 112
 }
89 113
 if (isset($options['disable-tracker'])) {
90
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
114
+	if ($globalDebug) {
115
+		echo 'Disable Tracker mode'."\n";
116
+	}
91 117
 	$globalTracker = FALSE;
92 118
 }
93 119
 if (isset($options['enable-marine'])) {
94
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
120
+	if ($globalDebug) {
121
+		echo 'Enable Marine mode'."\n";
122
+	}
95 123
 	$globalMarine = TRUE;
96 124
 }
97 125
 if (isset($options['disable-marine'])) {
98
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
126
+	if ($globalDebug) {
127
+		echo 'Disable Marine mode'."\n";
128
+	}
99 129
 	$globalMarine = FALSE;
100 130
 }
101
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
102
-if (isset($options['server'])) $globalServer = TRUE;
103
-if (isset($options['idsource'])) $id_source = $options['idsource'];
104
-else $id_source = 1;
131
+if (isset($options['nodaemon'])) {
132
+	$globalDaemon = FALSE;
133
+}
134
+if (isset($options['server'])) {
135
+	$globalServer = TRUE;
136
+}
137
+if (isset($options['idsource'])) {
138
+	$id_source = $options['idsource'];
139
+} else {
140
+	$id_source = 1;
141
+}
105 142
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
143
+    if ($globalDebug) {
144
+    	echo "Using Server Mode\n";
145
+    }
107 146
     $SI=new SpotterServer();
108 147
 /*
109 148
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 149
     $SI = new adsb2aprs();
111 150
     $SI->connect();
112 151
 */
113
-} else $SI=new SpotterImport($Connection->db);
152
+} else {
153
+	$SI=new SpotterImport($Connection->db);
154
+}
114 155
 
115
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
156
+if (isset($globalTracker) && $globalTracker) {
157
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
158
+}
116 159
 if (isset($globalMarine) && $globalMarine) {
117 160
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
118 161
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 162
 }
120 163
 
121
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
164
+if (isset($globalTracker) && $globalTracker) {
165
+	$TI = new TrackerImport($Connection->db);
166
+}
122 167
 if (isset($globalMarine) && $globalMarine) {
123 168
     $AIS = new AIS();
124 169
     $MI = new MarineImport($Connection->db);
@@ -143,7 +188,9 @@  discard block
 block discarded – undo
143 188
 }
144 189
 
145 190
 // let's try and connect
146
-if ($globalDebug) echo "Connecting...\n";
191
+if ($globalDebug) {
192
+	echo "Connecting...\n";
193
+}
147 194
 $use_aprs = false;
148 195
 $aprs_full = false;
149 196
 $reset = 0;
@@ -152,7 +199,9 @@  discard block
 block discarded – undo
152 199
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153 200
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154 201
     $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
202
+    if ($globalDebug) {
203
+    	echo 'Connect to all...'."\n";
204
+    }
156 205
     foreach ($hosts as $id => $value) {
157 206
 	$host = $value['host'];
158 207
 	$globalSources[$id]['last_exec'] = 0;
@@ -162,32 +211,44 @@  discard block
 block discarded – undo
162 211
         	//$formats[$id] = 'deltadbtxt';
163 212
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 213
         	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to deltadb source (".$host.")...\n";
216
+        	}
166 217
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167 218
         	//$formats[$id] = 'vatsimtxt';
168 219
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 220
         	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
221
+        	if ($globalDebug) {
222
+        		echo "Connect to vatsim source (".$host.")...\n";
223
+        	}
171 224
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172 225
         	//$formats[$id] = 'aircraftlistjson';
173 226
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 227
         	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
230
+        	}
176 231
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
177 232
         	//$formats[$id] = 'aircraftjson';
178 233
         	$globalSources[$id]['format'] = 'aircraftjson';
179 234
         	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to aircraft.json source (".$host.")...\n";
237
+        	}
181 238
     	    } else if (preg_match('/aircraft$/i',$host)) {
182 239
         	//$formats[$id] = 'planefinderclient';
183 240
         	$globalSources[$id]['format'] = 'planefinderclient';
184 241
         	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
242
+        	if ($globalDebug) {
243
+        		echo "Connect to planefinderclient source (".$host.")...\n";
244
+        	}
186 245
     	    } else if (preg_match('/opensky/i',$host)) {
187 246
         	//$formats[$id] = 'aircraftlistjson';
188 247
         	$globalSources[$id]['format'] = 'opensky';
189 248
         	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
249
+        	if ($globalDebug) {
250
+        		echo "Connect to opensky source (".$host.")...\n";
251
+        	}
191 252
     	    /*
192 253
     	    // Disabled for now, site change source format
193 254
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -204,7 +265,9 @@  discard block
 block discarded – undo
204 265
         	//$formats[$id] = 'planeupdatefaa';
205 266
         	$globalSources[$id]['format'] = 'planeupdatefaa';
206 267
         	//$last_exec['planeupdatefaa'] = 0;
207
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
268
+        	if ($globalDebug) {
269
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
270
+        	}
208 271
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209 272
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210 273
         	    exit(0);
@@ -213,37 +276,53 @@  discard block
 block discarded – undo
213 276
         	//$formats[$id] = 'phpvmacars';
214 277
         	$globalSources[$id]['format'] = 'phpvmacars';
215 278
         	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
279
+        	if ($globalDebug) {
280
+        		echo "Connect to phpvmacars source (".$host.")...\n";
281
+        	}
217 282
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218 283
         	//$formats[$id] = 'phpvmacars';
219 284
         	$globalSources[$id]['format'] = 'vaos';
220 285
         	//$last_exec['phpvmacars'] = 0;
221
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
286
+        	if ($globalDebug) {
287
+        		echo "Connect to vaos source (".$host.")...\n";
288
+        	}
222 289
             } else if (preg_match('/VAM-json.php$/i',$host)) {
223 290
         	//$formats[$id] = 'phpvmacars';
224 291
         	$globalSources[$id]['format'] = 'vam';
225
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
292
+        	if ($globalDebug) {
293
+        		echo "Connect to Vam source (".$host.")...\n";
294
+        	}
226 295
             } else if (preg_match('/whazzup/i',$host)) {
227 296
         	//$formats[$id] = 'whazzup';
228 297
         	$globalSources[$id]['format'] = 'whazzup';
229 298
         	//$last_exec['whazzup'] = 0;
230
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
299
+        	if ($globalDebug) {
300
+        		echo "Connect to whazzup source (".$host.")...\n";
301
+        	}
231 302
             } else if (preg_match('/blitzortung/i',$host)) {
232 303
         	$globalSources[$id]['format'] = 'blitzortung';
233
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
304
+        	if ($globalDebug) {
305
+        		echo "Connect to blitzortung source (".$host.")...\n";
306
+        	}
234 307
             } else if (preg_match('/airwhere/i',$host)) {
235 308
         	$globalSources[$id]['format'] = 'airwhere';
236
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
309
+        	if ($globalDebug) {
310
+        		echo "Connect to airwhere source (".$host.")...\n";
311
+        	}
237 312
             } else if (preg_match('/recentpireps/i',$host)) {
238 313
         	//$formats[$id] = 'pirepsjson';
239 314
         	$globalSources[$id]['format'] = 'pirepsjson';
240 315
         	//$last_exec['pirepsjson'] = 0;
241
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
316
+        	if ($globalDebug) {
317
+        		echo "Connect to pirepsjson source (".$host.")...\n";
318
+        	}
242 319
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243 320
         	//$formats[$id] = 'fr24json';
244 321
         	$globalSources[$id]['format'] = 'fr24json';
245 322
         	//$last_exec['fr24json'] = 0;
246
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
323
+        	if ($globalDebug) {
324
+        		echo "Connect to fr24 source (".$host.")...\n";
325
+        	}
247 326
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248 327
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249 328
         	    exit(0);
@@ -252,7 +331,9 @@  discard block
 block discarded – undo
252 331
         	//$formats[$id] = 'fr24json';
253 332
         	$globalSources[$id]['format'] = 'myshiptracking';
254 333
         	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
334
+        	if ($globalDebug) {
335
+        		echo "Connect to myshiptracking source (".$host.")...\n";
336
+        	}
256 337
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257 338
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258 339
         	    exit(0);
@@ -261,16 +342,24 @@  discard block
 block discarded – undo
261 342
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262 343
         	//$formats[$id] = 'tsv';
263 344
         	$globalSources[$id]['format'] = 'tsv';
264
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
345
+        	if ($globalDebug) {
346
+        		echo "Connect to tsv source (".$host.")...\n";
347
+        	}
265 348
             }
266 349
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
267 350
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268 351
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
269 352
     		    if ($idf !== false) {
270 353
     			$httpfeeds[$id] = $idf;
271
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
354
+        		if ($globalDebug) {
355
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
356
+        		}
357
+    		    } elseif ($globalDebug) {
358
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
359
+    		    }
360
+    		} elseif ($globalDebug) {
361
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
362
+    		}
274 363
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
275 364
 	    $hostport = explode(':',$host);
276 365
 	    if (isset($hostport[1])) {
@@ -310,19 +399,27 @@  discard block
 block discarded – undo
310 399
         		//$formats[$id] = 'beast';
311 400
         		$globalSources[$id]['format'] = 'beast';
312 401
 		    //} else $formats[$id] = 'sbs';
313
-		    } else $globalSources[$id]['format'] = 'sbs';
402
+		    } else {
403
+		    	$globalSources[$id]['format'] = 'sbs';
404
+		    }
314 405
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
315 406
 		}
316
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
407
+		if ($globalDebug) {
408
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
409
+		}
317 410
             } else {
318
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
411
+		if ($globalDebug) {
412
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
413
+		}
319 414
 		sleep(10);
320 415
 		connect_all($hosts);
321 416
     	    }
322 417
         }
323 418
     }
324 419
 }
325
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
420
+if (!isset($globalMinFetch)) {
421
+	$globalMinFetch = 15;
422
+}
326 423
 
327 424
 // Initialize all
328 425
 $status = array();
@@ -331,13 +428,19 @@  discard block
 block discarded – undo
331 428
 $formats = array();
332 429
 $last_exec = array();
333 430
 $time = time();
334
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
335
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
336
-else $timeout = 20;
431
+if (isset($globalSourcesTimeout)) {
432
+	$timeout = $globalSourcesTimeOut;
433
+} else if (isset($globalSBS1TimeOut)) {
434
+	$timeout = $globalSBS1TimeOut;
435
+} else {
436
+	$timeout = 20;
437
+}
337 438
 $errno = '';
338 439
 $errstr='';
339 440
 
340
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
441
+if (!isset($globalDaemon)) {
442
+	$globalDaemon = TRUE;
443
+}
341 444
 /* Initiate connections to all the hosts simultaneously */
342 445
 //connect_all($hosts);
343 446
 //connect_all($globalSources);
@@ -366,7 +469,9 @@  discard block
 block discarded – undo
366 469
     if (isset($source['format']) && $source['format'] == 'aprs') {
367 470
 	$aprs_connect = 0;
368 471
 	$use_aprs = true;
369
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
472
+	if (isset($source['port']) && $source['port'] == '10152') {
473
+		$aprs_full = true;
474
+	}
370 475
 	break;
371 476
     }
372 477
 }
@@ -377,25 +482,46 @@  discard block
 block discarded – undo
377 482
 	$aprs_connect = 0;
378 483
 	$aprs_keep = 120;
379 484
 	$aprs_last_tx = time();
380
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
381
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
382
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
383
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
384
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
385
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
386
-	if ($aprs_full) $aprs_filter = '';
387
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
388
-	else $aprs_pass = '-1';
485
+	if (isset($globalAPRSversion)) {
486
+		$aprs_version = $globalAPRSversion;
487
+	} else {
488
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
489
+	}
490
+	if (isset($globalAPRSssid)) {
491
+		$aprs_ssid = $globalAPRSssid;
492
+	} else {
493
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
494
+	}
495
+	if (isset($globalAPRSfilter)) {
496
+		$aprs_filter = $globalAPRSfilter;
497
+	} else {
498
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
499
+	}
500
+	if ($aprs_full) {
501
+		$aprs_filter = '';
502
+	}
503
+	if (isset($globalAPRSpass)) {
504
+		$aprs_pass = $globalAPRSpass;
505
+	} else {
506
+		$aprs_pass = '-1';
507
+	}
389 508
 
390
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
391
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
392
-}
509
+	if ($aprs_filter != '') {
510
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
511
+	} else {
512
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
513
+	}
514
+	}
393 515
 
394 516
 // connected - lets do some work
395 517
 //if ($globalDebug) echo "Connected!\n";
396 518
 sleep(1);
397
-if ($globalDebug) echo "SCAN MODE \n\n";
398
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
519
+if ($globalDebug) {
520
+	echo "SCAN MODE \n\n";
521
+}
522
+if (!isset($globalCronEnd)) {
523
+	$globalCronEnd = 60;
524
+}
399 525
 $endtime = time()+$globalCronEnd;
400 526
 $i = 1;
401 527
 $tt = array();
@@ -409,22 +535,32 @@  discard block
 block discarded – undo
409 535
 
410 536
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
411 537
 while ($i > 0) {
412
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
538
+    if (function_exists('pcntl_fork')) {
539
+    	pcntl_signal_dispatch();
540
+    }
413 541
 
414
-    if (!$globalDaemon) $i = $endtime-time();
542
+    if (!$globalDaemon) {
543
+    	$i = $endtime-time();
544
+    }
415 545
     // Delete old ATC
416 546
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
417
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
547
+	if ($globalDebug) {
548
+		echo 'Delete old ATC...'."\n";
549
+	}
418 550
         $ATC->deleteOldATC();
419 551
     }
420 552
     
421 553
     if (count($last_exec) == count($globalSources)) {
422 554
 	$max = $globalMinFetch;
423 555
 	foreach ($last_exec as $last) {
424
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
556
+	    if ((time() - $last['last']) < $max) {
557
+	    	$max = time() - $last['last'];
558
+	    }
425 559
 	}
426 560
 	if ($max < $globalMinFetch) {
427
-	    if ($globalDebug) echo 'Sleeping...'."\n";
561
+	    if ($globalDebug) {
562
+	    	echo 'Sleeping...'."\n";
563
+	    }
428 564
 	    sleep($globalMinFetch-$max+2);
429 565
 	}
430 566
     }
@@ -434,7 +570,9 @@  discard block
 block discarded – undo
434 570
     foreach ($globalSources as $id => $value) {
435 571
 	date_default_timezone_set('UTC');
436 572
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
437
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
573
+	if (!isset($last_exec[$id]['last'])) {
574
+		$last_exec[$id]['last'] = 0;
575
+	}
438 576
 	if ($value['format'] === 'deltadbtxt' && 
439 577
 	    (
440 578
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -443,7 +581,9 @@  discard block
 block discarded – undo
443 581
 	) {
444 582
 	    //$buffer = $Common->getData($hosts[$id]);
445 583
 	    $buffer = $Common->getData($value['host']);
446
-	    if ($buffer != '') $reset = 0;
584
+	    if ($buffer != '') {
585
+	    	$reset = 0;
586
+	    }
447 587
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
448 588
 	    $buffer = explode('\n',$buffer);
449 589
 	    foreach ($buffer as $line) {
@@ -452,20 +592,41 @@  discard block
 block discarded – undo
452 592
 	            $data = array();
453 593
 	            $data['hex'] = $line[1]; // hex
454 594
 	            $data['ident'] = $line[2]; // ident
455
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
456
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
457
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
458
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
459
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
595
+	            if (isset($line[3])) {
596
+	            	$data['altitude'] = $line[3];
597
+	            }
598
+	            // altitude
599
+	            if (isset($line[4])) {
600
+	            	$data['speed'] = $line[4];
601
+	            }
602
+	            // speed
603
+	            if (isset($line[5])) {
604
+	            	$data['heading'] = $line[5];
605
+	            }
606
+	            // heading
607
+	            if (isset($line[6])) {
608
+	            	$data['latitude'] = $line[6];
609
+	            }
610
+	            // lat
611
+	            if (isset($line[7])) {
612
+	            	$data['longitude'] = $line[7];
613
+	            }
614
+	            // long
460 615
 	            $data['verticalrate'] = ''; // vertical rate
461 616
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
462 617
 	            $data['emergency'] = ''; // emergency
463 618
 		    $data['datetime'] = date('Y-m-d H:i:s');
464 619
 		    $data['format_source'] = 'deltadbtxt';
465 620
     		    $data['id_source'] = $id_source;
466
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
467
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
468
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
621
+		    if (isset($value['name']) && $value['name'] != '') {
622
+		    	$data['source_name'] = $value['name'];
623
+		    }
624
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
625
+		    	$data['noarchive'] = true;
626
+		    }
627
+		    if (isset($value['sourcestats'])) {
628
+		    	$data['sourcestats'] = $value['sourcestats'];
629
+		    }
469 630
     		    $SI->add($data);
470 631
 		    unset($data);
471 632
     		}
@@ -480,7 +641,9 @@  discard block
 block discarded – undo
480 641
 	    date_default_timezone_set('CET');
481 642
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
482 643
 	    date_default_timezone_set('UTC');
483
-	    if ($buffer != '') $reset = 0;
644
+	    if ($buffer != '') {
645
+	    	$reset = 0;
646
+	    }
484 647
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
485 648
 	    $buffer = explode('\n',$buffer);
486 649
 	    foreach ($buffer as $line) {
@@ -489,18 +652,42 @@  discard block
 block discarded – undo
489 652
 		    $add = false;
490 653
 		    $ais_data = $AIS->parse_line(trim($line));
491 654
 		    $data = array();
492
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
493
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
494
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
495
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
496
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
497
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
498
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
499
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
500
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
501
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
502
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
503
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
655
+		    if (isset($ais_data['ident'])) {
656
+		    	$data['ident'] = $ais_data['ident'];
657
+		    }
658
+		    if (isset($ais_data['mmsi'])) {
659
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
660
+		    }
661
+		    if (isset($ais_data['speed'])) {
662
+		    	$data['speed'] = $ais_data['speed'];
663
+		    }
664
+		    if (isset($ais_data['heading'])) {
665
+		    	$data['heading'] = $ais_data['heading'];
666
+		    }
667
+		    if (isset($ais_data['latitude'])) {
668
+		    	$data['latitude'] = $ais_data['latitude'];
669
+		    }
670
+		    if (isset($ais_data['longitude'])) {
671
+		    	$data['longitude'] = $ais_data['longitude'];
672
+		    }
673
+		    if (isset($ais_data['status'])) {
674
+		    	$data['status'] = $ais_data['status'];
675
+		    }
676
+		    if (isset($ais_data['statusid'])) {
677
+		    	$data['status_id'] = $ais_data['statusid'];
678
+		    }
679
+		    if (isset($ais_data['type'])) {
680
+		    	$data['type'] = $ais_data['type'];
681
+		    }
682
+		    if (isset($ais_data['typeid'])) {
683
+		    	$data['type_id'] = $ais_data['typeid'];
684
+		    }
685
+		    if (isset($ais_data['imo'])) {
686
+		    	$data['imo'] = $ais_data['imo'];
687
+		    }
688
+		    if (isset($ais_data['callsign'])) {
689
+		    	$data['callsign'] = $ais_data['callsign'];
690
+		    }
504 691
 		    if (isset($ais_data['timestamp'])) {
505 692
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
506 693
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -514,8 +701,12 @@  discard block
 block discarded – undo
514 701
 		    $data['format_source'] = 'aisnmeatxt';
515 702
     		    $data['id_source'] = $id_source;
516 703
 		    //print_r($data);
517
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
518
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
704
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
705
+		    	$data['noarchive'] = true;
706
+		    }
707
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
708
+		    	$MI->add($data);
709
+		    }
519 710
 		    unset($data);
520 711
 		}
521 712
     	    }
@@ -538,20 +729,48 @@  discard block
 block discarded – undo
538 729
 			    if ($line != '') {
539 730
 				$ais_data = $AIS->parse_line(trim($line));
540 731
 				$data = array();
541
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
542
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
543
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
544
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
545
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
546
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
547
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
548
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
549
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
550
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
551
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
552
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
553
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
554
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
732
+				if (isset($ais_data['ident'])) {
733
+					$data['ident'] = $ais_data['ident'];
734
+				}
735
+				if (isset($ais_data['mmsi'])) {
736
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
737
+				}
738
+				if (isset($ais_data['speed'])) {
739
+					$data['speed'] = $ais_data['speed'];
740
+				}
741
+				if (isset($ais_data['heading'])) {
742
+					$data['heading'] = $ais_data['heading'];
743
+				}
744
+				if (isset($ais_data['latitude'])) {
745
+					$data['latitude'] = $ais_data['latitude'];
746
+				}
747
+				if (isset($ais_data['longitude'])) {
748
+					$data['longitude'] = $ais_data['longitude'];
749
+				}
750
+				if (isset($ais_data['status'])) {
751
+					$data['status'] = $ais_data['status'];
752
+				}
753
+				if (isset($ais_data['statusid'])) {
754
+					$data['status_id'] = $ais_data['statusid'];
755
+				}
756
+				if (isset($ais_data['type'])) {
757
+					$data['type'] = $ais_data['type'];
758
+				}
759
+				if (isset($ais_data['typeid'])) {
760
+					$data['type_id'] = $ais_data['typeid'];
761
+				}
762
+				if (isset($ais_data['imo'])) {
763
+					$data['imo'] = $ais_data['imo'];
764
+				}
765
+				if (isset($ais_data['callsign'])) {
766
+					$data['callsign'] = $ais_data['callsign'];
767
+				}
768
+				if (isset($ais_data['destination'])) {
769
+					$data['arrival_code'] = $ais_data['destination'];
770
+				}
771
+				if (isset($ais_data['eta_ts'])) {
772
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
773
+				}
555 774
 				if (isset($ais_data['timestamp'])) {
556 775
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
557 776
 				} else {
@@ -559,18 +778,27 @@  discard block
 block discarded – undo
559 778
 				}
560 779
 				$data['format_source'] = 'aisnmeahttp';
561 780
 				$data['id_source'] = $id_source;
562
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
563
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
781
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
782
+					$data['noarchive'] = true;
783
+				}
784
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
785
+					$MI->add($data);
786
+				}
564 787
 				unset($data);
565 788
 			    }
566 789
 			}
567 790
 		    }
568 791
 		} else {
569 792
 		    $format = $value['format'];
570
-		    if (isset($tt[$format])) $tt[$format]++;
571
-		    else $tt[$format] = 0;
793
+		    if (isset($tt[$format])) {
794
+		    	$tt[$format]++;
795
+		    } else {
796
+		    	$tt[$format] = 0;
797
+		    }
572 798
 		    if ($tt[$format] > 30) {
573
-			if ($globalDebug) echo 'Reconnect...'."\n";
799
+			if ($globalDebug) {
800
+				echo 'Reconnect...'."\n";
801
+			}
574 802
 			sleep(2);
575 803
 			//$sourceeen[] = $value;
576 804
 			//connect_all($sourceeen);
@@ -606,12 +834,18 @@  discard block
 block discarded – undo
606 834
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
607 835
 			    //$data['type_id'] = $line['TYPE'];
608 836
 			    $data['imo'] = $line['IMO'];
609
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
610
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
837
+			    if ($line['DEST'] != '') {
838
+			    	$data['arrival_code'] = $line['DEST'];
839
+			    }
840
+			    if ($line['ARV'] != '') {
841
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
842
+			    }
611 843
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
612 844
 			    $data['format_source'] = 'myshiptracking';
613 845
 			    $data['id_source'] = $id_source;
614
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
846
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
847
+			    	$data['noarchive'] = true;
848
+			    }
615 849
 			    $MI->add($data);
616 850
 			    unset($data);
617 851
 			}
@@ -636,7 +870,9 @@  discard block
 block discarded – undo
636 870
 			    $data['callsign'] = $line['callsign'];
637 871
 			    $data['mmsi'] = substr($line['mmsi'],-9);
638 872
 			    $data['speed'] = $line['sog'];
639
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
873
+			    if ($line['heading'] != '511') {
874
+			    	$data['heading'] = $line['heading'];
875
+			    }
640 876
 			    $data['latitude'] = $line['latitude'];
641 877
 			    $data['longitude'] = $line['longitude'];
642 878
 			    $data['type_id'] = $line['shiptype'];
@@ -644,7 +880,9 @@  discard block
 block discarded – undo
644 880
 			    $data['datetime'] = $line['time'];
645 881
 			    $data['format_source'] = 'boatbeaconapp';
646 882
 			    $data['id_source'] = $id_source;
647
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
883
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
884
+			    	$data['noarchive'] = true;
885
+			    }
648 886
 			    $MI->add($data);
649 887
 			    unset($data);
650 888
 			}
@@ -666,22 +904,44 @@  discard block
 block discarded – undo
666 904
 		    foreach ($all_data['features'] as $line) {
667 905
 			print_r($line);
668 906
 			$data = array();
669
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
670
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
671
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
672
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
673
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
674
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
907
+			if (isset($line['properties']['name'])) {
908
+				$data['ident'] = $line['properties']['name'];
909
+			}
910
+			if (isset($line['properties']['callsign'])) {
911
+				$data['callsign'] = $line['properties']['callsign'];
912
+			}
913
+			if (isset($line['properties']['mmsi'])) {
914
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
915
+			}
916
+			if (isset($line['properties']['imo'])) {
917
+				$data['imo'] = $line['properties']['imo'];
918
+			}
919
+			if (isset($line['properties']['speed'])) {
920
+				$data['speed'] = $line['properties']['speed'];
921
+			}
922
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
923
+				$data['heading'] = $line['properties']['heading'];
924
+			}
675 925
 			$data['latitude'] = $line['geometry']['coordinates'][1];
676 926
 			$data['longitude'] = $line['geometry']['coordinates'][0];
677
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
678
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
679
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
927
+			if (isset($line['properties']['vesselType'])) {
928
+				$data['type'] = $line['properties']['vesselType'];
929
+			}
930
+			if (isset($line['properties']['destination'])) {
931
+				$data['arrival_code'] = $line['properties']['destination'];
932
+			}
933
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
934
+				$data['arrival_date'] = $line['properties']['eta'];
935
+			}
680 936
 			$data['format_source'] = 'boatnerd';
681 937
 			$data['id_source'] = $id_source;
682 938
 			$data['datetime'] = date('Y-m-d H:i:s');
683
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
684
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
939
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
940
+				$data['noarchive'] = true;
941
+			}
942
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
943
+				$MI->add($data);
944
+			}
685 945
 			unset($data);
686 946
 		    }
687 947
 		}
@@ -698,7 +958,9 @@  discard block
 block discarded – undo
698 958
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
699 959
 	    echo 'done !'."\n";
700 960
 	    // FIXME: Need more work
701
-	    if ($buffer != '') $reset = 0;
961
+	    if ($buffer != '') {
962
+	    	$reset = 0;
963
+	    }
702 964
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
703 965
 	    $buffer = explode('\n',$buffer);
704 966
 	    foreach ($buffer as $line) {
@@ -724,7 +986,9 @@  discard block
 block discarded – undo
724 986
 		    //$data['etaTime'] = substr($line,135,5);
725 987
 		    $data['format_source'] = 'shipplotter';
726 988
     		    $data['id_source'] = $id_source;
727
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
989
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
990
+		    	$data['noarchive'] = true;
991
+		    }
728 992
 		    //print_r($data);
729 993
 		    echo 'Add...'."\n";
730 994
 		    $MI->add($data);
@@ -758,16 +1022,28 @@  discard block
 block discarded – undo
758 1022
     		    $line = explode(':', $line);
759 1023
     		    if (count($line) > 30 && $line[0] != 'callsign') {
760 1024
 			$data = array();
761
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
762
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1025
+			if (isset($line[37]) && $line[37] != '') {
1026
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1027
+			} else {
1028
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1029
+			}
763 1030
 			$data['pilot_id'] = $line[1];
764 1031
 			$data['pilot_name'] = $line[2];
765 1032
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
766 1033
 			$data['ident'] = $line[0]; // ident
767
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1034
+			if ($line[7] != '' && $line[7] != 0) {
1035
+				$data['altitude'] = $line[7];
1036
+			}
1037
+			// altitude
768 1038
 			$data['speed'] = $line[8]; // speed
769
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
770
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1039
+			if (isset($line[45])) {
1040
+				$data['heading'] = $line[45];
1041
+			}
1042
+			// heading
1043
+			elseif (isset($line[38])) {
1044
+				$data['heading'] = $line[38];
1045
+			}
1046
+			// heading
771 1047
 			$data['latitude'] = $line[5]; // lat
772 1048
 	        	$data['longitude'] = $line[6]; // long
773 1049
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -783,7 +1059,9 @@  discard block
 block discarded – undo
783 1059
 			$data['frequency'] = $line[4];
784 1060
 			$data['type'] = $line[18];
785 1061
 			$data['range'] = $line[19];
786
-			if (isset($line[35])) $data['info'] = $line[35];
1062
+			if (isset($line[35])) {
1063
+				$data['info'] = $line[35];
1064
+			}
787 1065
     			$data['id_source'] = $id_source;
788 1066
 	    		//$data['arrival_airport_time'] = ;
789 1067
 	    		if ($line[9] != '') {
@@ -797,27 +1075,47 @@  discard block
 block discarded – undo
797 1075
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
798 1076
 	    		*/
799 1077
 	    		$data['format_source'] = $value['format'];
800
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
801
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
802
-    			if ($line[3] === 'PILOT') $SI->add($data);
803
-			elseif ($line[3] === 'ATC') {
1078
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1079
+				$data['noarchive'] = true;
1080
+			}
1081
+			if (isset($value['name']) && $value['name'] != '') {
1082
+				$data['source_name'] = $value['name'];
1083
+			}
1084
+    			if ($line[3] === 'PILOT') {
1085
+    				$SI->add($data);
1086
+    			} elseif ($line[3] === 'ATC') {
804 1087
 				//print_r($data);
805 1088
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
806 1089
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
807 1090
 				$typec = substr($data['ident'],-3);
808
-				if ($typec === 'APP') $data['type'] = 'Approach';
809
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
810
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
811
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
812
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
813
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
814
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
815
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
816
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
817
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1091
+				if ($typec === 'APP') {
1092
+					$data['type'] = 'Approach';
1093
+				} elseif ($typec === 'TWR') {
1094
+					$data['type'] = 'Tower';
1095
+				} elseif ($typec === 'OBS') {
1096
+					$data['type'] = 'Observer';
1097
+				} elseif ($typec === 'GND') {
1098
+					$data['type'] = 'Ground';
1099
+				} elseif ($typec === 'DEL') {
1100
+					$data['type'] = 'Delivery';
1101
+				} elseif ($typec === 'DEP') {
1102
+					$data['type'] = 'Departure';
1103
+				} elseif ($typec === 'FSS') {
1104
+					$data['type'] = 'Flight Service Station';
1105
+				} elseif ($typec === 'CTR') {
1106
+					$data['type'] = 'Control Radar or Centre';
1107
+				} elseif ($data['type'] === '') {
1108
+					$data['type'] = 'Observer';
1109
+				}
1110
+				if (!isset($data['source_name'])) {
1111
+					$data['source_name'] = '';
1112
+				}
818 1113
 				if (isset($ATC)) {
819
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
820
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1114
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1115
+						echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1116
+					} else {
1117
+						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']);
1118
+					}
821 1119
 				}
822 1120
 			}
823 1121
     			unset($data);
@@ -844,14 +1142,20 @@  discard block
 block discarded – undo
844 1142
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
845 1143
 			$data['latitude'] = (float)$line['pktLatitude'];
846 1144
 			$data['longitude'] = (float)$line['pktLongitude'];
847
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
848
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1145
+			if ((float)$line['pktTrack'] != 0) {
1146
+				$data['heading'] = (float)$line['pktTrack'];
1147
+			}
1148
+			if ((int)$line['pktSpeed'] != 0) {
1149
+				$data['speed'] = (int)$line['pktSpeed'];
1150
+			}
849 1151
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
850 1152
 			$data['altitude_relative'] = 'AMSL';
851 1153
 			$data['pilot_id'] = (int)$line['pktPilotID'];
852 1154
 			$data['aircraft_icao'] = 'PARAGLIDER';
853 1155
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
854
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1156
+			if (isset($pilot_data[4])) {
1157
+				$data['pilot_name'] = $pilot_data[4];
1158
+			}
855 1159
 			$data['format_source'] = $value['format'];
856 1160
 			$SI->add($data);
857 1161
 			unset($data);
@@ -899,25 +1203,59 @@  discard block
 block discarded – undo
899 1203
 		    foreach ($all_data['acList'] as $line) {
900 1204
 			$data = array();
901 1205
 			$data['hex'] = $line['Icao']; // hex
902
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
903
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
904
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
905
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
906
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
907
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1206
+			if (isset($line['Call'])) {
1207
+				$data['ident'] = $line['Call'];
1208
+			}
1209
+			// ident
1210
+			if (isset($line['Alt'])) {
1211
+				$data['altitude'] = $line['Alt'];
1212
+			}
1213
+			// altitude
1214
+			if (isset($line['Spd'])) {
1215
+				$data['speed'] = $line['Spd'];
1216
+			}
1217
+			// speed
1218
+			if (isset($line['Trak'])) {
1219
+				$data['heading'] = $line['Trak'];
1220
+			}
1221
+			// heading
1222
+			if (isset($line['Lat'])) {
1223
+				$data['latitude'] = $line['Lat'];
1224
+			}
1225
+			// lat
1226
+			if (isset($line['Long'])) {
1227
+				$data['longitude'] = $line['Long'];
1228
+			}
1229
+			// long
908 1230
 			//$data['verticalrate'] = $line['']; // verticale rate
909
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1231
+			if (isset($line['Sqk'])) {
1232
+				$data['squawk'] = $line['Sqk'];
1233
+			}
1234
+			// squawk
910 1235
 			$data['emergency'] = ''; // emergency
911
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
912
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
913
-			else $data['datetime'] = date('Y-m-d H:i:s');
1236
+			if (isset($line['Reg'])) {
1237
+				$data['registration'] = $line['Reg'];
1238
+			}
1239
+			if (isset($line['PosTime'])) {
1240
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1241
+			} else {
1242
+				$data['datetime'] = date('Y-m-d H:i:s');
1243
+			}
914 1244
 			//$data['datetime'] = date('Y-m-d H:i:s');
915
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1245
+			if (isset($line['Type'])) {
1246
+				$data['aircraft_icao'] = $line['Type'];
1247
+			}
916 1248
 			$data['format_source'] = 'aircraftlistjson';
917 1249
 			$data['id_source'] = $id_source;
918
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
919
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
920
-			if (isset($data['latitude'])) $SI->add($data);
1250
+			if (isset($value['name']) && $value['name'] != '') {
1251
+				$data['source_name'] = $value['name'];
1252
+			}
1253
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1254
+				$data['noarchive'] = true;
1255
+			}
1256
+			if (isset($data['latitude'])) {
1257
+				$SI->add($data);
1258
+			}
921 1259
 			unset($data);
922 1260
 		    }
923 1261
 		} elseif (is_array($all_data)) {
@@ -934,17 +1272,26 @@  discard block
 block discarded – undo
934 1272
 			$data['verticalrate'] = $line['vrt']; // verticale rate
935 1273
 			$data['squawk'] = $line['squawk']; // squawk
936 1274
 			$data['emergency'] = ''; // emergency
937
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
938
-			else $data['datetime'] = date('Y-m-d H:i:s');
1275
+			if (isset($line['PosTime'])) {
1276
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1277
+			} else {
1278
+				$data['datetime'] = date('Y-m-d H:i:s');
1279
+			}
939 1280
 			$data['format_source'] = 'aircraftlistjson';
940 1281
 			$data['id_source'] = $id_source;
941
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
942
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1282
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1283
+				$data['noarchive'] = true;
1284
+			}
1285
+			if (isset($value['name']) && $value['name'] != '') {
1286
+				$data['source_name'] = $value['name'];
1287
+			}
943 1288
 			$SI->add($data);
944 1289
 			unset($data);
945 1290
 		    }
946 1291
 		}
947
-	    } elseif ($globalDebug) echo 'No data'."\n";
1292
+	    } elseif ($globalDebug) {
1293
+	    	echo 'No data'."\n";
1294
+	    }
948 1295
     	    //$last_exec['aircraftlistjson'] = time();
949 1296
     	    $last_exec[$id]['last'] = time();
950 1297
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -980,8 +1327,12 @@  discard block
 block discarded – undo
980 1327
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
981 1328
 	    	    $data['format_source'] = 'planeupdatefaa';
982 1329
     		    $data['id_source'] = $id_source;
983
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
984
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1330
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1331
+		    	$data['noarchive'] = true;
1332
+		    }
1333
+		    if (isset($value['name']) && $value['name'] != '') {
1334
+		    	$data['source_name'] = $value['name'];
1335
+		    }
985 1336
 		    $SI->add($data);
986 1337
 		    unset($data);
987 1338
 		}
@@ -1015,7 +1366,9 @@  discard block
 block discarded – undo
1015 1366
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1016 1367
 		    $data['format_source'] = 'opensky';
1017 1368
 		    $data['id_source'] = $id_source;
1018
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1369
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1370
+		    	$data['noarchive'] = true;
1371
+		    }
1019 1372
 		    $SI->add($data);
1020 1373
 		    unset($data);
1021 1374
 		}
@@ -1035,15 +1388,42 @@  discard block
 block discarded – undo
1035 1388
 		foreach ($all_data['aircraft'] as $key => $line) {
1036 1389
 		    $data = array();
1037 1390
 		    // add support for ground vehicule with ~ in front of hex
1038
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1039
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1040
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1041
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1042
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1043
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1044
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1045
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1046
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1391
+		    if (isset($line['hex'])) {
1392
+		    	$data['hex'] = $line['hex'];
1393
+		    }
1394
+		    // hex
1395
+		    if (isset($line['flight'])) {
1396
+		    	$data['ident'] = trim($line['flight']);
1397
+		    }
1398
+		    // ident
1399
+		    if (isset($line['altitude'])) {
1400
+		    	$data['altitude'] = $line['altitude'];
1401
+		    }
1402
+		    // altitude
1403
+		    if (isset($line['speed'])) {
1404
+		    	$data['speed'] = $line['speed'];
1405
+		    }
1406
+		    // speed
1407
+		    if (isset($line['track'])) {
1408
+		    	$data['heading'] = $line['track'];
1409
+		    }
1410
+		    // heading
1411
+		    if (isset($line['lat'])) {
1412
+		    	$data['latitude'] = $line['lat'];
1413
+		    }
1414
+		    // lat
1415
+		    if (isset($line['lon'])) {
1416
+		    	$data['longitude'] = $line['lon'];
1417
+		    }
1418
+		    // long
1419
+		    if (isset($line['vert_rate'])) {
1420
+		    	$data['verticalrate'] = $line['vert_rate'];
1421
+		    }
1422
+		    // verticale rate
1423
+		    if (isset($line['squawk'])) {
1424
+		    	$data['squawk'] = $line['squawk'];
1425
+		    }
1426
+		    // squawk
1047 1427
 		    //$data['emergency'] = ''; // emergency
1048 1428
 		    //$data['registration'] = $line[2];
1049 1429
 		    //$data['aircraft_icao'] = $line[0];
@@ -1051,10 +1431,17 @@  discard block
 block discarded – undo
1051 1431
 		    $data['format_source'] = 'aircraftjson';
1052 1432
 		    $data['id_source'] = $id_source;
1053 1433
 		    if (isset($value['name']) && $value['name'] != '') {
1054
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1055
-			    else $data['source_name'] = $value['name'];
1056
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1057
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1434
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1435
+			    	$data['source_name'] = $value['name'].'_MLAT';
1436
+			    } else {
1437
+			    	$data['source_name'] = $value['name'];
1438
+			    }
1439
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1440
+		    	$data['source_name'] = 'MLAT';
1441
+		    }
1442
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1443
+		    	$data['noarchive'] = true;
1444
+		    }
1058 1445
 		    $SI->add($data);
1059 1446
 		    unset($data);
1060 1447
 		}
@@ -1074,22 +1461,54 @@  discard block
 block discarded – undo
1074 1461
 		foreach ($all_data['aircraft'] as $key => $line) {
1075 1462
 		    $data = array();
1076 1463
 		    $data['hex'] = $key; // hex
1077
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1078
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1079
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1080
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1081
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1082
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1083
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1084
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1464
+		    if (isset($line['callsign'])) {
1465
+		    	$data['ident'] = trim($line['callsign']);
1466
+		    }
1467
+		    // ident
1468
+		    if (isset($line['altitude'])) {
1469
+		    	$data['altitude'] = $line['altitude'];
1470
+		    }
1471
+		    // altitude
1472
+		    if (isset($line['speed'])) {
1473
+		    	$data['speed'] = $line['speed'];
1474
+		    }
1475
+		    // speed
1476
+		    if (isset($line['heading'])) {
1477
+		    	$data['heading'] = $line['heading'];
1478
+		    }
1479
+		    // heading
1480
+		    if (isset($line['lat'])) {
1481
+		    	$data['latitude'] = $line['lat'];
1482
+		    }
1483
+		    // lat
1484
+		    if (isset($line['lon'])) {
1485
+		    	$data['longitude'] = $line['lon'];
1486
+		    }
1487
+		    // long
1488
+		    if (isset($line['vert_rate'])) {
1489
+		    	$data['verticalrate'] = $line['vert_rate'];
1490
+		    }
1491
+		    // verticale rate
1492
+		    if (isset($line['squawk'])) {
1493
+		    	$data['squawk'] = $line['squawk'];
1494
+		    }
1495
+		    // squawk
1085 1496
 		    //$data['emergency'] = ''; // emergency
1086
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1087
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1497
+		    if (isset($line['reg'])) {
1498
+		    	$data['registration'] = $line['reg'];
1499
+		    }
1500
+		    if (isset($line['type'])) {
1501
+		    	$data['aircraft_icao'] = $line['type'];
1502
+		    }
1088 1503
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1089 1504
 		    $data['format_source'] = 'planefinderclient';
1090 1505
 		    $data['id_source'] = $id_source;
1091
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1092
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1506
+		    if (isset($value['name']) && $value['name'] != '') {
1507
+		    	$data['source_name'] = $value['name'];
1508
+		    }
1509
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1510
+		    	$data['noarchive'] = true;
1511
+		    }
1093 1512
 		    $SI->add($data);
1094 1513
 		    unset($data);
1095 1514
 		}
@@ -1105,7 +1524,9 @@  discard block
 block discarded – undo
1105 1524
 	    //$buffer = $Common->getData($hosts[$id]);
1106 1525
 	    $buffer = $Common->getData($value['host']);
1107 1526
 	    $all_data = json_decode($buffer,true);
1108
-	    if (!empty($all_data)) $reset = 0;
1527
+	    if (!empty($all_data)) {
1528
+	    	$reset = 0;
1529
+	    }
1109 1530
 	    foreach ($all_data as $key => $line) {
1110 1531
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1111 1532
 		    $data = array();
@@ -1126,8 +1547,12 @@  discard block
 block discarded – undo
1126 1547
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1127 1548
 	    	    $data['format_source'] = 'fr24json';
1128 1549
     		    $data['id_source'] = $id_source;
1129
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1130
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1550
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1551
+		    	$data['noarchive'] = true;
1552
+		    }
1553
+		    if (isset($value['name']) && $value['name'] != '') {
1554
+		    	$data['source_name'] = $value['name'];
1555
+		    }
1131 1556
 		    $SI->add($data);
1132 1557
 		    unset($data);
1133 1558
 		}
@@ -1156,24 +1581,42 @@  discard block
 block discarded – undo
1156 1581
 		    if (isset($line['inf'])) {
1157 1582
 			$data = array();
1158 1583
 			$data['hex'] = $line['inf']['ia'];
1159
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1584
+			if (isset($line['inf']['cs'])) {
1585
+				$data['ident'] = $line['inf']['cs'];
1586
+			}
1587
+			//$line[13]
1160 1588
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1161
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1162
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1589
+	    		if (isset($line['inf']['gs'])) {
1590
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1591
+	    		}
1592
+	    		// speed
1593
+	    		if (isset($line['inf']['tr'])) {
1594
+	    			$data['heading'] = $line['inf']['tr'];
1595
+	    		}
1596
+	    		// heading
1163 1597
 	    		$data['latitude'] = $line['pt'][0]; // lat
1164 1598
 	    		$data['longitude'] = $line['pt'][1]; // long
1165 1599
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1166
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1600
+	    		if (isset($line['inf']['sq'])) {
1601
+	    			$data['squawk'] = $line['inf']['sq'];
1602
+	    		}
1603
+	    		// squawk
1167 1604
 	    		//$data['aircraft_icao'] = $line[8];
1168
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1605
+	    		if (isset($line['inf']['rc'])) {
1606
+	    			$data['registration'] = $line['inf']['rc'];
1607
+	    		}
1169 1608
 			//$data['departure_airport_iata'] = $line[11];
1170 1609
 			//$data['arrival_airport_iata'] = $line[12];
1171 1610
 	    		//$data['emergency'] = ''; // emergency
1172 1611
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1173 1612
 	    		$data['format_source'] = 'radarvirtueljson';
1174 1613
     			$data['id_source'] = $id_source;
1175
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1176
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1614
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1615
+				$data['noarchive'] = true;
1616
+			}
1617
+			if (isset($value['name']) && $value['name'] != '') {
1618
+				$data['source_name'] = $value['name'];
1619
+			}
1177 1620
 			$SI->add($data);
1178 1621
 			unset($data);
1179 1622
 		    }
@@ -1199,30 +1642,65 @@  discard block
 block discarded – undo
1199 1642
 		    $data['id'] = $line['id'];
1200 1643
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1201 1644
 		    $data['ident'] = $line['callsign']; // ident
1202
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1203
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1204
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1205
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1206
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1207
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1645
+		    if (isset($line['pilotid'])) {
1646
+		    	$data['pilot_id'] = $line['pilotid'];
1647
+		    }
1648
+		    // pilot id
1649
+		    if (isset($line['name'])) {
1650
+		    	$data['pilot_name'] = $line['name'];
1651
+		    }
1652
+		    // pilot name
1653
+		    if (isset($line['alt'])) {
1654
+		    	$data['altitude'] = $line['alt'];
1655
+		    }
1656
+		    // altitude
1657
+		    if (isset($line['gs'])) {
1658
+		    	$data['speed'] = $line['gs'];
1659
+		    }
1660
+		    // speed
1661
+		    if (isset($line['heading'])) {
1662
+		    	$data['heading'] = $line['heading'];
1663
+		    }
1664
+		    // heading
1665
+		    if (isset($line['route'])) {
1666
+		    	$data['waypoints'] = $line['route'];
1667
+		    }
1668
+		    // route
1208 1669
 		    $data['latitude'] = $line['lat']; // lat
1209 1670
 		    $data['longitude'] = $line['lon']; // long
1210 1671
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1211 1672
 		    //$data['squawk'] = $line['squawk']; // squawk
1212 1673
 		    //$data['emergency'] = ''; // emergency
1213
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1214
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1215
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1674
+		    if (isset($line['depicao'])) {
1675
+		    	$data['departure_airport_icao'] = $line['depicao'];
1676
+		    }
1677
+		    if (isset($line['deptime'])) {
1678
+		    	$data['departure_airport_time'] = $line['deptime'];
1679
+		    }
1680
+		    if (isset($line['arricao'])) {
1681
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1682
+		    }
1216 1683
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1217
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1218
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1219
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1220
-		    else $data['info'] = '';
1684
+		    if (isset($line['aircraft'])) {
1685
+		    	$data['aircraft_icao'] = $line['aircraft'];
1686
+		    }
1687
+		    if (isset($line['transponder'])) {
1688
+		    	$data['squawk'] = $line['transponder'];
1689
+		    }
1690
+		    if (isset($line['atis'])) {
1691
+		    	$data['info'] = $line['atis'];
1692
+		    } else {
1693
+		    	$data['info'] = '';
1694
+		    }
1221 1695
 		    $data['format_source'] = 'pireps';
1222 1696
     		    $data['id_source'] = $id_source;
1223 1697
 		    $data['datetime'] = date('Y-m-d H:i:s');
1224
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1225
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1698
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1699
+		    	$data['noarchive'] = true;
1700
+		    }
1701
+		    if (isset($value['name']) && $value['name'] != '') {
1702
+		    	$data['source_name'] = $value['name'];
1703
+		    }
1226 1704
 		    if ($line['icon'] === 'plane') {
1227 1705
 			$SI->add($data);
1228 1706
 		    //    print_r($data);
@@ -1231,16 +1709,28 @@  discard block
 block discarded – undo
1231 1709
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1232 1710
 			$typec = substr($data['ident'],-3);
1233 1711
 			$data['type'] = '';
1234
-			if ($typec === 'APP') $data['type'] = 'Approach';
1235
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1236
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1237
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1238
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1239
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1240
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1241
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1242
-			else $data['type'] = 'Observer';
1243
-			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']);
1712
+			if ($typec === 'APP') {
1713
+				$data['type'] = 'Approach';
1714
+			} elseif ($typec === 'TWR') {
1715
+				$data['type'] = 'Tower';
1716
+			} elseif ($typec === 'OBS') {
1717
+				$data['type'] = 'Observer';
1718
+			} elseif ($typec === 'GND') {
1719
+				$data['type'] = 'Ground';
1720
+			} elseif ($typec === 'DEL') {
1721
+				$data['type'] = 'Delivery';
1722
+			} elseif ($typec === 'DEP') {
1723
+				$data['type'] = 'Departure';
1724
+			} elseif ($typec === 'FSS') {
1725
+				$data['type'] = 'Flight Service Station';
1726
+			} elseif ($typec === 'CTR') {
1727
+				$data['type'] = 'Control Radar or Centre';
1728
+			} else {
1729
+				$data['type'] = 'Observer';
1730
+			}
1731
+			if (isset($ATC)) {
1732
+				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']);
1733
+			}
1244 1734
 		    }
1245 1735
 		    unset($data);
1246 1736
 		}
@@ -1255,7 +1745,9 @@  discard block
 block discarded – undo
1255 1745
 	    )
1256 1746
 	) {
1257 1747
 	    //$buffer = $Common->getData($hosts[$id]);
1258
-	    if ($globalDebug) echo 'Get Data...'."\n";
1748
+	    if ($globalDebug) {
1749
+	    	echo 'Get Data...'."\n";
1750
+	    }
1259 1751
 	    $buffer = $Common->getData($value['host']);
1260 1752
 	    $all_data = json_decode($buffer,true);
1261 1753
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1263,10 +1755,16 @@  discard block
 block discarded – undo
1263 1755
 		foreach ($all_data as $line) {
1264 1756
 	    	    $data = array();
1265 1757
 	    	    //$data['id'] = $line['id']; // id not usable
1266
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1758
+	    	    if (isset($line['pilotid'])) {
1759
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1760
+	    	    }
1267 1761
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1268
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1269
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1762
+	    	    if (isset($line['pilotname'])) {
1763
+	    	    	$data['pilot_name'] = $line['pilotname'];
1764
+	    	    }
1765
+	    	    if (isset($line['pilotid'])) {
1766
+	    	    	$data['pilot_id'] = $line['pilotid'];
1767
+	    	    }
1270 1768
 	    	    $data['ident'] = $line['flightnum']; // ident
1271 1769
 	    	    $data['altitude'] = $line['alt']; // altitude
1272 1770
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1282,7 +1780,9 @@  discard block
 block discarded – undo
1282 1780
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1283 1781
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1284 1782
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1285
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1783
+	    	    } else {
1784
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1785
+	    	    }
1286 1786
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1287 1787
 	    	    $data['departure_airport_time'] = $line['deptime'];
1288 1788
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1290,29 +1790,47 @@  discard block
 block discarded – undo
1290 1790
     		    if (isset($line['registration'])) {
1291 1791
     			$data['registration'] = $line['registration'];
1292 1792
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1293
-    		    } else $data['registration'] = $line['aircraft'];
1294
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1295
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1793
+    		    } else {
1794
+    		    	$data['registration'] = $line['aircraft'];
1795
+    		    }
1796
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1797
+		    	$data['noarchive'] = true;
1798
+		    }
1799
+		    if (isset($line['route'])) {
1800
+		    	$data['waypoints'] = $line['route'];
1801
+		    }
1802
+		    // route
1296 1803
 		    if (isset($line['aircraftname'])) {
1297 1804
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1298 1805
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1299 1806
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1300
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1301
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1302
-	    		else {
1807
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1808
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1809
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1810
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1811
+	    		} else {
1303 1812
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1304
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1305
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1813
+	    		    if (isset($aircraft_data[1])) {
1814
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1815
+	    		    } else {
1816
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1817
+	    		    }
1306 1818
 	    		}
1307 1819
 	    	    }
1308
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1820
+    		    if (isset($line['route'])) {
1821
+    		    	$data['waypoints'] = $line['route'];
1822
+    		    }
1309 1823
     		    $data['id_source'] = $id_source;
1310 1824
 	    	    $data['format_source'] = 'phpvmacars';
1311
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1825
+		    if (isset($value['name']) && $value['name'] != '') {
1826
+		    	$data['source_name'] = $value['name'];
1827
+		    }
1312 1828
 		    $SI->add($data);
1313 1829
 		    unset($data);
1314 1830
 		}
1315
-		if ($globalDebug) echo 'No more data...'."\n";
1831
+		if ($globalDebug) {
1832
+			echo 'No more data...'."\n";
1833
+		}
1316 1834
 		unset($buffer);
1317 1835
 		unset($all_data);
1318 1836
 	    }
@@ -1325,7 +1843,9 @@  discard block
 block discarded – undo
1325 1843
 	    )
1326 1844
 	) {
1327 1845
 	    //$buffer = $Common->getData($hosts[$id]);
1328
-	    if ($globalDebug) echo 'Get Data...'."\n";
1846
+	    if ($globalDebug) {
1847
+	    	echo 'Get Data...'."\n";
1848
+	    }
1329 1849
 	    $buffer = $Common->getData($value['host']);
1330 1850
 	    $all_data = json_decode($buffer,true);
1331 1851
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1336,10 +1856,16 @@  discard block
 block discarded – undo
1336 1856
 	    	    //$data['id'] = $line['id']; // id not usable
1337 1857
 	    	    $data['id'] = $line['id'];
1338 1858
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1339
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1340
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1859
+	    	    if (isset($line['user']['username'])) {
1860
+	    	    	$data['pilot_name'] = $line['user']['username'];
1861
+	    	    }
1862
+	    	    if (isset($line['user_id'])) {
1863
+	    	    	$data['pilot_id'] = $line['user_id'];
1864
+	    	    }
1341 1865
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1342
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1866
+	    	    if (is_numeric($data['ident'])) {
1867
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1868
+	    	    }
1343 1869
 	    	    $data['altitude'] = $line['altitude']; // altitude
1344 1870
 	    	    $data['speed'] = $line['groundspeed']; // speed
1345 1871
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1352,7 +1878,9 @@  discard block
 block discarded – undo
1352 1878
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1353 1879
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1354 1880
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1355
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1881
+	    	    } else {
1882
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1883
+	    	    }
1356 1884
 	    	    
1357 1885
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1358 1886
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1360,17 +1888,26 @@  discard block
 block discarded – undo
1360 1888
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1361 1889
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1362 1890
 
1363
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1364
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1891
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1892
+		    	$data['noarchive'] = true;
1893
+		    }
1894
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
1895
+		    	$data['waypoints'] = $line['bid']['route'];
1896
+		    }
1897
+		    // route
1365 1898
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1366 1899
 
1367 1900
     		    $data['id_source'] = $id_source;
1368 1901
 	    	    $data['format_source'] = 'vaos';
1369
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1902
+		    if (isset($value['name']) && $value['name'] != '') {
1903
+		    	$data['source_name'] = $value['name'];
1904
+		    }
1370 1905
 		    $SI->add($data);
1371 1906
 		    unset($data);
1372 1907
 		}
1373
-		if ($globalDebug) echo 'No more data...'."\n";
1908
+		if ($globalDebug) {
1909
+			echo 'No more data...'."\n";
1910
+		}
1374 1911
 		unset($buffer);
1375 1912
 		unset($all_data);
1376 1913
 	    }
@@ -1383,7 +1920,9 @@  discard block
 block discarded – undo
1383 1920
 	    )
1384 1921
 	) {
1385 1922
 	    //$buffer = $Common->getData($hosts[$id]);
1386
-	    if ($globalDebug) echo 'Get Data...'."\n";
1923
+	    if ($globalDebug) {
1924
+	    	echo 'Get Data...'."\n";
1925
+	    }
1387 1926
 	    $buffer = $Common->getData($value['host']);
1388 1927
 	    $all_data = json_decode($buffer,true);
1389 1928
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1412,16 +1951,25 @@  discard block
 block discarded – undo
1412 1951
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1413 1952
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1414 1953
     		    //$data['registration'] = $line['aircraft'];
1415
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1954
+		    if (isset($line['route'])) {
1955
+		    	$data['waypoints'] = $line['route'];
1956
+		    }
1957
+		    // route
1416 1958
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1417 1959
     		    $data['id_source'] = $id_source;
1418 1960
 	    	    $data['format_source'] = 'vam';
1419
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1420
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1961
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1962
+		    	$data['noarchive'] = true;
1963
+		    }
1964
+		    if (isset($value['name']) && $value['name'] != '') {
1965
+		    	$data['source_name'] = $value['name'];
1966
+		    }
1421 1967
 		    $SI->add($data);
1422 1968
 		    unset($data);
1423 1969
 		}
1424
-		if ($globalDebug) echo 'No more data...'."\n";
1970
+		if ($globalDebug) {
1971
+			echo 'No more data...'."\n";
1972
+		}
1425 1973
 		unset($buffer);
1426 1974
 		unset($all_data);
1427 1975
 	    }
@@ -1434,7 +1982,9 @@  discard block
 block discarded – undo
1434 1982
 	    )
1435 1983
 	) {
1436 1984
 	    //$buffer = $Common->getData($hosts[$id]);
1437
-	    if ($globalDebug) echo 'Get Data...'."\n";
1985
+	    if ($globalDebug) {
1986
+	    	echo 'Get Data...'."\n";
1987
+	    }
1438 1988
 	    $buffer = $Common->getData($value['host']);
1439 1989
 	    $all_data = json_decode($buffer,true);
1440 1990
 	    if ($buffer != '') {
@@ -1452,12 +2002,16 @@  discard block
 block discarded – undo
1452 2002
 			$data['id_source'] = $id_source;
1453 2003
 			$data['format_source'] = 'blitzortung';
1454 2004
 			$SI->add($data);
1455
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2005
+			if ($globalDebug) {
2006
+				echo '☈ Lightning added'."\n";
2007
+			}
1456 2008
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1457 2009
 			unset($data);
1458 2010
 		    }
1459 2011
 		}
1460
-		if ($globalDebug) echo 'No more data...'."\n";
2012
+		if ($globalDebug) {
2013
+			echo 'No more data...'."\n";
2014
+		}
1461 2015
 		unset($buffer);
1462 2016
 	    }
1463 2017
 	    $last_exec[$id]['last'] = time();
@@ -1469,7 +2023,9 @@  discard block
 block discarded – undo
1469 2023
 	    $write = NULL;
1470 2024
 	    $e = NULL;
1471 2025
 	    $n = socket_select($read, $write, $e, $timeout);
1472
-	    if ($e != NULL) var_dump($e);
2026
+	    if ($e != NULL) {
2027
+	    	var_dump($e);
2028
+	    }
1473 2029
 	    if ($n > 0) {
1474 2030
 		$reset = 0;
1475 2031
 		foreach ($read as $nb => $r) {
@@ -1491,13 +2047,17 @@  discard block
 block discarded – undo
1491 2047
 		    if ($buffer !== FALSE) {
1492 2048
 			if ($format === 'vrstcp') {
1493 2049
 			    $buffer = explode('},{',$buffer);
1494
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2050
+			} else {
2051
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2052
+			}
1495 2053
 		    }
1496 2054
 		    // SBS format is CSV format
1497 2055
 		    if ($buffer !== FALSE && $buffer !== '') {
1498 2056
 			$tt[$format] = 0;
1499 2057
 			if ($format === 'acarssbs3') {
1500
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2058
+			    if ($globalDebug) {
2059
+			    	echo 'ACARS : '.$buffer."\n";
2060
+			    }
1501 2061
 			    $ACARS->add(trim($buffer));
1502 2062
 			    $ACARS->deleteLiveAcarsData();
1503 2063
 			} elseif ($format === 'raw') {
@@ -1506,30 +2066,70 @@  discard block
 block discarded – undo
1506 2066
 			    if (is_array($data)) {
1507 2067
 				$data['datetime'] = date('Y-m-d H:i:s');
1508 2068
 				$data['format_source'] = 'raw';
1509
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1510
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1511
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1512
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2069
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2070
+					$data['source_name'] = $globalSources[$nb]['name'];
2071
+				}
2072
+				if (isset($globalSources[$nb]['sourcestats'])) {
2073
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2074
+				}
2075
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2076
+					$data['noarchive'] = true;
2077
+				}
2078
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2079
+					$SI->add($data);
2080
+				}
1513 2081
 			    }
1514 2082
 			} elseif ($format === 'ais') {
1515 2083
 			    $ais_data = $AIS->parse_line(trim($buffer));
1516 2084
 			    $data = array();
1517
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1518
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1519
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1520
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1521
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1522
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1523
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1524
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1525
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1526
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1527
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1528
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1529
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1530
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1531
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1532
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2085
+			    if (isset($ais_data['ident'])) {
2086
+			    	$data['ident'] = $ais_data['ident'];
2087
+			    }
2088
+			    if (isset($ais_data['mmsi'])) {
2089
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2090
+			    }
2091
+			    if (isset($ais_data['speed'])) {
2092
+			    	$data['speed'] = $ais_data['speed'];
2093
+			    }
2094
+			    if (isset($ais_data['heading'])) {
2095
+			    	$data['heading'] = $ais_data['heading'];
2096
+			    }
2097
+			    if (isset($ais_data['latitude'])) {
2098
+			    	$data['latitude'] = $ais_data['latitude'];
2099
+			    }
2100
+			    if (isset($ais_data['longitude'])) {
2101
+			    	$data['longitude'] = $ais_data['longitude'];
2102
+			    }
2103
+			    if (isset($ais_data['status'])) {
2104
+			    	$data['status'] = $ais_data['status'];
2105
+			    }
2106
+			    if (isset($ais_data['statusid'])) {
2107
+			    	$data['status_id'] = $ais_data['statusid'];
2108
+			    }
2109
+			    if (isset($ais_data['type'])) {
2110
+			    	$data['type'] = $ais_data['type'];
2111
+			    }
2112
+			    if (isset($ais_data['imo'])) {
2113
+			    	$data['imo'] = $ais_data['imo'];
2114
+			    }
2115
+			    if (isset($ais_data['callsign'])) {
2116
+			    	$data['callsign'] = $ais_data['callsign'];
2117
+			    }
2118
+			    if (isset($ais_data['destination'])) {
2119
+			    	$data['arrival_code'] = $ais_data['destination'];
2120
+			    }
2121
+			    if (isset($ais_data['eta_ts'])) {
2122
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2123
+			    }
2124
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2125
+			    	$data['noarchive'] = true;
2126
+			    }
2127
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2128
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2129
+			    }
2130
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2131
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2132
+			    }
1533 2133
 
1534 2134
 			    if (isset($ais_data['timestamp'])) {
1535 2135
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1538,7 +2138,9 @@  discard block
 block discarded – undo
1538 2138
 			    }
1539 2139
 			    $data['format_source'] = 'aisnmea';
1540 2140
     			    $data['id_source'] = $id_source;
1541
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2141
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2142
+			    	$MI->add($data);
2143
+			    }
1542 2144
 			    unset($data);
1543 2145
                         } elseif ($format === 'flightgearsp') {
1544 2146
                     	    //echo $buffer."\n";
@@ -1556,12 +2158,18 @@  discard block
 block discarded – undo
1556 2158
 				$data['speed'] = round($line[5]*1.94384);
1557 2159
 				$data['datetime'] = date('Y-m-d H:i:s');
1558 2160
 				$data['format_source'] = 'flightgearsp';
1559
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1560
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2161
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2162
+					$data['noarchive'] = true;
2163
+				}
2164
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2165
+					$SI->add($data);
2166
+				}
1561 2167
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1562 2168
 			    }
1563 2169
                         } elseif ($format === 'acars') {
1564
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2170
+                    	    if ($globalDebug) {
2171
+                    	    	echo 'ACARS : '.$buffer."\n";
2172
+                    	    }
1565 2173
 			    $ACARS->add(trim($buffer));
1566 2174
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1567 2175
 			    $ACARS->deleteLiveAcarsData();
@@ -1582,8 +2190,12 @@  discard block
 block discarded – undo
1582 2190
 				    $aircraft_type = $line[10];
1583 2191
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1584 2192
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1585
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1586
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2193
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2194
+				    	$data['noarchive'] = true;
2195
+				    }
2196
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2197
+				    	$SI->add($data);
2198
+				    }
1587 2199
 				}
1588 2200
 			    }
1589 2201
 			} elseif ($format === 'beast') {
@@ -1593,28 +2205,62 @@  discard block
 block discarded – undo
1593 2205
 			    foreach($buffer as $all_data) {
1594 2206
 				$line = json_decode('{'.$all_data.'}',true);
1595 2207
 				$data = array();
1596
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1597
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1598
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1599
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1600
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1601
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1602
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2208
+				if (isset($line['Icao'])) {
2209
+					$data['hex'] = $line['Icao'];
2210
+				}
2211
+				// hex
2212
+				if (isset($line['Call'])) {
2213
+					$data['ident'] = $line['Call'];
2214
+				}
2215
+				// ident
2216
+				if (isset($line['Alt'])) {
2217
+					$data['altitude'] = $line['Alt'];
2218
+				}
2219
+				// altitude
2220
+				if (isset($line['Spd'])) {
2221
+					$data['speed'] = $line['Spd'];
2222
+				}
2223
+				// speed
2224
+				if (isset($line['Trak'])) {
2225
+					$data['heading'] = $line['Trak'];
2226
+				}
2227
+				// heading
2228
+				if (isset($line['Lat'])) {
2229
+					$data['latitude'] = $line['Lat'];
2230
+				}
2231
+				// lat
2232
+				if (isset($line['Long'])) {
2233
+					$data['longitude'] = $line['Long'];
2234
+				}
2235
+				// long
1603 2236
 				//$data['verticalrate'] = $line['']; // verticale rate
1604
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2237
+				if (isset($line['Sqk'])) {
2238
+					$data['squawk'] = $line['Sqk'];
2239
+				}
2240
+				// squawk
1605 2241
 				$data['emergency'] = ''; // emergency
1606
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2242
+				if (isset($line['Reg'])) {
2243
+					$data['registration'] = $line['Reg'];
2244
+				}
1607 2245
 				/*
1608 2246
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1609 2247
 				else $data['datetime'] = date('Y-m-d H:i:s');
1610 2248
 				*/
1611 2249
 				$data['datetime'] = date('Y-m-d H:i:s');
1612
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2250
+				if (isset($line['Type'])) {
2251
+					$data['aircraft_icao'] = $line['Type'];
2252
+				}
1613 2253
 		    		$data['format_source'] = 'vrstcp';
1614 2254
 				$data['id_source'] = $id_source;
1615
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1616
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1617
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2255
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2256
+					$data['noarchive'] = true;
2257
+				}
2258
+				if (isset($value['name']) && $value['name'] != '') {
2259
+					$data['source_name'] = $value['name'];
2260
+				}
2261
+				if (isset($data['latitude']) && isset($data['hex'])) {
2262
+					$SI->add($data);
2263
+				}
1618 2264
 				unset($data);
1619 2265
 			    }
1620 2266
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1627,22 +2273,46 @@  discard block
 block discarded – undo
1627 2273
     				$data['hex'] = $lined['hexid'];
1628 2274
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1629 2275
     				$data['datetime'] = date('Y-m-d H:i:s');;
1630
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1631
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1632
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1633
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1634
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1635
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1636
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2276
+    				if (isset($lined['ident'])) {
2277
+    					$data['ident'] = $lined['ident'];
2278
+    				}
2279
+    				if (isset($lined['lat'])) {
2280
+    					$data['latitude'] = $lined['lat'];
2281
+    				}
2282
+    				if (isset($lined['lon'])) {
2283
+    					$data['longitude'] = $lined['lon'];
2284
+    				}
2285
+    				if (isset($lined['speed'])) {
2286
+    					$data['speed'] = $lined['speed'];
2287
+    				}
2288
+    				if (isset($lined['squawk'])) {
2289
+    					$data['squawk'] = $lined['squawk'];
2290
+    				}
2291
+    				if (isset($lined['alt'])) {
2292
+    					$data['altitude'] = $lined['alt'];
2293
+    				}
2294
+    				if (isset($lined['heading'])) {
2295
+    					$data['heading'] = $lined['heading'];
2296
+    				}
1637 2297
     				$data['id_source'] = $id_source;
1638 2298
     				$data['format_source'] = 'tsv';
1639
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1640
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1641
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1642
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2299
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2300
+    					$data['source_name'] = $globalSources[$nb]['name'];
2301
+    				}
2302
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2303
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2304
+    				}
2305
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2306
+					$data['noarchive'] = true;
2307
+				}
2308
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2309
+    					$SI->add($data);
2310
+    				}
1643 2311
     				unset($lined);
1644 2312
     				unset($data);
1645
-    			    } else $error = true;
2313
+    			    } else {
2314
+    			    	$error = true;
2315
+    			    }
1646 2316
 			} elseif ($format === 'aprs' && $use_aprs) {
1647 2317
 			    if ($aprs_connect === 0) {
1648 2318
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1668,63 +2338,121 @@  discard block
 block discarded – undo
1668 2338
 				    $aprs_last_tx = time();
1669 2339
 				    $data = array();
1670 2340
 				    //print_r($line);
1671
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1672
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1673
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1674
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1675
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1676
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1677
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1678
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1679
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1680
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2341
+				    if (isset($line['address'])) {
2342
+				    	$data['hex'] = $line['address'];
2343
+				    }
2344
+				    if (isset($line['mmsi'])) {
2345
+				    	$data['mmsi'] = $line['mmsi'];
2346
+				    }
2347
+				    if (isset($line['imo'])) {
2348
+				    	$data['imo'] = $line['imo'];
2349
+				    }
2350
+				    if (isset($line['squawk'])) {
2351
+				    	$data['squawk'] = $line['squawk'];
2352
+				    }
2353
+				    if (isset($line['arrival_code'])) {
2354
+				    	$data['arrival_code'] = $line['arrival_code'];
2355
+				    }
2356
+				    if (isset($line['arrival_date'])) {
2357
+				    	$data['arrival_date'] = $line['arrival_date'];
2358
+				    }
2359
+				    if (isset($line['typeid'])) {
2360
+				    	$data['type_id'] = $line['typeid'];
2361
+				    }
2362
+				    if (isset($line['statusid'])) {
2363
+				    	$data['status_id'] = $line['statusid'];
2364
+				    }
2365
+				    if (isset($line['timestamp'])) {
2366
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2367
+				    } else {
2368
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2369
+				    }
1681 2370
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1682
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2371
+				    if (isset($line['ident'])) {
2372
+				    	$data['ident'] = $line['ident'];
2373
+				    }
1683 2374
 				    $data['latitude'] = $line['latitude'];
1684 2375
 				    $data['longitude'] = $line['longitude'];
1685 2376
 				    //$data['verticalrate'] = $line[16];
1686
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2377
+				    if (isset($line['speed'])) {
2378
+				    	$data['speed'] = $line['speed'];
2379
+				    }
1687 2380
 				    //else $data['speed'] = 0;
1688
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1689
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1690
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2381
+				    if (isset($line['altitude'])) {
2382
+				    	$data['altitude'] = $line['altitude'];
2383
+				    }
2384
+				    if (isset($line['comment'])) {
2385
+				    	$data['comment'] = $line['comment'];
2386
+				    }
2387
+				    if (isset($line['symbol'])) {
2388
+				    	$data['type'] = $line['symbol'];
2389
+				    }
1691 2390
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1692 2391
 				    
1693
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2392
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2393
+				    	$data['heading'] = $line['heading'];
2394
+				    }
1694 2395
 				    //else echo 'No heading...'."\n";
1695 2396
 				    //else $data['heading'] = 0;
1696
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2397
+				    if (isset($line['stealth'])) {
2398
+				    	$data['aircraft_type'] = $line['stealth'];
2399
+				    }
1697 2400
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1698
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1699
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1700
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1701
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2401
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2402
+				    	$data['noarchive'] = true;
2403
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2404
+				    	$data['noarchive'] = false;
2405
+				    }
2406
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2407
+				    	$data['noarchive'] = true;
2408
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2409
+				    	$data['noarchive'] = false;
2410
+				    }
1702 2411
     				    $data['id_source'] = $id_source;
1703
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1704
-				    else $data['format_source'] = 'aprs';
2412
+    				    if (isset($line['format_source'])) {
2413
+    				    	$data['format_source'] = $line['format_source'];
2414
+    				    } else {
2415
+				    	$data['format_source'] = 'aprs';
2416
+				    }
1705 2417
 				    $data['source_name'] = $line['source'];
1706
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1707
-				    else $data['source_type'] = 'flarm';
1708
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2418
+				    if (isset($line['source_type'])) {
2419
+				    	$data['source_type'] = $line['source_type'];
2420
+				    } else {
2421
+				    	$data['source_type'] = 'flarm';
2422
+				    }
2423
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2424
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2425
+    				    }
1709 2426
 				    $currentdate = date('Y-m-d H:i:s');
1710 2427
 				    $aprsdate = strtotime($data['datetime']);
1711
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2428
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2429
+				    	$data['altitude_relative'] = 'AMSL';
2430
+				    }
1712 2431
 				    // Accept data if time <= system time + 20s
1713 2432
 				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1714 2433
 				    if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1715 2434
 					$send = $SI->add($data);
1716 2435
 				    } elseif ($data['source_type'] === 'ais') {
1717 2436
 					$data['type'] = '';
1718
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2437
+					if (isset($globalMarine) && $globalMarine) {
2438
+						$send = $MI->add($data);
2439
+					}
1719 2440
 				    } elseif (isset($line['stealth'])) {
1720
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1721
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2441
+					if ($line['stealth'] != 0) {
2442
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
2443
+					} else {
2444
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2445
+					}
1722 2446
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1723 2447
 					    //$line['symbol'] === 'Balloon' ||
1724 2448
 					    $line['symbol'] === 'Glider' || 
1725 2449
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1726
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1727
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2450
+					    if ($line['symbol'] === 'Ballon') {
2451
+					    	$data['aircraft_icao'] = 'BALL';
2452
+					    }
2453
+					    if ($line['symbol'] === 'Glider') {
2454
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2455
+					    }
1728 2456
 					    $send = $SI->add($data);
1729 2457
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1730 2458
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1755,9 +2483,13 @@  discard block
 block discarded – undo
1755 2483
 				    //} 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') {
1756 2484
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1757 2485
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1758
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2486
+					if (isset($globalTracker) && $globalTracker) {
2487
+						$send = $TI->add($data);
2488
+					}
1759 2489
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1760
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2490
+					if (!isset($data['altitude'])) {
2491
+						$data['altitude'] = 0;
2492
+					}
1761 2493
 					$Source->deleteOldLocationByType('gs');
1762 2494
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1763 2495
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1766,7 +2498,9 @@  discard block
 block discarded – undo
1766 2498
 					}
1767 2499
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1768 2500
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1769
-					if ($globalDebug) echo '# Weather Station added'."\n";
2501
+					if ($globalDebug) {
2502
+						echo '# Weather Station added'."\n";
2503
+					}
1770 2504
 					$Source->deleteOldLocationByType('wx');
1771 2505
 					$weather_data = json_encode($line);
1772 2506
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1776,7 +2510,9 @@  discard block
 block discarded – undo
1776 2510
 					}
1777 2511
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1778 2512
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1779
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2513
+					if ($globalDebug) {
2514
+						echo '☈ Lightning added'."\n";
2515
+					}
1780 2516
 					$Source->deleteOldLocationByType('lightning');
1781 2517
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1782 2518
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1788,8 +2524,7 @@  discard block
 block discarded – undo
1788 2524
 				    	print_r($line);
1789 2525
 				    }
1790 2526
 				    unset($data);
1791
-				}
1792
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2527
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1793 2528
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1794 2529
 				}
1795 2530
 				/*
@@ -1798,7 +2533,9 @@  discard block
 block discarded – undo
1798 2533
 				}
1799 2534
 				*/
1800 2535
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1801
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2536
+				elseif ($line === true && $globalDebug) {
2537
+					echo '!! Failed : '.$buffer."!!\n";
2538
+				}
1802 2539
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1803 2540
 					$Source->deleteOldLocationByType('lightning');
1804 2541
 					$Source->deleteOldLocationByType('wx');
@@ -1834,26 +2571,45 @@  discard block
 block discarded – undo
1834 2571
     				$data['ground'] = $line[21];
1835 2572
     				$data['emergency'] = $line[19];
1836 2573
     				$data['format_source'] = 'sbs';
1837
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1838
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1839
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2574
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2575
+					$data['source_name'] = $globalSources[$nb]['name'];
2576
+				}
2577
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2578
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2579
+    				}
2580
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2581
+					$data['noarchive'] = true;
2582
+				}
1840 2583
     				$data['id_source'] = $id_source;
1841
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1842
-    				else $error = true;
2584
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2585
+    					$send = $SI->add($data);
2586
+    				} else {
2587
+    					$error = true;
2588
+    				}
1843 2589
     				unset($data);
1844
-    			    } else $error = true;
2590
+    			    } else {
2591
+    			    	$error = true;
2592
+    			    }
1845 2593
 			    if ($error) {
1846 2594
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1847
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2595
+					if ($globalDebug) {
2596
+						echo "Not a message. Ignoring... \n";
2597
+					}
1848 2598
 				} else {
1849
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2599
+					if ($globalDebug) {
2600
+						echo "Wrong line format. Ignoring... \n";
2601
+					}
1850 2602
 					if ($globalDebug) {
1851 2603
 						echo $buffer;
1852 2604
 						//print_r($line);
1853 2605
 					}
1854 2606
 					//socket_close($r);
1855
-					if ($globalDebug) echo "Reconnect after an error...\n";
1856
-					if ($format === 'aprs') $aprs_connect = 0;
2607
+					if ($globalDebug) {
2608
+						echo "Reconnect after an error...\n";
2609
+					}
2610
+					if ($format === 'aprs') {
2611
+						$aprs_connect = 0;
2612
+					}
1857 2613
 					$sourceer[$nb] = $globalSources[$nb];
1858 2614
 					connect_all($sourceer);
1859 2615
 					$sourceer = array();
@@ -1861,10 +2617,14 @@  discard block
 block discarded – undo
1861 2617
 			    }
1862 2618
 			}
1863 2619
 			// Sleep for xxx microseconds
1864
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2620
+			if (isset($globalSBSSleep)) {
2621
+				usleep($globalSBSSleep);
2622
+			}
1865 2623
 		    } else {
1866 2624
 			if ($format === 'flightgearmp') {
1867
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2625
+			    	if ($globalDebug) {
2626
+			    		echo "Reconnect FlightGear MP...";
2627
+			    	}
1868 2628
 				//@socket_close($r);
1869 2629
 				sleep($globalMinFetch);
1870 2630
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1873,10 +2633,15 @@  discard block
 block discarded – undo
1873 2633
 				break;
1874 2634
 				
1875 2635
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1876
-			    if (isset($tt[$format])) $tt[$format]++;
1877
-			    else $tt[$format] = 0;
2636
+			    if (isset($tt[$format])) {
2637
+			    	$tt[$format]++;
2638
+			    } else {
2639
+			    	$tt[$format] = 0;
2640
+			    }
1878 2641
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
1879
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2642
+				if ($globalDebug) {
2643
+					echo "ERROR : Reconnect ".$format."...";
2644
+				}
1880 2645
 				//@socket_close($r);
1881 2646
 				sleep(2);
1882 2647
 				$aprs_connect = 0;
@@ -1894,11 +2659,17 @@  discard block
 block discarded – undo
1894 2659
 	    } else {
1895 2660
 		$error = socket_strerror(socket_last_error());
1896 2661
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1897
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1898
-			if (isset($globalDebug)) echo "Restarting...\n";
2662
+			if ($globalDebug) {
2663
+				echo "ERROR : socket_select give this error ".$error . "\n";
2664
+			}
2665
+			if (isset($globalDebug)) {
2666
+				echo "Restarting...\n";
2667
+			}
1899 2668
 			// Restart the script if possible
1900 2669
 			if (is_array($sockets)) {
1901
-			    if ($globalDebug) echo "Shutdown all sockets...";
2670
+			    if ($globalDebug) {
2671
+			    	echo "Shutdown all sockets...";
2672
+			    }
1902 2673
 			    
1903 2674
 			    foreach ($sockets as $sock) {
1904 2675
 				@socket_shutdown($sock,2);
@@ -1906,25 +2677,45 @@  discard block
 block discarded – undo
1906 2677
 			    }
1907 2678
 			    
1908 2679
 			}
1909
-			if ($globalDebug) echo "Waiting...";
2680
+			if ($globalDebug) {
2681
+				echo "Waiting...";
2682
+			}
1910 2683
 			sleep(2);
1911 2684
 			$time = time();
1912 2685
 			//connect_all($hosts);
1913 2686
 			$aprs_connect = 0;
1914
-			if ($reset%5 === 0) sleep(20);
1915
-			if ($reset%10 === 0) sleep(100);
1916
-			if ($reset%20 === 0) sleep(200);
1917
-			if ($reset > 100) exit('Too many attempts...');
1918
-			if ($globalDebug) echo "Restart all connections...";
2687
+			if ($reset%5 === 0) {
2688
+				sleep(20);
2689
+			}
2690
+			if ($reset%10 === 0) {
2691
+				sleep(100);
2692
+			}
2693
+			if ($reset%20 === 0) {
2694
+				sleep(200);
2695
+			}
2696
+			if ($reset > 100) {
2697
+				exit('Too many attempts...');
2698
+			}
2699
+			if ($globalDebug) {
2700
+				echo "Restart all connections...";
2701
+			}
1919 2702
 			connect_all($globalSources);
1920 2703
 		}
1921 2704
 	    }
1922 2705
 	}
1923 2706
 	if ($globalDaemon === false) {
1924
-	    if ($globalDebug) echo 'Check all...'."\n";
1925
-	    if (isset($SI)) $SI->checkAll();
1926
-	    if (isset($TI)) $TI->checkAll();
1927
-	    if (isset($MI)) $MI->checkAll();
2707
+	    if ($globalDebug) {
2708
+	    	echo 'Check all...'."\n";
2709
+	    }
2710
+	    if (isset($SI)) {
2711
+	    	$SI->checkAll();
2712
+	    }
2713
+	    if (isset($TI)) {
2714
+	    	$TI->checkAll();
2715
+	    }
2716
+	    if (isset($MI)) {
2717
+	    	$MI->checkAll();
2718
+	    }
1928 2719
 	}
1929 2720
     }
1930 2721
 }
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +404 added lines, -144 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54 54
 		} catch(Exception $e) {
55
-			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
55
+			if ($globalDebug) {
56
+				echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
57
+			}
56 58
 			$GeoidClass = FALSE;
57 59
 		}
58 60
 	}
@@ -71,7 +73,9 @@  discard block
 block discarded – undo
71 73
 	$dbc = $this->db;
72 74
 	$this->all_flights[$id]['schedule_check'] = true;
73 75
 	if ($globalSchedulesFetch) {
74
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
76
+	if ($globalDebug) {
77
+		echo 'Getting schedule info...'."\n";
78
+	}
75 79
 	$Spotter = new Spotter($dbc);
76 80
 	$Schedule = new Schedule($dbc);
77 81
 	$Translation = new Translation($dbc);
@@ -82,7 +86,9 @@  discard block
 block discarded – undo
82 86
 	    if ($Schedule->checkSchedule($operator) == 0) {
83 87
 		$schedule = $Schedule->fetchSchedule($operator);
84 88
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
89
+		    if ($globalDebug) {
90
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
91
+		    }
86 92
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87 93
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88 94
 		    // Should also check if route schedule = route from DB
@@ -91,7 +97,9 @@  discard block
 block discarded – undo
91 97
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92 98
 			    if (trim($airport_icao) != '') {
93 99
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
100
+				if ($globalDebug) {
101
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
102
+				}
95 103
 			    }
96 104
 			}
97 105
 		    }
@@ -100,20 +108,30 @@  discard block
 block discarded – undo
100 108
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101 109
 			    if (trim($airport_icao) != '') {
102 110
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
111
+				if ($globalDebug) {
112
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
113
+				}
104 114
 			    }
105 115
 			}
106 116
 		    }
107 117
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
108 118
 		}
109
-	    } else $scheduleexist = true;
110
-	} else $scheduleexist = true;
119
+	    } else {
120
+	    	$scheduleexist = true;
121
+	    }
122
+	} else {
123
+		$scheduleexist = true;
124
+	}
111 125
 	// close connection, at least one way will work ?
112 126
        if ($scheduleexist) {
113
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
127
+		if ($globalDebug) {
128
+			echo "-> get arrival/departure airport info for ".$ident."\n";
129
+		}
114 130
     		$sch = $Schedule->getSchedule($operator);
115 131
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
116
-		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
132
+		if ($this->all_flights[$id]['addedSpotter'] == 1) {
133
+			$Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
134
+		}
117 135
        }
118 136
 	$Spotter->db = null;
119 137
 	$Schedule->db = null;
@@ -133,14 +151,18 @@  discard block
 block discarded – undo
133 151
 
134 152
     public function checkAll() {
135 153
 	global $globalDebug, $globalNoImport;
136
-	if ($globalDebug) echo "Update last seen flights data...\n";
154
+	if ($globalDebug) {
155
+		echo "Update last seen flights data...\n";
156
+	}
137 157
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
138 158
 	    foreach ($this->all_flights as $key => $flight) {
139 159
 		if (isset($this->all_flights[$key]['id'])) {
140 160
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141 161
     		    $Spotter = new Spotter($this->db);
142 162
         	    $real_arrival = $this->arrival($key);
143
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
163
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) {
164
+        	    	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
165
+        	    }
144 166
         	}
145 167
 	    }
146 168
 	}
@@ -148,24 +170,32 @@  discard block
 block discarded – undo
148 170
 
149 171
     public function arrival($key) {
150 172
 	global $globalClosestMinDist, $globalDebug;
151
-	if ($globalDebug) echo 'Update arrival...'."\n";
173
+	if ($globalDebug) {
174
+		echo 'Update arrival...'."\n";
175
+	}
152 176
 	$Spotter = new Spotter($this->db);
153 177
         $airport_icao = '';
154 178
         $airport_time = '';
155
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
179
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
180
+        	$globalClosestMinDist = 50;
181
+        }
156 182
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
157 183
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
158 184
     	    if (isset($closestAirports[0])) {
159 185
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160 186
         	    $airport_icao = $closestAirports[0]['icao'];
161 187
         	    $airport_time = $this->all_flights[$key]['datetime'];
162
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
188
+        	    if ($globalDebug) {
189
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
190
+        	    }
163 191
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
164 192
         	    foreach ($closestAirports as $airport) {
165 193
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
166 194
         		    $airport_icao = $airport['icao'];
167 195
         		    $airport_time = $this->all_flights[$key]['datetime'];
168
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
196
+        		    if ($globalDebug) {
197
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
198
+        		    }
169 199
         		    break;
170 200
         		}
171 201
         	    }
@@ -173,14 +203,20 @@  discard block
 block discarded – undo
173 203
         		$airport_icao = $closestAirports[0]['icao'];
174 204
         		$airport_time = $this->all_flights[$key]['datetime'];
175 205
         	} else {
176
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
206
+        		if ($globalDebug) {
207
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
208
+        		}
177 209
         	}
178 210
     	    } else {
179
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
211
+    		    if ($globalDebug) {
212
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
213
+    		    }
180 214
     	    }
181 215
 
182 216
         } else {
183
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
217
+        	if ($globalDebug) {
218
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
219
+        	}
184 220
         }
185 221
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
186 222
     }
@@ -190,7 +226,9 @@  discard block
 block discarded – undo
190 226
     public function del() {
191 227
 	global $globalDebug, $globalNoImport, $globalNoDB;
192 228
 	// Delete old infos
193
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
229
+	if ($globalDebug) {
230
+		echo 'Delete old values and update latest data...'."\n";
231
+	}
194 232
 	foreach ($this->all_flights as $key => $flight) {
195 233
 	    if (isset($flight['lastupdate'])) {
196 234
 		if ($flight['lastupdate'] < (time()-1800)) {
@@ -204,13 +242,17 @@  discard block
 block discarded – undo
204 242
 	global $globalDebug, $globalNoImport, $globalNoDB;
205 243
 	// Delete old infos
206 244
 	if (isset($this->all_flights[$key]['id'])) {
207
-		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
245
+		if ($globalDebug) {
246
+			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
247
+		}
208 248
 		if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
209 249
 			$real_arrival = $this->arrival($key);
210 250
 			$Spotter = new Spotter($this->db);
211 251
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
212 252
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
213
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
253
+				if ($globalDebug && $result != 'success') {
254
+					echo '!!! ERROR : '.$result."\n";
255
+				}
214 256
 			}
215 257
 		}
216 258
 	}
@@ -220,9 +262,13 @@  discard block
 block discarded – undo
220 262
     public function add($line) {
221 263
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive;
222 264
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
223
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
224
-	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000;
225
-/*
265
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
266
+		$globalCoordMinChange = '0.01';
267
+	}
268
+	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') {
269
+		$globalAircraftMaxUpdate = 3000;
270
+	}
271
+	/*
226 272
 	$Spotter = new Spotter();
227 273
 	$dbc = $Spotter->db;
228 274
 	$SpotterLive = new SpotterLive($dbc);
@@ -244,19 +290,28 @@  discard block
 block discarded – undo
244 290
 	// SBS format is CSV format
245 291
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
246 292
 	    //print_r($line);
247
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
293
+	    if (isset($line['hex'])) {
294
+	    	$line['hex'] = strtoupper($line['hex']);
295
+	    }
248 296
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
249 297
 
250 298
 		// Increment message number
251 299
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
252 300
 		    $current_date = date('Y-m-d');
253
-		    if (isset($line['source_name'])) $source = $line['source_name'];
254
-		    else $source = '';
255
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
301
+		    if (isset($line['source_name'])) {
302
+		    	$source = $line['source_name'];
303
+		    } else {
304
+		    	$source = '';
305
+		    }
306
+		    if ($source == '' || $line['format_source'] == 'aprs') {
307
+		    	$source = $line['format_source'];
308
+		    }
256 309
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
257 310
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
258 311
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
259
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
312
+		    } else {
313
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
314
+		    }
260 315
 		}
261 316
 		
262 317
 		/*
@@ -272,23 +327,38 @@  discard block
 block discarded – undo
272 327
 		//$this->db = $dbc;
273 328
 
274 329
 		//$hex = trim($line['hex']);
275
-	        if (!isset($line['id'])) $id = trim($line['hex']);
276
-	        else $id = trim($line['id']);
330
+	        if (!isset($line['id'])) {
331
+	        	$id = trim($line['hex']);
332
+	        } else {
333
+	        	$id = trim($line['id']);
334
+	        }
277 335
 		
278 336
 		if (!isset($this->all_flights[$id])) {
279
-		    if ($globalDebug) echo 'New flight...'."\n";
337
+		    if ($globalDebug) {
338
+		    	echo 'New flight...'."\n";
339
+		    }
280 340
 		    $this->all_flights[$id] = array();
281 341
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
282 342
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
283
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
343
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
344
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
345
+		    }
284 346
 		    if (!isset($line['id'])) {
285
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
286
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
347
+			if (!isset($globalDaemon)) {
348
+				$globalDaemon = TRUE;
349
+			}
350
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
287 351
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
288
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
352
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
353
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
354
+			}
289 355
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
290
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
291
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
356
+		     } else {
357
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
358
+		     }
359
+		    if ($globalAllFlights !== FALSE) {
360
+		    	$dataFound = true;
361
+		    }
292 362
 		}
293 363
 		if (isset($line['source_type']) && $line['source_type'] != '') {
294 364
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -310,12 +380,20 @@  discard block
 block discarded – undo
310 380
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
311 381
 			    }
312 382
 			    $Spotter->db = null;
313
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
314
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
383
+			    if ($globalDebugTimeElapsed) {
384
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
385
+			    }
386
+			    if ($aircraft_icao != '') {
387
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
388
+			    }
315 389
 			}
316 390
 		    }
317
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
318
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
391
+		    if ($globalAllFlights !== FALSE) {
392
+		    	$dataFound = true;
393
+		    }
394
+		    if ($globalDebug) {
395
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
396
+		    }
319 397
 		}
320 398
 	        if (isset($line['id']) && !isset($line['hex'])) {
321 399
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
@@ -324,7 +402,9 @@  discard block
 block discarded – undo
324 402
 			$icao = $line['aircraft_icao'];
325 403
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
326 404
 				$Spotter = new Spotter($this->db);
327
-				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
405
+				if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
406
+					$icao = $Spotter->aircraft_correct_icaotype[$icao];
407
+				}
328 408
 				$Spotter->db = null;
329 409
 			}
330 410
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
@@ -334,15 +414,24 @@  discard block
 block discarded – undo
334 414
 				$Spotter = new Spotter($this->db);
335 415
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
336 416
 				$Spotter->db = null;
337
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
417
+				if ($aircraft_icao != '') {
418
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
419
+				}
338 420
 			}
339 421
 		}
340 422
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
341
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
342
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
343
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
344
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
345
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
423
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
424
+				$aircraft_icao = 'GLID';
425
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
426
+				$aircraft_icao = 'UHEL';
427
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
428
+				$aircraft_icao = 'TOWPLANE';
429
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
430
+				$aircraft_icao = 'POWAIRC';
431
+			}
432
+			if (isset($aircraft_icao)) {
433
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
434
+			}
346 435
 		}
347 436
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
348 437
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -352,8 +441,11 @@  discard block
 block discarded – undo
352 441
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
353 442
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
354 443
 		    } else {
355
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
356
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
444
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
445
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
446
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
447
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
448
+				}
357 449
 				/*
358 450
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
359 451
 				print_r($this->all_flights[$id]);
@@ -362,16 +454,22 @@  discard block
 block discarded – undo
362 454
 				return '';
363 455
 		    }
364 456
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
365
-			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
457
+			if ($globalDebug) {
458
+				echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
459
+			}
366 460
 			return '';
367 461
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
368
-			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
462
+			if ($globalDebug) {
463
+				echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
464
+			}
369 465
 			return '';
370 466
 		} elseif (!isset($line['datetime'])) {
371 467
 			date_default_timezone_set('UTC');
372 468
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
373 469
 		} else {
374
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
470
+			if ($globalDebug) {
471
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
472
+			}
375 473
 			return '';
376 474
 		}
377 475
 
@@ -392,30 +490,48 @@  discard block
 block discarded – undo
392 490
 
393 491
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
394 492
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
395
-				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
493
+				if ($globalDebug) {
494
+					echo '---!!!! New ident, reset aircraft data...'."\n";
495
+				}
396 496
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
397 497
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
398
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
399
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
400
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
498
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
499
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
500
+				} elseif (isset($line['id'])) {
501
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
502
+				} elseif (isset($this->all_flights[$id]['ident'])) {
503
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
504
+				}
401 505
 			} else {
402 506
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
403 507
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
404 508
 				$timeelapsed = microtime(true);
405 509
             			$Spotter = new Spotter($this->db);
406 510
             			$fromsource = NULL;
407
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
408
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
409
-				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
410
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
411
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
511
+            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
512
+            				$fromsource = $globalAirlinesSource;
513
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
514
+            				$fromsource = 'vatsim';
515
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
516
+					$fromsource = 'ivao';
517
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
518
+					$fromsource = 'vatsim';
519
+				} elseif (isset($globalIVAO) && $globalIVAO) {
520
+					$fromsource = 'ivao';
521
+				}
412 522
             			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
413
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
523
+				if ($globalDebug && $result != 'success') {
524
+					echo '!!! ERROR : '.$result."\n";
525
+				}
414 526
 				$Spotter->db = null;
415
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
527
+				if ($globalDebugTimeElapsed) {
528
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
529
+				}
416 530
 			    }
417 531
 			}
418
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
532
+		    } else {
533
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
534
+		    }
419 535
 		    
420 536
 /*
421 537
 		    if (!isset($line['id'])) {
@@ -425,7 +541,9 @@  discard block
 block discarded – undo
425 541
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
426 542
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
427 543
   */
428
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
544
+		    if (!isset($this->all_flights[$id]['id'])) {
545
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
546
+		    }
429 547
 
430 548
 		    //$putinarchive = true;
431 549
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -443,7 +561,9 @@  discard block
 block discarded – undo
443 561
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
444 562
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
445 563
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
446
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
564
+				if ($globalDebugTimeElapsed) {
565
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
566
+				}
447 567
                         }
448 568
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
449 569
 			$timeelapsed = microtime(true);
@@ -457,7 +577,9 @@  discard block
 block discarded – undo
457 577
 				$Translation->db = null;
458 578
 			    }
459 579
 			    $Spotter->db = null;
460
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
580
+			    if ($globalDebugTimeElapsed) {
581
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
582
+			    }
461 583
                     	}
462 584
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
463 585
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -466,9 +588,13 @@  discard block
 block discarded – undo
466 588
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
467 589
 		    	    }
468 590
 			}
469
-			if (!isset($globalFork)) $globalFork = TRUE;
591
+			if (!isset($globalFork)) {
592
+				$globalFork = TRUE;
593
+			}
470 594
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
471
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
595
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
596
+					$this->get_Schedule($id,trim($line['ident']));
597
+				}
472 598
 			}
473 599
 		    }
474 600
 		}
@@ -486,9 +612,13 @@  discard block
 block discarded – undo
486 612
 			$speed = $speed*3.6;
487 613
 			if ($speed < 1000) {
488 614
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
489
-	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
615
+	  			if ($globalDebug) {
616
+	  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
617
+	  			}
490 618
 	  		} else {
491
-	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
619
+	  			if ($globalDebug) {
620
+	  				echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
621
+	  			}
492 622
 	  		}
493 623
 		    }
494 624
 		}
@@ -497,13 +627,21 @@  discard block
 block discarded – undo
497 627
 
498 628
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
499 629
 	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
500
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
630
+	    	    	if ($globalDebug) {
631
+	    	    		echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
632
+	    	    	}
501 633
 	    	    	return false;
502 634
 	    	    }
503
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
504
-	    	    else unset($timediff);
505
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
506
-	    	    else unset($timediff_archive);
635
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
636
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
637
+	    	    } else {
638
+	    	    	unset($timediff);
639
+	    	    }
640
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) {
641
+	    	    	$timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
642
+	    	    } else {
643
+	    	    	unset($timediff_archive);
644
+	    	    }
507 645
 	    	    if ($this->tmd > 5
508 646
 	    	        || (isset($line['format_source']) 
509 647
 	    	    	    && $line['format_source'] == 'airwhere' 
@@ -540,16 +678,25 @@  discard block
 block discarded – undo
540 678
 				$this->all_flights[$id]['putinarchive'] = true;
541 679
 				$this->tmd = 0;
542 680
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
543
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
681
+				    if ($globalDebug) {
682
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
683
+				    }
544 684
 				    $timeelapsed = microtime(true);
545 685
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
546 686
 					$Spotter = new Spotter($this->db);
547 687
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
548
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
549
-					else $this->all_flights[$id]['over_country'] = '';
688
+					if (!empty($all_country)) {
689
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
690
+					} else {
691
+						$this->all_flights[$id]['over_country'] = '';
692
+					}
550 693
 					$Spotter->db = null;
551
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
552
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
694
+					if ($globalDebugTimeElapsed) {
695
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
696
+					}
697
+					if ($globalDebug) {
698
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
699
+					}
553 700
 				    }
554 701
 				}
555 702
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
@@ -595,7 +742,9 @@  discard block
 block discarded – undo
595 742
 			    */
596 743
 			}
597 744
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
598
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
745
+			    if ($line['longitude'] > 180) {
746
+			    	$line['longitude'] = $line['longitude'] - 360;
747
+			    }
599 748
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
600 749
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
601 750
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -632,7 +781,9 @@  discard block
 block discarded – undo
632 781
 		    }
633 782
 		}
634 783
 		if (isset($line['last_update']) && $line['last_update'] != '') {
635
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
784
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
785
+		    	$dataFound = true;
786
+		    }
636 787
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
637 788
 		}
638 789
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -654,35 +805,53 @@  discard block
 block discarded – undo
654 805
 			// Here we force archive of flight because after ground it's a new one (or should be)
655 806
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
656 807
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
657
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
658
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
659
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
808
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
809
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
810
+			} elseif (isset($line['id'])) {
811
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
812
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
813
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
814
+			}
815
+		    }
816
+		    if ($line['ground'] != 1) {
817
+		    	$line['ground'] = 0;
660 818
 		    }
661
-		    if ($line['ground'] != 1) $line['ground'] = 0;
662 819
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
663 820
 		    //$dataFound = true;
664 821
 		}
665 822
 		if (isset($line['squawk']) && $line['squawk'] != '') {
666 823
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
667
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
824
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
825
+			    	$this->all_flights[$id]['putinarchive'] = true;
826
+			    }
668 827
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
669 828
 			    $highlight = '';
670
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
671
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
672
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
829
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
830
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
831
+			    }
832
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
833
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
834
+			    }
835
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
836
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
837
+			    }
673 838
 			    if ($highlight != '') {
674 839
 				$timeelapsed = microtime(true);
675 840
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
676 841
 				    $Spotter = new Spotter($this->db);
677 842
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
678 843
 				    $Spotter->db = null;
679
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
844
+				    if ($globalDebugTimeElapsed) {
845
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
846
+				    }
680 847
 				}
681 848
 				//$putinarchive = true;
682 849
 				//$highlight = '';
683 850
 			    }
684 851
 			    
685
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
852
+		    } else {
853
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
854
+		    }
686 855
 		    //$dataFound = true;
687 856
 		}
688 857
 
@@ -695,19 +864,27 @@  discard block
 block discarded – undo
695 864
 				}
696 865
 			}
697 866
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
698
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
867
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
868
+				$this->all_flights[$id]['putinarchive'] = true;
869
+			}
699 870
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
700 871
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
701 872
 			//$dataFound = true;
702 873
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
703 874
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
704 875
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
705
-				if ($globalDebug) echo '--- Reset because of altitude'."\n";
876
+				if ($globalDebug) {
877
+					echo '--- Reset because of altitude'."\n";
878
+				}
706 879
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
707 880
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
708
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
709
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
710
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
881
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
882
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
883
+				} elseif (isset($line['id'])) {
884
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
885
+				} elseif (isset($this->all_flights[$id]['ident'])) {
886
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
887
+				}
711 888
 			}
712 889
 		    }
713 890
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
@@ -718,22 +895,32 @@  discard block
 block discarded – undo
718 895
 		}
719 896
 		
720 897
 		if (isset($line['heading']) && $line['heading'] != '') {
721
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
898
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
899
+		    	$this->all_flights[$id]['putinarchive'] = true;
900
+		    }
722 901
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
723 902
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
724 903
 		    //$dataFound = true;
725 904
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
726 905
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
727 906
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
728
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
729
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
907
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
908
+		    	$this->all_flights[$id]['putinarchive'] = true;
909
+		    }
910
+  		    if ($globalDebug) {
911
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
912
+  		    }
730 913
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
731 914
   		    // If not enough messages and ACARS set heading to 0
732 915
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
733 916
   		}
734
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
735
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
736
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
917
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
918
+			$dataFound = false;
919
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
920
+			$dataFound = false;
921
+		} elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) {
922
+			$dataFound = false;
923
+		}
737 924
 
738 925
 //		print_r($this->all_flights[$id]);
739 926
 		//gets the callsign from the last hour
@@ -750,23 +937,38 @@  discard block
 block discarded – undo
750 937
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
751 938
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
752 939
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
753
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
940
+				    if ($globalDebug) {
941
+				    	echo "Check if aircraft is already in DB...";
942
+				    }
754 943
 				    $timeelapsed = microtime(true);
755 944
 				    $SpotterLive = new SpotterLive($this->db);
756 945
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
757 946
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
758
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
947
+					if ($globalDebugTimeElapsed) {
948
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
949
+					}
759 950
 				    } elseif (isset($line['id'])) {
760 951
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
761
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
952
+					if ($globalDebugTimeElapsed) {
953
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
954
+					}
762 955
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
763 956
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
764
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
765
-				    } else $recent_ident = '';
957
+					if ($globalDebugTimeElapsed) {
958
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
959
+					}
960
+				    } else {
961
+				    	$recent_ident = '';
962
+				    }
766 963
 				    $SpotterLive->db=null;
767
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
768
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
769
-				} else $recent_ident = '';
964
+				    if ($globalDebug && $recent_ident == '') {
965
+				    	echo " Not in DB.\n";
966
+				    } elseif ($globalDebug && $recent_ident != '') {
967
+				    	echo " Already in DB.\n";
968
+				    }
969
+				} else {
970
+					$recent_ident = '';
971
+				}
770 972
 			    } else {
771 973
 				$recent_ident = '';
772 974
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -774,7 +976,9 @@  discard block
 block discarded – undo
774 976
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
775 977
 			    if($recent_ident == "")
776 978
 			    {
777
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
979
+				if ($globalDebug) {
980
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
981
+				}
778 982
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
779 983
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
780 984
 				//adds the spotter data for the archive
@@ -818,31 +1022,49 @@  discard block
 block discarded – undo
818 1022
 				
819 1023
 				if (!$ignoreImport) {
820 1024
 				    $highlight = '';
821
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
822
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
823
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
824
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1025
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
1026
+				    	$highlight = 'Squawk 7500 : Hijack';
1027
+				    }
1028
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
1029
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
1030
+				    }
1031
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
1032
+				    	$highlight = 'Squawk 7700 : Emergency';
1033
+				    }
1034
+				    if (!isset($this->all_flights[$id]['id'])) {
1035
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1036
+				    }
825 1037
 				    $timeelapsed = microtime(true);
826 1038
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
827 1039
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
828 1040
 					    $Spotter = new Spotter($this->db);
829 1041
 					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
830 1042
 					    $Spotter->db = null;
831
-					    if ($globalDebug && isset($result)) echo $result."\n";
1043
+					    if ($globalDebug && isset($result)) {
1044
+					    	echo $result."\n";
1045
+					    }
832 1046
 					}
833 1047
 				    }
834
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1048
+				    if ($globalDebugTimeElapsed) {
1049
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1050
+				    }
835 1051
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
836 1052
 
837 1053
 				    // Add source stat in DB
838 1054
 				    $Stats = new Stats($this->db);
839 1055
 				    if (!empty($this->stats)) {
840
-					if ($globalDebug) echo 'Add source stats : ';
1056
+					if ($globalDebug) {
1057
+						echo 'Add source stats : ';
1058
+					}
841 1059
 				        foreach($this->stats as $date => $data) {
842 1060
 					    foreach($data as $source => $sourced) {
843 1061
 					        //print_r($sourced);
844
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
845
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1062
+				    	        if (isset($sourced['polar'])) {
1063
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
1064
+				    	        }
1065
+				    	        if (isset($sourced['hist'])) {
1066
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1067
+				    	        }
846 1068
 				    		if (isset($sourced['msg'])) {
847 1069
 				    		    if (time() - $sourced['msg']['date'] > 10) {
848 1070
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -855,13 +1077,17 @@  discard block
 block discarded – undo
855 1077
 			    			unset($this->stats[$date]);
856 1078
 			    		    }
857 1079
 				    	}
858
-				    	if ($globalDebug) echo 'Done'."\n";
1080
+				    	if ($globalDebug) {
1081
+				    		echo 'Done'."\n";
1082
+				    	}
859 1083
 
860 1084
 				    }
861 1085
 				    $Stats->db = null;
862 1086
 				    }
863 1087
 				    $this->del();
864
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
1088
+				} elseif ($globalDebug) {
1089
+					echo 'Ignore data'."\n";
1090
+				}
865 1091
 				//$ignoreImport = false;
866 1092
 				$this->all_flights[$id]['addedSpotter'] = 1;
867 1093
 				//print_r($this->all_flights[$id]);
@@ -878,7 +1104,9 @@  discard block
 block discarded – undo
878 1104
 			*/
879 1105
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
880 1106
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
881
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
1107
+				    if ($globalDebug) {
1108
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
1109
+				    }
882 1110
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
883 1111
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
884 1112
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -887,7 +1115,9 @@  discard block
 block discarded – undo
887 1115
 					    $SpotterLive->db=null;
888 1116
 					}
889 1117
 				    }
890
-				    if ($globalDebug) echo " Done\n";
1118
+				    if ($globalDebug) {
1119
+				    	echo " Done\n";
1120
+				    }
891 1121
 				    $this->last_delete = time();
892 1122
 				}
893 1123
 			    } else {
@@ -914,11 +1144,17 @@  discard block
 block discarded – undo
914 1144
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
915 1145
 		    if ($globalDebug) {
916 1146
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
917
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
918
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1147
+				if (isset($this->all_flights[$id]['source_name'])) {
1148
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
1149
+				} else {
1150
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1151
+				}
919 1152
 			} else {
920
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
921
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1153
+				if (isset($this->all_flights[$id]['source_name'])) {
1154
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
1155
+				} else {
1156
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1157
+				}
922 1158
 			}
923 1159
 		    }
924 1160
 		    $ignoreImport = false;
@@ -964,22 +1200,30 @@  discard block
 block discarded – undo
964 1200
 
965 1201
 		    if (!$ignoreImport) {
966 1202
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
967
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1203
+				if (!isset($this->all_flights[$id]['id'])) {
1204
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1205
+				}
968 1206
 				$timeelapsed = microtime(true);
969 1207
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
970 1208
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
971
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1209
+					if ($globalDebug) {
1210
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1211
+					}
972 1212
 					$SpotterLive = new SpotterLive($this->db);
973 1213
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
974 1214
 					$SpotterLive->db = null;
975
-					if ($globalDebug) echo $result."\n";
1215
+					if ($globalDebug) {
1216
+						echo $result."\n";
1217
+					}
976 1218
 				    }
977 1219
 				}
978 1220
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
979 1221
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
980 1222
 				}
981 1223
 				$this->all_flights[$id]['putinarchive'] = false;
982
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1224
+				if ($globalDebugTimeElapsed) {
1225
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1226
+				}
983 1227
 
984 1228
 				// Put statistics in $this->stats variable
985 1229
 				//if ($line['format_source'] != 'aprs') {
@@ -987,7 +1231,9 @@  discard block
 block discarded – undo
987 1231
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
988 1232
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
989 1233
 					$source = $this->all_flights[$id]['source_name'];
990
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1234
+					if ($source == '') {
1235
+						$source = $this->all_flights[$id]['format_source'];
1236
+					}
991 1237
 					if (!isset($this->source_location[$source])) {
992 1238
 						$Location = new Source($this->db);
993 1239
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -1008,7 +1254,9 @@  discard block
 block discarded – undo
1008 1254
 					$stats_heading = round($stats_heading/22.5);
1009 1255
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1010 1256
 					$current_date = date('Y-m-d');
1011
-					if ($stats_heading == 16) $stats_heading = 0;
1257
+					if ($stats_heading == 16) {
1258
+						$stats_heading = 0;
1259
+					}
1012 1260
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1013 1261
 						for ($i=0;$i<=15;$i++) {
1014 1262
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -1026,7 +1274,9 @@  discard block
 block discarded – undo
1026 1274
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1027 1275
 						    end($this->stats[$current_date][$source]['hist']);
1028 1276
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1029
-						} else $mini = 0;
1277
+						} else {
1278
+							$mini = 0;
1279
+						}
1030 1280
 						for ($i=$mini;$i<=$distance;$i+=10) {
1031 1281
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1032 1282
 						}
@@ -1038,19 +1288,27 @@  discard block
 block discarded – undo
1038 1288
 				}
1039 1289
 
1040 1290
 				$this->all_flights[$id]['lastupdate'] = time();
1041
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1291
+				if ($this->all_flights[$id]['putinarchive']) {
1292
+					$send = true;
1293
+				}
1042 1294
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1043
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1295
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1296
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1297
+			}
1044 1298
 			//$this->del();
1045 1299
 			
1046 1300
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1047 1301
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1048
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1302
+				if ($globalDebug) {
1303
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1304
+				}
1049 1305
 				$SpotterLive = new SpotterLive($this->db);
1050 1306
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
1051 1307
 				$SpotterLive->db = null;
1052 1308
 				//SpotterLive->deleteLiveSpotterData();
1053
-				if ($globalDebug) echo " Done\n";
1309
+				if ($globalDebug) {
1310
+					echo " Done\n";
1311
+				}
1054 1312
 				$this->last_delete_hourly = time();
1055 1313
 			    } else {
1056 1314
 				$this->del();
@@ -1062,7 +1320,9 @@  discard block
 block discarded – undo
1062 1320
 		    //$ignoreImport = false;
1063 1321
 		}
1064 1322
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1065
-		if ($send) return $this->all_flights[$id];
1323
+		if ($send) {
1324
+			return $this->all_flights[$id];
1325
+		}
1066 1326
 	    }
1067 1327
 	}
1068 1328
     }
Please login to merge, or discard this patch.
require/class.Scheduler.php 1 patch
Braces   +180 added lines, -62 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 	public function __construct($dbc = null) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27
-		if ($this->db === null) die('Error: No DB connection.');
27
+		if ($this->db === null) {
28
+			die('Error: No DB connection.');
29
+		}
28 30
 	}
29 31
 
30 32
 	/**
@@ -139,7 +141,9 @@  discard block
 block discarded – undo
139 141
 		$sth->closeCursor();
140 142
 		if (count($row) > 0) {
141 143
 			return $row;
142
-		} else return array();
144
+		} else {
145
+			return array();
146
+		}
143 147
 	}
144 148
 
145 149
 	/*
@@ -180,7 +184,9 @@  discard block
 block discarded – undo
180 184
 		$Common = new Common();
181 185
 		$check_date = new Datetime($date);
182 186
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
183
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
187
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
188
+			return array();
189
+		}
184 190
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
185 191
 		$json = $Common->getData($url);
186 192
 		var_dump($json);
@@ -207,7 +213,9 @@  discard block
 block discarded – undo
207 213
 			*/
208 214
 		
209 215
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
210
-		} else return array();
216
+		} else {
217
+			return array();
218
+		}
211 219
 	}
212 220
 
213 221
 	/**
@@ -222,7 +230,9 @@  discard block
 block discarded – undo
222 230
 		date_default_timezone_set($globalTimezone);
223 231
 		$check_date = new Datetime($date);
224 232
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
225
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
233
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
234
+			return array();
235
+		}
226 236
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
227 237
 		$json = $Common->getData($url);
228 238
 		$parsed_json = json_decode($json);
@@ -235,7 +245,9 @@  discard block
 block discarded – undo
235 245
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
236 246
 
237 247
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
238
-		} else return array();
248
+		} else {
249
+			return array();
250
+		}
239 251
 	}
240 252
 
241 253
 	/**
@@ -246,7 +258,9 @@  discard block
 block discarded – undo
246 258
 	private function getRyanair($callsign) {
247 259
 		$Common = new Common();
248 260
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
249
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
261
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
262
+			return array();
263
+		}
250 264
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
251 265
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
252 266
 		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
@@ -260,8 +274,12 @@  discard block
 block discarded – undo
260 274
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
261 275
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
262 276
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
263
-			} else return array();
264
-		} else return array();
277
+			} else {
278
+				return array();
279
+			}
280
+		} else {
281
+			return array();
282
+		}
265 283
 	}
266 284
 
267 285
 	/**
@@ -272,7 +290,9 @@  discard block
 block discarded – undo
272 290
 	private function getSwiss($callsign) {
273 291
 		$Common = new Common();
274 292
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
275
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
293
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
294
+			return array();
295
+		}
276 296
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
277 297
 		$json = $Common->getData($url);
278 298
 		$parsed_json = json_decode($json);
@@ -292,8 +312,12 @@  discard block
 block discarded – undo
292 312
 			}
293 313
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
294 314
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
295
-			} else return array();
296
-		} else return array();
315
+			} else {
316
+				return array();
317
+			}
318
+		} else {
319
+			return array();
320
+		}
297 321
 	}
298 322
 	
299 323
 	/**
@@ -307,12 +331,18 @@  discard block
 block discarded – undo
307 331
 		$Common = new Common();
308 332
 		$check_date = new Datetime($date);
309 333
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
310
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
311
-		if ($globalBritishAirwaysKey == '') return array();
334
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
335
+			return array();
336
+		}
337
+		if ($globalBritishAirwaysKey == '') {
338
+			return array();
339
+		}
312 340
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
313 341
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
314 342
 		$json = $Common->getData($url,'get','',$headers);
315
-		if ($json == '') return array();
343
+		if ($json == '') {
344
+			return array();
345
+		}
316 346
 		$parsed_json = json_decode($json);
317 347
 		$flights = $parsed_json->{'FlightsResponse'};
318 348
 		if (count($flights) > 0) {
@@ -321,7 +351,9 @@  discard block
 block discarded – undo
321 351
 			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
322 352
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
323 353
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
324
-		} else return array();
354
+		} else {
355
+			return array();
356
+		}
325 357
 	}
326 358
 
327 359
 	/**
@@ -335,19 +367,27 @@  discard block
 block discarded – undo
335 367
 		$Common = new Common();
336 368
 		$check_date = new Datetime($date);
337 369
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
338
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
339
-		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
370
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
371
+			return array();
372
+		}
373
+		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') {
374
+			return array();
375
+		}
340 376
 		$url = "https://api.lufthansa.com/v1/oauth/token";
341 377
 		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
342 378
 		$data = $Common->getData($url,'post',$post);
343 379
 		$parsed_data = json_decode($data);
344
-		if (!isset($parsed_data->{'access_token'})) return array();
380
+		if (!isset($parsed_data->{'access_token'})) {
381
+			return array();
382
+		}
345 383
 		$token = $parsed_data->{'access_token'};
346 384
 		
347 385
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
348 386
 		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
349 387
 		$json = $Common->getData($url,'get','',$headers);
350
-		if ($json == '') return array();
388
+		if ($json == '') {
389
+			return array();
390
+		}
351 391
 		$parsed_json = json_decode($json);
352 392
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
353 393
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
@@ -355,7 +395,9 @@  discard block
 block discarded – undo
355 395
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
356 396
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
357 397
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
358
-		} else return array();
398
+		} else {
399
+			return array();
400
+		}
359 401
 	}
360 402
 
361 403
 	/**
@@ -369,14 +411,20 @@  discard block
 block discarded – undo
369 411
 		$Common = new Common();
370 412
 		$check_date = new Datetime($date);
371 413
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
372
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
373
-		if ($globalTransaviaKey == '') return array();
414
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
415
+			return array();
416
+		}
417
+		if ($globalTransaviaKey == '') {
418
+			return array();
419
+		}
374 420
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
375 421
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
376 422
 		$headers = array('apikey: '.$globalTransaviaKey);
377 423
 		$json = $Common->getData($url,'get','',$headers);
378 424
 		//echo 'result : '.$json;
379
-		if ($json == '') return array();
425
+		if ($json == '') {
426
+			return array();
427
+		}
380 428
 		$parsed_json = json_decode($json);
381 429
 		
382 430
 		if (isset($parsed_json->{'data'}[0])) {
@@ -385,7 +433,9 @@  discard block
 block discarded – undo
385 433
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
386 434
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
387 435
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
388
-		} else return array();
436
+		} else {
437
+			return array();
438
+		}
389 439
 	}
390 440
 
391 441
 	/**
@@ -396,7 +446,9 @@  discard block
 block discarded – undo
396 446
 	public function getTunisair($callsign) {
397 447
 		$Common = new Common();
398 448
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
399
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
449
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
450
+			return array();
451
+		}
400 452
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
401 453
 		$data = $Common->getData($url);
402 454
 		$table = $Common->table2array($data);
@@ -417,7 +469,9 @@  discard block
 block discarded – undo
417 469
 		$Common = new Common();
418 470
 		$check_date = new Datetime($date);
419 471
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
420
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
472
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
473
+			return array();
474
+		}
421 475
 		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
422 476
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
423 477
 		$data = $Common->getData($url);
@@ -427,8 +481,11 @@  discard block
 block discarded – undo
427 481
 			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
428 482
 			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
429 483
 			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
430
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
431
-			else return array();
484
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') {
485
+				return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
486
+			} else {
487
+				return array();
488
+			}
432 489
 		}
433 490
 		return array();
434 491
 	}
@@ -443,7 +500,9 @@  discard block
 block discarded – undo
443 500
 		$Common = new Common();
444 501
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
445 502
 		$check_date = new Datetime($date);
446
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
503
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
504
+			return array();
505
+		}
447 506
 		$url = "https://www.iberia.com/web/flightDetail.do";
448 507
 		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
449 508
 		$data = $Common->getData($url,'post',$post);
@@ -460,7 +519,9 @@  discard block
 block discarded – undo
460 519
 				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
461 520
 				if ($arrivalTime == 'Hora estimada de llegada') {
462 521
 					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
463
-				} else $arrivalTime = substr($arrivalTime,0,5);
522
+				} else {
523
+					$arrivalTime = substr($arrivalTime,0,5);
524
+				}
464 525
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
465 526
 			}
466 527
 		}
@@ -478,7 +539,9 @@  discard block
 block discarded – undo
478 539
 		$Common = new Common();
479 540
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
480 541
 		$check_date = new Datetime($date);
481
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
542
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
543
+			return array();
544
+		}
482 545
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
483 546
 		$data = $Common->getData($url);
484 547
 		if ($data != '') {
@@ -494,7 +557,9 @@  discard block
 block discarded – undo
494 557
 					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
495 558
 					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
496 559
 					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
497
-				} else return array();
560
+				} else {
561
+					return array();
562
+				}
498 563
 			}
499 564
 			
500 565
 
@@ -514,7 +579,9 @@  discard block
 block discarded – undo
514 579
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
515 580
 		$check_date = new Datetime($date);
516 581
 		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
517
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
582
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
583
+			return array();
584
+		}
518 585
 		$data = $Common->getData($url);
519 586
 		if ($data != '') {
520 587
 			$table = $Common->text2array($data);
@@ -538,7 +605,9 @@  discard block
 block discarded – undo
538 605
 		$check_date = new Datetime($date);
539 606
 		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
540 607
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
541
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
608
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
609
+			return array();
610
+		}
542 611
 		$data = $Common->getData($url);
543 612
 		if ($data != '') {
544 613
 		    //echo $data;
@@ -628,7 +697,9 @@  discard block
 block discarded – undo
628 697
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
629 698
 		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
630 699
 		//$check_date = new Datetime($date);
631
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
700
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
701
+			return array();
702
+		}
632 703
 		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
633 704
 		$data = $Common->getData($url,'post',$post);
634 705
 		if ($data != '') {
@@ -660,11 +731,15 @@  discard block
 block discarded – undo
660 731
 				$airline_icao = substr($callsign, 0, 3);
661 732
 			} 
662 733
 		}
663
-		if ($airline_icao == '') return array();
734
+		if ($airline_icao == '') {
735
+			return array();
736
+		}
664 737
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
665 738
 		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
666 739
 		//$check_date = new Datetime($date);
667
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
740
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
741
+			return array();
742
+		}
668 743
 		$data = $Common->getData($url);
669 744
 		if ($data != '') {
670 745
 			$table = $Common->table2array($data);
@@ -757,10 +832,16 @@  discard block
 block discarded – undo
757 832
 		if ($data != '') {
758 833
 			$table = $Common->table2array($data);
759 834
 			if (isset($table[11][1])) {
760
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
761
-				else $departureTime = '';
762
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
763
-				else $arrivalTime = '';
835
+				if (is_numeric(substr($table[11][1],0,1))) {
836
+					$departureTime = substr($table[11][1],0,5);
837
+				} else {
838
+					$departureTime = '';
839
+				}
840
+				if (is_numeric(substr($table[17][1],0,1))) {
841
+					$arrivalTime = substr($table[17][1],0,5);
842
+				} else {
843
+					$arrivalTime = '';
844
+				}
764 845
 				$DepartureAirportIata = substr($table[13][1],0,3);
765 846
 				$ArrivalAirportIata = substr($table[15][1],0,3);
766 847
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
@@ -777,16 +858,22 @@  discard block
 block discarded – undo
777 858
 	*/
778 859
 	private function getAirCanada($callsign,$date = 'NOW') {
779 860
 		$Common = new Common();
780
-		if (class_exists("DomDocument") === FALSE) return array();
861
+		if (class_exists("DomDocument") === FALSE) {
862
+			return array();
863
+		}
781 864
 		date_default_timezone_set('UTC');
782 865
 		$check_date = new Datetime($date);
783 866
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
784 867
 		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
785
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
868
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
869
+			return array();
870
+		}
786 871
 		$data = $Common->getData($url);
787 872
 		$dom = new DomDocument();
788 873
 		$dom->loadXML($data);
789
-		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array();
874
+		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) {
875
+			return array();
876
+		}
790 877
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
791 878
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
792 879
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
@@ -795,7 +882,9 @@  discard block
 block discarded – undo
795 882
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
796 883
 			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
797 884
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
798
-		} else return array();
885
+		} else {
886
+			return array();
887
+		}
799 888
 	}
800 889
 
801 890
 	/**
@@ -809,7 +898,9 @@  discard block
 block discarded – undo
809 898
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
810 899
 		$check_date = new Datetime($date);
811 900
 		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
812
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
901
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
902
+			return array();
903
+		}
813 904
 		$data = $Common->getData($url);
814 905
 		if ($data != '') {
815 906
 			$table = $Common->table2array($data);
@@ -838,7 +929,9 @@  discard block
 block discarded – undo
838 929
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
839 930
 		$check_date = new Datetime($date);
840 931
 		$url= "http://www.airberlin.com/en-US/site/aims.php";
841
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
932
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
933
+			return array();
934
+		}
842 935
 		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
843 936
 		$data = $Common->getData($url,'post',$post);
844 937
 		//echo $data;
@@ -848,11 +941,19 @@  discard block
 block discarded – undo
848 941
 		if ($data != '') {
849 942
 			$table = $Common->table2array($data);
850 943
 			$flight = $table;
851
-			if (isset($flight[5][4])) $departureTime = $flight[5][4];
852
-			else $departureTime = '';
853
-			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
854
-			else $departureAirport = '';
855
-		} else return array();
944
+			if (isset($flight[5][4])) {
945
+				$departureTime = $flight[5][4];
946
+			} else {
947
+				$departureTime = '';
948
+			}
949
+			if (isset($flight[5][2])) {
950
+				$departureAirport = $flight[5][2];
951
+			} else {
952
+				$departureAirport = '';
953
+			}
954
+		} else {
955
+			return array();
956
+		}
856 957
 		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
857 958
 		$data = $Common->getData($url,'post',$post);
858 959
 		if ($data != '') {
@@ -865,10 +966,14 @@  discard block
 block discarded – undo
865 966
 			    $arrivalTime = '';
866 967
 			    $arrivalAirport = '';
867 968
 			}
868
-		} else return array();
969
+		} else {
970
+			return array();
971
+		}
869 972
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
870 973
 		$json = $Common->getData($url);
871
-		if ($json == '') return array();
974
+		if ($json == '') {
975
+			return array();
976
+		}
872 977
 		$parsed_json = json_decode($json);
873 978
 		$airports = $parsed_json->{'suggestList'};
874 979
 		if (count($airports) > 0) {
@@ -883,7 +988,9 @@  discard block
 block discarded – undo
883 988
 		}
884 989
 		if (isset($DepartureAirportIata)) {
885 990
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
886
-		} else return array();
991
+		} else {
992
+			return array();
993
+		}
887 994
 	}
888 995
 
889 996
 	/*
@@ -895,7 +1002,9 @@  discard block
 block discarded – undo
895 1002
 	public function fetchSchedule($ident,$date = 'NOW') {
896 1003
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername;
897 1004
 		//$Common = new Common();
898
-		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
1005
+		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) {
1006
+			return array();
1007
+		}
899 1008
 		$airline_icao = '';
900 1009
 		if (!is_numeric(substr($ident, 0, 3)))
901 1010
 		{
@@ -1130,18 +1239,27 @@  discard block
 block discarded – undo
1130 1239
 					if (strlen($airline_icao) == 3) {
1131 1240
 						$Spotter = new Spotter($this->db);
1132 1241
 						$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
1133
-						if (isset($airline_info[0]['iata'])) $airline_icao = $airline_info[0]['iata'];
1242
+						if (isset($airline_info[0]['iata'])) {
1243
+							$airline_icao = $airline_info[0]['iata'];
1244
+						}
1134 1245
 					}
1135 1246
 					// Randomly use a generic function to get hours
1136 1247
 					if (strlen($airline_icao) == 2) {
1137
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1248
+						if (!isset($globalSchedulesSources)) {
1249
+							$globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1250
+						}
1138 1251
 						if (count($globalSchedulesSources) > 0) {
1139 1252
 							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1140 1253
 							$source = $globalSchedulesSources[$rand];
1141
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1142
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
1254
+							if ($source == 'flightmapper') {
1255
+								return $this->getFlightMapper($ident);
1256
+							} elseif ($source == 'costtotravel') {
1257
+								return $this->getCostToTravel($ident);
1258
+							}
1143 1259
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1144
-							elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') return $this->getFlightAware($ident);
1260
+							elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') {
1261
+								return $this->getFlightAware($ident);
1262
+							}
1145 1263
 						}
1146 1264
 					}
1147 1265
 			}
Please login to merge, or discard this patch.
require/class.Common.php 1 patch
Braces   +110 added lines, -48 removed lines patch added patch discarded remove patch
@@ -37,8 +37,11 @@  discard block
 block discarded – undo
37 37
 		} else {
38 38
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
39 39
 		}
40
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
40
+		if ($timeout == '') {
41
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
42
+		} else {
43
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
44
+		}
42 45
 		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
43 46
 		if ($type == 'post') {
44 47
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -51,7 +54,9 @@  discard block
 block discarded – undo
51 54
 			} else {
52 55
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
53 56
 			}
54
-		} elseif ($type != 'get' && $type != '') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
57
+		} elseif ($type != 'get' && $type != '') {
58
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
59
+		}
55 60
 		if ($headers != '') {
56 61
 			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
57 62
 		}
@@ -95,8 +100,9 @@  discard block
 block discarded – undo
95 100
 	private function curlResponseHeaderCallback($ch, $headerLine) {
96 101
 		//global $cookies;
97 102
 		$cookies = array();
98
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
99
-			$cookies[] = $cookie;
103
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
104
+					$cookies[] = $cookie;
105
+		}
100 106
 		return strlen($headerLine); // Needed by curl
101 107
 	}
102 108
 
@@ -107,7 +113,9 @@  discard block
 block discarded – undo
107 113
 		curl_setopt($ch, CURLOPT_URL, $url);
108 114
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
109 115
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
110
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
116
+		if ($referer != '') {
117
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
118
+		}
111 119
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
112 120
 			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
113 121
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
@@ -119,7 +127,9 @@  discard block
 block discarded – undo
119 127
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
120 128
 		curl_setopt($ch, CURLOPT_FILE, $fp);
121 129
 		curl_exec($ch);
122
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
130
+		if (curl_errno($ch) && $globalDebug) {
131
+			echo 'Download error: '.curl_error($ch);
132
+		}
123 133
 		curl_close($ch);
124 134
 		fclose($fp);
125 135
 	}
@@ -127,12 +137,16 @@  discard block
 block discarded – undo
127 137
 	public static function gunzip($in_file,$out_file_name = '') {
128 138
 		//echo $in_file.' -> '.$out_file_name."\n";
129 139
 		$buffer_size = 4096; // read 4kb at a time
130
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
140
+		if ($out_file_name == '') {
141
+			$out_file_name = str_replace('.gz', '', $in_file);
142
+		}
131 143
 		if ($in_file != '' && file_exists($in_file)) {
132 144
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
133
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
134
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
135
-			else {
145
+			if (function_exists('gzopen')) {
146
+				$file = gzopen($in_file,'rb');
147
+			} elseif (function_exists('gzopen64')) {
148
+				$file = gzopen64($in_file,'rb');
149
+			} else {
136 150
 				echo 'gzopen not available';
137 151
 				die;
138 152
 			}
@@ -148,11 +162,14 @@  discard block
 block discarded – undo
148 162
 	public static function bunzip2($in_file,$out_file_name = '') {
149 163
 		//echo $in_file.' -> '.$out_file_name."\n";
150 164
 		$buffer_size = 4096; // read 4kb at a time
151
-		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
165
+		if ($out_file_name == '') {
166
+			$out_file_name = str_replace('.bz2', '', $in_file);
167
+		}
152 168
 		if ($in_file != '' && file_exists($in_file)) {
153 169
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
154
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
155
-			else {
170
+			if (function_exists('bzopen')) {
171
+				$file = bzopen($in_file,'rb');
172
+			} else {
156 173
 				echo 'bzopen not available';
157 174
 				die;
158 175
 			}
@@ -171,10 +188,16 @@  discard block
 block discarded – undo
171 188
 	* @return Array array of the tables in HTML page
172 189
 	*/
173 190
 	public function table2array($data) {
174
-		if (!is_string($data)) return array();
175
-		if ($data == '') return array();
191
+		if (!is_string($data)) {
192
+			return array();
193
+		}
194
+		if ($data == '') {
195
+			return array();
196
+		}
176 197
 		$html = str_get_html($data);
177
-		if ($html === false) return array();
198
+		if ($html === false) {
199
+			return array();
200
+		}
178 201
 		$tabledata=array();
179 202
 		foreach($html->find('tr') as $element)
180 203
 		{
@@ -209,7 +232,9 @@  discard block
 block discarded – undo
209 232
 	*/
210 233
 	public function text2array($data) {
211 234
 		$html = str_get_html($data);
212
-		if ($html === false) return array();
235
+		if ($html === false) {
236
+			return array();
237
+		}
213 238
 		$tabledata=array();
214 239
 		foreach($html->find('p') as $element)
215 240
 		{
@@ -230,7 +255,9 @@  discard block
 block discarded – undo
230 255
 	* @return Float Distance in $unit
231 256
 	*/
232 257
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233
-		if ($lat == $latc && $lon == $lonc) return 0;
258
+		if ($lat == $latc && $lon == $lonc) {
259
+			return 0;
260
+		}
234 261
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
235 262
 		if ($unit == "km") {
236 263
 			return round($dist * 1.609344);
@@ -269,7 +296,9 @@  discard block
 block discarded – undo
269 296
 		$dX = $latc - $lat;
270 297
 		$dY = $lonc - $lon;
271 298
 		$azimuth = rad2deg(atan2($dY,$dX));
272
-		if ($azimuth < 0) return $azimuth+360;
299
+		if ($azimuth < 0) {
300
+			return $azimuth+360;
301
+		}
273 302
 		return $azimuth;
274 303
 	}
275 304
 	
@@ -283,10 +312,16 @@  discard block
 block discarded – undo
283 312
 	public function withinThreshold ($timeDifference, $distance) {
284 313
 		$x = abs($timeDifference);
285 314
 		$d = abs($distance);
286
-		if ($x == 0 || $d == 0) return true;
315
+		if ($x == 0 || $d == 0) {
316
+			return true;
317
+		}
287 318
 		// may be due to Internet jitter; distance is realistic
288
-		if ($x < 0.7 && $d < 2000) return true;
289
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
319
+		if ($x < 0.7 && $d < 2000) {
320
+			return true;
321
+		} else {
322
+			return $d/$x < 1500*0.27778;
323
+		}
324
+		// 1500 km/h max
290 325
 	}
291 326
 
292 327
 
@@ -314,11 +349,17 @@  discard block
 block discarded – undo
314 349
 	
315 350
 	public function convertDM($coord,$latlong) {
316 351
 		if ($latlong == 'latitude') {
317
-			if ($coord < 0) $NSEW = 'S';
318
-			else $NSEW = 'N';
352
+			if ($coord < 0) {
353
+				$NSEW = 'S';
354
+			} else {
355
+				$NSEW = 'N';
356
+			}
319 357
 		} else {
320
-			if ($coord < 0) $NSEW = 'W';
321
-			else $NSEW = 'E';
358
+			if ($coord < 0) {
359
+				$NSEW = 'W';
360
+			} else {
361
+				$NSEW = 'E';
362
+			}
322 363
 		}
323 364
 		$coord = abs($coord);
324 365
 		$deg = floor($coord);
@@ -361,7 +402,9 @@  discard block
 block discarded – undo
361 402
 	public function hex2str($hex) {
362 403
 		$str = '';
363 404
 		$hexln = strlen($hex);
364
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
405
+		for($i=0;$i<$hexln;$i+=2) {
406
+			$str .= chr(hexdec(substr($hex,$i,2)));
407
+		}
365 408
 		return $str;
366 409
 	}
367 410
 	
@@ -398,8 +441,11 @@  discard block
 block discarded – undo
398 441
 		$b = $lat2 - $lat1;
399 442
 		$c = -($a*$lat1+$b*$lon1);
400 443
 		$d = $a*$lat3+$b*$lon3+$c;
401
-		if ($d > -$approx && $d < $approx) return true;
402
-		else return false;
444
+		if ($d > -$approx && $d < $approx) {
445
+			return true;
446
+		} else {
447
+			return false;
448
+		}
403 449
 	}
404 450
 	
405 451
 	public function array_merge_noappend() {
@@ -458,7 +504,9 @@  discard block
 block discarded – undo
458 504
 			return $result;
459 505
 		}
460 506
 		$handle = @opendir('./locale');
461
-		if ($handle === false) return $result;
507
+		if ($handle === false) {
508
+			return $result;
509
+		}
462 510
 		while (false !== ($file = readdir($handle))) {
463 511
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
464 512
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -529,8 +577,9 @@  discard block
 block discarded – undo
529 577
 		$error = false; 
530 578
 		if ($fp_out = gzopen($dest, $mode)) { 
531 579
 			if ($fp_in = fopen($source,'rb')) { 
532
-				while (!feof($fp_in)) 
533
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
580
+				while (!feof($fp_in)) {
581
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
582
+				}
534 583
 				fclose($fp_in); 
535 584
 			} else {
536 585
 				$error = true; 
@@ -539,14 +588,17 @@  discard block
 block discarded – undo
539 588
 		} else {
540 589
 			$error = true; 
541 590
 		}
542
-		if ($error)
543
-			return false; 
544
-		else
545
-			return $dest; 
591
+		if ($error) {
592
+					return false;
593
+		} else {
594
+					return $dest;
595
+		}
546 596
 	} 
547 597
 	
548 598
 	public function remove_accents($string) {
549
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
599
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
600
+			return $string;
601
+		}
550 602
 		$chars = array(
551 603
 		    // Decompositions for Latin-1 Supplement
552 604
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -670,7 +722,9 @@  discard block
 block discarded – undo
670 722
 		$ip = gethostbyname($host);
671 723
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
672 724
 		$r = @socket_connect($s, $ip, $port);
673
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
725
+		if (!socket_set_nonblock($s)) {
726
+			echo "Unable to set nonblock on socket\n";
727
+		}
674 728
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
675 729
 			return $s;
676 730
 		}
@@ -715,18 +769,22 @@  discard block
 block discarded – undo
715 769
 		//NOTE: use a trailing slash for folders!!!
716 770
 		//see http://bugs.php.net/bug.php?id=27609
717 771
 		//see http://bugs.php.net/bug.php?id=30931
718
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
772
+		if ($path{strlen($path)-1}=='/') {
773
+			// recursively return a temporary file path
719 774
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
720
-		else if (is_dir($path))
721
-			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
775
+		} else if (is_dir($path)) {
776
+					return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
777
+		}
722 778
 		// check tmp file for read/write capabilities
723 779
 		$rm = file_exists($path);
724 780
 		$f = @fopen($path, 'a');
725
-		if ($f===false)
726
-			return false;
781
+		if ($f===false) {
782
+					return false;
783
+		}
727 784
 		fclose($f);
728
-		if (!$rm)
729
-			unlink($path);
785
+		if (!$rm) {
786
+					unlink($path);
787
+		}
730 788
 		return true;
731 789
 	}
732 790
 	
@@ -742,7 +800,9 @@  discard block
 block discarded – undo
742 800
 	 * @return Array Coordinate of the route
743 801
 	*/
744 802
 	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
745
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
803
+		if ($nbpts <= 2) {
804
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
805
+		}
746 806
 		$sx = deg2rad($begin_lon);
747 807
 		$sy = deg2rad($begin_lat);
748 808
 		$ex = deg2rad($end_lon);
@@ -751,7 +811,9 @@  discard block
 block discarded – undo
751 811
 		$h = $sy - $ey;
752 812
 		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
753 813
 		$g = 2.0*asin(sqrt($z));
754
-		if ($g == pi() || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
814
+		if ($g == pi() || is_nan($g)) {
815
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
816
+		}
755 817
 		$first_pass = array();
756 818
 		$delta = 1.0/($nbpts-1);
757 819
 		for ($i =0; $i < $nbpts; ++$i) {
Please login to merge, or discard this patch.
live-geojson.php 1 patch
Braces   +321 added lines, -130 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 $tracker = false;
13 13
 $marine = false;
14 14
 $usecoord = false;
15
-if (isset($_GET['test'])) exit();
15
+if (isset($_GET['test'])) {
16
+	exit();
17
+}
16 18
 if (isset($_GET['tracker'])) {
17 19
     $tracker = true;
18 20
 }
@@ -57,28 +59,55 @@  discard block
 block discarded – undo
57 59
 }
58 60
 header('Content-Type: text/javascript');
59 61
 
60
-if (!isset($globalJsonCompress)) $compress = true;
61
-else $compress = $globalJsonCompress;
62
+if (!isset($globalJsonCompress)) {
63
+	$compress = true;
64
+} else {
65
+	$compress = $globalJsonCompress;
66
+}
62 67
 
63 68
 $from_archive = false;
64 69
 $min = true;
65 70
 $allhistory = false;
66 71
 $filter['source'] = array();
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
72
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
72
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
73
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
74
+}
75
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
76
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
77
+}
78
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
79
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
80
+}
81
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
82
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
83
+}
84
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
85
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
86
+}
87
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
88
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
89
+}
90
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') {
91
+	$filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
92
+}
93
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
94
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
95
+}
96
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
97
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
98
+}
99
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
100
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
101
+}
102
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
103
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
104
+}
78 105
 
79 106
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
80 107
 	$min = true;
81
-} else $min = false;
108
+} else {
109
+	$min = false;
110
+}
82 111
 
83 112
 $spotter_array = array();
84 113
 
@@ -189,24 +218,38 @@  discard block
 block discarded – undo
189 218
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
190 219
 		}
191 220
 	}
192
-	if ($flightcnt == '') $flightcnt = 0;
193
-} else $flightcnt = 0;
221
+	if ($flightcnt == '') {
222
+		$flightcnt = 0;
223
+	}
224
+	} else {
225
+	$flightcnt = 0;
226
+}
194 227
 
195 228
 $sqltime = round(microtime(true)-$begintime,2);
196 229
 
197 230
 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
198
-if ($currenttime != '') $currenttime = round($currenttime/1000);
231
+if ($currenttime != '') {
232
+	$currenttime = round($currenttime/1000);
233
+}
199 234
 
200
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
201
-else $usenextlatlon = true;
202
-if ($usenextlatlon === false) $currenttime = '';
235
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
236
+	$usenextlatlon = false;
237
+} else {
238
+	$usenextlatlon = true;
239
+}
240
+if ($usenextlatlon === false) {
241
+	$currenttime = '';
242
+}
203 243
 $j = 0;
204 244
 $prev_flightaware_id = '';
205 245
 $aircrafts_shadow = array();
206 246
 $output = '{';
207 247
 	$output .= '"type": "FeatureCollection",';
208
-		if ($min) $output .= '"minimal": "true",';
209
-		else $output .= '"minimal": "false",';
248
+		if ($min) {
249
+			$output .= '"minimal": "true",';
250
+		} else {
251
+			$output .= '"minimal": "false",';
252
+		}
210 253
 		//$output .= '"fc": "'.$flightcnt.'",';
211 254
 		$output .= '"sqt": "'.$sqltime.'",';
212 255
 
@@ -251,18 +294,29 @@  discard block
 block discarded – undo
251 294
 						}
252 295
 						$output .= '"properties": {';
253 296
 						if (isset($spotter_item['flightaware_id'])) {
254
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
255
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
297
+							if ($compress) {
298
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
299
+							} else {
300
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
301
+							}
256 302
 						} elseif (isset($spotter_item['famtrackid'])) {
257
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
258
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
303
+							if ($compress) {
304
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
305
+							} else {
306
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
307
+							}
259 308
 						} elseif (isset($spotter_item['fammarine_id'])) {
260
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
261
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
309
+							if ($compress) {
310
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
311
+							} else {
312
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
313
+							}
262 314
 						}
263 315
 							$output .= '"fc": "'.$flightcnt.'",';
264 316
 							$output .= '"sqt": "'.$sqltime.'",';
265
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
317
+							if (isset($begindate)) {
318
+								$output .= '"archive_date": "'.$begindate.'",';
319
+							}
266 320
 
267 321
 /*
268 322
 							if ($min) $output .= '"minimal": "true",';
@@ -270,14 +324,22 @@  discard block
 block discarded – undo
270 324
 */
271 325
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
272 326
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
273
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
274
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
327
+							if ($compress) {
328
+								$output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
329
+							} else {
330
+								$output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
331
+							}
275 332
 							//"
276 333
 						} else {
277
-							if ($compress) $output .= '"c": "NA",';
278
-							else $output .= '"callsign": "NA",';
334
+							if ($compress) {
335
+								$output .= '"c": "NA",';
336
+							} else {
337
+								$output .= '"callsign": "NA",';
338
+							}
339
+						}
340
+						if (isset($spotter_item['registration'])) {
341
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
279 342
 						}
280
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
281 343
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
282 344
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
283 345
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -290,16 +352,23 @@  discard block
 block discarded – undo
290 352
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
291 353
 						}
292 354
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
293
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
294
-							else {
355
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
356
+								$spotter_item['aircraft_shadow'] = '';
357
+							} else {
295 358
 								$aircraft_icao = $spotter_item['aircraft_icao'];
296
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
297
-								else {
359
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
360
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
361
+								} else {
298 362
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
299
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
300
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
301
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
302
-									else $spotter_item['aircraft_shadow'] = '';
363
+									if (count($aircraft_info) > 0) {
364
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
365
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
366
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
367
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
368
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
369
+									} else {
370
+										$spotter_item['aircraft_shadow'] = '';
371
+									}
303 372
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
304 373
 								}
305 374
 							}
@@ -307,73 +376,139 @@  discard block
 block discarded – undo
307 376
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
308 377
 							if ($tracker) {
309 378
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
310
-									if ($compress) $output .= '"as": "ambulance.png",';
311
-									else $output .= '"aircraft_shadow": "ambulance.png",';
379
+									if ($compress) {
380
+										$output .= '"as": "ambulance.png",';
381
+									} else {
382
+										$output .= '"aircraft_shadow": "ambulance.png",';
383
+									}
312 384
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
313
-									if ($compress) $output .= '"as": "police.png",';
314
-									else $output .= '"aircraft_shadow": "police.png",';
385
+									if ($compress) {
386
+										$output .= '"as": "police.png",';
387
+									} else {
388
+										$output .= '"aircraft_shadow": "police.png",';
389
+									}
315 390
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
316
-									if ($compress) $output .= '"as": "ship.png",';
317
-									else $output .= '"aircraft_shadow": "ship.png",';
391
+									if ($compress) {
392
+										$output .= '"as": "ship.png",';
393
+									} else {
394
+										$output .= '"aircraft_shadow": "ship.png",';
395
+									}
318 396
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
319
-									if ($compress) $output .= '"as": "ship.png",';
320
-									else $output .= '"aircraft_shadow": "ship.png",';
397
+									if ($compress) {
398
+										$output .= '"as": "ship.png",';
399
+									} else {
400
+										$output .= '"aircraft_shadow": "ship.png",';
401
+									}
321 402
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
322
-									if ($compress) $output .= '"as": "ship.png",';
323
-									else $output .= '"aircraft_shadow": "ship.png",';
403
+									if ($compress) {
404
+										$output .= '"as": "ship.png",';
405
+									} else {
406
+										$output .= '"aircraft_shadow": "ship.png",';
407
+									}
324 408
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
325
-									if ($compress) $output .= '"as": "truck.png",';
326
-									else $output .= '"aircraft_shadow": "truck.png",';
409
+									if ($compress) {
410
+										$output .= '"as": "truck.png",';
411
+									} else {
412
+										$output .= '"aircraft_shadow": "truck.png",';
413
+									}
327 414
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
328
-									if ($compress) $output .= '"as": "truck.png",';
329
-									else $output .= '"aircraft_shadow": "truck.png",';
415
+									if ($compress) {
416
+										$output .= '"as": "truck.png",';
417
+									} else {
418
+										$output .= '"aircraft_shadow": "truck.png",';
419
+									}
330 420
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
331
-									if ($compress) $output .= '"as": "aircraft.png",';
332
-									else $output .= '"aircraft_shadow": "aircraft.png",';
421
+									if ($compress) {
422
+										$output .= '"as": "aircraft.png",';
423
+									} else {
424
+										$output .= '"aircraft_shadow": "aircraft.png",';
425
+									}
333 426
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
334
-									if ($compress) $output .= '"as": "aircraft.png",';
335
-									else $output .= '"aircraft_shadow": "aircraft.png",';
427
+									if ($compress) {
428
+										$output .= '"as": "aircraft.png",';
429
+									} else {
430
+										$output .= '"aircraft_shadow": "aircraft.png",';
431
+									}
336 432
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
337
-									if ($compress) $output .= '"as": "helico.png",';
338
-									else $output .= '"aircraft_shadow": "helico.png",';
433
+									if ($compress) {
434
+										$output .= '"as": "helico.png",';
435
+									} else {
436
+										$output .= '"aircraft_shadow": "helico.png",';
437
+									}
339 438
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
340
-									if ($compress) $output .= '"as": "rail.png",';
341
-									else $output .= '"aircraft_shadow": "rail.png",';
439
+									if ($compress) {
440
+										$output .= '"as": "rail.png",';
441
+									} else {
442
+										$output .= '"aircraft_shadow": "rail.png",';
443
+									}
342 444
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
343
-									if ($compress) $output .= '"as": "firetruck.png",';
344
-									else $output .= '"aircraft_shadow": "firetruck.png",';
445
+									if ($compress) {
446
+										$output .= '"as": "firetruck.png",';
447
+									} else {
448
+										$output .= '"aircraft_shadow": "firetruck.png",';
449
+									}
345 450
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
346
-									if ($compress) $output .= '"as": "bus.png",';
347
-									else $output .= '"aircraft_shadow": "bus.png",';
451
+									if ($compress) {
452
+										$output .= '"as": "bus.png",';
453
+									} else {
454
+										$output .= '"aircraft_shadow": "bus.png",';
455
+									}
348 456
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
349
-									if ($compress) $output .= '"as": "phone.png",';
350
-									else $output .= '"aircraft_shadow": "phone.png",';
457
+									if ($compress) {
458
+										$output .= '"as": "phone.png",';
459
+									} else {
460
+										$output .= '"aircraft_shadow": "phone.png",';
461
+									}
351 462
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
352
-									if ($compress) $output .= '"as": "jogger.png",';
353
-									else $output .= '"aircraft_shadow": "jogger.png",';
463
+									if ($compress) {
464
+										$output .= '"as": "jogger.png",';
465
+									} else {
466
+										$output .= '"aircraft_shadow": "jogger.png",';
467
+									}
354 468
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
355
-									if ($compress) $output .= '"as": "bike.png",';
356
-									else $output .= '"aircraft_shadow": "bike.png",';
469
+									if ($compress) {
470
+										$output .= '"as": "bike.png",';
471
+									} else {
472
+										$output .= '"aircraft_shadow": "bike.png",';
473
+									}
357 474
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
358
-									if ($compress) $output .= '"as": "motorcycle.png",';
359
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
475
+									if ($compress) {
476
+										$output .= '"as": "motorcycle.png",';
477
+									} else {
478
+										$output .= '"aircraft_shadow": "motorcycle.png",';
479
+									}
360 480
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
361
-									if ($compress) $output .= '"as": "balloon.png",';
362
-									else $output .= '"aircraft_shadow": "balloon.png",';
481
+									if ($compress) {
482
+										$output .= '"as": "balloon.png",';
483
+									} else {
484
+										$output .= '"aircraft_shadow": "balloon.png",';
485
+									}
363 486
 								} else {
364
-									if ($compress) $output .= '"as": "car.png",';
365
-									else $output .= '"aircraft_shadow": "car.png",';
487
+									if ($compress) {
488
+										$output .= '"as": "car.png",';
489
+									} else {
490
+										$output .= '"aircraft_shadow": "car.png",';
491
+									}
366 492
 								}
367 493
 							} elseif ($marine) {
368
-								if ($compress) $output .= '"as": "ship.png",';
369
-								else $output .= '"aircraft_shadow": "ship.png",';
494
+								if ($compress) {
495
+									$output .= '"as": "ship.png",';
496
+								} else {
497
+									$output .= '"aircraft_shadow": "ship.png",';
498
+								}
370 499
 							} else {
371
-								if ($compress) $output .= '"as": "default.png",';
372
-								else $output .= '"aircraft_shadow": "default.png",';
500
+								if ($compress) {
501
+									$output .= '"as": "default.png",';
502
+								} else {
503
+									$output .= '"aircraft_shadow": "default.png",';
504
+								}
373 505
 							}
374 506
 						} else {
375
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
376
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
507
+							if ($compress) {
508
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
509
+							} else {
510
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
511
+							}
377 512
 						}
378 513
 						if (isset($spotter_item['airline_name'])) {
379 514
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -381,8 +516,11 @@  discard block
 block discarded – undo
381 516
 							$output .= '"airline_name": "NA",';
382 517
 						}
383 518
 						if (isset($spotter_item['departure_airport'])) {
384
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
385
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
519
+							if ($compress) {
520
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
521
+							} else {
522
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
523
+							}
386 524
 						}
387 525
 						if (isset($spotter_item['departure_airport_city'])) {
388 526
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -394,8 +532,11 @@  discard block
 block discarded – undo
394 532
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
395 533
 						}
396 534
 						if (isset($spotter_item['arrival_airport'])) {
397
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
398
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
535
+							if ($compress) {
536
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
537
+							} else {
538
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
539
+							}
399 540
 						}
400 541
 						if (isset($spotter_item['arrival_airport_city'])) {
401 542
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -414,8 +555,11 @@  discard block
 block discarded – undo
414 555
 						}
415 556
 						
416 557
 						if (isset($spotter_item['altitude'])) {
417
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
418
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
558
+							if ($compress) {
559
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
560
+							} else {
561
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
562
+							}
419 563
 						}
420 564
 						
421 565
 						$heading = $spotter_item['heading'];
@@ -439,19 +583,24 @@  discard block
 block discarded – undo
439 583
 							}
440 584
 						}
441 585
 						
442
-						if ($compress)$output .= '"h": "'.$heading.'",';
443
-						else $output .= '"heading": "'.$heading.'",';
586
+						if ($compress) {
587
+							$output .= '"h": "'.$heading.'",';
588
+						} else {
589
+							$output .= '"heading": "'.$heading.'",';
590
+						}
444 591
 						if ($currenttime != '') {
445 592
 							if (strtotime($spotter_item['date']) < $currenttime) {
446 593
 								if (isset($archivespeed)) {
447 594
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
448 595
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
449
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
450
-									else {
596
+									if (!isset($idistance) || $fdistance < $idistance) {
597
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
598
+									} else {
451 599
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
452 600
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
453
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
454
-										else {
601
+										if (!isset($idistance) || $fdistance < $idistance) {
602
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
603
+										} else {
455 604
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
456 605
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
457 606
 										}
@@ -459,12 +608,14 @@  discard block
 block discarded – undo
459 608
 								} elseif ($usenextlatlon) {
460 609
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
461 610
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
462
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
463
-									else {
611
+									if (!isset($idistance) || $fdistance < $idistance) {
612
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
613
+									} else {
464 614
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
465 615
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
466
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
467
-										else {
616
+										if (!isset($idistance) || $fdistance < $idistance) {
617
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
618
+										} else {
468 619
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
469 620
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
470 621
 										}
@@ -503,7 +654,9 @@  discard block
 block discarded – undo
503 654
 							}
504 655
 						}
505 656
 
506
-						if (!$min) $output .= '"image": "'.$image.'",';
657
+						if (!$min) {
658
+							$output .= '"image": "'.$image.'",';
659
+						}
507 660
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
508 661
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
509 662
 						}
@@ -511,8 +664,11 @@  discard block
 block discarded – undo
511 664
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
512 665
 						}
513 666
 						if (isset($spotter_item['squawk'])) {
514
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
515
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
667
+							if ($compress) {
668
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
669
+							} else {
670
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
671
+							}
516 672
 						}
517 673
 						if (isset($spotter_item['squawk_usage'])) {
518 674
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -531,14 +687,23 @@  discard block
 block discarded – undo
531 687
 						}
532 688
 						// type when not aircraft ?
533 689
 						if (isset($spotter_item['type'])) {
534
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
535
-							else $output .= '"type": "'.$spotter_item['type'].'"';
690
+							if ($compress) {
691
+								$output .= '"t": "'.$spotter_item['type'].'"';
692
+							} else {
693
+								$output .= '"type": "'.$spotter_item['type'].'"';
694
+							}
536 695
 						} elseif ($marine) {
537
-							if ($compress) $output .= '"t": "ship"';
538
-							else $output .= '"type": "ship"';
696
+							if ($compress) {
697
+								$output .= '"t": "ship"';
698
+							} else {
699
+								$output .= '"type": "ship"';
700
+							}
539 701
 						} else {
540
-							if ($compress) $output .= '"t": "aircraft"';
541
-							else $output .= '"type": "aircraft"';
702
+							if ($compress) {
703
+								$output .= '"t": "aircraft"';
704
+							} else {
705
+								$output .= '"type": "aircraft"';
706
+							}
542 707
 						}
543 708
 						$output .= '},';
544 709
 						$output .= '"geometry": {';
@@ -546,15 +711,19 @@  discard block
 block discarded – undo
546 711
 								$output .= '"coordinates": [';
547 712
 								if ($currenttime != '') {
548 713
 									if (strtotime($spotter_item['date']) < $currenttime) {
549
-										if (!isset($archivespeed)) $archivespeed = 1;
714
+										if (!isset($archivespeed)) {
715
+											$archivespeed = 1;
716
+										}
550 717
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
551 718
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
552
-										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
553
-										else {
719
+										if (!isset($idistance) || $fdistance < $idistance) {
720
+											$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
721
+										} else {
554 722
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
555 723
 											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
556
-											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
557
-											else {
724
+											if (!isset($idistance) || $fdistance < $idistance) {
725
+												$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
726
+											} else {
558 727
 												$output .= $spotter_item['longitude'].', ';
559 728
 												$output .= $spotter_item['latitude'];
560 729
 											}
@@ -632,7 +801,9 @@  discard block
 block discarded – undo
632 801
 			}
633 802
 */
634 803
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
635
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
804
+				if ($history == '' && isset($_COOKIE['history'])) {
805
+					$history = $_COOKIE['history'];
806
+				}
636 807
 				
637 808
 				if (
638 809
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -702,8 +873,11 @@  discard block
 block discarded – undo
702 873
 									$output_history .= ']}},';
703 874
 									$output .= $output_history;
704 875
 								}
705
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
706
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
876
+								if ($compress) {
877
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
878
+								} else {
879
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
880
+								}
707 881
 							}
708 882
 							$output_history .= '[';
709 883
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -724,10 +898,15 @@  discard block
 block discarded – undo
724 898
 							if ($d == false) {
725 899
 								if ($compress) {
726 900
 									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",';
727
-									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
728
-									elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
901
+									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') {
902
+										$output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
903
+									} elseif (isset($spotter_history_array[0]['mapmatching_engine'])) {
904
+										$output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
905
+									}
729 906
 									$output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": [';
730
-								} else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
907
+								} else {
908
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
909
+								}
731 910
 								$d = true;
732 911
 							}
733 912
 							$output_history .= '[';
@@ -750,7 +929,9 @@  discard block
 block discarded – undo
750 929
 							$output_historyd = '[';
751 930
 							$output_historyd .=  $spotter_item['longitude'].', ';
752 931
 							$output_historyd .=  $spotter_item['latitude'];
753
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
932
+							if (isset($spotter_history['altitude'])) {
933
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
934
+							}
754 935
 							$output_historyd .= '],';
755 936
 							//$output_history = $output_historyd.$output_history;
756 937
 							$output_history = $output_history.$output_historyd;
@@ -777,8 +958,11 @@  discard block
 block discarded – undo
777 958
 				        && $spotter_item['arrival_airport'] != 'NA' 
778 959
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
779 960
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
780
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
781
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
961
+				    if ($compress) {
962
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
963
+				    } else {
964
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
965
+				    }
782 966
 				    if (isset($spotter_item['departure_airport_latitude'])) {
783 967
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
784 968
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -811,8 +995,11 @@  discard block
 block discarded – undo
811 995
 				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
812 996
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
813 997
 				    $havedata = false;
814
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
815
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
998
+				    if ($compress) {
999
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1000
+				    } else {
1001
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1002
+				    }
816 1003
 				    
817 1004
 				    //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
818 1005
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -837,7 +1024,9 @@  discard block
 block discarded – undo
837 1024
 					$output_dest  = substr($output_dest, 0, -1);
838 1025
 				    }
839 1026
 				    $output_dest .= ']}},';
840
-				    if ($havedata) $output .= $output_dest;
1027
+				    if ($havedata) {
1028
+				    	$output .= $output_dest;
1029
+				    }
841 1030
 				    unset($output_dest);
842 1031
 				}
843 1032
 			}
@@ -845,7 +1034,9 @@  discard block
 block discarded – undo
845 1034
 			$output .= ']';
846 1035
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
847 1036
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
848
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
1037
+			if (isset($begindate)) {
1038
+				$output .= '"archive_date": "'.$begindate.'",';
1039
+			}
849 1040
 			$output .= '"fc": "'.$j.'"';
850 1041
 		} else {
851 1042
 			$output .= '"features": ';
Please login to merge, or discard this patch.
scripts/update_db.php 1 patch
Braces   +30 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ") && !strpos($line, "sudo ")) $j++;
12
+	foreach ($output as $line) {
13
+		if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ") && !strpos($line, "sudo ")) $j++;
14
+	}
13 15
 	if ($j > 1) {
14 16
 		echo "Script is already runnning...";
15 17
 		die();
@@ -29,14 +31,18 @@  discard block
 block discarded – undo
29 31
 			$update_db->update_notam();
30 32
 		}
31 33
 		$update_db->insert_last_notam_update();
32
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n";
34
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) {
35
+		echo "NOTAM are only updated once a day.\n";
36
+	}
33 37
 	if ($update_db->check_last_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
34 38
 		$update_db->update_all();
35 39
 	//	require_once(dirname(__FILE__).'/../require/class.Spotter.php');
36 40
 	//	$Spotter = new Spotter();
37 41
 	//	$Spotter->updateFieldsFromOtherTables();
38 42
 		$update_db->insert_last_update();
39
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
43
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) {
44
+		echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
45
+	}
40 46
 	if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) {
41 47
 		echo "Check if new airspace version exist...";
42 48
 		echo $update_db->update_airspace_fam();
@@ -45,8 +51,11 @@  discard block
 block discarded – undo
45 51
 	if (isset($globalGeoid) && $globalGeoid && $update_db->check_last_geoid_update()) {
46 52
 		echo "Check if new geoid version exist...";
47 53
 		$error = $update_db->update_geoid_fam();
48
-		if ($error == '') $update_db->insert_last_geoid_update();
49
-		else echo $error;
54
+		if ($error == '') {
55
+			$update_db->insert_last_geoid_update();
56
+		} else {
57
+			echo $error;
58
+		}
50 59
 	}
51 60
 	if (isset($globalMarine) && $globalMarine && $update_db->check_last_marine_identity_update()) {
52 61
 		echo "Check if new marine identity version exist...";
@@ -64,13 +73,17 @@  discard block
 block discarded – undo
64 73
 			//echo "Done";
65 74
 		}
66 75
 		$update_db->insert_last_owner_update();
67
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n";
76
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
77
+		echo "Owner are only updated every 15 days.\n";
78
+	}
68 79
 
69 80
 	if ($update_db->check_last_airlines_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
70 81
 		echo "Updating airlines...\n";
71 82
 		echo $update_db->update_airlines_fam();
72 83
 		$update_db->insert_last_airlines_update();
73
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Airlines are only updated every 15 days.\n";
84
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
85
+		echo "Airlines are only updated every 15 days.\n";
86
+	}
74 87
 
75 88
 	if (isset($globalAccidents) && $globalAccidents && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
76 89
 		require_once(dirname(__FILE__).'/../require/class.Accident.php');
@@ -79,7 +92,9 @@  discard block
 block discarded – undo
79 92
 		if ($Accident->check_last_accidents_update()) {
80 93
 			$Accident->download_update();
81 94
 			$Accident->insert_last_accidents_update();
82
-		} else echo "Accidents are updated once a day.\n";
95
+		} else {
96
+			echo "Accidents are updated once a day.\n";
97
+		}
83 98
 	}
84 99
   
85 100
 }
@@ -92,7 +107,9 @@  discard block
 block discarded – undo
92 107
 		if ($METAR->check_last_update()) {
93 108
 			$METAR->addMETARCycle();
94 109
 			$METAR->insert_last_update();
95
-		} else echo "METAR are only updated every 30 minutes.\n";
110
+		} else {
111
+			echo "METAR are only updated every 30 minutes.\n";
112
+		}
96 113
 	}
97 114
 
98 115
 	if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
@@ -100,8 +117,10 @@  discard block
 block discarded – undo
100 117
 		//$update_db->update_oneworld();
101 118
 		$update_db->update_skyteam();
102 119
 		$update_db->insert_last_schedules_update();
103
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n";
104
-}
120
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
121
+		echo "Schedules are only updated every 15 days.\n";
122
+	}
123
+	}
105 124
 
106 125
 if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) {
107 126
 	echo "Updating statistics and archive old data...\n";
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Braces   +1160 added lines, -402 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
27 27
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
28 28
 		curl_setopt($ch, CURLOPT_TIMEOUT, 200);
29
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
29
+		if ($referer != '') {
30
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
31
+		}
30 32
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
31 33
 		curl_setopt($ch, CURLOPT_FILE, $fp);
32 34
 		curl_exec($ch);
@@ -37,12 +39,16 @@  discard block
 block discarded – undo
37 39
 	public static function gunzip($in_file,$out_file_name = '') {
38 40
 		//echo $in_file.' -> '.$out_file_name."\n";
39 41
 		$buffer_size = 4096; // read 4kb at a time
40
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
42
+		if ($out_file_name == '') {
43
+			$out_file_name = str_replace('.gz', '', $in_file);
44
+		}
41 45
 		if ($in_file != '' && file_exists($in_file)) {
42 46
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
43
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
44
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
45
-			else {
47
+			if (function_exists('gzopen')) {
48
+				$file = gzopen($in_file,'rb');
49
+			} elseif (function_exists('gzopen64')) {
50
+				$file = gzopen64($in_file,'rb');
51
+			} else {
46 52
 				echo 'gzopen not available';
47 53
 				die;
48 54
 			}
@@ -63,8 +69,12 @@  discard block
 block discarded – undo
63 69
 			if ($res === TRUE) {
64 70
 				$zip->extractTo($path);
65 71
 				$zip->close();
66
-			} else return false;
67
-		} else return false;
72
+			} else {
73
+				return false;
74
+			}
75
+		} else {
76
+			return false;
77
+		}
68 78
 	}
69 79
 	
70 80
 	public static function connect_sqlite($database) {
@@ -79,7 +89,9 @@  discard block
 block discarded – undo
79 89
 	public static function retrieve_route_sqlite_to_dest($database_file) {
80 90
 		global $globalDebug, $globalTransaction;
81 91
 		//$query = 'TRUNCATE TABLE routes';
82
-		if ($globalDebug) echo " - Delete previous routes from DB -";
92
+		if ($globalDebug) {
93
+			echo " - Delete previous routes from DB -";
94
+		}
83 95
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
84 96
 		$Connection = new Connection();
85 97
 		try {
@@ -90,7 +102,9 @@  discard block
 block discarded – undo
90 102
                         return "error : ".$e->getMessage();
91 103
                 }
92 104
 
93
-    		if ($globalDebug) echo " - Add routes to DB -";
105
+    		if ($globalDebug) {
106
+    			echo " - Add routes to DB -";
107
+    		}
94 108
     		update_db::connect_sqlite($database_file);
95 109
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
96 110
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -105,15 +119,21 @@  discard block
 block discarded – undo
105 119
 		$Connection = new Connection();
106 120
 		$sth_dest = $Connection->db->prepare($query_dest);
107 121
 		try {
108
-			if ($globalTransaction) $Connection->db->beginTransaction();
122
+			if ($globalTransaction) {
123
+				$Connection->db->beginTransaction();
124
+			}
109 125
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 126
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
111 127
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
112 128
 				$sth_dest->execute($query_dest_values);
113 129
             		}
114
-			if ($globalTransaction) $Connection->db->commit();
130
+			if ($globalTransaction) {
131
+				$Connection->db->commit();
132
+			}
115 133
 		} catch(PDOException $e) {
116
-			if ($globalTransaction) $Connection->db->rollBack(); 
134
+			if ($globalTransaction) {
135
+				$Connection->db->rollBack();
136
+			}
117 137
 			return "error : ".$e->getMessage();
118 138
 		}
119 139
                 return '';
@@ -121,7 +141,9 @@  discard block
 block discarded – undo
121 141
 	public static function retrieve_route_oneworld($database_file) {
122 142
 		global $globalDebug, $globalTransaction;
123 143
 		//$query = 'TRUNCATE TABLE routes';
124
-		if ($globalDebug) echo " - Delete previous routes from DB -";
144
+		if ($globalDebug) {
145
+			echo " - Delete previous routes from DB -";
146
+		}
125 147
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
126 148
 		$Connection = new Connection();
127 149
 		try {
@@ -132,14 +154,18 @@  discard block
 block discarded – undo
132 154
                         return "error : ".$e->getMessage();
133 155
                 }
134 156
 
135
-    		if ($globalDebug) echo " - Add routes to DB -";
157
+    		if ($globalDebug) {
158
+    			echo " - Add routes to DB -";
159
+    		}
136 160
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 161
 		$Spotter = new Spotter();
138 162
 		if ($fh = fopen($database_file,"r")) {
139 163
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
140 164
 			$Connection = new Connection();
141 165
 			$sth_dest = $Connection->db->prepare($query_dest);
142
-			if ($globalTransaction) $Connection->db->beginTransaction();
166
+			if ($globalTransaction) {
167
+				$Connection->db->beginTransaction();
168
+			}
143 169
 			while (!feof($fh)) {
144 170
 				$line = fgetcsv($fh,9999,',');
145 171
 				if ($line[0] != '') {
@@ -148,13 +174,17 @@  discard block
 block discarded – undo
148 174
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
149 175
 							$sth_dest->execute($query_dest_values);
150 176
 						} catch(PDOException $e) {
151
-							if ($globalTransaction) $Connection->db->rollBack(); 
177
+							if ($globalTransaction) {
178
+								$Connection->db->rollBack();
179
+							}
152 180
 							return "error : ".$e->getMessage();
153 181
 						}
154 182
 					}
155 183
 				}
156 184
 			}
157
-			if ($globalTransaction) $Connection->db->commit();
185
+			if ($globalTransaction) {
186
+				$Connection->db->commit();
187
+			}
158 188
 		}
159 189
                 return '';
160 190
 	}
@@ -162,7 +192,9 @@  discard block
 block discarded – undo
162 192
 	public static function retrieve_route_skyteam($database_file) {
163 193
 		global $globalDebug, $globalTransaction;
164 194
 		//$query = 'TRUNCATE TABLE routes';
165
-		if ($globalDebug) echo " - Delete previous routes from DB -";
195
+		if ($globalDebug) {
196
+			echo " - Delete previous routes from DB -";
197
+		}
166 198
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
167 199
 		$Connection = new Connection();
168 200
 		try {
@@ -173,7 +205,9 @@  discard block
 block discarded – undo
173 205
                         return "error : ".$e->getMessage();
174 206
                 }
175 207
 
176
-    		if ($globalDebug) echo " - Add routes to DB -";
208
+    		if ($globalDebug) {
209
+    			echo " - Add routes to DB -";
210
+    		}
177 211
 
178 212
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 213
 		$Spotter = new Spotter();
@@ -182,7 +216,9 @@  discard block
 block discarded – undo
182 216
 			$Connection = new Connection();
183 217
 			$sth_dest = $Connection->db->prepare($query_dest);
184 218
 			try {
185
-				if ($globalTransaction) $Connection->db->beginTransaction();
219
+				if ($globalTransaction) {
220
+					$Connection->db->beginTransaction();
221
+				}
186 222
 				while (!feof($fh)) {
187 223
 					$line = fgetcsv($fh,9999,',');
188 224
 					if ($line[0] != '') {
@@ -193,9 +229,13 @@  discard block
 block discarded – undo
193 229
 						}
194 230
 					}
195 231
 				}
196
-				if ($globalTransaction) $Connection->db->commit();
232
+				if ($globalTransaction) {
233
+					$Connection->db->commit();
234
+				}
197 235
 			} catch(PDOException $e) {
198
-				if ($globalTransaction) $Connection->db->rollBack(); 
236
+				if ($globalTransaction) {
237
+					$Connection->db->rollBack();
238
+				}
199 239
 				return "error : ".$e->getMessage();
200 240
 			}
201 241
 		}
@@ -238,11 +278,16 @@  discard block
 block discarded – undo
238 278
 		$sth_dest = $Connection->db->prepare($query_dest);
239 279
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
240 280
 		try {
241
-			if ($globalTransaction) $Connection->db->beginTransaction();
281
+			if ($globalTransaction) {
282
+				$Connection->db->beginTransaction();
283
+			}
242 284
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
243 285
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
244
-				if ($values['UserString4'] == 'M') $type = 'military';
245
-				else $type = null;
286
+				if ($values['UserString4'] == 'M') {
287
+					$type = 'military';
288
+				} else {
289
+					$type = null;
290
+				}
246 291
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
247 292
 				$sth_dest->execute($query_dest_values);
248 293
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -250,7 +295,9 @@  discard block
 block discarded – undo
250 295
 				    $sth_dest_owner->execute($query_dest_owner_values);
251 296
 				}
252 297
             		}
253
-			if ($globalTransaction) $Connection->db->commit();
298
+			if ($globalTransaction) {
299
+				$Connection->db->commit();
300
+			}
254 301
 		} catch(PDOException $e) {
255 302
 			return "error : ".$e->getMessage();
256 303
 		}
@@ -287,7 +334,9 @@  discard block
 block discarded – undo
287 334
 			$Connection = new Connection();
288 335
 			$sth_dest = $Connection->db->prepare($query_dest);
289 336
 			try {
290
-				if ($globalTransaction) $Connection->db->beginTransaction();
337
+				if ($globalTransaction) {
338
+					$Connection->db->beginTransaction();
339
+				}
291 340
             			while (!feof($fh)) {
292 341
             				$values = array();
293 342
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -298,7 +347,9 @@  discard block
 block discarded – undo
298 347
             				// Check if we can find ICAO, else set it to GLID
299 348
             				$aircraft_name_split = explode(' ',$aircraft_name);
300 349
             				$search_more = '';
301
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
350
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
351
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
352
+            				}
302 353
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303 354
             				$sth_search = $Connection->db->prepare($query_search);
304 355
 					try {
@@ -311,7 +362,9 @@  discard block
 block discarded – undo
311 362
 					} catch(PDOException $e) {
312 363
 						return "error : ".$e->getMessage();
313 364
 					}
314
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
365
+					if (!isset($values['ICAOTypeCode'])) {
366
+						$values['ICAOTypeCode'] = 'GLID';
367
+					}
315 368
 					// Add data to db
316 369
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
317 370
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -320,7 +373,9 @@  discard block
 block discarded – undo
320 373
 						$sth_dest->execute($query_dest_values);
321 374
 					}
322 375
 				}
323
-				if ($globalTransaction) $Connection->db->commit();
376
+				if ($globalTransaction) {
377
+					$Connection->db->commit();
378
+				}
324 379
 			} catch(PDOException $e) {
325 380
 				return "error : ".$e->getMessage();
326 381
 			}
@@ -356,7 +411,9 @@  discard block
 block discarded – undo
356 411
 			$Connection = new Connection();
357 412
 			$sth_dest = $Connection->db->prepare($query_dest);
358 413
 			try {
359
-				if ($globalTransaction) $Connection->db->beginTransaction();
414
+				if ($globalTransaction) {
415
+					$Connection->db->beginTransaction();
416
+				}
360 417
 				$tmp = fgetcsv($fh,9999,',',"'");
361 418
             			while (!feof($fh)) {
362 419
             				$line = fgetcsv($fh,9999,',',"'");
@@ -370,13 +427,17 @@  discard block
 block discarded – undo
370 427
             				// Check if we can find ICAO, else set it to GLID
371 428
             				$aircraft_name_split = explode(' ',$aircraft_name);
372 429
             				$search_more = '';
373
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
430
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
431
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
432
+            				}
374 433
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375 434
             				$sth_search = $Connection->db->prepare($query_search);
376 435
 					try {
377 436
                                     		$sth_search->execute();
378 437
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
438
+	            				if (isset($result['icao']) && $result['icao'] != '') {
439
+	            					$values['ICAOTypeCode'] = $result['icao'];
440
+	            				}
380 441
 					} catch(PDOException $e) {
381 442
 						return "error : ".$e->getMessage();
382 443
 					}
@@ -389,7 +450,9 @@  discard block
 block discarded – undo
389 450
 						$sth_dest->execute($query_dest_values);
390 451
 					}
391 452
 				}
392
-				if ($globalTransaction) $Connection->db->commit();
453
+				if ($globalTransaction) {
454
+					$Connection->db->commit();
455
+				}
393 456
 			} catch(PDOException $e) {
394 457
 				return "error : ".$e->getMessage();
395 458
 			}
@@ -428,7 +491,9 @@  discard block
 block discarded – undo
428 491
 			$sth_dest = $Connection->db->prepare($query_dest);
429 492
 			$sth_modes = $Connection->db->prepare($query_modes);
430 493
 			try {
431
-				if ($globalTransaction) $Connection->db->beginTransaction();
494
+				if ($globalTransaction) {
495
+					$Connection->db->beginTransaction();
496
+				}
432 497
 				$tmp = fgetcsv($fh,9999,',','"');
433 498
             			while (!feof($fh)) {
434 499
             				$line = fgetcsv($fh,9999,',','"');
@@ -438,16 +503,22 @@  discard block
 block discarded – undo
438 503
             				    $values['registration'] = $line[0];
439 504
             				    $values['base'] = $line[4];
440 505
             				    $values['owner'] = $line[5];
441
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
+            				    if ($line[6] == '') {
507
+            				    	$values['date_first_reg'] = null;
508
+            				    } else {
509
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
510
+					    }
443 511
 					    $values['cancel'] = $line[7];
444 512
 					} elseif ($country == 'EI') {
445 513
 					    // TODO : add modeS & reg to aircraft_modes
446 514
             				    $values['registration'] = $line[0];
447 515
             				    $values['base'] = $line[3];
448 516
             				    $values['owner'] = $line[2];
449
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
517
+            				    if ($line[1] == '') {
518
+            				    	$values['date_first_reg'] = null;
519
+            				    } else {
520
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
521
+					    }
451 522
 					    $values['cancel'] = '';
452 523
 					    $values['modes'] = $line[7];
453 524
 					    $values['icao'] = $line[8];
@@ -466,16 +537,22 @@  discard block
 block discarded – undo
466 537
             				    $values['registration'] = $line[3];
467 538
             				    $values['base'] = null;
468 539
             				    $values['owner'] = $line[5];
469
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
540
+            				    if ($line[18] == '') {
541
+            				    	$values['date_first_reg'] = null;
542
+            				    } else {
543
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
544
+					    }
471 545
 					    $values['cancel'] = '';
472 546
 					} elseif ($country == 'VH') {
473 547
 					    // TODO : add modeS & reg to aircraft_modes
474 548
             				    $values['registration'] = $line[0];
475 549
             				    $values['base'] = null;
476 550
             				    $values['owner'] = $line[12];
477
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
551
+            				    if ($line[28] == '') {
552
+            				    	$values['date_first_reg'] = null;
553
+            				    } else {
554
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
555
+					    }
479 556
 
480 557
 					    $values['cancel'] = $line[39];
481 558
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -494,29 +571,41 @@  discard block
 block discarded – undo
494 571
             				    $values['registration'] = $line[0];
495 572
             				    $values['base'] = null;
496 573
             				    $values['owner'] = $line[8];
497
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
574
+            				    if ($line[7] == '') {
575
+            				    	$values['date_first_reg'] = null;
576
+            				    } else {
577
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
578
+					    }
499 579
 					    $values['cancel'] = '';
500 580
 					} elseif ($country == 'PP') {
501 581
             				    $values['registration'] = $line[0];
502 582
             				    $values['base'] = null;
503 583
             				    $values['owner'] = $line[4];
504
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
584
+            				    if ($line[6] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
588
+					    }
506 589
 					    $values['cancel'] = $line[7];
507 590
 					} elseif ($country == 'E7') {
508 591
             				    $values['registration'] = $line[0];
509 592
             				    $values['base'] = null;
510 593
             				    $values['owner'] = $line[4];
511
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
594
+            				    if ($line[5] == '') {
595
+            				    	$values['date_first_reg'] = null;
596
+            				    } else {
597
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
598
+					    }
513 599
 					    $values['cancel'] = '';
514 600
 					} elseif ($country == '8Q') {
515 601
             				    $values['registration'] = $line[0];
516 602
             				    $values['base'] = null;
517 603
             				    $values['owner'] = $line[3];
518
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
604
+            				    if ($line[7] == '') {
605
+            				    	$values['date_first_reg'] = null;
606
+            				    } else {
607
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
608
+					    }
520 609
 					    $values['cancel'] = '';
521 610
 					} elseif ($country == 'ZK') {
522 611
             				    $values['registration'] = $line[0];
@@ -561,7 +650,9 @@  discard block
 block discarded – undo
561 650
 						$sth_modes->execute($query_modes_values);
562 651
 					}
563 652
 				}
564
-				if ($globalTransaction) $Connection->db->commit();
653
+				if ($globalTransaction) {
654
+					$Connection->db->commit();
655
+				}
565 656
 			} catch(PDOException $e) {
566 657
 				return "error : ".$e->getMessage();
567 658
 			}
@@ -697,25 +788,45 @@  discard block
 block discarded – undo
697 788
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
698 789
 		$Connection = new Connection();
699 790
 		$sth_dest = $Connection->db->prepare($query_dest);
700
-		if ($globalTransaction) $Connection->db->beginTransaction();
791
+		if ($globalTransaction) {
792
+			$Connection->db->beginTransaction();
793
+		}
701 794
   
702 795
 		$i = 0;
703 796
 		while($row = sparql_fetch_array($result))
704 797
 		{
705 798
 			if ($i >= 1) {
706 799
 			//print_r($row);
707
-			if (!isset($row['iata'])) $row['iata'] = '';
708
-			if (!isset($row['icao'])) $row['icao'] = '';
709
-			if (!isset($row['type'])) $row['type'] = '';
710
-			if (!isset($row['altitude'])) $row['altitude'] = '';
800
+			if (!isset($row['iata'])) {
801
+				$row['iata'] = '';
802
+			}
803
+			if (!isset($row['icao'])) {
804
+				$row['icao'] = '';
805
+			}
806
+			if (!isset($row['type'])) {
807
+				$row['type'] = '';
808
+			}
809
+			if (!isset($row['altitude'])) {
810
+				$row['altitude'] = '';
811
+			}
711 812
 			if (isset($row['city_bis'])) {
712 813
 				$row['city'] = $row['city_bis'];
713 814
 			}
714
-			if (!isset($row['city'])) $row['city'] = '';
715
-			if (!isset($row['country'])) $row['country'] = '';
716
-			if (!isset($row['homepage'])) $row['homepage'] = '';
717
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
718
-			if (!isset($row['name'])) continue;
815
+			if (!isset($row['city'])) {
816
+				$row['city'] = '';
817
+			}
818
+			if (!isset($row['country'])) {
819
+				$row['country'] = '';
820
+			}
821
+			if (!isset($row['homepage'])) {
822
+				$row['homepage'] = '';
823
+			}
824
+			if (!isset($row['wikipedia_page'])) {
825
+				$row['wikipedia_page'] = '';
826
+			}
827
+			if (!isset($row['name'])) {
828
+				continue;
829
+			}
719 830
 			if (!isset($row['image'])) {
720 831
 				$row['image'] = '';
721 832
 				$row['image_thumb'] = '';
@@ -771,7 +882,9 @@  discard block
 block discarded – undo
771 882
 
772 883
 			$i++;
773 884
 		}
774
-		if ($globalTransaction) $Connection->db->commit();
885
+		if ($globalTransaction) {
886
+			$Connection->db->commit();
887
+		}
775 888
 		/*
776 889
 		echo "Delete duplicate rows...\n";
777 890
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -814,7 +927,9 @@  discard block
 block discarded – undo
814 927
 		$delimiter = ',';
815 928
 		$out_file = $tmp_dir.'airports.csv';
816 929
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
817
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
930
+		if (!file_exists($out_file) || !is_readable($out_file)) {
931
+			return FALSE;
932
+		}
818 933
 		echo "Add data from ourairports.com...\n";
819 934
 
820 935
 		$header = NULL;
@@ -824,8 +939,9 @@  discard block
 block discarded – undo
824 939
 			//$Connection->db->beginTransaction();
825 940
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
826 941
 			{
827
-				if(!$header) $header = $row;
828
-				else {
942
+				if(!$header) {
943
+					$header = $row;
944
+				} else {
829 945
 					$data = array();
830 946
 					$data = array_combine($header, $row);
831 947
 					try {
@@ -866,7 +982,9 @@  discard block
 block discarded – undo
866 982
 		echo "Download data from another free database...\n";
867 983
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
868 984
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
869
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
985
+		if (!file_exists($out_file) || !is_readable($out_file)) {
986
+			return FALSE;
987
+		}
870 988
 		update_db::unzip($out_file);
871 989
 		$header = NULL;
872 990
 		echo "Add data from another free database...\n";
@@ -877,8 +995,9 @@  discard block
 block discarded – undo
877 995
 			//$Connection->db->beginTransaction();
878 996
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
879 997
 			{
880
-				if(!$header) $header = $row;
881
-				else {
998
+				if(!$header) {
999
+					$header = $row;
1000
+				} else {
882 1001
 					$data = $row;
883 1002
 
884 1003
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1047,7 +1166,9 @@  discard block
 block discarded – undo
1047 1166
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1048 1167
 		{
1049 1168
 			$i = 0;
1050
-			if ($globalTransaction) $Connection->db->beginTransaction();
1169
+			if ($globalTransaction) {
1170
+				$Connection->db->beginTransaction();
1171
+			}
1051 1172
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1052 1173
 			{
1053 1174
 				if ($i > 0) {
@@ -1060,7 +1181,9 @@  discard block
 block discarded – undo
1060 1181
 					}
1061 1182
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1062 1183
 					if (!empty($result_search)) {
1063
-						if ($globalDebug) echo '.';
1184
+						if ($globalDebug) {
1185
+							echo '.';
1186
+						}
1064 1187
 							//if ($globalDBdriver == 'mysql') {
1065 1188
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1066 1189
 							//} else {
@@ -1082,8 +1205,12 @@  discard block
 block discarded – undo
1082 1205
 						}
1083 1206
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1084 1207
 						if (!empty($result_search_mfr)) {
1085
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1086
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1208
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1209
+								$data[16] = $data[23];
1210
+							}
1211
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1212
+								$data[16] = $data[15];
1213
+							}
1087 1214
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1088 1215
 							try {
1089 1216
 								$sthf = $Connection->db->prepare($queryf);
@@ -1094,7 +1221,9 @@  discard block
 block discarded – undo
1094 1221
 						}
1095 1222
 					}
1096 1223
 					if (strtotime($data[29]) > time()) {
1097
-						if ($globalDebug) echo 'i';
1224
+						if ($globalDebug) {
1225
+							echo 'i';
1226
+						}
1098 1227
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1099 1228
 						try {
1100 1229
 							$sth = $Connection->db->prepare($query);
@@ -1105,13 +1234,19 @@  discard block
 block discarded – undo
1105 1234
 					}
1106 1235
 				}
1107 1236
 				if ($i % 90 == 0) {
1108
-					if ($globalTransaction) $Connection->db->commit();
1109
-					if ($globalTransaction) $Connection->db->beginTransaction();
1237
+					if ($globalTransaction) {
1238
+						$Connection->db->commit();
1239
+					}
1240
+					if ($globalTransaction) {
1241
+						$Connection->db->beginTransaction();
1242
+					}
1110 1243
 				}
1111 1244
 				$i++;
1112 1245
 			}
1113 1246
 			fclose($handle);
1114
-			if ($globalTransaction) $Connection->db->commit();
1247
+			if ($globalTransaction) {
1248
+				$Connection->db->commit();
1249
+			}
1115 1250
 		}
1116 1251
 		return '';
1117 1252
 	}
@@ -1131,11 +1266,15 @@  discard block
 block discarded – undo
1131 1266
 		if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE)
1132 1267
 		{
1133 1268
 			$i = 0;
1134
-			if ($globalTransaction) $Connection->db->beginTransaction();
1269
+			if ($globalTransaction) {
1270
+				$Connection->db->beginTransaction();
1271
+			}
1135 1272
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1136 1273
 			{
1137 1274
 				if ($i > 0) {
1138
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1275
+					if ($data[1] == 'NULL') {
1276
+						$data[1] = $data[0];
1277
+					}
1139 1278
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1140 1279
 					try {
1141 1280
 						$sth = $Connection->db->prepare($query);
@@ -1147,7 +1286,9 @@  discard block
 block discarded – undo
1147 1286
 				$i++;
1148 1287
 			}
1149 1288
 			fclose($handle);
1150
-			if ($globalTransaction) $Connection->db->commit();
1289
+			if ($globalTransaction) {
1290
+				$Connection->db->commit();
1291
+			}
1151 1292
 		}
1152 1293
 		return '';
1153 1294
 	}
@@ -1179,11 +1320,15 @@  discard block
 block discarded – undo
1179 1320
 		if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE)
1180 1321
 		{
1181 1322
 			$i = 0;
1182
-			if ($globalTransaction) $Connection->db->beginTransaction();
1323
+			if ($globalTransaction) {
1324
+				$Connection->db->beginTransaction();
1325
+			}
1183 1326
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1184 1327
 			{
1185 1328
 				if ($i > 0) {
1186
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1329
+					if ($data[1] == 'NULL') {
1330
+						$data[1] = $data[0];
1331
+					}
1187 1332
 					$query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)';
1188 1333
 					try {
1189 1334
 						$sth = $Connection->db->prepare($query);
@@ -1195,7 +1340,9 @@  discard block
 block discarded – undo
1195 1340
 				$i++;
1196 1341
 			}
1197 1342
 			fclose($handle);
1198
-			if ($globalTransaction) $Connection->db->commit();
1343
+			if ($globalTransaction) {
1344
+				$Connection->db->commit();
1345
+			}
1199 1346
 		}
1200 1347
 		/*
1201 1348
 		$query = "UNLOCK TABLES";
@@ -1225,7 +1372,9 @@  discard block
 block discarded – undo
1225 1372
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1226 1373
 		{
1227 1374
 			$i = 0;
1228
-			if ($globalTransaction) $Connection->db->beginTransaction();
1375
+			if ($globalTransaction) {
1376
+				$Connection->db->beginTransaction();
1377
+			}
1229 1378
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1230 1379
 			{
1231 1380
 				if ($i > 0) {
@@ -1241,7 +1390,9 @@  discard block
 block discarded – undo
1241 1390
 				$i++;
1242 1391
 			}
1243 1392
 			fclose($handle);
1244
-			if ($globalTransaction) $Connection->db->commit();
1393
+			if ($globalTransaction) {
1394
+				$Connection->db->commit();
1395
+			}
1245 1396
 		}
1246 1397
 		return '';
1247 1398
         }
@@ -1261,7 +1412,9 @@  discard block
 block discarded – undo
1261 1412
 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)
1262 1413
 		{
1263 1414
 			$i = 0;
1264
-			if ($globalTransaction) $Connection->db->beginTransaction();
1415
+			if ($globalTransaction) {
1416
+				$Connection->db->beginTransaction();
1417
+			}
1265 1418
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1266 1419
 			{
1267 1420
 				if ($i > 0) {
@@ -1271,19 +1424,25 @@  discard block
 block discarded – undo
1271 1424
 						$sth = $Connection->db->prepare($query);
1272 1425
 						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1273 1426
 					} catch(PDOException $e) {
1274
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1427
+						if ($globalDebug) {
1428
+							echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1429
+						}
1275 1430
 						die();
1276 1431
 					}
1277 1432
 				}
1278 1433
 				if ($globalTransaction && $i % 2000 == 0) {
1279 1434
 					$Connection->db->commit();
1280
-					if ($globalDebug) echo '.';
1435
+					if ($globalDebug) {
1436
+						echo '.';
1437
+					}
1281 1438
 					$Connection->db->beginTransaction();
1282 1439
 				}
1283 1440
 				$i++;
1284 1441
 			}
1285 1442
 			fclose($handle);
1286
-			if ($globalTransaction) $Connection->db->commit();
1443
+			if ($globalTransaction) {
1444
+				$Connection->db->commit();
1445
+			}
1287 1446
 		}
1288 1447
 		return '';
1289 1448
         }
@@ -1308,7 +1467,9 @@  discard block
 block discarded – undo
1308 1467
 			$i = 0;
1309 1468
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1310 1469
 			//$Connection->db->beginTransaction();
1311
-			if ($globalTransaction) $Connection->db->beginTransaction();
1470
+			if ($globalTransaction) {
1471
+				$Connection->db->beginTransaction();
1472
+			}
1312 1473
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1313 1474
 			{
1314 1475
 				if ($i > 0) {
@@ -1324,7 +1485,9 @@  discard block
 block discarded – undo
1324 1485
 				$i++;
1325 1486
 			}
1326 1487
 			fclose($handle);
1327
-			if ($globalTransaction) $Connection->db->commit();
1488
+			if ($globalTransaction) {
1489
+				$Connection->db->commit();
1490
+			}
1328 1491
 		}
1329 1492
 		return '';
1330 1493
         }
@@ -1344,7 +1507,9 @@  discard block
 block discarded – undo
1344 1507
 		if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE)
1345 1508
 		{
1346 1509
 			$i = 0;
1347
-			if ($globalTransaction) $Connection->db->beginTransaction();
1510
+			if ($globalTransaction) {
1511
+				$Connection->db->beginTransaction();
1512
+			}
1348 1513
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1349 1514
 			{
1350 1515
 				if ($i > 0) {
@@ -1361,7 +1526,9 @@  discard block
 block discarded – undo
1361 1526
 				$i++;
1362 1527
 			}
1363 1528
 			fclose($handle);
1364
-			if ($globalTransaction) $Connection->db->commit();
1529
+			if ($globalTransaction) {
1530
+				$Connection->db->commit();
1531
+			}
1365 1532
 		}
1366 1533
 		return '';
1367 1534
 	}
@@ -1380,7 +1547,9 @@  discard block
 block discarded – undo
1380 1547
 		$Connection = new Connection();
1381 1548
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1382 1549
 		{
1383
-			if ($globalTransaction) $Connection->db->beginTransaction();
1550
+			if ($globalTransaction) {
1551
+				$Connection->db->beginTransaction();
1552
+			}
1384 1553
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1385 1554
 			{
1386 1555
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1395,7 +1564,9 @@  discard block
 block discarded – undo
1395 1564
 				}
1396 1565
 			}
1397 1566
 			fclose($handle);
1398
-			if ($globalTransaction) $Connection->db->commit();
1567
+			if ($globalTransaction) {
1568
+				$Connection->db->commit();
1569
+			}
1399 1570
 		}
1400 1571
 		return '';
1401 1572
         }
@@ -1471,9 +1642,14 @@  discard block
 block discarded – undo
1471 1642
 				if ($i > 0 && $data[0] != '') {
1472 1643
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1473 1644
 					$period = str_replace(',','',$data[14]);
1474
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1475
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1476
-					else $launch_date = NULL;
1645
+					if (!empty($period) && strpos($period,'days')) {
1646
+						$period = str_replace(' days','',$period)*24*60;
1647
+					}
1648
+					if ($data[18] != '') {
1649
+						$launch_date = date('Y-m-d',strtotime($data[18]));
1650
+					} else {
1651
+						$launch_date = NULL;
1652
+					}
1477 1653
 					$data = array_map(function($value) {
1478 1654
 						return trim($value) === '' ? null : $value;
1479 1655
 					}, $data);
@@ -1836,7 +2012,9 @@  discard block
 block discarded – undo
1836 2012
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1837 2013
 		{
1838 2014
 			$i = 0;
1839
-			if ($globalTransaction) $Connection->db->beginTransaction();
2015
+			if ($globalTransaction) {
2016
+				$Connection->db->beginTransaction();
2017
+			}
1840 2018
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1841 2019
 			{
1842 2020
 				$i++;
@@ -1864,7 +2042,9 @@  discard block
 block discarded – undo
1864 2042
 				}
1865 2043
 			}
1866 2044
 			fclose($handle);
1867
-			if ($globalTransaction) $Connection->db->commit();
2045
+			if ($globalTransaction) {
2046
+				$Connection->db->commit();
2047
+			}
1868 2048
 		}
1869 2049
 		return '';
1870 2050
 	}
@@ -1907,7 +2087,9 @@  discard block
 block discarded – undo
1907 2087
 		$Connection = new Connection();
1908 2088
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1909 2089
 		{
1910
-			if ($globalTransaction) $Connection->db->beginTransaction();
2090
+			if ($globalTransaction) {
2091
+				$Connection->db->beginTransaction();
2092
+			}
1911 2093
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1912 2094
 			{
1913 2095
 				if(count($row) > 1) {
@@ -1921,7 +2103,9 @@  discard block
 block discarded – undo
1921 2103
 				}
1922 2104
 			}
1923 2105
 			fclose($handle);
1924
-			if ($globalTransaction) $Connection->db->commit();
2106
+			if ($globalTransaction) {
2107
+				$Connection->db->commit();
2108
+			}
1925 2109
 		}
1926 2110
 		return '';
1927 2111
         }
@@ -1941,8 +2125,9 @@  discard block
 block discarded – undo
1941 2125
 	        }
1942 2126
 
1943 2127
 
1944
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1945
-		else {
2128
+		if ($globalDBdriver == 'mysql') {
2129
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2130
+		} else {
1946 2131
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1947 2132
 			$query = "CREATE EXTENSION postgis";
1948 2133
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1961,7 +2146,9 @@  discard block
 block discarded – undo
1961 2146
 		global $tmp_dir, $globalDebug;
1962 2147
 		include_once('class.create_db.php');
1963 2148
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1964
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2149
+		if ($globalDebug) {
2150
+			echo "NOTAM from FlightAirMap website : Download...";
2151
+		}
1965 2152
 		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
1966 2153
 		$error = '';
1967 2154
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
@@ -1971,20 +2158,34 @@  discard block
 block discarded – undo
1971 2158
 				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1972 2159
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
1973 2160
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
1974
-						if ($globalDebug) echo "Gunzip...";
2161
+						if ($globalDebug) {
2162
+							echo "Gunzip...";
2163
+						}
1975 2164
 						update_db::gunzip($tmp_dir.'notam.txt.gz');
1976
-						if ($globalDebug) echo "Add to DB...";
2165
+						if ($globalDebug) {
2166
+							echo "Add to DB...";
2167
+						}
1977 2168
 						//$error = create_db::import_file($tmp_dir.'notam.sql');
1978 2169
 						$NOTAM = new NOTAM();
1979 2170
 						$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1980 2171
 						update_db::insert_notam_version($notam_md5);
1981
-					} else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
1982
-				} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1983
-			} elseif ($globalDebug) echo "No new version.";
1984
-		} else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2172
+					} else {
2173
+						$error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2174
+					}
2175
+				} else {
2176
+					$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2177
+				}
2178
+			} elseif ($globalDebug) {
2179
+				echo "No new version.";
2180
+			}
2181
+		} else {
2182
+			$error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2183
+		}
1985 2184
 		if ($error != '') {
1986 2185
 			return $error;
1987
-		} elseif ($globalDebug) echo "Done\n";
2186
+		} elseif ($globalDebug) {
2187
+			echo "Done\n";
2188
+		}
1988 2189
 		return '';
1989 2190
 	}
1990 2191
 
@@ -2039,68 +2240,114 @@  discard block
 block discarded – undo
2039 2240
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
2040 2241
 		if (extension_loaded('zip')) {
2041 2242
 			if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
2042
-				if ($globalDebug) echo "Unzip...";
2243
+				if ($globalDebug) {
2244
+					echo "Unzip...";
2245
+				}
2043 2246
 				update_db::unzip($tmp_dir.'ivae_feb2013.zip');
2044
-				if ($globalDebug) echo "Add to DB...";
2247
+				if ($globalDebug) {
2248
+					echo "Add to DB...";
2249
+				}
2045 2250
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2046
-				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2251
+				if ($globalDebug) {
2252
+					echo "Copy airlines logos to airlines images directory...";
2253
+				}
2047 2254
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2048
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2049
-				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2050
-			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2051
-		} else $error = "ZIP module not loaded but required for IVAO.";
2255
+					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
2256
+						$error = "Failed to copy airlines logo.";
2257
+					}
2258
+				} else {
2259
+					$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2260
+				}
2261
+			} else {
2262
+				$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2263
+			}
2264
+		} else {
2265
+			$error = "ZIP module not loaded but required for IVAO.";
2266
+		}
2052 2267
 		if ($error != '') {
2053 2268
 			return $error;
2054
-		} elseif ($globalDebug) echo "Done\n";
2269
+		} elseif ($globalDebug) {
2270
+			echo "Done\n";
2271
+		}
2055 2272
 		return '';
2056 2273
 	}
2057 2274
 
2058 2275
 	public static function update_routes() {
2059 2276
 		global $tmp_dir, $globalDebug;
2060 2277
 		$error = '';
2061
-		if ($globalDebug) echo "Routes : Download...";
2278
+		if ($globalDebug) {
2279
+			echo "Routes : Download...";
2280
+		}
2062 2281
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2063 2282
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2064
-			if ($globalDebug) echo "Gunzip...";
2283
+			if ($globalDebug) {
2284
+				echo "Gunzip...";
2285
+			}
2065 2286
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
2066
-			if ($globalDebug) echo "Add to DB...";
2287
+			if ($globalDebug) {
2288
+				echo "Add to DB...";
2289
+			}
2067 2290
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
2068
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2291
+		} else {
2292
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2293
+		}
2069 2294
 		if ($error != '') {
2070 2295
 			return $error;
2071
-		} elseif ($globalDebug) echo "Done\n";
2296
+		} elseif ($globalDebug) {
2297
+			echo "Done\n";
2298
+		}
2072 2299
 		return '';
2073 2300
 	}
2074 2301
 	public static function update_oneworld() {
2075 2302
 		global $tmp_dir, $globalDebug;
2076 2303
 		$error = '';
2077
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
2304
+		if ($globalDebug) {
2305
+			echo "Schedules Oneworld : Download...";
2306
+		}
2078 2307
 		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2079 2308
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2080
-			if ($globalDebug) echo "Gunzip...";
2309
+			if ($globalDebug) {
2310
+				echo "Gunzip...";
2311
+			}
2081 2312
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
2082
-			if ($globalDebug) echo "Add to DB...";
2313
+			if ($globalDebug) {
2314
+				echo "Add to DB...";
2315
+			}
2083 2316
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
2084
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2317
+		} else {
2318
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2319
+		}
2085 2320
 		if ($error != '') {
2086 2321
 			return $error;
2087
-		} elseif ($globalDebug) echo "Done\n";
2322
+		} elseif ($globalDebug) {
2323
+			echo "Done\n";
2324
+		}
2088 2325
 		return '';
2089 2326
 	}
2090 2327
 	public static function update_skyteam() {
2091 2328
 		global $tmp_dir, $globalDebug;
2092 2329
 		$error = '';
2093
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
2330
+		if ($globalDebug) {
2331
+			echo "Schedules Skyteam : Download...";
2332
+		}
2094 2333
 		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2095 2334
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2096
-			if ($globalDebug) echo "Gunzip...";
2335
+			if ($globalDebug) {
2336
+				echo "Gunzip...";
2337
+			}
2097 2338
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
2098
-			if ($globalDebug) echo "Add to DB...";
2339
+			if ($globalDebug) {
2340
+				echo "Add to DB...";
2341
+			}
2099 2342
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
2100
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2343
+		} else {
2344
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2345
+		}
2101 2346
 		if ($error != '') {
2102 2347
 			return $error;
2103
-		} elseif ($globalDebug) echo "Done\n";
2348
+		} elseif ($globalDebug) {
2349
+			echo "Done\n";
2350
+		}
2104 2351
 		return '';
2105 2352
 	}
2106 2353
 	public static function update_ModeS() {
@@ -2117,340 +2364,590 @@  discard block
 block discarded – undo
2117 2364
 			exit;
2118 2365
 		} elseif ($globalDebug) echo "Done\n";
2119 2366
 */
2120
-		if ($globalDebug) echo "Modes : Download...";
2121
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2367
+		if ($globalDebug) {
2368
+			echo "Modes : Download...";
2369
+		}
2370
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2122 2371
 		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2123 2372
 
2124 2373
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2125 2374
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
2126
-			if ($globalDebug) echo "Unzip...";
2127
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2375
+			if ($globalDebug) {
2376
+				echo "Unzip...";
2377
+			}
2378
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2128 2379
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
2129
-			if ($globalDebug) echo "Add to DB...";
2380
+			if ($globalDebug) {
2381
+				echo "Add to DB...";
2382
+			}
2130 2383
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
2131 2384
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
2132
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2385
+		} else {
2386
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2387
+		}
2133 2388
 		if ($error != '') {
2134 2389
 			return $error;
2135
-		} elseif ($globalDebug) echo "Done\n";
2390
+		} elseif ($globalDebug) {
2391
+			echo "Done\n";
2392
+		}
2136 2393
 		return '';
2137 2394
 	}
2138 2395
 
2139 2396
 	public static function update_ModeS_faa() {
2140 2397
 		global $tmp_dir, $globalDebug;
2141
-		if ($globalDebug) echo "Modes FAA: Download...";
2398
+		if ($globalDebug) {
2399
+			echo "Modes FAA: Download...";
2400
+		}
2142 2401
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2143 2402
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2144
-			if ($globalDebug) echo "Unzip...";
2403
+			if ($globalDebug) {
2404
+				echo "Unzip...";
2405
+			}
2145 2406
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
2146
-			if ($globalDebug) echo "Add to DB...";
2407
+			if ($globalDebug) {
2408
+				echo "Add to DB...";
2409
+			}
2147 2410
 			$error = update_db::modes_faa();
2148
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2411
+		} else {
2412
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2413
+		}
2149 2414
 		if ($error != '') {
2150 2415
 			return $error;
2151
-		} elseif ($globalDebug) echo "Done\n";
2416
+		} elseif ($globalDebug) {
2417
+			echo "Done\n";
2418
+		}
2152 2419
 		return '';
2153 2420
 	}
2154 2421
 
2155 2422
 	public static function update_ModeS_flarm() {
2156 2423
 		global $tmp_dir, $globalDebug;
2157
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
2424
+		if ($globalDebug) {
2425
+			echo "Modes Flarmnet: Download...";
2426
+		}
2158 2427
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2159 2428
 		if (file_exists($tmp_dir.'data.fln')) {
2160
-			if ($globalDebug) echo "Add to DB...";
2429
+			if ($globalDebug) {
2430
+				echo "Add to DB...";
2431
+			}
2161 2432
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
2162
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2433
+		} else {
2434
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2435
+		}
2163 2436
 		if ($error != '') {
2164 2437
 			return $error;
2165
-		} elseif ($globalDebug) echo "Done\n";
2438
+		} elseif ($globalDebug) {
2439
+			echo "Done\n";
2440
+		}
2166 2441
 		return '';
2167 2442
 	}
2168 2443
 
2169 2444
 	public static function update_ModeS_ogn() {
2170 2445
 		global $tmp_dir, $globalDebug;
2171
-		if ($globalDebug) echo "Modes OGN: Download...";
2446
+		if ($globalDebug) {
2447
+			echo "Modes OGN: Download...";
2448
+		}
2172 2449
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2173 2450
 		if (file_exists($tmp_dir.'ogn.csv')) {
2174
-			if ($globalDebug) echo "Add to DB...";
2451
+			if ($globalDebug) {
2452
+				echo "Add to DB...";
2453
+			}
2175 2454
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
2176
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2455
+		} else {
2456
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2457
+		}
2177 2458
 		if ($error != '') {
2178 2459
 			return $error;
2179
-		} elseif ($globalDebug) echo "Done\n";
2460
+		} elseif ($globalDebug) {
2461
+			echo "Done\n";
2462
+		}
2180 2463
 		return '';
2181 2464
 	}
2182 2465
 
2183 2466
 	public static function update_owner() {
2184 2467
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2185 2468
 		
2186
-		if ($globalDebug) echo "Owner France: Download...";
2469
+		if ($globalDebug) {
2470
+			echo "Owner France: Download...";
2471
+		}
2187 2472
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2188 2473
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2189
-			if ($globalDebug) echo "Add to DB...";
2474
+			if ($globalDebug) {
2475
+				echo "Add to DB...";
2476
+			}
2190 2477
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2191
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2478
+		} else {
2479
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2480
+		}
2192 2481
 		if ($error != '') {
2193 2482
 			return $error;
2194
-		} elseif ($globalDebug) echo "Done\n";
2483
+		} elseif ($globalDebug) {
2484
+			echo "Done\n";
2485
+		}
2195 2486
 		
2196
-		if ($globalDebug) echo "Owner Ireland: Download...";
2487
+		if ($globalDebug) {
2488
+			echo "Owner Ireland: Download...";
2489
+		}
2197 2490
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2198 2491
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2199
-			if ($globalDebug) echo "Add to DB...";
2492
+			if ($globalDebug) {
2493
+				echo "Add to DB...";
2494
+			}
2200 2495
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2201
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2496
+		} else {
2497
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2498
+		}
2202 2499
 		if ($error != '') {
2203 2500
 			return $error;
2204
-		} elseif ($globalDebug) echo "Done\n";
2205
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2501
+		} elseif ($globalDebug) {
2502
+			echo "Done\n";
2503
+		}
2504
+		if ($globalDebug) {
2505
+			echo "Owner Switzerland: Download...";
2506
+		}
2206 2507
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2207 2508
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2208
-			if ($globalDebug) echo "Add to DB...";
2509
+			if ($globalDebug) {
2510
+				echo "Add to DB...";
2511
+			}
2209 2512
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2210
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2513
+		} else {
2514
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2515
+		}
2211 2516
 		if ($error != '') {
2212 2517
 			return $error;
2213
-		} elseif ($globalDebug) echo "Done\n";
2214
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2518
+		} elseif ($globalDebug) {
2519
+			echo "Done\n";
2520
+		}
2521
+		if ($globalDebug) {
2522
+			echo "Owner Czech Republic: Download...";
2523
+		}
2215 2524
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2216 2525
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2217
-			if ($globalDebug) echo "Add to DB...";
2526
+			if ($globalDebug) {
2527
+				echo "Add to DB...";
2528
+			}
2218 2529
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2219
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2530
+		} else {
2531
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2532
+		}
2220 2533
 		if ($error != '') {
2221 2534
 			return $error;
2222
-		} elseif ($globalDebug) echo "Done\n";
2223
-		if ($globalDebug) echo "Owner Australia: Download...";
2535
+		} elseif ($globalDebug) {
2536
+			echo "Done\n";
2537
+		}
2538
+		if ($globalDebug) {
2539
+			echo "Owner Australia: Download...";
2540
+		}
2224 2541
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2225 2542
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2226
-			if ($globalDebug) echo "Add to DB...";
2543
+			if ($globalDebug) {
2544
+				echo "Add to DB...";
2545
+			}
2227 2546
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2228
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2547
+		} else {
2548
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2549
+		}
2229 2550
 		if ($error != '') {
2230 2551
 			return $error;
2231
-		} elseif ($globalDebug) echo "Done\n";
2232
-		if ($globalDebug) echo "Owner Austria: Download...";
2552
+		} elseif ($globalDebug) {
2553
+			echo "Done\n";
2554
+		}
2555
+		if ($globalDebug) {
2556
+			echo "Owner Austria: Download...";
2557
+		}
2233 2558
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2234 2559
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2235
-			if ($globalDebug) echo "Add to DB...";
2560
+			if ($globalDebug) {
2561
+				echo "Add to DB...";
2562
+			}
2236 2563
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2237
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2564
+		} else {
2565
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2566
+		}
2238 2567
 		if ($error != '') {
2239 2568
 			return $error;
2240
-		} elseif ($globalDebug) echo "Done\n";
2241
-		if ($globalDebug) echo "Owner Chile: Download...";
2569
+		} elseif ($globalDebug) {
2570
+			echo "Done\n";
2571
+		}
2572
+		if ($globalDebug) {
2573
+			echo "Owner Chile: Download...";
2574
+		}
2242 2575
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2243 2576
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2244
-			if ($globalDebug) echo "Add to DB...";
2577
+			if ($globalDebug) {
2578
+				echo "Add to DB...";
2579
+			}
2245 2580
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2246
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2581
+		} else {
2582
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2583
+		}
2247 2584
 		if ($error != '') {
2248 2585
 			return $error;
2249
-		} elseif ($globalDebug) echo "Done\n";
2250
-		if ($globalDebug) echo "Owner Colombia: Download...";
2586
+		} elseif ($globalDebug) {
2587
+			echo "Done\n";
2588
+		}
2589
+		if ($globalDebug) {
2590
+			echo "Owner Colombia: Download...";
2591
+		}
2251 2592
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2252 2593
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2253
-			if ($globalDebug) echo "Add to DB...";
2594
+			if ($globalDebug) {
2595
+				echo "Add to DB...";
2596
+			}
2254 2597
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2255
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2598
+		} else {
2599
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2600
+		}
2256 2601
 		if ($error != '') {
2257 2602
 			return $error;
2258
-		} elseif ($globalDebug) echo "Done\n";
2259
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2603
+		} elseif ($globalDebug) {
2604
+			echo "Done\n";
2605
+		}
2606
+		if ($globalDebug) {
2607
+			echo "Owner Bosnia Herzegobina: Download...";
2608
+		}
2260 2609
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2261 2610
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2262
-			if ($globalDebug) echo "Add to DB...";
2611
+			if ($globalDebug) {
2612
+				echo "Add to DB...";
2613
+			}
2263 2614
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2264
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2615
+		} else {
2616
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2617
+		}
2265 2618
 		if ($error != '') {
2266 2619
 			return $error;
2267
-		} elseif ($globalDebug) echo "Done\n";
2268
-		if ($globalDebug) echo "Owner Brazil: Download...";
2620
+		} elseif ($globalDebug) {
2621
+			echo "Done\n";
2622
+		}
2623
+		if ($globalDebug) {
2624
+			echo "Owner Brazil: Download...";
2625
+		}
2269 2626
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2270 2627
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2271
-			if ($globalDebug) echo "Add to DB...";
2628
+			if ($globalDebug) {
2629
+				echo "Add to DB...";
2630
+			}
2272 2631
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2273
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2632
+		} else {
2633
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2634
+		}
2274 2635
 		if ($error != '') {
2275 2636
 			return $error;
2276
-		} elseif ($globalDebug) echo "Done\n";
2277
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2637
+		} elseif ($globalDebug) {
2638
+			echo "Done\n";
2639
+		}
2640
+		if ($globalDebug) {
2641
+			echo "Owner Cayman Islands: Download...";
2642
+		}
2278 2643
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2279 2644
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2280
-			if ($globalDebug) echo "Add to DB...";
2645
+			if ($globalDebug) {
2646
+				echo "Add to DB...";
2647
+			}
2281 2648
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2282
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2649
+		} else {
2650
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2651
+		}
2283 2652
 		if ($error != '') {
2284 2653
 			return $error;
2285
-		} elseif ($globalDebug) echo "Done\n";
2286
-		if ($globalDebug) echo "Owner Croatia: Download...";
2654
+		} elseif ($globalDebug) {
2655
+			echo "Done\n";
2656
+		}
2657
+		if ($globalDebug) {
2658
+			echo "Owner Croatia: Download...";
2659
+		}
2287 2660
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2288 2661
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2289
-			if ($globalDebug) echo "Add to DB...";
2662
+			if ($globalDebug) {
2663
+				echo "Add to DB...";
2664
+			}
2290 2665
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2291
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2666
+		} else {
2667
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2668
+		}
2292 2669
 		if ($error != '') {
2293 2670
 			return $error;
2294
-		} elseif ($globalDebug) echo "Done\n";
2295
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2671
+		} elseif ($globalDebug) {
2672
+			echo "Done\n";
2673
+		}
2674
+		if ($globalDebug) {
2675
+			echo "Owner Luxembourg: Download...";
2676
+		}
2296 2677
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2297 2678
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2298
-			if ($globalDebug) echo "Add to DB...";
2679
+			if ($globalDebug) {
2680
+				echo "Add to DB...";
2681
+			}
2299 2682
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2300
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2683
+		} else {
2684
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2685
+		}
2301 2686
 		if ($error != '') {
2302 2687
 			return $error;
2303
-		} elseif ($globalDebug) echo "Done\n";
2304
-		if ($globalDebug) echo "Owner Maldives: Download...";
2688
+		} elseif ($globalDebug) {
2689
+			echo "Done\n";
2690
+		}
2691
+		if ($globalDebug) {
2692
+			echo "Owner Maldives: Download...";
2693
+		}
2305 2694
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2306 2695
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2307
-			if ($globalDebug) echo "Add to DB...";
2696
+			if ($globalDebug) {
2697
+				echo "Add to DB...";
2698
+			}
2308 2699
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2309
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2700
+		} else {
2701
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2702
+		}
2310 2703
 		if ($error != '') {
2311 2704
 			return $error;
2312
-		} elseif ($globalDebug) echo "Done\n";
2313
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2705
+		} elseif ($globalDebug) {
2706
+			echo "Done\n";
2707
+		}
2708
+		if ($globalDebug) {
2709
+			echo "Owner New Zealand: Download...";
2710
+		}
2314 2711
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2315 2712
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2316
-			if ($globalDebug) echo "Add to DB...";
2713
+			if ($globalDebug) {
2714
+				echo "Add to DB...";
2715
+			}
2317 2716
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2318
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2717
+		} else {
2718
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2719
+		}
2319 2720
 		if ($error != '') {
2320 2721
 			return $error;
2321
-		} elseif ($globalDebug) echo "Done\n";
2322
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2722
+		} elseif ($globalDebug) {
2723
+			echo "Done\n";
2724
+		}
2725
+		if ($globalDebug) {
2726
+			echo "Owner Papua New Guinea: Download...";
2727
+		}
2323 2728
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2324 2729
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2325
-			if ($globalDebug) echo "Add to DB...";
2730
+			if ($globalDebug) {
2731
+				echo "Add to DB...";
2732
+			}
2326 2733
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2327
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2734
+		} else {
2735
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2736
+		}
2328 2737
 		if ($error != '') {
2329 2738
 			return $error;
2330
-		} elseif ($globalDebug) echo "Done\n";
2331
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2739
+		} elseif ($globalDebug) {
2740
+			echo "Done\n";
2741
+		}
2742
+		if ($globalDebug) {
2743
+			echo "Owner Slovakia: Download...";
2744
+		}
2332 2745
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2333 2746
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2334
-			if ($globalDebug) echo "Add to DB...";
2747
+			if ($globalDebug) {
2748
+				echo "Add to DB...";
2749
+			}
2335 2750
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2336
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2751
+		} else {
2752
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2753
+		}
2337 2754
 		if ($error != '') {
2338 2755
 			return $error;
2339
-		} elseif ($globalDebug) echo "Done\n";
2340
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2756
+		} elseif ($globalDebug) {
2757
+			echo "Done\n";
2758
+		}
2759
+		if ($globalDebug) {
2760
+			echo "Owner Ecuador: Download...";
2761
+		}
2341 2762
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2342 2763
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2343
-			if ($globalDebug) echo "Add to DB...";
2764
+			if ($globalDebug) {
2765
+				echo "Add to DB...";
2766
+			}
2344 2767
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2345
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2768
+		} else {
2769
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2770
+		}
2346 2771
 		if ($error != '') {
2347 2772
 			return $error;
2348
-		} elseif ($globalDebug) echo "Done\n";
2349
-		if ($globalDebug) echo "Owner Iceland: Download...";
2773
+		} elseif ($globalDebug) {
2774
+			echo "Done\n";
2775
+		}
2776
+		if ($globalDebug) {
2777
+			echo "Owner Iceland: Download...";
2778
+		}
2350 2779
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2351 2780
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2352
-			if ($globalDebug) echo "Add to DB...";
2781
+			if ($globalDebug) {
2782
+				echo "Add to DB...";
2783
+			}
2353 2784
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2354
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2785
+		} else {
2786
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2787
+		}
2355 2788
 		if ($error != '') {
2356 2789
 			return $error;
2357
-		} elseif ($globalDebug) echo "Done\n";
2358
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2790
+		} elseif ($globalDebug) {
2791
+			echo "Done\n";
2792
+		}
2793
+		if ($globalDebug) {
2794
+			echo "Owner Isle of Man: Download...";
2795
+		}
2359 2796
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2360 2797
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2361
-			if ($globalDebug) echo "Add to DB...";
2798
+			if ($globalDebug) {
2799
+				echo "Add to DB...";
2800
+			}
2362 2801
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2363
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2802
+		} else {
2803
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2804
+		}
2364 2805
 		if ($error != '') {
2365 2806
 			return $error;
2366
-		} elseif ($globalDebug) echo "Done\n";
2807
+		} elseif ($globalDebug) {
2808
+			echo "Done\n";
2809
+		}
2367 2810
 		if ($globalMasterSource) {
2368
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2811
+			if ($globalDebug) {
2812
+				echo "ModeS Netherlands: Download...";
2813
+			}
2369 2814
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2370 2815
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2371
-				if ($globalDebug) echo "Add to DB...";
2816
+				if ($globalDebug) {
2817
+					echo "Add to DB...";
2818
+				}
2372 2819
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2373
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2820
+			} else {
2821
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2822
+			}
2374 2823
 			if ($error != '') {
2375 2824
 				return $error;
2376
-			} elseif ($globalDebug) echo "Done\n";
2377
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2825
+			} elseif ($globalDebug) {
2826
+				echo "Done\n";
2827
+			}
2828
+			if ($globalDebug) {
2829
+				echo "ModeS Denmark: Download...";
2830
+			}
2378 2831
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2379 2832
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2380
-				if ($globalDebug) echo "Add to DB...";
2833
+				if ($globalDebug) {
2834
+					echo "Add to DB...";
2835
+				}
2381 2836
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2382
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2837
+			} else {
2838
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2839
+			}
2383 2840
 			if ($error != '') {
2384 2841
 				return $error;
2385
-			} elseif ($globalDebug) echo "Done\n";
2386
-		} elseif ($globalDebug) echo "Done\n";
2842
+			} elseif ($globalDebug) {
2843
+				echo "Done\n";
2844
+			}
2845
+		} elseif ($globalDebug) {
2846
+			echo "Done\n";
2847
+		}
2387 2848
 		return '';
2388 2849
 	}
2389 2850
 
2390 2851
 	public static function update_translation() {
2391 2852
 		global $tmp_dir, $globalDebug;
2392 2853
 		$error = '';
2393
-		if ($globalDebug) echo "Translation : Download...";
2854
+		if ($globalDebug) {
2855
+			echo "Translation : Download...";
2856
+		}
2394 2857
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2395 2858
 		if (file_exists($tmp_dir.'translation.zip')) {
2396
-			if ($globalDebug) echo "Unzip...";
2859
+			if ($globalDebug) {
2860
+				echo "Unzip...";
2861
+			}
2397 2862
 			update_db::unzip($tmp_dir.'translation.zip');
2398
-			if ($globalDebug) echo "Add to DB...";
2863
+			if ($globalDebug) {
2864
+				echo "Add to DB...";
2865
+			}
2399 2866
 			$error = update_db::translation();
2400
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2867
+		} else {
2868
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2869
+		}
2401 2870
 		if ($error != '') {
2402 2871
 			return $error;
2403
-		} elseif ($globalDebug) echo "Done\n";
2872
+		} elseif ($globalDebug) {
2873
+			echo "Done\n";
2874
+		}
2404 2875
 		return '';
2405 2876
 	}
2406 2877
 
2407 2878
 	public static function update_translation_fam() {
2408 2879
 		global $tmp_dir, $globalDebug;
2409 2880
 		$error = '';
2410
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2881
+		if ($globalDebug) {
2882
+			echo "Translation from FlightAirMap website : Download...";
2883
+		}
2411 2884
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2412 2885
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2413 2886
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2414 2887
 			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2415 2888
 			$translation_md5 = $translation_md5_file[0];
2416 2889
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2417
-				if ($globalDebug) echo "Gunzip...";
2890
+				if ($globalDebug) {
2891
+					echo "Gunzip...";
2892
+				}
2418 2893
 				update_db::gunzip($tmp_dir.'translation.tsv.gz');
2419
-				if ($globalDebug) echo "Add to DB...";
2894
+				if ($globalDebug) {
2895
+					echo "Add to DB...";
2896
+				}
2420 2897
 				$error = update_db::translation_fam();
2421
-			} else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2422
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2898
+			} else {
2899
+				$error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2900
+			}
2901
+		} else {
2902
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2903
+		}
2423 2904
 		if ($error != '') {
2424 2905
 			return $error;
2425
-		} elseif ($globalDebug) echo "Done\n";
2906
+		} elseif ($globalDebug) {
2907
+			echo "Done\n";
2908
+		}
2426 2909
 		return '';
2427 2910
 	}
2428 2911
 	public static function update_ModeS_fam() {
2429 2912
 		global $tmp_dir, $globalDebug;
2430 2913
 		$error = '';
2431
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2914
+		if ($globalDebug) {
2915
+			echo "ModeS from FlightAirMap website : Download...";
2916
+		}
2432 2917
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2433 2918
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2434 2919
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2435 2920
 			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2436 2921
 			$modes_md5 = $modes_md5_file[0];
2437 2922
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2438
-				if ($globalDebug) echo "Gunzip...";
2923
+				if ($globalDebug) {
2924
+					echo "Gunzip...";
2925
+				}
2439 2926
 				update_db::gunzip($tmp_dir.'modes.tsv.gz');
2440
-				if ($globalDebug) echo "Add to DB...";
2927
+				if ($globalDebug) {
2928
+					echo "Add to DB...";
2929
+				}
2441 2930
 				$error = update_db::modes_fam();
2442
-			} else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2443
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2931
+			} else {
2932
+				$error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2933
+			}
2934
+		} else {
2935
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2936
+		}
2444 2937
 		if ($error != '') {
2445 2938
 			return $error;
2446
-		} elseif ($globalDebug) echo "Done\n";
2939
+		} elseif ($globalDebug) {
2940
+			echo "Done\n";
2941
+		}
2447 2942
 		return '';
2448 2943
 	}
2449 2944
 
2450 2945
 	public static function update_airlines_fam() {
2451 2946
 		global $tmp_dir, $globalDebug;
2452 2947
 		$error = '';
2453
-		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2948
+		if ($globalDebug) {
2949
+			echo "Airlines from FlightAirMap website : Download...";
2950
+		}
2454 2951
 		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2455 2952
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2456 2953
 			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
@@ -2459,26 +2956,42 @@  discard block
 block discarded – undo
2459 2956
 				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2460 2957
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2461 2958
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2462
-						if ($globalDebug) echo "Gunzip...";
2959
+						if ($globalDebug) {
2960
+							echo "Gunzip...";
2961
+						}
2463 2962
 						update_db::gunzip($tmp_dir.'airlines.tsv.gz');
2464
-						if ($globalDebug) echo "Add to DB...";
2963
+						if ($globalDebug) {
2964
+							echo "Add to DB...";
2965
+						}
2465 2966
 						$error = update_db::airlines_fam();
2466 2967
 						update_db::insert_airlines_version($airlines_md5);
2467
-					} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2468
-			    } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2469
-			} elseif ($globalDebug) echo "No update.";
2470
-		} else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
2968
+					} else {
2969
+						$error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2970
+					}
2971
+			    } else {
2972
+			    	$error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2973
+			    }
2974
+			} elseif ($globalDebug) {
2975
+				echo "No update.";
2976
+			}
2977
+		} else {
2978
+			$error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
2979
+		}
2471 2980
 		if ($error != '') {
2472 2981
 			return $error;
2473 2982
 		} else {
2474
-			if ($globalDebug) echo "Done\n";
2983
+			if ($globalDebug) {
2984
+				echo "Done\n";
2985
+			}
2475 2986
 		}
2476 2987
 		return '';
2477 2988
 	}
2478 2989
 
2479 2990
 	public static function update_owner_fam() {
2480 2991
 		global $tmp_dir, $globalDebug, $globalOwner;
2481
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2992
+		if ($globalDebug) {
2993
+			echo "owner from FlightAirMap website : Download...";
2994
+		}
2482 2995
 		$error = '';
2483 2996
 		if ($globalOwner === TRUE) {
2484 2997
 			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
@@ -2491,35 +3004,57 @@  discard block
 block discarded – undo
2491 3004
 			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2492 3005
 			$owners_md5 = $owners_md5_file[0];
2493 3006
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2494
-				if ($globalDebug) echo "Gunzip...";
3007
+				if ($globalDebug) {
3008
+					echo "Gunzip...";
3009
+				}
2495 3010
 				update_db::gunzip($tmp_dir.'owners.tsv.gz');
2496
-				if ($globalDebug) echo "Add to DB...";
3011
+				if ($globalDebug) {
3012
+					echo "Add to DB...";
3013
+				}
2497 3014
 				$error = update_db::owner_fam();
2498
-			} else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
2499
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3015
+			} else {
3016
+				$error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
3017
+			}
3018
+		} else {
3019
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3020
+		}
2500 3021
 		if ($error != '') {
2501 3022
 			return $error;
2502
-		} elseif ($globalDebug) echo "Done\n";
3023
+		} elseif ($globalDebug) {
3024
+			echo "Done\n";
3025
+		}
2503 3026
 		return '';
2504 3027
 	}
2505 3028
 	public static function update_routes_fam() {
2506 3029
 		global $tmp_dir, $globalDebug;
2507
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
3030
+		if ($globalDebug) {
3031
+			echo "Routes from FlightAirMap website : Download...";
3032
+		}
2508 3033
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2509 3034
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2510 3035
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2511 3036
 			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2512 3037
 			$routes_md5 = $routes_md5_file[0];
2513 3038
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2514
-				if ($globalDebug) echo "Gunzip...";
3039
+				if ($globalDebug) {
3040
+					echo "Gunzip...";
3041
+				}
2515 3042
 				update_db::gunzip($tmp_dir.'routes.tsv.gz');
2516
-				if ($globalDebug) echo "Add to DB...";
3043
+				if ($globalDebug) {
3044
+					echo "Add to DB...";
3045
+				}
2517 3046
 				$error = update_db::routes_fam();
2518
-			} else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
2519
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3047
+			} else {
3048
+				$error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
3049
+			}
3050
+		} else {
3051
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3052
+		}
2520 3053
 		if ($error != '') {
2521 3054
 			return $error;
2522
-		} elseif ($globalDebug) echo "Done\n";
3055
+		} elseif ($globalDebug) {
3056
+			echo "Done\n";
3057
+		}
2523 3058
 		return '';
2524 3059
 	}
2525 3060
 	public static function update_marine_identity_fam() {
@@ -2529,21 +3064,33 @@  discard block
 block discarded – undo
2529 3064
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2530 3065
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2531 3066
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2532
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
3067
+				if ($globalDebug) {
3068
+					echo "Marine identity from FlightAirMap website : Download...";
3069
+				}
2533 3070
 				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2534 3071
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2535 3072
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2536
-						if ($globalDebug) echo "Gunzip...";
3073
+						if ($globalDebug) {
3074
+							echo "Gunzip...";
3075
+						}
2537 3076
 						update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2538
-						if ($globalDebug) echo "Add to DB...";
3077
+						if ($globalDebug) {
3078
+							echo "Add to DB...";
3079
+						}
2539 3080
 						$error = update_db::marine_identity_fam();
2540
-					} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
2541
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3081
+					} else {
3082
+						$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
3083
+					}
3084
+				} else {
3085
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3086
+				}
2542 3087
 				if ($error != '') {
2543 3088
 					return $error;
2544 3089
 				} else {
2545 3090
 					update_db::insert_marine_identity_version($marine_identity_md5);
2546
-					if ($globalDebug) echo "Done\n";
3091
+					if ($globalDebug) {
3092
+						echo "Done\n";
3093
+					}
2547 3094
 				}
2548 3095
 			}
2549 3096
 		}
@@ -2557,21 +3104,33 @@  discard block
 block discarded – undo
2557 3104
 			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2558 3105
 			$satellite_md5 = $satellite_md5_file[0];
2559 3106
 			if (!update_db::check_satellite_version($satellite_md5)) {
2560
-				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
3107
+				if ($globalDebug) {
3108
+					echo "Satellite from FlightAirMap website : Download...";
3109
+				}
2561 3110
 				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2562 3111
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2563 3112
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2564
-						if ($globalDebug) echo "Gunzip...";
3113
+						if ($globalDebug) {
3114
+							echo "Gunzip...";
3115
+						}
2565 3116
 						update_db::gunzip($tmp_dir.'satellite.tsv.gz');
2566
-						if ($globalDebug) echo "Add to DB...";
3117
+						if ($globalDebug) {
3118
+							echo "Add to DB...";
3119
+						}
2567 3120
 						$error = update_db::satellite_fam();
2568
-					} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
2569
-				} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3121
+					} else {
3122
+						$error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
3123
+					}
3124
+				} else {
3125
+					$error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3126
+				}
2570 3127
 				if ($error != '') {
2571 3128
 					return $error;
2572 3129
 				} else {
2573 3130
 					update_db::insert_satellite_version($satellite_md5);
2574
-					if ($globalDebug) echo "Done\n";
3131
+					if ($globalDebug) {
3132
+						echo "Done\n";
3133
+					}
2575 3134
 				}
2576 3135
 			}
2577 3136
 		}
@@ -2579,17 +3138,25 @@  discard block
 block discarded – undo
2579 3138
 	}
2580 3139
 	public static function update_banned_fam() {
2581 3140
 		global $tmp_dir, $globalDebug;
2582
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
3141
+		if ($globalDebug) {
3142
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
3143
+		}
2583 3144
 		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2584 3145
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2585 3146
 			//if ($globalDebug) echo "Gunzip...";
2586 3147
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2587
-			if ($globalDebug) echo "Add to DB...";
3148
+			if ($globalDebug) {
3149
+				echo "Add to DB...";
3150
+			}
2588 3151
 			$error = update_db::banned_fam();
2589
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3152
+		} else {
3153
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3154
+		}
2590 3155
 		if ($error != '') {
2591 3156
 			return $error;
2592
-		} elseif ($globalDebug) echo "Done\n";
3157
+		} elseif ($globalDebug) {
3158
+			echo "Done\n";
3159
+		}
2593 3160
 		return '';
2594 3161
 	}
2595 3162
 
@@ -2597,7 +3164,9 @@  discard block
 block discarded – undo
2597 3164
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2598 3165
 		include_once('class.create_db.php');
2599 3166
 		$error = '';
2600
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
3167
+		if ($globalDebug) {
3168
+			echo "Airspace from FlightAirMap website : Download...";
3169
+		}
2601 3170
 		if ($globalDBdriver == 'mysql') {
2602 3171
 			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2603 3172
 		} else {
@@ -2614,9 +3183,13 @@  discard block
 block discarded – undo
2614 3183
 				}
2615 3184
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2616 3185
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
2617
-						if ($globalDebug) echo "Gunzip...";
3186
+						if ($globalDebug) {
3187
+							echo "Gunzip...";
3188
+						}
2618 3189
 						update_db::gunzip($tmp_dir.'airspace.sql.gz');
2619
-						if ($globalDebug) echo "Add to DB...";
3190
+						if ($globalDebug) {
3191
+							echo "Add to DB...";
3192
+						}
2620 3193
 						$Connection = new Connection();
2621 3194
 						if ($Connection->tableExists('airspace')) {
2622 3195
 							$query = 'DROP TABLE airspace';
@@ -2629,20 +3202,30 @@  discard block
 block discarded – undo
2629 3202
 						}
2630 3203
 						$error = create_db::import_file($tmp_dir.'airspace.sql');
2631 3204
 						update_db::insert_airspace_version($airspace_md5);
2632
-					} else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
2633
-				} else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3205
+					} else {
3206
+						$error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
3207
+					}
3208
+				} else {
3209
+					$error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3210
+				}
2634 3211
 			}
2635
-		} else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3212
+		} else {
3213
+			$error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3214
+		}
2636 3215
 		if ($error != '') {
2637 3216
 			return $error;
2638
-		} elseif ($globalDebug) echo "Done\n";
3217
+		} elseif ($globalDebug) {
3218
+			echo "Done\n";
3219
+		}
2639 3220
 		return '';
2640 3221
 	}
2641 3222
 
2642 3223
 	public static function update_geoid_fam() {
2643 3224
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2644 3225
 		$error = '';
2645
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
3226
+		if ($globalDebug) {
3227
+			echo "Geoid from FlightAirMap website : Download...";
3228
+		}
2646 3229
 		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2647 3230
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2648 3231
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2651,76 +3234,120 @@  discard block
 block discarded – undo
2651 3234
 				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2652 3235
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2653 3236
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2654
-						if ($globalDebug) echo "Gunzip...";
3237
+						if ($globalDebug) {
3238
+							echo "Gunzip...";
3239
+						}
2655 3240
 						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2656 3241
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2657 3242
 							update_db::insert_geoid_version($geoid_md5);
2658
-						} else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
2659
-					} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
2660
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
2661
-			} elseif ($globalDebug) echo 'No new version'."\n";
2662
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3243
+						} else {
3244
+							$error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
3245
+						}
3246
+					} else {
3247
+						$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
3248
+					}
3249
+				} else {
3250
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3251
+				}
3252
+			} elseif ($globalDebug) {
3253
+				echo 'No new version'."\n";
3254
+			}
3255
+		} else {
3256
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3257
+		}
2663 3258
 		if ($error != '') {
2664 3259
 			return $error;
2665
-		} elseif ($globalDebug) echo "Done\n";
3260
+		} elseif ($globalDebug) {
3261
+			echo "Done\n";
3262
+		}
2666 3263
 		return '';
2667 3264
 	}
2668 3265
 
2669 3266
 	public static function update_tle() {
2670 3267
 		global $tmp_dir, $globalDebug;
2671
-		if ($globalDebug) echo "Download TLE : Download...";
3268
+		if ($globalDebug) {
3269
+			echo "Download TLE : Download...";
3270
+		}
2672 3271
 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2673 3272
 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2674 3273
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt');
2675 3274
 		foreach ($alltle as $filename) {
2676
-			if ($globalDebug) echo "downloading ".$filename.'...';
3275
+			if ($globalDebug) {
3276
+				echo "downloading ".$filename.'...';
3277
+			}
2677 3278
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2678 3279
 			if (file_exists($tmp_dir.$filename)) {
2679
-				if ($globalDebug) echo "Add to DB ".$filename."...";
3280
+				if ($globalDebug) {
3281
+					echo "Add to DB ".$filename."...";
3282
+				}
2680 3283
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2681
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3284
+			} else {
3285
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3286
+			}
2682 3287
 			if ($error != '') {
2683 3288
 				echo $error."\n";
2684
-			} elseif ($globalDebug) echo "Done\n";
3289
+			} elseif ($globalDebug) {
3290
+				echo "Done\n";
3291
+			}
2685 3292
 		}
2686 3293
 		return '';
2687 3294
 	}
2688 3295
 
2689 3296
 	public static function update_ucsdb() {
2690 3297
 		global $tmp_dir, $globalDebug;
2691
-		if ($globalDebug) echo "Download UCS DB : Download...";
3298
+		if ($globalDebug) {
3299
+			echo "Download UCS DB : Download...";
3300
+		}
2692 3301
 		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2693 3302
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2694
-			if ($globalDebug) echo "Add to DB...";
3303
+			if ($globalDebug) {
3304
+				echo "Add to DB...";
3305
+			}
2695 3306
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2696
-		} else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3307
+		} else {
3308
+			$error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3309
+		}
2697 3310
 		if ($error != '') {
2698 3311
 			echo $error."\n";
2699
-		} elseif ($globalDebug) echo "Done\n";
3312
+		} elseif ($globalDebug) {
3313
+			echo "Done\n";
3314
+		}
2700 3315
 		return '';
2701 3316
 	}
2702 3317
 
2703 3318
 	public static function update_celestrak() {
2704 3319
 		global $tmp_dir, $globalDebug;
2705
-		if ($globalDebug) echo "Download Celestrak DB : Download...";
3320
+		if ($globalDebug) {
3321
+			echo "Download Celestrak DB : Download...";
3322
+		}
2706 3323
 		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2707 3324
 		if (file_exists($tmp_dir.'satcat.txt')) {
2708
-			if ($globalDebug) echo "Add to DB...";
3325
+			if ($globalDebug) {
3326
+				echo "Add to DB...";
3327
+			}
2709 3328
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
2710
-		} else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3329
+		} else {
3330
+			$error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3331
+		}
2711 3332
 		if ($error != '') {
2712 3333
 			echo $error."\n";
2713
-		} elseif ($globalDebug) echo "Done\n";
3334
+		} elseif ($globalDebug) {
3335
+			echo "Done\n";
3336
+		}
2714 3337
 		return '';
2715 3338
 	}
2716 3339
 
2717 3340
 	public static function update_models() {
2718 3341
 		global $tmp_dir, $globalDebug;
2719 3342
 		$error = '';
2720
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3343
+		if ($globalDebug) {
3344
+			echo "Models from FlightAirMap website : Download...";
3345
+		}
2721 3346
 		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2722 3347
 		if (file_exists($tmp_dir.'models.md5sum')) {
2723
-			if ($globalDebug) echo "Check files...\n";
3348
+			if ($globalDebug) {
3349
+				echo "Check files...\n";
3350
+			}
2724 3351
 			$newmodelsdb = array();
2725 3352
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2726 3353
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2739,19 +3366,29 @@  discard block
 block discarded – undo
2739 3366
 			}
2740 3367
 			$diff = array_diff($newmodelsdb,$modelsdb);
2741 3368
 			foreach ($diff as $key => $value) {
2742
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3369
+				if ($globalDebug) {
3370
+					echo 'Downloading model '.$key.' ...'."\n";
3371
+				}
2743 3372
 				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2744 3373
 				
2745 3374
 			}
2746 3375
 			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2747
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3376
+		} else {
3377
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3378
+		}
2748 3379
 		if ($error != '') {
2749 3380
 			return $error;
2750
-		} elseif ($globalDebug) echo "Done\n";
2751
-		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
3381
+		} elseif ($globalDebug) {
3382
+			echo "Done\n";
3383
+		}
3384
+		if ($globalDebug) {
3385
+			echo "glTF 2.0 Models from FlightAirMap website : Download...";
3386
+		}
2752 3387
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2753 3388
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2754
-			if ($globalDebug) echo "Check files...\n";
3389
+			if ($globalDebug) {
3390
+				echo "Check files...\n";
3391
+			}
2755 3392
 			$newmodelsdb = array();
2756 3393
 			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2757 3394
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2770,25 +3407,35 @@  discard block
 block discarded – undo
2770 3407
 			}
2771 3408
 			$diff = array_diff($newmodelsdb,$modelsdb);
2772 3409
 			foreach ($diff as $key => $value) {
2773
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3410
+				if ($globalDebug) {
3411
+					echo 'Downloading model '.$key.' ...'."\n";
3412
+				}
2774 3413
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2775 3414
 				
2776 3415
 			}
2777 3416
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2778
-		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3417
+		} else {
3418
+			$error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3419
+		}
2779 3420
 		if ($error != '') {
2780 3421
 			return $error;
2781
-		} elseif ($globalDebug) echo "Done\n";
3422
+		} elseif ($globalDebug) {
3423
+			echo "Done\n";
3424
+		}
2782 3425
 		return '';
2783 3426
 	}
2784 3427
 
2785 3428
 	public static function update_liveries() {
2786 3429
 		global $tmp_dir, $globalDebug;
2787 3430
 		$error = '';
2788
-		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
3431
+		if ($globalDebug) {
3432
+			echo "Liveries from FlightAirMap website : Download...";
3433
+		}
2789 3434
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2790 3435
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2791
-			if ($globalDebug) echo "Check files...\n";
3436
+			if ($globalDebug) {
3437
+				echo "Check files...\n";
3438
+			}
2792 3439
 			$newmodelsdb = array();
2793 3440
 			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2794 3441
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2807,25 +3454,35 @@  discard block
 block discarded – undo
2807 3454
 			}
2808 3455
 			$diff = array_diff($newmodelsdb,$modelsdb);
2809 3456
 			foreach ($diff as $key => $value) {
2810
-				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
3457
+				if ($globalDebug) {
3458
+					echo 'Downloading liveries '.$key.' ...'."\n";
3459
+				}
2811 3460
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2812 3461
 				
2813 3462
 			}
2814 3463
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2815
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3464
+		} else {
3465
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3466
+		}
2816 3467
 		if ($error != '') {
2817 3468
 			return $error;
2818
-		} elseif ($globalDebug) echo "Done\n";
3469
+		} elseif ($globalDebug) {
3470
+			echo "Done\n";
3471
+		}
2819 3472
 		return '';
2820 3473
 	}
2821 3474
 
2822 3475
 	public static function update_space_models() {
2823 3476
 		global $tmp_dir, $globalDebug;
2824 3477
 		$error = '';
2825
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3478
+		if ($globalDebug) {
3479
+			echo "Space models from FlightAirMap website : Download...";
3480
+		}
2826 3481
 		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2827 3482
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2828
-			if ($globalDebug) echo "Check files...\n";
3483
+			if ($globalDebug) {
3484
+				echo "Check files...\n";
3485
+			}
2829 3486
 			$newmodelsdb = array();
2830 3487
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2831 3488
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2844,25 +3501,35 @@  discard block
 block discarded – undo
2844 3501
 			}
2845 3502
 			$diff = array_diff($newmodelsdb,$modelsdb);
2846 3503
 			foreach ($diff as $key => $value) {
2847
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3504
+				if ($globalDebug) {
3505
+					echo 'Downloading space model '.$key.' ...'."\n";
3506
+				}
2848 3507
 				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2849 3508
 				
2850 3509
 			}
2851 3510
 			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2852
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3511
+		} else {
3512
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3513
+		}
2853 3514
 		if ($error != '') {
2854 3515
 			return $error;
2855
-		} elseif ($globalDebug) echo "Done\n";
3516
+		} elseif ($globalDebug) {
3517
+			echo "Done\n";
3518
+		}
2856 3519
 		return '';
2857 3520
 	}
2858 3521
 
2859 3522
 	public static function update_vehicules_models() {
2860 3523
 		global $tmp_dir, $globalDebug;
2861 3524
 		$error = '';
2862
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3525
+		if ($globalDebug) {
3526
+			echo "Vehicules models from FlightAirMap website : Download...";
3527
+		}
2863 3528
 		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2864 3529
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2865
-			if ($globalDebug) echo "Check files...\n";
3530
+			if ($globalDebug) {
3531
+				echo "Check files...\n";
3532
+			}
2866 3533
 			$newmodelsdb = array();
2867 3534
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2868 3535
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2881,15 +3548,21 @@  discard block
 block discarded – undo
2881 3548
 			}
2882 3549
 			$diff = array_diff($newmodelsdb,$modelsdb);
2883 3550
 			foreach ($diff as $key => $value) {
2884
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3551
+				if ($globalDebug) {
3552
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
3553
+				}
2885 3554
 				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2886 3555
 				
2887 3556
 			}
2888 3557
 			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2889
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3558
+		} else {
3559
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3560
+		}
2890 3561
 		if ($error != '') {
2891 3562
 			return $error;
2892
-		} elseif ($globalDebug) echo "Done\n";
3563
+		} elseif ($globalDebug) {
3564
+			echo "Done\n";
3565
+		}
2893 3566
 		return '';
2894 3567
 	}
2895 3568
 
@@ -2962,7 +3635,9 @@  discard block
 block discarded – undo
2962 3635
                 }
2963 3636
 
2964 3637
 		$error = '';
2965
-		if ($globalDebug) echo "Notam : Download...";
3638
+		if ($globalDebug) {
3639
+			echo "Notam : Download...";
3640
+		}
2966 3641
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2967 3642
 		if (file_exists($tmp_dir.'notam.rss')) {
2968 3643
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2977,14 +3652,30 @@  discard block
 block discarded – undo
2977 3652
 				$data['fir'] = $q[0];
2978 3653
 				$data['code'] = $q[1];
2979 3654
 				$ifrvfr = $q[2];
2980
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2981
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2982
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2983
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2984
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2985
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2986
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2987
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
3655
+				if ($ifrvfr == 'IV') {
3656
+					$data['rules'] = 'IFR/VFR';
3657
+				}
3658
+				if ($ifrvfr == 'I') {
3659
+					$data['rules'] = 'IFR';
3660
+				}
3661
+				if ($ifrvfr == 'V') {
3662
+					$data['rules'] = 'VFR';
3663
+				}
3664
+				if ($q[4] == 'A') {
3665
+					$data['scope'] = 'Airport warning';
3666
+				}
3667
+				if ($q[4] == 'E') {
3668
+					$data['scope'] = 'Enroute warning';
3669
+				}
3670
+				if ($q[4] == 'W') {
3671
+					$data['scope'] = 'Navigation warning';
3672
+				}
3673
+				if ($q[4] == 'AE') {
3674
+					$data['scope'] = 'Airport/Enroute warning';
3675
+				}
3676
+				if ($q[4] == 'AW') {
3677
+					$data['scope'] = 'Airport/Navigation warning';
3678
+				}
2988 3679
 				//$data['scope'] = $q[4];
2989 3680
 				$data['lower_limit'] = $q[5];
2990 3681
 				$data['upper_limit'] = $q[6];
@@ -2992,8 +3683,12 @@  discard block
 block discarded – undo
2992 3683
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2993 3684
 				$latitude = $Common->convertDec($las,'latitude');
2994 3685
 				$longitude = $Common->convertDec($lns,'longitude');
2995
-				if ($lac == 'S') $latitude = '-'.$latitude;
2996
-				if ($lnc == 'W') $longitude = '-'.$longitude;
3686
+				if ($lac == 'S') {
3687
+					$latitude = '-'.$latitude;
3688
+				}
3689
+				if ($lnc == 'W') {
3690
+					$longitude = '-'.$longitude;
3691
+				}
2997 3692
 				$data['center_latitude'] = $latitude;
2998 3693
 				$data['center_longitude'] = $longitude;
2999 3694
 				$data['radius'] = intval($radius);
@@ -3023,10 +3718,14 @@  discard block
 block discarded – undo
3023 3718
 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
3024 3719
 				unset($data);
3025 3720
 			} 
3026
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3721
+		} else {
3722
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3723
+		}
3027 3724
 		if ($error != '') {
3028 3725
 			return $error;
3029
-		} elseif ($globalDebug) echo "Done\n";
3726
+		} elseif ($globalDebug) {
3727
+			echo "Done\n";
3728
+		}
3030 3729
 		return '';
3031 3730
 	}
3032 3731
 	
@@ -3051,7 +3750,9 @@  discard block
 block discarded – undo
3051 3750
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3052 3751
 		$airspace_json = json_decode($airspace_lst,true);
3053 3752
 		foreach ($airspace_json['records'] as $airspace) {
3054
-			if ($globalDebug) echo $airspace['name']."...\n";
3753
+			if ($globalDebug) {
3754
+				echo $airspace['name']."...\n";
3755
+			}
3055 3756
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3056 3757
 			if (file_exists($tmp_dir.$airspace['name'])) {
3057 3758
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -3095,8 +3796,11 @@  discard block
 block discarded – undo
3095 3796
                         return "error : ".$e->getMessage();
3096 3797
                 }
3097 3798
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3098
-                if ($row['nb'] > 0) return false;
3099
-                else return true;
3799
+                if ($row['nb'] > 0) {
3800
+                	return false;
3801
+                } else {
3802
+                	return true;
3803
+                }
3100 3804
 	}
3101 3805
 
3102 3806
 	public static function insert_last_update() {
@@ -3121,8 +3825,11 @@  discard block
 block discarded – undo
3121 3825
                         return "error : ".$e->getMessage();
3122 3826
                 }
3123 3827
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3124
-                if ($row['nb'] > 0) return true;
3125
-                else return false;
3828
+                if ($row['nb'] > 0) {
3829
+                	return true;
3830
+                } else {
3831
+                	return false;
3832
+                }
3126 3833
 	}
3127 3834
 
3128 3835
 	public static function check_geoid_version($version) {
@@ -3135,8 +3842,11 @@  discard block
 block discarded – undo
3135 3842
                         return "error : ".$e->getMessage();
3136 3843
                 }
3137 3844
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3138
-                if ($row['nb'] > 0) return true;
3139
-                else return false;
3845
+                if ($row['nb'] > 0) {
3846
+                	return true;
3847
+                } else {
3848
+                	return false;
3849
+                }
3140 3850
 	}
3141 3851
 
3142 3852
 	public static function check_marine_identity_version($version) {
@@ -3149,8 +3859,11 @@  discard block
 block discarded – undo
3149 3859
 			return "error : ".$e->getMessage();
3150 3860
 		}
3151 3861
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3152
-		if ($row['nb'] > 0) return true;
3153
-		else return false;
3862
+		if ($row['nb'] > 0) {
3863
+			return true;
3864
+		} else {
3865
+			return false;
3866
+		}
3154 3867
 	}
3155 3868
 
3156 3869
 	public static function check_satellite_version($version) {
@@ -3163,8 +3876,11 @@  discard block
 block discarded – undo
3163 3876
 			return "error : ".$e->getMessage();
3164 3877
 		}
3165 3878
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3166
-		if ($row['nb'] > 0) return true;
3167
-		else return false;
3879
+		if ($row['nb'] > 0) {
3880
+			return true;
3881
+		} else {
3882
+			return false;
3883
+		}
3168 3884
 	}
3169 3885
 
3170 3886
 	public static function check_airlines_version($version) {
@@ -3177,8 +3893,11 @@  discard block
 block discarded – undo
3177 3893
 			return "error : ".$e->getMessage();
3178 3894
 		}
3179 3895
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3180
-		if ($row['nb'] > 0) return true;
3181
-		else return false;
3896
+		if ($row['nb'] > 0) {
3897
+			return true;
3898
+		} else {
3899
+			return false;
3900
+		}
3182 3901
 	}
3183 3902
 
3184 3903
 	public static function check_notam_version($version) {
@@ -3191,8 +3910,11 @@  discard block
 block discarded – undo
3191 3910
 			return "error : ".$e->getMessage();
3192 3911
 		}
3193 3912
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3194
-		if ($row['nb'] > 0) return true;
3195
-		else return false;
3913
+		if ($row['nb'] > 0) {
3914
+			return true;
3915
+		} else {
3916
+			return false;
3917
+		}
3196 3918
 	}
3197 3919
 
3198 3920
 	public static function insert_airlines_version($version) {
@@ -3282,8 +4004,11 @@  discard block
 block discarded – undo
3282 4004
                         return "error : ".$e->getMessage();
3283 4005
                 }
3284 4006
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3285
-                if ($row['nb'] > 0) return false;
3286
-                else return true;
4007
+                if ($row['nb'] > 0) {
4008
+                	return false;
4009
+                } else {
4010
+                	return true;
4011
+                }
3287 4012
 	}
3288 4013
 
3289 4014
 	public static function insert_last_notam_update() {
@@ -3313,8 +4038,11 @@  discard block
 block discarded – undo
3313 4038
                         return "error : ".$e->getMessage();
3314 4039
                 }
3315 4040
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3316
-                if ($row['nb'] > 0) return false;
3317
-                else return true;
4041
+                if ($row['nb'] > 0) {
4042
+                	return false;
4043
+                } else {
4044
+                	return true;
4045
+                }
3318 4046
 	}
3319 4047
 
3320 4048
 	public static function insert_last_airspace_update() {
@@ -3344,8 +4072,11 @@  discard block
 block discarded – undo
3344 4072
                         return "error : ".$e->getMessage();
3345 4073
                 }
3346 4074
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3347
-                if ($row['nb'] > 0) return false;
3348
-                else return true;
4075
+                if ($row['nb'] > 0) {
4076
+                	return false;
4077
+                } else {
4078
+                	return true;
4079
+                }
3349 4080
 	}
3350 4081
 
3351 4082
 	public static function insert_last_geoid_update() {
@@ -3375,8 +4106,11 @@  discard block
 block discarded – undo
3375 4106
 			return "error : ".$e->getMessage();
3376 4107
 		}
3377 4108
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3378
-		if ($row['nb'] > 0) return false;
3379
-		else return true;
4109
+		if ($row['nb'] > 0) {
4110
+			return false;
4111
+		} else {
4112
+			return true;
4113
+		}
3380 4114
 	}
3381 4115
 
3382 4116
 	public static function insert_last_owner_update() {
@@ -3406,8 +4140,11 @@  discard block
 block discarded – undo
3406 4140
 			return "error : ".$e->getMessage();
3407 4141
 		}
3408 4142
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3409
-		if ($row['nb'] > 0) return false;
3410
-		else return true;
4143
+		if ($row['nb'] > 0) {
4144
+			return false;
4145
+		} else {
4146
+			return true;
4147
+		}
3411 4148
 	}
3412 4149
 
3413 4150
 	public static function insert_last_fires_update() {
@@ -3437,8 +4174,11 @@  discard block
 block discarded – undo
3437 4174
 			return "error : ".$e->getMessage();
3438 4175
 		}
3439 4176
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3440
-		if ($row['nb'] > 0) return false;
3441
-		else return true;
4177
+		if ($row['nb'] > 0) {
4178
+			return false;
4179
+		} else {
4180
+			return true;
4181
+		}
3442 4182
 	}
3443 4183
 
3444 4184
 	public static function insert_last_airlines_update() {
@@ -3468,8 +4208,11 @@  discard block
 block discarded – undo
3468 4208
                         return "error : ".$e->getMessage();
3469 4209
                 }
3470 4210
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3471
-                if ($row['nb'] > 0) return false;
3472
-                else return true;
4211
+                if ($row['nb'] > 0) {
4212
+                	return false;
4213
+                } else {
4214
+                	return true;
4215
+                }
3473 4216
 	}
3474 4217
 
3475 4218
 	public static function insert_last_schedules_update() {
@@ -3499,8 +4242,11 @@  discard block
 block discarded – undo
3499 4242
 			return "error : ".$e->getMessage();
3500 4243
 		}
3501 4244
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3502
-		if ($row['nb'] > 0) return false;
3503
-		else return true;
4245
+		if ($row['nb'] > 0) {
4246
+			return false;
4247
+		} else {
4248
+			return true;
4249
+		}
3504 4250
 	}
3505 4251
 
3506 4252
 	public static function insert_last_tle_update() {
@@ -3530,8 +4276,11 @@  discard block
 block discarded – undo
3530 4276
 			return "error : ".$e->getMessage();
3531 4277
 		}
3532 4278
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3533
-		if ($row['nb'] > 0) return false;
3534
-		else return true;
4279
+		if ($row['nb'] > 0) {
4280
+			return false;
4281
+		} else {
4282
+			return true;
4283
+		}
3535 4284
 	}
3536 4285
 
3537 4286
 	public static function insert_last_ucsdb_update() {
@@ -3561,8 +4310,11 @@  discard block
 block discarded – undo
3561 4310
 			return "error : ".$e->getMessage();
3562 4311
 		}
3563 4312
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3564
-		if ($row['nb'] > 0) return false;
3565
-		else return true;
4313
+		if ($row['nb'] > 0) {
4314
+			return false;
4315
+		} else {
4316
+			return true;
4317
+		}
3566 4318
 	}
3567 4319
 
3568 4320
 	public static function insert_last_celestrak_update() {
@@ -3592,8 +4344,11 @@  discard block
 block discarded – undo
3592 4344
 			return "error : ".$e->getMessage();
3593 4345
 		}
3594 4346
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3595
-		if ($row['nb'] > 0) return false;
3596
-		else return true;
4347
+		if ($row['nb'] > 0) {
4348
+			return false;
4349
+		} else {
4350
+			return true;
4351
+		}
3597 4352
 	}
3598 4353
 
3599 4354
 	public static function check_last_satellite_update() {
@@ -3611,8 +4366,11 @@  discard block
 block discarded – undo
3611 4366
 			return "error : ".$e->getMessage();
3612 4367
 		}
3613 4368
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3614
-		if ($row['nb'] > 0) return false;
3615
-		else return true;
4369
+		if ($row['nb'] > 0) {
4370
+			return false;
4371
+		} else {
4372
+			return true;
4373
+		}
3616 4374
 	}
3617 4375
 
3618 4376
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.
tools-geoid.php 1 patch
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,7 +11,9 @@  discard block
 block discarded – undo
11 11
 	print '<h1>'._("Geoid Height Calculator").'</h1>';
12 12
 	print '</div>';
13 13
 	print '<p>Not available</p>';
14
-	if (isset($globalDebug) && $globalDebug) echo '<p>'.$e.'</p>';
14
+	if (isset($globalDebug) && $globalDebug) {
15
+		echo '<p>'.$e.'</p>';
16
+	}
15 17
 	require_once('footer.php');
16 18
 }
17 19
 $title = _("Geoid Height Calculator");
@@ -68,8 +70,11 @@  discard block
 block discarded – undo
68 70
 		print '<div class="col-sm-6">'.round($altitude-$geoid,3).'</div>';
69 71
 	}
70 72
 	print '<div class="col-sm-6"><b>Earth Gravity Model</b></div>';
71
-	if (isset($globalGeoidSource) && $globalGeoidSource != '') $geoidsource = $globalGeoidSource;
72
-	else $geoidsource = 'EGM96-15';
73
+	if (isset($globalGeoidSource) && $globalGeoidSource != '') {
74
+		$geoidsource = $globalGeoidSource;
75
+	} else {
76
+		$geoidsource = 'EGM96-15';
77
+	}
73 78
 	print '<div class="col-sm-6">'.$geoidsource.'</div>';
74 79
 	print '</div>';
75 80
 }
Please login to merge, or discard this patch.