Completed
Push — master ( aa8319...e96b22 )
by Yannick
07:18
created
install/index.php 1 patch
Braces   +449 added lines, -120 removed lines patch added patch discarded remove patch
@@ -131,45 +131,72 @@  discard block
 block discarded – undo
131 131
 			</div>
132 132
 			<p>
133 133
 				<label for="dbhost">Database hostname</label>
134
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
134
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
135
+	print $globalDBhost;
136
+}
137
+?>" />
135 138
 			</p>
136 139
 			<p>
137 140
 				<label for="dbport">Database port</label>
138
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
141
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
142
+	print $globalDBport;
143
+}
144
+?>" />
139 145
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
140 146
 			</p>
141 147
 			<p>
142 148
 				<label for="dbname">Database name</label>
143
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
149
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
150
+	print $globalDBname;
151
+}
152
+?>" />
144 153
 			</p>
145 154
 			<p>
146 155
 				<label for="dbuser">Database user</label>
147
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
156
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
157
+	print $globalDBuser;
158
+}
159
+?>" />
148 160
 			</p>
149 161
 			<p>
150 162
 				<label for="dbuserpass">Database user password</label>
151
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
163
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
164
+	print $globalDBpass;
165
+}
166
+?>" />
152 167
 			</p>
153 168
 		</fieldset>
154 169
 		<fieldset id="site">
155 170
 			<legend>Site configuration</legend>
156 171
 			<p>
157 172
 				<label for="sitename">Site name</label>
158
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
173
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
174
+	print $globalName;
175
+}
176
+?>" />
159 177
 			</p>
160 178
 			<p>
161 179
 				<label for="siteurl">Site directory</label>
162
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
180
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
181
+	print $globalURL;
182
+}
183
+?>" />
163 184
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
164 185
 			</p>
165 186
 			<p>
166 187
 				<label for="timezone">Timezone</label>
167
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
188
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
189
+	print $globalTimezone;
190
+}
191
+?>" />
168 192
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
169 193
 			</p>
170 194
 			<p>
171 195
 				<label for="language">Language</label>
172
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
196
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
197
+	print $globalLanguage;
198
+}
199
+?>" />
173 200
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
174 201
 			</p>
175 202
 		</fieldset>
@@ -190,11 +217,17 @@  discard block
 block discarded – undo
190 217
 			<div id="mapbox_data">
191 218
 				<p>
192 219
 					<label for="mapboxid">Mapbox id</label>
193
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
220
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
221
+	print $globalMapboxId;
222
+}
223
+?>" />
194 224
 				</p>
195 225
 				<p>
196 226
 					<label for="mapboxtoken">Mapbox token</label>
197
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
227
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
228
+	print $globalMapboxToken;
229
+}
230
+?>" />
198 231
 				</p>
199 232
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
200 233
 			</div>
@@ -202,7 +235,10 @@  discard block
 block discarded – undo
202 235
 			<div id="google_data">
203 236
 				<p>
204 237
 					<label for="googlekey">Google API key</label>
205
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
238
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
239
+	print $globalGoogleAPIKey;
240
+}
241
+?>" />
206 242
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
207 243
 				</p>
208 244
 			</div>
@@ -210,7 +246,10 @@  discard block
 block discarded – undo
210 246
 			<div id="bing_data">
211 247
 				<p>
212 248
 					<label for="bingkey">Bing Map key</label>
213
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
249
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
250
+	print $globalBingMapKey;
251
+}
252
+?>" />
214 253
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
215 254
 				</p>
216 255
 			</div>
@@ -218,7 +257,10 @@  discard block
 block discarded – undo
218 257
 			<div id="mapquest_data">
219 258
 				<p>
220 259
 					<label for="mapquestkey">MapQuest key</label>
221
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
260
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
261
+	print $globalMapQuestKey;
262
+}
263
+?>" />
222 264
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
223 265
 				</p>
224 266
 			</div>
@@ -226,11 +268,17 @@  discard block
 block discarded – undo
226 268
 			<div id="here_data">
227 269
 				<p>
228 270
 					<label for="hereappid">Here App_Id</label>
229
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
271
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
272
+	print $globalHereappId;
273
+}
274
+?>" />
230 275
 				</p>
231 276
 				<p>
232 277
 					<label for="hereappcode">Here App_Code</label>
233
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
278
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
279
+	print $globalHereappCode;
280
+}
281
+?>" />
234 282
 				</p>
235 283
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
236 284
 			</div>
@@ -239,42 +287,86 @@  discard block
 block discarded – undo
239 287
 			<legend>Coverage area</legend>
240 288
 			<p>
241 289
 				<label for="latitudemax">The maximum latitude (north)</label>
242
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
290
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
291
+	print $globalLatitudeMax;
292
+}
293
+?>" />
243 294
 			</p>
244 295
 			<p>
245 296
 				<label for="latitudemin">The minimum latitude (south)</label>
246
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
297
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
298
+	print $globalLatitudeMin;
299
+}
300
+?>" />
247 301
 			</p>
248 302
 			<p>
249 303
 				<label for="longitudemax">The maximum longitude (west)</label>
250
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
304
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
305
+	print $globalLongitudeMax;
306
+}
307
+?>" />
251 308
 			</p>
252 309
 			<p>
253 310
 				<label for="longitudemin">The minimum longitude (east)</label>
254
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
311
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
312
+	print $globalLongitudeMin;
313
+}
314
+?>" />
255 315
 			</p>
256 316
 			<p>
257 317
 				<label for="latitudecenter">The latitude center</label>
258
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
318
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
319
+	print $globalCenterLatitude;
320
+}
321
+?>" />
259 322
 			</p>
260 323
 			<p>
261 324
 				<label for="longitudecenter">The longitude center</label>
262
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
325
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
326
+	print $globalCenterLongitude;
327
+}
328
+?>" />
263 329
 			</p>
264 330
 			<p>
265 331
 				<label for="livezoom">Default Zoom on live map</label>
266
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
332
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
333
+	print $globalLiveZoom;
334
+} else {
335
+	print '9';
336
+}
337
+?>" />
267 338
 			</p>
268 339
 			<p>
269 340
 				<label for="squawk_country">Country for squawk usage</label>
270 341
 				<select name="squawk_country" id="squawk_country">
271
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
272
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
273
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
274
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
275
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
276
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
277
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
342
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
343
+	print ' selected ';
344
+}
345
+?>>UK</option>
346
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
347
+	print ' selected ';
348
+}
349
+?>>NZ</option>
350
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
351
+	print ' selected ';
352
+}
353
+?>>US</option>
354
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
355
+	print ' selected ';
356
+}
357
+?>>AU</option>
358
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
359
+	print ' selected ';
360
+}
361
+?>>NL</option>
362
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
363
+	print ' selected ';
364
+}
365
+?>>FR</option>
366
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
367
+	print ' selected ';
368
+}
369
+?>>TR</option>
278 370
 				</select>
279 371
 			</p>
280 372
 		</fieldset>
@@ -283,15 +375,24 @@  discard block
 block discarded – undo
283 375
 			<p><i>Only put in DB flights that are inside a circle</i></p>
284 376
 			<p>
285 377
 				<label for="latitude">Center latitude</label>
286
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
378
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
379
+	echo $globalDistanceIgnore['latitude'];
380
+}
381
+?>" />
287 382
 			</p>
288 383
 			<p>
289 384
 				<label for="longitude">Center longitude</label>
290
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
385
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
386
+	echo $globalDistanceIgnore['longitude'];
387
+}
388
+?>" />
291 389
 			</p>
292 390
 			<p>
293 391
 				<label for="Distance">Distance (in km)</label>
294
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
392
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
393
+	echo $globalDistanceIgnore['distance'];
394
+}
395
+?>" />
295 396
 			</p>
296 397
 		</fieldset>
297 398
 		<fieldset id="sourceloc">
@@ -399,11 +500,17 @@  discard block
 block discarded – undo
399 500
 			<div id="flightaware_data">
400 501
 				<p>
401 502
 					<label for="flightawareusername">FlightAware username</label>
402
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
503
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
504
+	print $globalFlightAwareUsername;
505
+}
506
+?>" />
403 507
 				</p>
404 508
 				<p>
405 509
 					<label for="flightawarepassword">FlightAware password/API key</label>
406
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
510
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
511
+	print $globalFlightAwarePassword;
512
+}
513
+?>" />
407 514
 				</p>
408 515
 			</div>
409 516
 -->
@@ -463,28 +570,88 @@  discard block
 block discarded – undo
463 570
 								?>
464 571
 								<td>
465 572
 									<select name="format[]" id="format">
466
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
467
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
468
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
469
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
470
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
471
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
472
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
473
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
474
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
475
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
476
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
477
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
478
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
479
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
480
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
481
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
482
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
573
+										<option value="auto" <?php if (!isset($source['format'])) {
574
+	print 'selected';
575
+}
576
+?>>Auto</option>
577
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
578
+	print 'selected';
579
+}
580
+?>>SBS</option>
581
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
582
+	print 'selected';
583
+}
584
+?>>TSV</option>
585
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
586
+	print 'selected';
587
+}
588
+?>>Raw</option>
589
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
590
+	print 'selected';
591
+}
592
+?>>APRS</option>
593
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
594
+	print 'selected';
595
+}
596
+?>>Radarcape deltadb.txt</option>
597
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
598
+	print 'selected';
599
+}
600
+?>>Vatsim</option>
601
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
602
+	print 'selected';
603
+}
604
+?>>Virtual Radar Server AircraftList.json</option>
605
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
606
+	print 'selected';
607
+}
608
+?>>Virtual Radar Server TCP</option>
609
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
610
+	print 'selected';
611
+}
612
+?>>phpVMS</option>
613
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
614
+	print 'selected';
615
+}
616
+?>>Virtual Airlines Manager</option>
617
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
618
+	print 'selected';
619
+}
620
+?>>IVAO</option>
621
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
622
+	print 'selected';
623
+}
624
+?>>FlightGear Multiplayer</option>
625
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
626
+	print 'selected';
627
+}
628
+?>>FlightGear Singleplayer</option>
629
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
630
+	print 'selected';
631
+}
632
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
633
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
634
+	print 'selected';
635
+}
636
+?>>ACARS SBS-3 over TCP</option>
637
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
638
+	print 'selected';
639
+}
640
+?>>NMEA AIS over TCP</option>
483 641
 									</select>
484 642
 								</td>
485
-								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /></td>
486
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
487
-								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
643
+								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
644
+	print $source['name'];
645
+}
646
+?>" /></td>
647
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
648
+	print 'checked';
649
+}
650
+?> /></td>
651
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
652
+	print 'checked';
653
+}
654
+?> /></td>
488 655
 								<td><input type="button" id="delhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td>
489 656
 							</tr>
490 657
 <?php
@@ -533,11 +700,17 @@  discard block
 block discarded – undo
533 700
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
534 701
 					<p>
535 702
 						<label for="acarshost">ACARS UDP host</label>
536
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
703
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
704
+	print $globalACARSHost;
705
+}
706
+?>" />
537 707
 					</p>
538 708
 					<p>
539 709
 						<label for="acarsport">ACARS UDP port</label>
540
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
710
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
711
+	print $globalACARSPort;
712
+}
713
+?>" />
541 714
 					</p>
542 715
 				</fieldset>
543 716
 			</div>
@@ -617,13 +790,19 @@  discard block
 block discarded – undo
617 790
 			<div id="schedules_options">
618 791
 				<p>
619 792
 					<label for="britishairways">British Airways API Key</label>
620
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
793
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
794
+	print $globalBritishAirwaysKey;
795
+}
796
+?>" />
621 797
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
622 798
 				</p>
623 799
 				<!--
624 800
 				<p>
625 801
 					<label for="transavia">Transavia Test API Consumer Key</label>
626
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
802
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
803
+	print $globalTransaviaKey;
804
+}
805
+?>" />
627 806
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
628 807
 				</p>
629 808
 				-->
@@ -632,10 +811,16 @@  discard block
 block discarded – undo
632 811
 						<b>Lufthansa API Key</b>
633 812
 						<p>
634 813
 							<label for="lufthansakey">Key</label>
635
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
814
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
815
+	print $globalLufthansaKey['key'];
816
+}
817
+?>" />
636 818
 						</p><p>
637 819
 							<label for="lufthansasecret">Secret</label>
638
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
820
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
821
+	print $globalLufthansaKey['secret'];
822
+}
823
+?>" />
639 824
 						</p>
640 825
 					</div>
641 826
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -655,7 +840,10 @@  discard block
 block discarded – undo
655 840
 			</p>
656 841
 			<p>
657 842
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
658
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
843
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
844
+	print $globalNOTAMSource;
845
+}
846
+?>" />
659 847
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
660 848
 			</p>
661 849
 			<br />
@@ -671,14 +859,20 @@  discard block
 block discarded – undo
671 859
 			<div id="metarsrc">
672 860
 				<p>
673 861
 					<label for="metarsource">URL of your METAR source</label>
674
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
862
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
863
+	print $globalMETARurl;
864
+}
865
+?>" />
675 866
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
676 867
 				</p>
677 868
 			</div>
678 869
 			<br />
679 870
 			<p>
680 871
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
681
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
872
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
873
+	print $globalBitlyAccessToken;
874
+}
875
+?>" />
682 876
 			</p>
683 877
 			<br />
684 878
 			<p>
@@ -698,7 +892,12 @@  discard block
 block discarded – undo
698 892
 			</p>
699 893
 			<p>
700 894
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
701
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
895
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
896
+	print $globalArchiveMonths;
897
+} else {
898
+	echo '0';
899
+}
900
+?>" />
702 901
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
703 902
 			</p>
704 903
 			<p>
@@ -708,12 +907,22 @@  discard block
 block discarded – undo
708 907
 			</p>
709 908
 			<p>
710 909
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
711
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
910
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
911
+	print $globalArchiveKeepMonths;
912
+} else {
913
+	echo '0';
914
+}
915
+?>" />
712 916
 				<p class="help-block">0 to disable</p>
713 917
 			</p>
714 918
 			<p>
715 919
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
716
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
920
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
921
+	print $globalArchiveKeepTrackMonths;
922
+} else {
923
+	echo '0';
924
+}
925
+?>" />
717 926
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
718 927
 			</p>
719 928
 			<br />
@@ -723,7 +932,12 @@  discard block
 block discarded – undo
723 932
 				<p class="help-block">Uncheck if the script is running as cron job</p>
724 933
 				<div id="cronends"> 
725 934
 					<label for="cronend">Run script for xx seconds</label>
726
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
935
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
936
+	print $globalCronEnd;
937
+} else {
938
+	print '0';
939
+}
940
+?>" />
727 941
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
728 942
 				</div>
729 943
 			</p>
@@ -768,15 +982,30 @@  discard block
 block discarded – undo
768 982
 			<br />
769 983
 			<p>
770 984
 				<label for="refresh">Show flights detected since xxx seconds</label>
771
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
985
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
986
+	echo $globalLiveInterval;
987
+} else {
988
+	echo '200';
989
+}
990
+?>" />
772 991
 			</p>
773 992
 			<p>
774 993
 				<label for="maprefresh">Live map refresh (in seconds)</label>
775
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
994
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
995
+	echo $globalMapRefresh;
996
+} else {
997
+	echo '30';
998
+}
999
+?>" />
776 1000
 			</p>
777 1001
 			<p>
778 1002
 				<label for="mapidle">Map idle timeout (in minutes)</label>
779
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1003
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1004
+	echo $globalMapIdleTimeout;
1005
+} else {
1006
+	echo '30';
1007
+}
1008
+?>" />
780 1009
 				<p class="help-block">0 to disable</p>
781 1010
 			</p>
782 1011
 			<p>
@@ -786,12 +1015,20 @@  discard block
 block discarded – undo
786 1015
 			<br />
787 1016
 			<p>
788 1017
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
789
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1018
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1019
+	echo $globalClosestMinDist;
1020
+} else {
1021
+	echo '50';
1022
+}
1023
+?>" />
790 1024
 			</p>
791 1025
 			<br />
792 1026
 			<p>
793 1027
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
794
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1028
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1029
+	echo $globalAircraftSize;
1030
+}
1031
+?>" />
795 1032
 			</p>
796 1033
 			<br />
797 1034
 			<p>
@@ -804,7 +1041,12 @@  discard block
 block discarded – undo
804 1041
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
805 1042
 			?>
806 1043
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
807
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1044
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1045
+	echo $globalAircraftIconColor;
1046
+} else {
1047
+	echo '1a3151';
1048
+}
1049
+?>" />
808 1050
 			<?php
809 1051
 				if (!is_writable('../cache')) {
810 1052
 			?>
@@ -822,8 +1064,18 @@  discard block
 block discarded – undo
822 1064
 			<p>
823 1065
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
824 1066
 				<div class="range">
825
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
826
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1067
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1068
+	echo $globalAirportZoom;
1069
+} else {
1070
+	echo '7';
1071
+}
1072
+?>" />
1073
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1074
+	echo $globalAirportZoom;
1075
+} else {
1076
+	echo '7';
1077
+}
1078
+?></output>
827 1079
 				</div>
828 1080
 			</p>
829 1081
 		</fieldset>
@@ -851,8 +1103,12 @@  discard block
 block discarded – undo
851 1103
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
852 1104
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
853 1105
 
854
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
855
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1106
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1107
+		$error .= 'Mysql driver for PDO must be loaded';
1108
+	}
1109
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1110
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1111
+	}
856 1112
 	
857 1113
 	$_SESSION['database_root'] = $dbroot;
858 1114
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -919,15 +1175,23 @@  discard block
 block discarded – undo
919 1175
 	$source_city = $_POST['source_city'];
920 1176
 	$source_country = $_POST['source_country'];
921 1177
 	$source_ref = $_POST['source_ref'];
922
-	if (isset($source_id)) $source_id = $_POST['source_id'];
923
-	else $source_id = array();
1178
+	if (isset($source_id)) {
1179
+		$source_id = $_POST['source_id'];
1180
+	} else {
1181
+		$source_id = array();
1182
+	}
924 1183
 	
925 1184
 	$sources = array();
926 1185
 	foreach ($source_name as $keys => $name) {
927
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
928
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1186
+	    if (isset($source_id[$keys])) {
1187
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1188
+	    } else {
1189
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1190
+	    }
1191
+	}
1192
+	if (count($sources) > 0) {
1193
+		$_SESSION['sources'] = $sources;
929 1194
 	}
930
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
931 1195
 
932 1196
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
933 1197
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -948,14 +1212,23 @@  discard block
 block discarded – undo
948 1212
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
949 1213
 
950 1214
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
951
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
952
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1215
+	if ($globalaircraft == 'aircraft') {
1216
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1217
+	} else {
1218
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1219
+	}
953 1220
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
954
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
955
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1221
+	if ($globaltracker == 'tracker') {
1222
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1223
+	} else {
1224
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1225
+	}
956 1226
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
957
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
958
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1227
+	if ($globalmarine == 'marine') {
1228
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1229
+	} else {
1230
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1231
+	}
959 1232
 
960 1233
 /*	
961 1234
 	$globalSBS1Hosts = array();
@@ -976,17 +1249,31 @@  discard block
 block discarded – undo
976 1249
 	$port = $_POST['port'];
977 1250
 	$name = $_POST['name'];
978 1251
 	$format = $_POST['format'];
979
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
980
-	else $sourcestats = array();
981
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
982
-	else $noarchive = array();
1252
+	if (isset($_POST['sourcestats'])) {
1253
+		$sourcestats = $_POST['sourcestats'];
1254
+	} else {
1255
+		$sourcestats = array();
1256
+	}
1257
+	if (isset($_POST['noarchive'])) {
1258
+		$noarchive = $_POST['noarchive'];
1259
+	} else {
1260
+		$noarchive = array();
1261
+	}
983 1262
 	$gSources = array();
984 1263
 	foreach ($host as $key => $h) {
985
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
986
-		else $cov = 'FALSE';
987
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
988
-		else $arch = 'FALSE';
989
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch);
1264
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1265
+			$cov = 'TRUE';
1266
+		} else {
1267
+			$cov = 'FALSE';
1268
+		}
1269
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1270
+			$arch = 'TRUE';
1271
+		} else {
1272
+			$arch = 'FALSE';
1273
+		}
1274
+		if ($h != '') {
1275
+			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch);
1276
+		}
990 1277
 	}
991 1278
 	$settings = array_merge($settings,array('globalSources' => $gSources));
992 1279
 
@@ -1011,7 +1298,9 @@  discard block
 block discarded – undo
1011 1298
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1012 1299
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1013 1300
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1014
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1301
+	} else {
1302
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1303
+	}
1015 1304
 
1016 1305
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1017 1306
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1050,7 +1339,9 @@  discard block
 block discarded – undo
1050 1339
 
1051 1340
 	// Create in settings.php keys not yet configurable if not already here
1052 1341
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1053
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1342
+	if (!isset($globalDebug)) {
1343
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1344
+	}
1054 1345
 
1055 1346
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1056 1347
 	if ($resetyearstats == 'resetyearstats') {
@@ -1087,33 +1378,51 @@  discard block
 block discarded – undo
1087 1378
 	}
1088 1379
 */
1089 1380
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1090
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1091
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1092
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1093
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1381
+	if ($globalsbs == 'sbs') {
1382
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1383
+	} else {
1384
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1385
+	}
1386
+	if ($globalaprs == 'aprs') {
1387
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1388
+	} else {
1389
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1390
+	}
1094 1391
 	$va = false;
1095 1392
 	if ($globalivao == 'ivao') {
1096 1393
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1097 1394
 		$va = true;
1098
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1395
+	} else {
1396
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1397
+	}
1099 1398
 	if ($globalvatsim == 'vatsim') {
1100 1399
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1101 1400
 		$va = true;
1102
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1401
+	} else {
1402
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1403
+	}
1103 1404
 	if ($globalphpvms == 'phpvms') {
1104 1405
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1105 1406
 		$va = true;
1106
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1407
+	} else {
1408
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1409
+	}
1107 1410
 	if ($globalvam == 'vam') {
1108 1411
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1109 1412
 		$va = true;
1110
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1413
+	} else {
1414
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1415
+	}
1111 1416
 	if ($va) {
1112 1417
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1113
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1418
+	} else {
1419
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1420
+	}
1114 1421
 	if ($globalva == 'va' || $va) {
1115 1422
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1116
-	} else $settings = array_merge($settings,array('globalVA' => 'FALSE'));
1423
+	} else {
1424
+		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1425
+	}
1117 1426
 	
1118 1427
 
1119 1428
 
@@ -1261,7 +1570,9 @@  discard block
 block discarded – undo
1261 1570
 		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1262 1571
 	}
1263 1572
 
1264
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1573
+	if (!isset($globalTransaction)) {
1574
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1575
+	}
1265 1576
 
1266 1577
 	// Set some defaults values...
1267 1578
 	if (!isset($globalAircraftImageSources)) {
@@ -1276,15 +1587,23 @@  discard block
 block discarded – undo
1276 1587
 
1277 1588
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1278 1589
 
1279
-	if ($error == '') settings::modify_settings($settings);
1280
-	if ($error == '') settings::comment_settings($settings_comment);
1590
+	if ($error == '') {
1591
+		settings::modify_settings($settings);
1592
+	}
1593
+	if ($error == '') {
1594
+		settings::comment_settings($settings_comment);
1595
+	}
1281 1596
 	if ($error != '') {
1282 1597
 		print '<div class="info column">'.$error.'</div>';
1283 1598
 		require('../footer.php');
1284 1599
 		exit;
1285 1600
 	} else {
1286
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1287
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1601
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1602
+			$_SESSION['waypoints'] = 1;
1603
+		}
1604
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1605
+			$_SESSION['owner'] = 1;
1606
+		}
1288 1607
 		if (isset($_POST['createdb'])) {
1289 1608
 			$_SESSION['install'] = 'database_create';
1290 1609
 		} else {
@@ -1325,10 +1644,18 @@  discard block
 block discarded – undo
1325 1644
 	$popw = false;
1326 1645
 	foreach ($_SESSION['done'] as $done) {
1327 1646
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1328
-	    if ($done == 'Create database') $pop = true;
1329
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1330
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1331
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1647
+	    if ($done == 'Create database') {
1648
+	    	$pop = true;
1649
+	    }
1650
+	    if ($_SESSION['install'] == 'database_create') {
1651
+	    	$pop = true;
1652
+	    }
1653
+	    if ($_SESSION['install'] == 'database_import') {
1654
+	    	$popi = true;
1655
+	    }
1656
+	    if ($_SESSION['install'] == 'waypoints') {
1657
+	    	$popw = true;
1658
+	    }
1332 1659
 	}
1333 1660
 	if ($pop) {
1334 1661
 	    sleep(5);
@@ -1339,7 +1666,9 @@  discard block
 block discarded – undo
1339 1666
 	} else if ($popw) {
1340 1667
 	    sleep(5);
1341 1668
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1342
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1669
+	} else {
1670
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1671
+	}
1343 1672
 	print '</div></ul>';
1344 1673
 	print '<div id="error"></div>';
1345 1674
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +363 added lines, -134 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1332,20 +1390,28 @@  discard block
 block discarded – undo
1332 1390
 		}
1333 1391
 		if ($globalDBdriver == 'mysql') {
1334 1392
 			$error .= create_db::import_file('../db/airlines.sql');
1335
-			if ($error != '') return $error;
1393
+			if ($error != '') {
1394
+				return $error;
1395
+			}
1336 1396
 		} else {
1337 1397
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1338
-			if ($error != '') return $error;
1398
+			if ($error != '') {
1399
+				return $error;
1400
+			}
1339 1401
 		}
1340 1402
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1341 1403
 			include_once(dirname(__FILE__).'/class.update_db.php');
1342 1404
 			if (isset($globalVATSIM) && $globalVATSIM) {
1343 1405
 				$error .= update_db::update_vatsim();
1344
-				if ($error != '') return $error;
1406
+				if ($error != '') {
1407
+					return $error;
1408
+				}
1345 1409
 			}
1346 1410
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1347 1411
 				$error .= update_db::update_IVAO();
1348
-				if ($error != '') return $error;
1412
+				if ($error != '') {
1413
+					return $error;
1414
+				}
1349 1415
 			}
1350 1416
 		}
1351 1417
 
@@ -1608,41 +1674,65 @@  discard block
 block discarded – undo
1608 1674
 		if ($globalDBdriver == 'mysql') {
1609 1675
 			if (!$Connection->tableExists('tracker_output')) {
1610 1676
 				$error .= create_db::import_file('../db/tracker_output.sql');
1611
-				if ($error != '') return $error;
1677
+				if ($error != '') {
1678
+					return $error;
1679
+				}
1612 1680
 			}
1613 1681
 			if (!$Connection->tableExists('tracker_live')) {
1614 1682
 				$error .= create_db::import_file('../db/tracker_live.sql');
1615
-				if ($error != '') return $error;
1683
+				if ($error != '') {
1684
+					return $error;
1685
+				}
1616 1686
 			}
1617 1687
 			if (!$Connection->tableExists('marine_output')) {
1618 1688
 				$error .= create_db::import_file('../db/marine_output.sql');
1619
-				if ($error != '') return $error;
1689
+				if ($error != '') {
1690
+					return $error;
1691
+				}
1620 1692
 			}
1621 1693
 			if (!$Connection->tableExists('marine_live')) {
1622 1694
 				$error .= create_db::import_file('../db/marine_live.sql');
1623
-				if ($error != '') return $error;
1695
+				if ($error != '') {
1696
+					return $error;
1697
+				}
1624 1698
 			}
1625 1699
 			if (!$Connection->tableExists('marine_identity')) {
1626 1700
 				$error .= create_db::import_file('../db/marine_identity.sql');
1627
-				if ($error != '') return $error;
1701
+				if ($error != '') {
1702
+					return $error;
1703
+				}
1628 1704
 			}
1629 1705
 			if (!$Connection->tableExists('marine_mid')) {
1630 1706
 				$error .= create_db::import_file('../db/marine_mid.sql');
1631
-				if ($error != '') return $error;
1707
+				if ($error != '') {
1708
+					return $error;
1709
+				}
1632 1710
 			}
1633 1711
 		} else {
1634 1712
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1635
-			if ($error != '') return $error;
1713
+			if ($error != '') {
1714
+				return $error;
1715
+			}
1636 1716
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1637
-			if ($error != '') return $error;
1717
+			if ($error != '') {
1718
+				return $error;
1719
+			}
1638 1720
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1639
-			if ($error != '') return $error;
1721
+			if ($error != '') {
1722
+				return $error;
1723
+			}
1640 1724
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1641
-			if ($error != '') return $error;
1725
+			if ($error != '') {
1726
+				return $error;
1727
+			}
1642 1728
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1643
-			if ($error != '') return $error;
1729
+			if ($error != '') {
1730
+				return $error;
1731
+			}
1644 1732
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1645
-			if ($error != '') return $error;
1733
+			if ($error != '') {
1734
+				return $error;
1735
+			}
1646 1736
 		}
1647 1737
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1648 1738
 		try {
@@ -1661,35 +1751,55 @@  discard block
 block discarded – undo
1661 1751
 		if ($globalDBdriver == 'mysql') {
1662 1752
 			if (!$Connection->tableExists('marine_image')) {
1663 1753
 				$error .= create_db::import_file('../db/marine_image.sql');
1664
-				if ($error != '') return $error;
1754
+				if ($error != '') {
1755
+					return $error;
1756
+				}
1665 1757
 			}
1666 1758
 			if (!$Connection->tableExists('marine_archive')) {
1667 1759
 				$error .= create_db::import_file('../db/marine_archive.sql');
1668
-				if ($error != '') return $error;
1760
+				if ($error != '') {
1761
+					return $error;
1762
+				}
1669 1763
 			}
1670 1764
 			if (!$Connection->tableExists('marine_archive_output')) {
1671 1765
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1672
-				if ($error != '') return $error;
1766
+				if ($error != '') {
1767
+					return $error;
1768
+				}
1673 1769
 			}
1674 1770
 			if (!$Connection->tableExists('tracker_archive')) {
1675 1771
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1676
-				if ($error != '') return $error;
1772
+				if ($error != '') {
1773
+					return $error;
1774
+				}
1677 1775
 			}
1678 1776
 			if (!$Connection->tableExists('marine_archive_output')) {
1679 1777
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1680
-				if ($error != '') return $error;
1778
+				if ($error != '') {
1779
+					return $error;
1780
+				}
1681 1781
 			}
1682 1782
 		} else {
1683 1783
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1684
-			if ($error != '') return $error;
1784
+			if ($error != '') {
1785
+				return $error;
1786
+			}
1685 1787
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1686
-			if ($error != '') return $error;
1788
+			if ($error != '') {
1789
+				return $error;
1790
+			}
1687 1791
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1688
-			if ($error != '') return $error;
1792
+			if ($error != '') {
1793
+				return $error;
1794
+			}
1689 1795
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1690
-			if ($error != '') return $error;
1796
+			if ($error != '') {
1797
+				return $error;
1798
+			}
1691 1799
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1692
-			if ($error != '') return $error;
1800
+			if ($error != '') {
1801
+				return $error;
1802
+			}
1693 1803
 		}
1694 1804
 		if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) {
1695 1805
 			// Add index key
@@ -1880,8 +1990,11 @@  discard block
 block discarded – undo
1880 1990
     	    if ($Connection->tableExists('aircraft')) {
1881 1991
     		if (!$Connection->tableExists('config')) {
1882 1992
     		    $version = '1';
1883
-    		    if ($update) return self::update_from_1();
1884
-    		    else return $version;
1993
+    		    if ($update) {
1994
+    		    	return self::update_from_1();
1995
+    		    } else {
1996
+    		    	return $version;
1997
+    		    }
1885 1998
 		} else {
1886 1999
     		    $Connection = new Connection();
1887 2000
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1895,158 +2008,274 @@  discard block
 block discarded – undo
1895 2008
     		    if ($update) {
1896 2009
     			if ($result['value'] == '2') {
1897 2010
     			    $error = self::update_from_2();
1898
-    			    if ($error != '') return $error;
1899
-    			    else return self::check_version(true);
2011
+    			    if ($error != '') {
2012
+    			    	return $error;
2013
+    			    } else {
2014
+    			    	return self::check_version(true);
2015
+    			    }
1900 2016
     			} elseif ($result['value'] == '3') {
1901 2017
     			    $error = self::update_from_3();
1902
-    			    if ($error != '') return $error;
1903
-    			    else return self::check_version(true);
2018
+    			    if ($error != '') {
2019
+    			    	return $error;
2020
+    			    } else {
2021
+    			    	return self::check_version(true);
2022
+    			    }
1904 2023
     			} elseif ($result['value'] == '4') {
1905 2024
     			    $error = self::update_from_4();
1906
-    			    if ($error != '') return $error;
1907
-    			    else return self::check_version(true);
2025
+    			    if ($error != '') {
2026
+    			    	return $error;
2027
+    			    } else {
2028
+    			    	return self::check_version(true);
2029
+    			    }
1908 2030
     			} elseif ($result['value'] == '5') {
1909 2031
     			    $error = self::update_from_5();
1910
-    			    if ($error != '') return $error;
1911
-    			    else return self::check_version(true);
2032
+    			    if ($error != '') {
2033
+    			    	return $error;
2034
+    			    } else {
2035
+    			    	return self::check_version(true);
2036
+    			    }
1912 2037
     			} elseif ($result['value'] == '6') {
1913 2038
     			    $error = self::update_from_6();
1914
-    			    if ($error != '') return $error;
1915
-    			    else return self::check_version(true);
2039
+    			    if ($error != '') {
2040
+    			    	return $error;
2041
+    			    } else {
2042
+    			    	return self::check_version(true);
2043
+    			    }
1916 2044
     			} elseif ($result['value'] == '7') {
1917 2045
     			    $error = self::update_from_7();
1918
-    			    if ($error != '') return $error;
1919
-    			    else return self::check_version(true);
2046
+    			    if ($error != '') {
2047
+    			    	return $error;
2048
+    			    } else {
2049
+    			    	return self::check_version(true);
2050
+    			    }
1920 2051
     			} elseif ($result['value'] == '8') {
1921 2052
     			    $error = self::update_from_8();
1922
-    			    if ($error != '') return $error;
1923
-    			    else return self::check_version(true);
2053
+    			    if ($error != '') {
2054
+    			    	return $error;
2055
+    			    } else {
2056
+    			    	return self::check_version(true);
2057
+    			    }
1924 2058
     			} elseif ($result['value'] == '9') {
1925 2059
     			    $error = self::update_from_9();
1926
-    			    if ($error != '') return $error;
1927
-    			    else return self::check_version(true);
2060
+    			    if ($error != '') {
2061
+    			    	return $error;
2062
+    			    } else {
2063
+    			    	return self::check_version(true);
2064
+    			    }
1928 2065
     			} elseif ($result['value'] == '10') {
1929 2066
     			    $error = self::update_from_10();
1930
-    			    if ($error != '') return $error;
1931
-    			    else return self::check_version(true);
2067
+    			    if ($error != '') {
2068
+    			    	return $error;
2069
+    			    } else {
2070
+    			    	return self::check_version(true);
2071
+    			    }
1932 2072
     			} elseif ($result['value'] == '11') {
1933 2073
     			    $error = self::update_from_11();
1934
-    			    if ($error != '') return $error;
1935
-    			    else return self::check_version(true);
2074
+    			    if ($error != '') {
2075
+    			    	return $error;
2076
+    			    } else {
2077
+    			    	return self::check_version(true);
2078
+    			    }
1936 2079
     			} elseif ($result['value'] == '12') {
1937 2080
     			    $error = self::update_from_12();
1938
-    			    if ($error != '') return $error;
1939
-    			    else return self::check_version(true);
2081
+    			    if ($error != '') {
2082
+    			    	return $error;
2083
+    			    } else {
2084
+    			    	return self::check_version(true);
2085
+    			    }
1940 2086
     			} elseif ($result['value'] == '13') {
1941 2087
     			    $error = self::update_from_13();
1942
-    			    if ($error != '') return $error;
1943
-    			    else return self::check_version(true);
2088
+    			    if ($error != '') {
2089
+    			    	return $error;
2090
+    			    } else {
2091
+    			    	return self::check_version(true);
2092
+    			    }
1944 2093
     			} elseif ($result['value'] == '14') {
1945 2094
     			    $error = self::update_from_14();
1946
-    			    if ($error != '') return $error;
1947
-    			    else return self::check_version(true);
2095
+    			    if ($error != '') {
2096
+    			    	return $error;
2097
+    			    } else {
2098
+    			    	return self::check_version(true);
2099
+    			    }
1948 2100
     			} elseif ($result['value'] == '15') {
1949 2101
     			    $error = self::update_from_15();
1950
-    			    if ($error != '') return $error;
1951
-    			    else return self::check_version(true);
2102
+    			    if ($error != '') {
2103
+    			    	return $error;
2104
+    			    } else {
2105
+    			    	return self::check_version(true);
2106
+    			    }
1952 2107
     			} elseif ($result['value'] == '16') {
1953 2108
     			    $error = self::update_from_16();
1954
-    			    if ($error != '') return $error;
1955
-    			    else return self::check_version(true);
2109
+    			    if ($error != '') {
2110
+    			    	return $error;
2111
+    			    } else {
2112
+    			    	return self::check_version(true);
2113
+    			    }
1956 2114
     			} elseif ($result['value'] == '17') {
1957 2115
     			    $error = self::update_from_17();
1958
-    			    if ($error != '') return $error;
1959
-    			    else return self::check_version(true);
2116
+    			    if ($error != '') {
2117
+    			    	return $error;
2118
+    			    } else {
2119
+    			    	return self::check_version(true);
2120
+    			    }
1960 2121
     			} elseif ($result['value'] == '18') {
1961 2122
     			    $error = self::update_from_18();
1962
-    			    if ($error != '') return $error;
1963
-    			    else return self::check_version(true);
2123
+    			    if ($error != '') {
2124
+    			    	return $error;
2125
+    			    } else {
2126
+    			    	return self::check_version(true);
2127
+    			    }
1964 2128
     			} elseif ($result['value'] == '19') {
1965 2129
     			    $error = self::update_from_19();
1966
-    			    if ($error != '') return $error;
1967
-    			    else return self::check_version(true);
2130
+    			    if ($error != '') {
2131
+    			    	return $error;
2132
+    			    } else {
2133
+    			    	return self::check_version(true);
2134
+    			    }
1968 2135
     			} elseif ($result['value'] == '20') {
1969 2136
     			    $error = self::update_from_20();
1970
-    			    if ($error != '') return $error;
1971
-    			    else return self::check_version(true);
2137
+    			    if ($error != '') {
2138
+    			    	return $error;
2139
+    			    } else {
2140
+    			    	return self::check_version(true);
2141
+    			    }
1972 2142
     			} elseif ($result['value'] == '21') {
1973 2143
     			    $error = self::update_from_21();
1974
-    			    if ($error != '') return $error;
1975
-    			    else return self::check_version(true);
2144
+    			    if ($error != '') {
2145
+    			    	return $error;
2146
+    			    } else {
2147
+    			    	return self::check_version(true);
2148
+    			    }
1976 2149
     			} elseif ($result['value'] == '22') {
1977 2150
     			    $error = self::update_from_22();
1978
-    			    if ($error != '') return $error;
1979
-    			    else return self::check_version(true);
2151
+    			    if ($error != '') {
2152
+    			    	return $error;
2153
+    			    } else {
2154
+    			    	return self::check_version(true);
2155
+    			    }
1980 2156
     			} elseif ($result['value'] == '23') {
1981 2157
     			    $error = self::update_from_23();
1982
-    			    if ($error != '') return $error;
1983
-    			    else return self::check_version(true);
2158
+    			    if ($error != '') {
2159
+    			    	return $error;
2160
+    			    } else {
2161
+    			    	return self::check_version(true);
2162
+    			    }
1984 2163
     			} elseif ($result['value'] == '24') {
1985 2164
     			    $error = self::update_from_24();
1986
-    			    if ($error != '') return $error;
1987
-    			    else return self::check_version(true);
2165
+    			    if ($error != '') {
2166
+    			    	return $error;
2167
+    			    } else {
2168
+    			    	return self::check_version(true);
2169
+    			    }
1988 2170
     			} elseif ($result['value'] == '25') {
1989 2171
     			    $error = self::update_from_25();
1990
-    			    if ($error != '') return $error;
1991
-    			    else return self::check_version(true);
2172
+    			    if ($error != '') {
2173
+    			    	return $error;
2174
+    			    } else {
2175
+    			    	return self::check_version(true);
2176
+    			    }
1992 2177
     			} elseif ($result['value'] == '26') {
1993 2178
     			    $error = self::update_from_26();
1994
-    			    if ($error != '') return $error;
1995
-    			    else return self::check_version(true);
2179
+    			    if ($error != '') {
2180
+    			    	return $error;
2181
+    			    } else {
2182
+    			    	return self::check_version(true);
2183
+    			    }
1996 2184
     			} elseif ($result['value'] == '27') {
1997 2185
     			    $error = self::update_from_27();
1998
-    			    if ($error != '') return $error;
1999
-    			    else return self::check_version(true);
2186
+    			    if ($error != '') {
2187
+    			    	return $error;
2188
+    			    } else {
2189
+    			    	return self::check_version(true);
2190
+    			    }
2000 2191
     			} elseif ($result['value'] == '28') {
2001 2192
     			    $error = self::update_from_28();
2002
-    			    if ($error != '') return $error;
2003
-    			    else return self::check_version(true);
2193
+    			    if ($error != '') {
2194
+    			    	return $error;
2195
+    			    } else {
2196
+    			    	return self::check_version(true);
2197
+    			    }
2004 2198
     			} elseif ($result['value'] == '29') {
2005 2199
     			    $error = self::update_from_29();
2006
-    			    if ($error != '') return $error;
2007
-    			    else return self::check_version(true);
2200
+    			    if ($error != '') {
2201
+    			    	return $error;
2202
+    			    } else {
2203
+    			    	return self::check_version(true);
2204
+    			    }
2008 2205
     			} elseif ($result['value'] == '30') {
2009 2206
     			    $error = self::update_from_30();
2010
-    			    if ($error != '') return $error;
2011
-    			    else return self::check_version(true);
2207
+    			    if ($error != '') {
2208
+    			    	return $error;
2209
+    			    } else {
2210
+    			    	return self::check_version(true);
2211
+    			    }
2012 2212
     			} elseif ($result['value'] == '31') {
2013 2213
     			    $error = self::update_from_31();
2014
-    			    if ($error != '') return $error;
2015
-    			    else return self::check_version(true);
2214
+    			    if ($error != '') {
2215
+    			    	return $error;
2216
+    			    } else {
2217
+    			    	return self::check_version(true);
2218
+    			    }
2016 2219
     			} elseif ($result['value'] == '32') {
2017 2220
     			    $error = self::update_from_32();
2018
-    			    if ($error != '') return $error;
2019
-    			    else return self::check_version(true);
2221
+    			    if ($error != '') {
2222
+    			    	return $error;
2223
+    			    } else {
2224
+    			    	return self::check_version(true);
2225
+    			    }
2020 2226
     			} elseif ($result['value'] == '33') {
2021 2227
     			    $error = self::update_from_33();
2022
-    			    if ($error != '') return $error;
2023
-    			    else return self::check_version(true);
2228
+    			    if ($error != '') {
2229
+    			    	return $error;
2230
+    			    } else {
2231
+    			    	return self::check_version(true);
2232
+    			    }
2024 2233
     			} elseif ($result['value'] == '34') {
2025 2234
     			    $error = self::update_from_34();
2026
-    			    if ($error != '') return $error;
2027
-    			    else return self::check_version(true);
2235
+    			    if ($error != '') {
2236
+    			    	return $error;
2237
+    			    } else {
2238
+    			    	return self::check_version(true);
2239
+    			    }
2028 2240
     			} elseif ($result['value'] == '35') {
2029 2241
     			    $error = self::update_from_35();
2030
-    			    if ($error != '') return $error;
2031
-    			    else return self::check_version(true);
2242
+    			    if ($error != '') {
2243
+    			    	return $error;
2244
+    			    } else {
2245
+    			    	return self::check_version(true);
2246
+    			    }
2032 2247
     			} elseif ($result['value'] == '36') {
2033 2248
     			    $error = self::update_from_36();
2034
-    			    if ($error != '') return $error;
2035
-    			    else return self::check_version(true);
2249
+    			    if ($error != '') {
2250
+    			    	return $error;
2251
+    			    } else {
2252
+    			    	return self::check_version(true);
2253
+    			    }
2036 2254
     			} elseif ($result['value'] == '37') {
2037 2255
     			    $error = self::update_from_37();
2038
-    			    if ($error != '') return $error;
2039
-    			    else return self::check_version(true);
2256
+    			    if ($error != '') {
2257
+    			    	return $error;
2258
+    			    } else {
2259
+    			    	return self::check_version(true);
2260
+    			    }
2040 2261
     			} elseif ($result['value'] == '38') {
2041 2262
     			    $error = self::update_from_38();
2042
-    			    if ($error != '') return $error;
2043
-    			    else return self::check_version(true);
2044
-    			} else return '';
2263
+    			    if ($error != '') {
2264
+    			    	return $error;
2265
+    			    } else {
2266
+    			    	return self::check_version(true);
2267
+    			    }
2268
+    			} else {
2269
+    				return '';
2270
+    			}
2271
+    		    } else {
2272
+    		    	return $result['value'];
2045 2273
     		    }
2046
-    		    else return $result['value'];
2047 2274
 		}
2048 2275
 		
2049
-	    } else return $version;
2276
+	    } else {
2277
+	    	return $version;
2278
+	    }
2050 2279
     	}
2051 2280
     	
2052 2281
 }
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Braces   +161 added lines, -55 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@  discard block
 block discarded – undo
53 53
 
54 54
     public function checkAll() {
55 55
 	global $globalDebug;
56
-	if ($globalDebug) echo "Update last seen tracked data...\n";
56
+	if ($globalDebug) {
57
+		echo "Update last seen tracked data...\n";
58
+	}
57 59
 	foreach ($this->all_tracked as $key => $flight) {
58 60
 	    if (isset($this->all_tracked[$key]['id'])) {
59 61
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -66,13 +68,17 @@  discard block
 block discarded – undo
66 68
     public function del() {
67 69
 	global $globalDebug, $globalNoDB, $globalNoImport;
68 70
 	// Delete old infos
69
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
71
+	if ($globalDebug) {
72
+		echo 'Delete old values and update latest data...'."\n";
73
+	}
70 74
 	foreach ($this->all_tracked as $key => $flight) {
71 75
     	    if (isset($flight['lastupdate'])) {
72 76
         	if ($flight['lastupdate'] < (time()-3000)) {
73 77
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
74 78
             		if (isset($this->all_tracked[$key]['id'])) {
75
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
79
+            		    if ($globalDebug) {
80
+            		    	echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
81
+            		    }
76 82
 			    /*
77 83
 			    $MarineLive = new MarineLive();
78 84
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -82,7 +88,9 @@  discard block
 block discarded – undo
82 88
             		    $Marine = new Marine($this->db);
83 89
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
84 90
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
85
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
91
+				if ($globalDebug && $result != 'success') {
92
+					echo '!!! ERROR : '.$result."\n";
93
+				}
86 94
 			    }
87 95
 			    // Put in archive
88 96
 //				$Marine->db = null;
@@ -96,7 +104,9 @@  discard block
 block discarded – undo
96 104
 
97 105
     public function add($line) {
98 106
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
99
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
107
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
108
+		$globalCoordMinChange = '0.02';
109
+	}
100 110
 	date_default_timezone_set('UTC');
101 111
 	$dataFound = false;
102 112
 	$send = false;
@@ -121,8 +131,11 @@  discard block
 block discarded – undo
121 131
 		
122 132
 		$Common = new Common();
123 133
 		$AIS = new AIS();
124
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
125
-	        else $id = trim($line['id']);
134
+	        if (!isset($line['id'])) {
135
+	        	$id = trim($line['mmsi']);
136
+	        } else {
137
+	        	$id = trim($line['id']);
138
+	        }
126 139
 		
127 140
 		if (!isset($this->all_tracked[$id])) {
128 141
 		    $this->all_tracked[$id] = array();
@@ -130,10 +143,16 @@  discard block
 block discarded – undo
130 143
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
131 144
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
132 145
 		    if (!isset($line['id'])) {
133
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
146
+			if (!isset($globalDaemon)) {
147
+				$globalDaemon = TRUE;
148
+			}
134 149
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
135
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
136
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
150
+		     } else {
151
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
152
+		     }
153
+		    if ($globalAllTracked !== FALSE) {
154
+		    	$dataFound = true;
155
+		    }
137 156
 		}
138 157
 		
139 158
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -183,34 +202,49 @@  discard block
 block discarded – undo
183 202
 				$Marine = new Marine($this->db);
184 203
 				$fromsource = NULL;
185 204
 				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
186
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
205
+				if ($globalDebug && $result != 'success') {
206
+					echo '!!! ERROR : '.$result."\n";
207
+				}
187 208
 				$Marine->db = null;
188
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
209
+				if ($globalDebugTimeElapsed) {
210
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
211
+				}
189 212
 			    }
190 213
 			}
191 214
 		    }
192
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
215
+		    if (!isset($this->all_tracked[$id]['id'])) {
216
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
217
+		    }
193 218
 		}
194 219
 
195 220
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
196 221
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
197 222
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
198 223
 		    } else {
199
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
200
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
224
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
225
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
226
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
227
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
228
+				}
201 229
 				return '';
202 230
 		    }
203 231
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
204
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
232
+			if ($globalDebug) {
233
+				echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
234
+			}
205 235
 			return '';
206 236
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
207
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
237
+			if ($globalDebug) {
238
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
239
+			}
208 240
 			return '';
209 241
 		} elseif (!isset($line['datetime'])) {
210 242
 			date_default_timezone_set('UTC');
211 243
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
212 244
 		} else {
213
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
245
+			if ($globalDebug) {
246
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
247
+			}
214 248
 			return '';
215 249
 		}
216 250
 
@@ -223,14 +257,21 @@  discard block
 block discarded – undo
223 257
 		    if ($distance > 1000 && $distance < 10000) {
224 258
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
225 259
 			$speed = $speed*3.6;
226
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
227
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
260
+			if ($speed < 1000) {
261
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
262
+			}
263
+  			if ($globalDebug) {
264
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
265
+  			}
228 266
 		    }
229 267
 		}
230 268
 
231 269
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
232
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
233
-	    	    else unset($timediff);
270
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
271
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
272
+	    	    } else {
273
+	    	    	unset($timediff);
274
+	    	    }
234 275
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
235 276
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
236 277
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -238,22 +279,32 @@  discard block
 block discarded – undo
238 279
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
239 280
 				$this->all_tracked[$id]['putinarchive'] = true;
240 281
 				
241
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
282
+				if ($globalDebug) {
283
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
284
+				}
242 285
 				$timeelapsed = microtime(true);
243 286
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
244 287
 				    $Marine = new Marine($this->db);
245 288
 				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
246
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
289
+				    if (!empty($all_country)) {
290
+				    	$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
291
+				    }
247 292
 				    $Marine->db = null;
248
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
293
+				    if ($globalDebugTimeElapsed) {
294
+				    	echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
295
+				    }
249 296
 				}
250 297
 				$this->tmd = 0;
251
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
298
+				if ($globalDebug) {
299
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
300
+				}
252 301
 			    }
253 302
 			}
254 303
 
255 304
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
256
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
305
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
306
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
307
+				}
257 308
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
258 309
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
259 310
 				    $dataFound = true;
@@ -262,8 +313,12 @@  discard block
 block discarded – undo
262 313
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
263 314
 			}
264 315
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
265
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
266
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
316
+			    if ($line['longitude'] > 180) {
317
+			    	$line['longitude'] = $line['longitude'] - 360;
318
+			    }
319
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
320
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
321
+				}
267 322
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
268 323
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
269 324
 				    $dataFound = true;
@@ -281,7 +336,9 @@  discard block
 block discarded – undo
281 336
 		    }
282 337
 		}
283 338
 		if (isset($line['last_update']) && $line['last_update'] != '') {
284
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
339
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
340
+		    	$dataFound = true;
341
+		    }
285 342
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
286 343
 		}
287 344
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -302,15 +359,21 @@  discard block
 block discarded – undo
302 359
 		}
303 360
 		
304 361
 		if (isset($line['heading']) && $line['heading'] != '') {
305
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
362
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
363
+		    	$this->all_tracked[$id]['putinarchive'] = true;
364
+		    }
306 365
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
307 366
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
308 367
 		    //$dataFound = true;
309 368
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
310 369
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
311 370
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
312
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
313
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
371
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
372
+		    	$this->all_tracked[$id]['putinarchive'] = true;
373
+		    }
374
+  		    if ($globalDebug) {
375
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
376
+  		    }
314 377
   		}
315 378
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
316 379
 
@@ -322,23 +385,38 @@  discard block
 block discarded – undo
322 385
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
323 386
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
324 387
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
325
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
388
+				    if ($globalDebug) {
389
+				    	echo "Check if aircraft is already in DB...";
390
+				    }
326 391
 				    $timeelapsed = microtime(true);
327 392
 				    $MarineLive = new MarineLive($this->db);
328 393
 				    if (isset($line['id'])) {
329 394
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
330
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
395
+					if ($globalDebugTimeElapsed) {
396
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
397
+					}
331 398
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
332 399
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
333
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
400
+					if ($globalDebugTimeElapsed) {
401
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
402
+					}
334 403
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
335 404
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
336
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
337
-				    } else $recent_ident = '';
405
+					if ($globalDebugTimeElapsed) {
406
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
407
+					}
408
+				    } else {
409
+				    	$recent_ident = '';
410
+				    }
338 411
 				    $MarineLive->db=null;
339
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
340
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
341
-				} else $recent_ident = '';
412
+				    if ($globalDebug && $recent_ident == '') {
413
+				    	echo " Not in DB.\n";
414
+				    } elseif ($globalDebug && $recent_ident != '') {
415
+				    	echo " Already in DB.\n";
416
+				    }
417
+				} else {
418
+					$recent_ident = '';
419
+				}
342 420
 			    } else {
343 421
 				$recent_ident = '';
344 422
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -346,18 +424,26 @@  discard block
 block discarded – undo
346 424
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
347 425
 			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
348 426
 			    {
349
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
427
+				if ($globalDebug) {
428
+					echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
429
+				}
350 430
 				//adds the spotter data for the archive
351 431
 				    $highlight = '';
352
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
432
+				    if (!isset($this->all_tracked[$id]['id'])) {
433
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
434
+				    }
353 435
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
354 436
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
355 437
 					    $timeelapsed = microtime(true);
356 438
 					    $Marine = new Marine($this->db);
357 439
 					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
358 440
 					    $Marine->db = null;
359
-					    if ($globalDebug && isset($result)) echo $result."\n";
360
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
441
+					    if ($globalDebug && isset($result)) {
442
+					    	echo $result."\n";
443
+					    }
444
+					    if ($globalDebugTimeElapsed) {
445
+					    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
446
+					    }
361 447
 					}
362 448
 				    }
363 449
 				    /*
@@ -392,13 +478,17 @@  discard block
 block discarded – undo
392 478
 				$this->all_tracked[$id]['addedMarine'] = 1;
393 479
 				//print_r($this->all_tracked[$id]);
394 480
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
395
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
481
+				    if ($globalDebug) {
482
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
483
+				    }
396 484
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
397 485
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
398 486
 					$MarineLive = new MarineLive($this->db);
399 487
 					$MarineLive->deleteLiveMarineData();
400 488
 					$MarineLive->db=null;
401
-					if ($globalDebug) echo " Done\n";
489
+					if ($globalDebug) {
490
+						echo " Done\n";
491
+					}
402 492
 				    }
403 493
 				    $this->last_delete = time();
404 494
 				}
@@ -424,15 +514,21 @@  discard block
 block discarded – undo
424 514
 
425 515
 		    if (!$ignoreImport) {
426 516
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
427
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
517
+				if ($globalDebug) {
518
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
519
+				}
428 520
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
429 521
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
430 522
 					$timeelapsed = microtime(true);
431 523
 					$MarineLive = new MarineLive($this->db);
432 524
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
433 525
 					$MarineLive->db = null;
434
-					if ($globalDebug) echo $result."\n";
435
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
526
+					if ($globalDebug) {
527
+						echo $result."\n";
528
+					}
529
+					if ($globalDebugTimeElapsed) {
530
+						echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
531
+					}
436 532
 				    }
437 533
 				}
438 534
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
@@ -495,19 +591,27 @@  discard block
 block discarded – undo
495 591
 				*/
496 592
 
497 593
 				$this->all_tracked[$id]['lastupdate'] = time();
498
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
499
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
594
+				if ($this->all_tracked[$id]['putinarchive']) {
595
+					$send = true;
596
+				}
597
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
598
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
599
+			}
500 600
 			//$this->del();
501 601
 			
502 602
 			
503 603
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
504 604
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
505
-				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
605
+				if ($globalDebug) {
606
+					echo "---- Deleting Live Marine data Not updated since 2 hour...";
607
+				}
506 608
 				$MarineLive = new MarineLive($this->db);
507 609
 				$MarineLive->deleteLiveMarineDataNotUpdated();
508 610
 				$MarineLive->db = null;
509 611
 				//MarineLive->deleteLiveMarineData();
510
-				if ($globalDebug) echo " Done\n";
612
+				if ($globalDebug) {
613
+					echo " Done\n";
614
+				}
511 615
 			    }
512 616
 			    $this->last_delete_hourly = time();
513 617
 			}
@@ -516,7 +620,9 @@  discard block
 block discarded – undo
516 620
 		    //$ignoreImport = false;
517 621
 		}
518 622
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
519
-		if ($send) return $this->all_tracked[$id];
623
+		if ($send) {
624
+			return $this->all_tracked[$id];
625
+		}
520 626
 	    }
521 627
 	}
522 628
     }
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +355 added lines, -125 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
 	$dbc = $this->db;
64 64
 	$this->all_flights[$id]['schedule_check'] = true;
65 65
 	if ($globalSchedulesFetch) {
66
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
66
+	if ($globalDebug) {
67
+		echo 'Getting schedule info...'."\n";
68
+	}
67 69
 	$Spotter = new Spotter($dbc);
68 70
 	$Schedule = new Schedule($dbc);
69 71
 	$Translation = new Translation($dbc);
@@ -74,7 +76,9 @@  discard block
 block discarded – undo
74 76
 	    if ($Schedule->checkSchedule($operator) == 0) {
75 77
 		$schedule = $Schedule->fetchSchedule($operator);
76 78
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
79
+		    if ($globalDebug) {
80
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
81
+		    }
78 82
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79 83
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80 84
 		    // Should also check if route schedule = route from DB
@@ -83,7 +87,9 @@  discard block
 block discarded – undo
83 87
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84 88
 			    if (trim($airport_icao) != '') {
85 89
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
86
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
90
+				if ($globalDebug) {
91
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
92
+				}
87 93
 			    }
88 94
 			}
89 95
 		    }
@@ -92,17 +98,25 @@  discard block
 block discarded – undo
92 98
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93 99
 			    if (trim($airport_icao) != '') {
94 100
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
95
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
101
+				if ($globalDebug) {
102
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
103
+				}
96 104
 			    }
97 105
 			}
98 106
 		    }
99 107
 		    $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']);
100 108
 		}
101
-	    } else $scheduleexist = true;
102
-	} else $scheduleexist = true;
109
+	    } else {
110
+	    	$scheduleexist = true;
111
+	    }
112
+	} else {
113
+		$scheduleexist = true;
114
+	}
103 115
 	// close connection, at least one way will work ?
104 116
        if ($scheduleexist) {
105
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
117
+		if ($globalDebug) {
118
+			echo "-> get arrival/departure airport info for ".$ident."\n";
119
+		}
106 120
     		$sch = $Schedule->getSchedule($operator);
107 121
 		$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']));
108 122
        }
@@ -124,14 +138,18 @@  discard block
 block discarded – undo
124 138
 
125 139
     public function checkAll() {
126 140
 	global $globalDebug, $globalNoImport;
127
-	if ($globalDebug) echo "Update last seen flights data...\n";
141
+	if ($globalDebug) {
142
+		echo "Update last seen flights data...\n";
143
+	}
128 144
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
129 145
 	    foreach ($this->all_flights as $key => $flight) {
130 146
 		if (isset($this->all_flights[$key]['id'])) {
131 147
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 148
     		    $Spotter = new Spotter($this->db);
133 149
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $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']);
150
+        	    if (isset($this->all_flights[$key]['altitude'])) {
151
+        	    	$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']);
152
+        	    }
135 153
         	}
136 154
 	    }
137 155
 	}
@@ -139,24 +157,32 @@  discard block
 block discarded – undo
139 157
 
140 158
     public function arrival($key) {
141 159
 	global $globalClosestMinDist, $globalDebug;
142
-	if ($globalDebug) echo 'Update arrival...'."\n";
160
+	if ($globalDebug) {
161
+		echo 'Update arrival...'."\n";
162
+	}
143 163
 	$Spotter = new Spotter($this->db);
144 164
         $airport_icao = '';
145 165
         $airport_time = '';
146
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
166
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
167
+        	$globalClosestMinDist = 50;
168
+        }
147 169
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148 170
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149 171
     	    if (isset($closestAirports[0])) {
150 172
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 173
         	    $airport_icao = $closestAirports[0]['icao'];
152 174
         	    $airport_time = $this->all_flights[$key]['datetime'];
153
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
175
+        	    if ($globalDebug) {
176
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
177
+        	    }
154 178
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155 179
         	    foreach ($closestAirports as $airport) {
156 180
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157 181
         		    $airport_icao = $airport['icao'];
158 182
         		    $airport_time = $this->all_flights[$key]['datetime'];
159
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
183
+        		    if ($globalDebug) {
184
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
185
+        		    }
160 186
         		    break;
161 187
         		}
162 188
         	    }
@@ -164,14 +190,20 @@  discard block
 block discarded – undo
164 190
         		$airport_icao = $closestAirports[0]['icao'];
165 191
         		$airport_time = $this->all_flights[$key]['datetime'];
166 192
         	} else {
167
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
193
+        		if ($globalDebug) {
194
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
195
+        		}
168 196
         	}
169 197
     	    } else {
170
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
198
+    		    if ($globalDebug) {
199
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
200
+    		    }
171 201
     	    }
172 202
 
173 203
         } else {
174
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
204
+        	if ($globalDebug) {
205
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
206
+        	}
175 207
         }
176 208
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177 209
     }
@@ -181,12 +213,16 @@  discard block
 block discarded – undo
181 213
     public function del() {
182 214
 	global $globalDebug, $globalNoImport, $globalNoDB;
183 215
 	// Delete old infos
184
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
216
+	if ($globalDebug) {
217
+		echo 'Delete old values and update latest data...'."\n";
218
+	}
185 219
 	foreach ($this->all_flights as $key => $flight) {
186 220
     	    if (isset($flight['lastupdate'])) {
187 221
         	if ($flight['lastupdate'] < (time()-3000)) {
188 222
             	    if (isset($this->all_flights[$key]['id'])) {
189
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
223
+            		if ($globalDebug) {
224
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
225
+            		}
190 226
 			/*
191 227
 			$SpotterLive = new SpotterLive();
192 228
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -197,7 +233,9 @@  discard block
 block discarded – undo
197 233
             		    $Spotter = new Spotter($this->db);
198 234
             	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
199 235
 				$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']);
200
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
236
+				if ($globalDebug && $result != 'success') {
237
+					echo '!!! ERROR : '.$result."\n";
238
+				}
201 239
 			    }
202 240
 			// Put in archive
203 241
 //				$Spotter->db = null;
@@ -212,8 +250,10 @@  discard block
 block discarded – undo
212 250
     public function add($line) {
213 251
 	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;
214 252
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
215
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
216
-/*
253
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
254
+		$globalCoordMinChange = '0.02';
255
+	}
256
+	/*
217 257
 	$Spotter = new Spotter();
218 258
 	$dbc = $Spotter->db;
219 259
 	$SpotterLive = new SpotterLive($dbc);
@@ -241,11 +281,15 @@  discard block
 block discarded – undo
241 281
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
242 282
 		    $current_date = date('Y-m-d');
243 283
 		    $source = $line['source_name'];
244
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
284
+		    if ($source == '' || $line['format_source'] == 'aprs') {
285
+		    	$source = $line['format_source'];
286
+		    }
245 287
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
246 288
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
247 289
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
248
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
290
+		    } else {
291
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
292
+		    }
249 293
 		}
250 294
 		
251 295
 		/*
@@ -261,22 +305,35 @@  discard block
 block discarded – undo
261 305
 		//$this->db = $dbc;
262 306
 
263 307
 		//$hex = trim($line['hex']);
264
-	        if (!isset($line['id'])) $id = trim($line['hex']);
265
-	        else $id = trim($line['id']);
308
+	        if (!isset($line['id'])) {
309
+	        	$id = trim($line['hex']);
310
+	        } else {
311
+	        	$id = trim($line['id']);
312
+	        }
266 313
 		
267 314
 		if (!isset($this->all_flights[$id])) {
268 315
 		    $this->all_flights[$id] = array();
269 316
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270 317
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', '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' => ''));
271
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
318
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
319
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
320
+		    }
272 321
 		    if (!isset($line['id'])) {
273
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
274
-//			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')));
322
+			if (!isset($globalDaemon)) {
323
+				$globalDaemon = TRUE;
324
+			}
325
+			//			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')));
275 326
 //			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')));
276
-			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' || $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')));
327
+			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' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
328
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
329
+			}
277 330
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
279
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
331
+		     } else {
332
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
333
+		     }
334
+		    if ($globalAllFlights !== FALSE) {
335
+		    	$dataFound = true;
336
+		    }
280 337
 		}
281 338
 		if (isset($line['source_type']) && $line['source_type'] != '') {
282 339
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -298,17 +355,27 @@  discard block
 block discarded – undo
298 355
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
299 356
 			    }
300 357
 			    $Spotter->db = null;
301
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
358
+			    if ($globalDebugTimeElapsed) {
359
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
360
+			    }
361
+			    if ($aircraft_icao != '') {
362
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
363
+			    }
303 364
 			}
304 365
 		    }
305
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
306
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
366
+		    if ($globalAllFlights !== FALSE) {
367
+		    	$dataFound = true;
368
+		    }
369
+		    if ($globalDebug) {
370
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
371
+		    }
307 372
 		}
308 373
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
309 374
 			$icao = $line['aircraft_icao'];
310 375
 			$Spotter = new Spotter($this->db);
311
-			if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
376
+			if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
377
+				$icao = $Spotter->aircraft_correct_icaotype[$icao];
378
+			}
312 379
 			$Spotter->db = null;
313 380
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
314 381
 		}
@@ -318,15 +385,24 @@  discard block
 block discarded – undo
318 385
 				$Spotter = new Spotter($this->db);
319 386
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
320 387
 				$Spotter->db = null;
321
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
388
+				if ($aircraft_icao != '') {
389
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
390
+				}
322 391
 			}
323 392
 		}
324 393
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
325
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
326
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
327
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
328
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
329
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
394
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
395
+				$aircraft_icao = 'GLID';
396
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
397
+				$aircraft_icao = 'UHEL';
398
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
399
+				$aircraft_icao = 'TOWPLANE';
400
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
401
+				$aircraft_icao = 'POWAIRC';
402
+			}
403
+			if (isset($aircraft_icao)) {
404
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
405
+			}
330 406
 		}
331 407
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
332 408
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -336,8 +412,11 @@  discard block
 block discarded – undo
336 412
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
337 413
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
338 414
 		    } else {
339
-				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";
340
-				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";
415
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
416
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
417
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
418
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
419
+				}
341 420
 				/*
342 421
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
343 422
 				print_r($this->all_flights[$id]);
@@ -346,16 +425,22 @@  discard block
 block discarded – undo
346 425
 				return '';
347 426
 		    }
348 427
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
349
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
428
+			if ($globalDebug) {
429
+				echo "!!! Date is too old ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
430
+			}
350 431
 			return '';
351 432
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
352
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
433
+			if ($globalDebug) {
434
+				echo "!!! Date is in the future ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
435
+			}
353 436
 			return '';
354 437
 		} elseif (!isset($line['datetime'])) {
355 438
 			date_default_timezone_set('UTC');
356 439
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
357 440
 		} else {
358
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
441
+			if ($globalDebug) {
442
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
443
+			}
359 444
 			return '';
360 445
 		}
361 446
 
@@ -379,15 +464,25 @@  discard block
 block discarded – undo
379 464
 			    $timeelapsed = microtime(true);
380 465
             		    $Spotter = new Spotter($this->db);
381 466
             		    $fromsource = NULL;
382
-            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
383
-            		    elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
384
-			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
385
-			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
386
-			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
467
+            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
468
+            		    	$fromsource = $globalAirlinesSource;
469
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
470
+            		    	$fromsource = 'vatsim';
471
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
472
+			    	$fromsource = 'ivao';
473
+			    } elseif (isset($globalVATSIM) && $globalVATSIM) {
474
+			    	$fromsource = 'vatsim';
475
+			    } elseif (isset($globalIVAO) && $globalIVAO) {
476
+			    	$fromsource = 'ivao';
477
+			    }
387 478
             		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
388
-			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
479
+			    if ($globalDebug && $result != 'success') {
480
+			    	echo '!!! ERROR : '.$result."\n";
481
+			    }
389 482
 			    $Spotter->db = null;
390
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
483
+			    if ($globalDebugTimeElapsed) {
484
+			    	echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
485
+			    }
391 486
 			}
392 487
 		    }
393 488
 
@@ -399,7 +494,9 @@  discard block
 block discarded – undo
399 494
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
400 495
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
401 496
   */
402
-		    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']));
497
+		    if (!isset($this->all_flights[$id]['id'])) {
498
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
499
+		    }
403 500
 
404 501
 		    //$putinarchive = true;
405 502
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -417,7 +514,9 @@  discard block
 block discarded – undo
417 514
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
418 515
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
419 516
 		    		$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' => ''));
420
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
517
+				if ($globalDebugTimeElapsed) {
518
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
519
+				}
421 520
                         }
422 521
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
423 522
 			$timeelapsed = microtime(true);
@@ -431,7 +530,9 @@  discard block
 block discarded – undo
431 530
 				$Translation->db = null;
432 531
 			    }
433 532
 			    $Spotter->db = null;
434
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
533
+			    if ($globalDebugTimeElapsed) {
534
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
535
+			    }
435 536
                     	}
436 537
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
437 538
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -440,9 +541,13 @@  discard block
 block discarded – undo
440 541
 		    		$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']));
441 542
 		    	    }
442 543
 			}
443
-			if (!isset($globalFork)) $globalFork = TRUE;
544
+			if (!isset($globalFork)) {
545
+				$globalFork = TRUE;
546
+			}
444 547
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
445
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
548
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
549
+					$this->get_Schedule($id,trim($line['ident']));
550
+				}
446 551
 			}
447 552
 		    }
448 553
 		}
@@ -458,16 +563,23 @@  discard block
 block discarded – undo
458 563
 		    // use datetime
459 564
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
460 565
 			$speed = $speed*3.6;
461
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
462
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
566
+			if ($speed < 1000) {
567
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
568
+			}
569
+  			if ($globalDebug) {
570
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
571
+  			}
463 572
 		    }
464 573
 		}
465 574
 
466 575
 
467 576
 
468 577
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
469
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
470
-	    	    else unset($timediff);
578
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
579
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
580
+	    	    } else {
581
+	    	    	unset($timediff);
582
+	    	    }
471 583
 	    	    if ($this->tmd > 5 || (isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
472 584
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
473 585
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -476,15 +588,23 @@  discard block
 block discarded – undo
476 588
 				$this->all_flights[$id]['putinarchive'] = true;
477 589
 				$this->tmd = 0;
478 590
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
479
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
591
+				    if ($globalDebug) {
592
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
593
+				    }
480 594
 				    $timeelapsed = microtime(true);
481 595
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
482 596
 					$Spotter = new Spotter($this->db);
483 597
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
484
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
598
+					if (!empty($all_country)) {
599
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
600
+					}
485 601
 					$Spotter->db = null;
486
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
487
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
602
+					if ($globalDebugTimeElapsed) {
603
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
604
+					}
605
+					if ($globalDebug) {
606
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
607
+					}
488 608
 				    }
489 609
 				}
490 610
 			    }
@@ -492,7 +612,9 @@  discard block
 block discarded – undo
492 612
 
493 613
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
494 614
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
495
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
615
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
616
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
617
+				}
496 618
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
497 619
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
498 620
 				    $dataFound = true;
@@ -514,9 +636,13 @@  discard block
 block discarded – undo
514 636
 			    */
515 637
 			}
516 638
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
517
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
639
+			    if ($line['longitude'] > 180) {
640
+			    	$line['longitude'] = $line['longitude'] - 360;
641
+			    }
518 642
 			    //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) {
519
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
643
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
644
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
645
+				}
520 646
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
521 647
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
522 648
 				    $dataFound = true;
@@ -547,7 +673,9 @@  discard block
 block discarded – undo
547 673
 		    }
548 674
 		}
549 675
 		if (isset($line['last_update']) && $line['last_update'] != '') {
550
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
676
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
677
+		    	$dataFound = true;
678
+		    }
551 679
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
552 680
 		}
553 681
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -569,41 +697,61 @@  discard block
 block discarded – undo
569 697
 			// Here we force archive of flight because after ground it's a new one (or should be)
570 698
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
571 699
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
572
-			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'].'-'.date('YmdGi')));
573
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
574
-			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']));
700
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
701
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
702
+			} elseif (isset($line['id'])) {
703
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
704
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
705
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
706
+			}
707
+		    }
708
+		    if ($line['ground'] != 1) {
709
+		    	$line['ground'] = 0;
575 710
 		    }
576
-		    if ($line['ground'] != 1) $line['ground'] = 0;
577 711
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
578 712
 		    //$dataFound = true;
579 713
 		}
580 714
 		if (isset($line['squawk']) && $line['squawk'] != '') {
581 715
 		    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'])) {
582
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
716
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
717
+			    	$this->all_flights[$id]['putinarchive'] = true;
718
+			    }
583 719
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
584 720
 			    $highlight = '';
585
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
586
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
587
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
721
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
722
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
723
+			    }
724
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
725
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
726
+			    }
727
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
728
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
729
+			    }
588 730
 			    if ($highlight != '') {
589 731
 				$timeelapsed = microtime(true);
590 732
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
591 733
 				    $Spotter = new Spotter($this->db);
592 734
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
593 735
 				    $Spotter->db = null;
594
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
736
+				    if ($globalDebugTimeElapsed) {
737
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
738
+				    }
595 739
 				}
596 740
 				//$putinarchive = true;
597 741
 				//$highlight = '';
598 742
 			    }
599 743
 			    
600
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
744
+		    } else {
745
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
746
+		    }
601 747
 		    //$dataFound = true;
602 748
 		}
603 749
 
604 750
 		if (isset($line['altitude']) && $line['altitude'] != '') {
605 751
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
606
-			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;
752
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
753
+				$this->all_flights[$id]['putinarchive'] = true;
754
+			}
607 755
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
608 756
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
609 757
 			//$dataFound = true;
@@ -615,21 +763,30 @@  discard block
 block discarded – undo
615 763
 		}
616 764
 		
617 765
 		if (isset($line['heading']) && $line['heading'] != '') {
618
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
766
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
767
+		    	$this->all_flights[$id]['putinarchive'] = true;
768
+		    }
619 769
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
620 770
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
621 771
 		    //$dataFound = true;
622 772
   		} 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']) {
623 773
   		    $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']);
624 774
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
625
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
626
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
775
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
776
+		    	$this->all_flights[$id]['putinarchive'] = true;
777
+		    }
778
+  		    if ($globalDebug) {
779
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
780
+  		    }
627 781
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
628 782
   		    // If not enough messages and ACARS set heading to 0
629 783
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
630 784
   		}
631
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
632
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
785
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
786
+			$dataFound = false;
787
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
788
+			$dataFound = false;
789
+		}
633 790
 
634 791
 //		print_r($this->all_flights[$id]);
635 792
 		//gets the callsign from the last hour
@@ -645,23 +802,38 @@  discard block
 block discarded – undo
645 802
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
646 803
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
647 804
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
648
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
805
+				    if ($globalDebug) {
806
+				    	echo "Check if aircraft is already in DB...";
807
+				    }
649 808
 				    $timeelapsed = microtime(true);
650 809
 				    $SpotterLive = new SpotterLive($this->db);
651 810
 				    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' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
652 811
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
653
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
812
+					if ($globalDebugTimeElapsed) {
813
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
814
+					}
654 815
 				    } elseif (isset($line['id'])) {
655 816
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
656
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
817
+					if ($globalDebugTimeElapsed) {
818
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
819
+					}
657 820
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
658 821
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
659
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
660
-				    } else $recent_ident = '';
822
+					if ($globalDebugTimeElapsed) {
823
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
824
+					}
825
+				    } else {
826
+				    	$recent_ident = '';
827
+				    }
661 828
 				    $SpotterLive->db=null;
662
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
663
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
664
-				} else $recent_ident = '';
829
+				    if ($globalDebug && $recent_ident == '') {
830
+				    	echo " Not in DB.\n";
831
+				    } elseif ($globalDebug && $recent_ident != '') {
832
+				    	echo " Already in DB.\n";
833
+				    }
834
+				} else {
835
+					$recent_ident = '';
836
+				}
665 837
 			    } else {
666 838
 				$recent_ident = '';
667 839
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -669,7 +841,9 @@  discard block
 block discarded – undo
669 841
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
670 842
 			    if($recent_ident == "")
671 843
 			    {
672
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
844
+				if ($globalDebug) {
845
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
846
+				}
673 847
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
674 848
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
675 849
 				//adds the spotter data for the archive
@@ -713,31 +887,49 @@  discard block
 block discarded – undo
713 887
 				
714 888
 				if (!$ignoreImport) {
715 889
 				    $highlight = '';
716
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
717
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
718
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
719
-				    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')));
890
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
891
+				    	$highlight = 'Squawk 7500 : Hijack';
892
+				    }
893
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
894
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
895
+				    }
896
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
897
+				    	$highlight = 'Squawk 7700 : Emergency';
898
+				    }
899
+				    if (!isset($this->all_flights[$id]['id'])) {
900
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
901
+				    }
720 902
 				    $timeelapsed = microtime(true);
721 903
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
722 904
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
723 905
 					    $Spotter = new Spotter($this->db);
724 906
 					    $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']);
725 907
 					    $Spotter->db = null;
726
-					    if ($globalDebug && isset($result)) echo $result."\n";
908
+					    if ($globalDebug && isset($result)) {
909
+					    	echo $result."\n";
910
+					    }
727 911
 					}
728 912
 				    }
729
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
913
+				    if ($globalDebugTimeElapsed) {
914
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
915
+				    }
730 916
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
731 917
 
732 918
 				    // Add source stat in DB
733 919
 				    $Stats = new Stats($this->db);
734 920
 				    if (!empty($this->stats)) {
735
-					if ($globalDebug) echo 'Add source stats : ';
921
+					if ($globalDebug) {
922
+						echo 'Add source stats : ';
923
+					}
736 924
 				        foreach($this->stats as $date => $data) {
737 925
 					    foreach($data as $source => $sourced) {
738 926
 					        //print_r($sourced);
739
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
740
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
927
+				    	        if (isset($sourced['polar'])) {
928
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
929
+				    	        }
930
+				    	        if (isset($sourced['hist'])) {
931
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
932
+				    	        }
741 933
 				    		if (isset($sourced['msg'])) {
742 934
 				    		    if (time() - $sourced['msg']['date'] > 10) {
743 935
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -750,13 +942,17 @@  discard block
 block discarded – undo
750 942
 			    			unset($this->stats[$date]);
751 943
 			    		    }
752 944
 				    	}
753
-				    	if ($globalDebug) echo 'Done'."\n";
945
+				    	if ($globalDebug) {
946
+				    		echo 'Done'."\n";
947
+				    	}
754 948
 
755 949
 				    }
756 950
 				    $Stats->db = null;
757 951
 				    }
758 952
 				    $this->del();
759
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
953
+				} elseif ($globalDebug) {
954
+					echo 'Ignore data'."\n";
955
+				}
760 956
 				//$ignoreImport = false;
761 957
 				$this->all_flights[$id]['addedSpotter'] = 1;
762 958
 				//print_r($this->all_flights[$id]);
@@ -773,7 +969,9 @@  discard block
 block discarded – undo
773 969
 			*/
774 970
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
775 971
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
776
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
972
+				    if ($globalDebug) {
973
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
974
+				    }
777 975
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
778 976
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
779 977
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -782,7 +980,9 @@  discard block
 block discarded – undo
782 980
 					    $SpotterLive->db=null;
783 981
 					}
784 982
 				    }
785
-				    if ($globalDebug) echo " Done\n";
983
+				    if ($globalDebug) {
984
+				    	echo " Done\n";
985
+				    }
786 986
 				    $this->last_delete = time();
787 987
 				}
788 988
 			    } else {
@@ -809,11 +1009,17 @@  discard block
 block discarded – undo
809 1009
 		    //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";
810 1010
 		    if ($globalDebug) {
811 1011
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
812
-				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";
813
-				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";
1012
+				if (isset($this->all_flights[$id]['source_name'])) {
1013
+					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";
1014
+				} else {
1015
+					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";
1016
+				}
814 1017
 			} else {
815
-				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";
816
-				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";
1018
+				if (isset($this->all_flights[$id]['source_name'])) {
1019
+					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";
1020
+				} else {
1021
+					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";
1022
+				}
817 1023
 			}
818 1024
 		    }
819 1025
 		    $ignoreImport = false;
@@ -859,22 +1065,30 @@  discard block
 block discarded – undo
859 1065
 
860 1066
 		    if (!$ignoreImport) {
861 1067
 			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'])) {
862
-				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')));
1068
+				if (!isset($this->all_flights[$id]['id'])) {
1069
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1070
+				}
863 1071
 				$timeelapsed = microtime(true);
864 1072
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
865 1073
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
866
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1074
+					if ($globalDebug) {
1075
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1076
+					}
867 1077
 					$SpotterLive = new SpotterLive($this->db);
868 1078
 					$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']);
869 1079
 					$SpotterLive->db = null;
870
-					if ($globalDebug) echo $result."\n";
1080
+					if ($globalDebug) {
1081
+						echo $result."\n";
1082
+					}
871 1083
 				    }
872 1084
 				}
873 1085
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
874 1086
 					$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']);
875 1087
 				}
876 1088
 				$this->all_flights[$id]['putinarchive'] = false;
877
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1089
+				if ($globalDebugTimeElapsed) {
1090
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1091
+				}
878 1092
 
879 1093
 				// Put statistics in $this->stats variable
880 1094
 				//if ($line['format_source'] != 'aprs') {
@@ -882,7 +1096,9 @@  discard block
 block discarded – undo
882 1096
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
883 1097
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
884 1098
 					$source = $this->all_flights[$id]['source_name'];
885
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1099
+					if ($source == '') {
1100
+						$source = $this->all_flights[$id]['format_source'];
1101
+					}
886 1102
 					if (!isset($this->source_location[$source])) {
887 1103
 						$Location = new Source();
888 1104
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -903,7 +1119,9 @@  discard block
 block discarded – undo
903 1119
 					$stats_heading = round($stats_heading/22.5);
904 1120
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
905 1121
 					$current_date = date('Y-m-d');
906
-					if ($stats_heading == 16) $stats_heading = 0;
1122
+					if ($stats_heading == 16) {
1123
+						$stats_heading = 0;
1124
+					}
907 1125
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
908 1126
 						for ($i=0;$i<=15;$i++) {
909 1127
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -921,7 +1139,9 @@  discard block
 block discarded – undo
921 1139
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
922 1140
 						    end($this->stats[$current_date][$source]['hist']);
923 1141
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
924
-						} else $mini = 0;
1142
+						} else {
1143
+							$mini = 0;
1144
+						}
925 1145
 						for ($i=$mini;$i<=$distance;$i+=10) {
926 1146
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
927 1147
 						}
@@ -933,19 +1153,27 @@  discard block
 block discarded – undo
933 1153
 				}
934 1154
 
935 1155
 				$this->all_flights[$id]['lastupdate'] = time();
936
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1156
+				if ($this->all_flights[$id]['putinarchive']) {
1157
+					$send = true;
1158
+				}
937 1159
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
938
-			} 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";
1160
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1161
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1162
+			}
939 1163
 			//$this->del();
940 1164
 			
941 1165
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
942 1166
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
943
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1167
+				if ($globalDebug) {
1168
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1169
+				}
944 1170
 				$SpotterLive = new SpotterLive($this->db);
945 1171
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
946 1172
 				$SpotterLive->db = null;
947 1173
 				//SpotterLive->deleteLiveSpotterData();
948
-				if ($globalDebug) echo " Done\n";
1174
+				if ($globalDebug) {
1175
+					echo " Done\n";
1176
+				}
949 1177
 				$this->last_delete_hourly = time();
950 1178
 			    } else {
951 1179
 				$this->del();
@@ -957,7 +1185,9 @@  discard block
 block discarded – undo
957 1185
 		    //$ignoreImport = false;
958 1186
 		}
959 1187
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
960
-		if ($send) return $this->all_flights[$id];
1188
+		if ($send) {
1189
+			return $this->all_flights[$id];
1190
+		}
961 1191
 	    }
962 1192
 	}
963 1193
     }
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Braces   +77 added lines, -26 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -76,8 +78,11 @@  discard block
 block discarded – undo
76 78
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77 79
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78 80
 		}
79
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81
+		if ($filter_query_where == '' && $where) {
82
+			$filter_query_where = ' WHERE';
83
+		} elseif ($filter_query_where != '' && $and) {
84
+			$filter_query_where .= ' AND';
85
+		}
81 86
 		if ($filter_query_where != '') {
82 87
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83 88
 		}
@@ -118,9 +123,13 @@  discard block
 block discarded – undo
118 123
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
119 124
 			}
120 125
 		}
121
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
126
+		if ($orderby_query == '') {
127
+			$orderby_query= ' ORDER BY date DESC';
128
+		}
122 129
 
123
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
130
+		if (!isset($globalLiveInterval)) {
131
+			$globalLiveInterval = '200';
132
+		}
124 133
 		if ($globalDBdriver == 'mysql') {
125 134
 			//$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate";
126 135
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -145,7 +154,9 @@  discard block
 block discarded – undo
145 154
 
146 155
 		$filter_query = $this->getFilter($filter,true,true);
147 156
 
148
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
157
+		if (!isset($globalLiveInterval)) {
158
+			$globalLiveInterval = '200';
159
+		}
149 160
 		if ($globalDBdriver == 'mysql') {
150 161
 			$query  = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
151 162
 			FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0";
@@ -179,7 +190,9 @@  discard block
 block discarded – undo
179 190
 
180 191
 		$filter_query = $this->getFilter($filter,true,true);
181 192
 
182
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
193
+		if (!isset($globalLiveInterval)) {
194
+			$globalLiveInterval = '200';
195
+		}
183 196
 		if ($globalDBdriver == 'mysql') {
184 197
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
185 198
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
@@ -212,7 +225,9 @@  discard block
 block discarded – undo
212 225
 		global $globalDBdriver, $globalLiveInterval;
213 226
 		$filter_query = $this->getFilter($filter,true,true);
214 227
 
215
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
228
+		if (!isset($globalLiveInterval)) {
229
+			$globalLiveInterval = '200';
230
+		}
216 231
 		if ($globalDBdriver == 'mysql') {
217 232
 			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
218 233
 		} else {
@@ -240,7 +255,9 @@  discard block
 block discarded – undo
240 255
 	{
241 256
 		global $globalDBdriver, $globalLiveInterval;
242 257
 		$Spotter = new Spotter($this->db);
243
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
258
+		if (!isset($globalLiveInterval)) {
259
+			$globalLiveInterval = '200';
260
+		}
244 261
 		$filter_query = $this->getFilter($filter);
245 262
 
246 263
 		if (is_array($coord)) {
@@ -248,7 +265,9 @@  discard block
 block discarded – undo
248 265
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
249 266
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
250 267
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
251
-		} else return array();
268
+		} else {
269
+			return array();
270
+		}
252 271
 		if ($globalDBdriver == 'mysql') {
253 272
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
254 273
 		} else {
@@ -268,7 +287,9 @@  discard block
 block discarded – undo
268 287
 	{
269 288
 		global $globalDBdriver, $globalLiveInterval;
270 289
 		$Spotter = new Spotter($this->db);
271
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
290
+		if (!isset($globalLiveInterval)) {
291
+			$globalLiveInterval = '200';
292
+		}
272 293
 		$filter_query = $this->getFilter($filter);
273 294
 
274 295
 		if (is_array($coord)) {
@@ -276,7 +297,9 @@  discard block
 block discarded – undo
276 297
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
277 298
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
278 299
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
279
-		} else return array();
300
+		} else {
301
+			return array();
302
+		}
280 303
 		if ($globalDBdriver == 'mysql') {
281 304
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
282 305
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
@@ -444,11 +467,15 @@  discard block
 block discarded – undo
444 467
 		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
445 468
 		if ($globalDBdriver == 'mysql') {
446 469
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
447
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
470
+			if ($liveinterval) {
471
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
472
+			}
448 473
 			$query .= ' ORDER BY date';
449 474
 		} else {
450 475
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
451
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
476
+			if ($liveinterval) {
477
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
478
+			}
452 479
 			$query .= ' ORDER BY date';
453 480
 		}
454 481
 
@@ -543,7 +570,9 @@  discard block
 block discarded – undo
543 570
 				$i++;
544 571
 				$j++;
545 572
 				if ($j == 30) {
546
-					if ($globalDebug) echo ".";
573
+					if ($globalDebug) {
574
+						echo ".";
575
+					}
547 576
 				    	try {
548 577
 						
549 578
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -823,7 +852,9 @@  discard block
 block discarded – undo
823 852
 			{
824 853
 				return false;
825 854
 			}
826
-		} else return '';
855
+		} else {
856
+			return '';
857
+		}
827 858
 
828 859
 		if ($longitude != '')
829 860
 		{
@@ -831,7 +862,9 @@  discard block
 block discarded – undo
831 862
 			{
832 863
 				return false;
833 864
 			}
834
-		} else return '';
865
+		} else {
866
+			return '';
867
+		}
835 868
 
836 869
 
837 870
 		if ($heading != '')
@@ -840,7 +873,9 @@  discard block
 block discarded – undo
840 873
 			{
841 874
 				return false;
842 875
 			}
843
-		} else $heading = 0;
876
+		} else {
877
+			$heading = 0;
878
+		}
844 879
 
845 880
 		if ($groundspeed != '')
846 881
 		{
@@ -848,9 +883,13 @@  discard block
 block discarded – undo
848 883
 			{
849 884
 				return false;
850 885
 			}
851
-		} else $groundspeed = 0;
886
+		} else {
887
+			$groundspeed = 0;
888
+		}
852 889
 		date_default_timezone_set('UTC');
853
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
890
+		if ($date == '') {
891
+			$date = date("Y-m-d H:i:s", time());
892
+		}
854 893
 
855 894
         
856 895
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -871,12 +910,20 @@  discard block
 block discarded – undo
871 910
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
872 911
 		
873 912
 
874
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
875
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
876
-            	if ($arrival_date == '') $arrival_date = NULL;
913
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
914
+            		$groundspeed = 0;
915
+            	}
916
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
917
+            		$heading = 0;
918
+            	}
919
+            	if ($arrival_date == '') {
920
+            		$arrival_date = NULL;
921
+            	}
877 922
             	$query = '';
878 923
 		if ($globalArchive) {
879
-			if ($globalDebug) echo '-- Delete previous data -- ';
924
+			if ($globalDebug) {
925
+				echo '-- Delete previous data -- ';
926
+			}
880 927
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
881 928
 		}
882 929
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
@@ -891,10 +938,14 @@  discard block
 block discarded – undo
891 938
 		}
892 939
 		
893 940
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
894
-			if ($globalDebug) echo '(Add to Marine archive : ';
941
+			if ($globalDebug) {
942
+				echo '(Add to Marine archive : ';
943
+			}
895 944
 			$MarineArchive = new MarineArchive($this->db);
896 945
 			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country);
897
-			if ($globalDebug) echo $result.')';
946
+			if ($globalDebug) {
947
+				echo $result.')';
948
+			}
898 949
 		}
899 950
 		return "success";
900 951
 	}
Please login to merge, or discard this patch.
require/class.APRS.php 1 patch
Braces   +152 added lines, -58 removed lines patch added patch discarded remove patch
@@ -107,17 +107,23 @@  discard block
 block discarded – undo
107 107
 	
108 108
 	/* Check that end was found and body has at least one byte. */
109 109
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
110
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
110
+	    if ($globalDebug) {
111
+	    	echo '!!! APRS invalid : '.$input."\n";
112
+	    }
111 113
 	    return false;
112 114
 	}
113 115
 	
114
-	if ($debug) echo 'input : '.$input."\n";
116
+	if ($debug) {
117
+		echo 'input : '.$input."\n";
118
+	}
115 119
 	/* Save header and body. */
116 120
 	$body = substr($input,$splitpos+1,$input_len);
117 121
 	$body_len = strlen($body);
118 122
 	$header = substr($input,0,$splitpos);
119 123
 	//$header_len = strlen($header);
120
-	if ($debug) echo 'header : '.$header."\n";
124
+	if ($debug) {
125
+		echo 'header : '.$header."\n";
126
+	}
121 127
 	
122 128
 	/* Parse source, target and path. */
123 129
 	//FLRDF0A52>APRS,qAS,LSTB
@@ -131,10 +137,14 @@  discard block
 block discarded – undo
131 137
 		$result['format_source'] = 'famaprs';
132 138
 		$result['source_type'] = 'ais';
133 139
 	    } else {
134
-		if ($debug) echo 'ident : '.$ident."\n";
140
+		if ($debug) {
141
+			echo 'ident : '.$ident."\n";
142
+		}
135 143
 		$result['ident'] = $ident;
136 144
 	    }
137
-	} else return false;
145
+	} else {
146
+		return false;
147
+	}
138 148
 	$elements = explode(',',$all_elements);
139 149
 	$source = end($elements);
140 150
 	$result['source'] = $source;
@@ -143,7 +153,9 @@  discard block
 block discarded – undo
143 153
 	        //echo "ok";
144 154
 	        //if ($element == 'TCPIP*') return false;
145 155
 	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
146
-		if ($debug) echo 'element : '.$element."\n";
156
+		if ($debug) {
157
+			echo 'element : '.$element."\n";
158
+		}
147 159
 		return false;
148 160
 	    }
149 161
 	    /*
@@ -156,13 +168,17 @@  discard block
 block discarded – undo
156 168
 	}
157 169
 	
158 170
 	$type = substr($body,0,1);
159
-	if ($debug) echo 'type : '.$type."\n";
171
+	if ($debug) {
172
+		echo 'type : '.$type."\n";
173
+	}
160 174
 	if ($type == ';') {
161 175
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
162 176
 			$result['address'] = trim(substr($body,1,9));
163 177
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
164 178
 			$result['mmsi'] = trim(substr($body,1,9));
165
-		} else $result['ident'] = trim(substr($body,1,9));
179
+		} else {
180
+			$result['ident'] = trim(substr($body,1,9));
181
+		}
166 182
 	} elseif ($type == ',') {
167 183
 		// Invalid data or test data
168 184
 		return false;
@@ -230,7 +246,9 @@  discard block
 block discarded – undo
230 246
 		//$symbol_table = $matches[4];
231 247
 		$lat = intval($lat_deg);
232 248
 		$lon = intval($lon_deg);
233
-		if ($lat > 89 || $lon > 179) return false;
249
+		if ($lat > 89 || $lon > 179) {
250
+			return false;
251
+		}
234 252
 	    
235 253
 	    /*
236 254
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -240,8 +258,12 @@  discard block
 block discarded – undo
240 258
 	    */
241 259
 		$latitude = $lat + floatval($lat_min)/60;
242 260
 		$longitude = $lon + floatval($lon_min)/60;
243
-		if ($sind == 'S') $latitude = 0-$latitude;
244
-		if ($wind == 'W') $longitude = 0-$longitude;
261
+		if ($sind == 'S') {
262
+			$latitude = 0-$latitude;
263
+		}
264
+		if ($wind == 'W') {
265
+			$longitude = 0-$longitude;
266
+		}
245 267
 		$result['latitude'] = $latitude;
246 268
 		$result['longitude'] = $longitude;
247 269
 		$body_parse = substr($body_parse,18);
@@ -275,7 +297,9 @@  discard block
 block discarded – undo
275 297
 			$body_parse = substr($body_parse,1);
276 298
 			$body_parse_len = strlen($body_parse);
277 299
 			$result['symbol_code'] = $symbol_code;
278
-			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
300
+			if (isset($this->symbols[$symbol_code])) {
301
+				$result['symbol'] = $this->symbols[$symbol_code];
302
+			}
279 303
 			if ($symbol_code != '_') {
280 304
 			}
281 305
 		    //$body_parse = substr($body_parse,1);
@@ -286,7 +310,9 @@  discard block
 block discarded – undo
286 310
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
287 311
 		    	    $course = substr($body_parse,0,3);
288 312
 		    	    $tmp_s = intval($course);
289
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
313
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
314
+		    	    	$result['heading'] = intval($course);
315
+		    	    }
290 316
 		    	    $speed = substr($body_parse,4,3);
291 317
 		    	    if ($speed != '...') {
292 318
 		    		//$result['speed'] = round($speed*1.852);
@@ -327,10 +353,16 @@  discard block
 block discarded – undo
327 353
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
328 354
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
329 355
 			    
330
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
331
-				else $result['latitude'] += $lat_off;
332
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
333
-				else $result['longitude'] += $lon_off;
356
+				if ($result['latitude'] < 0) {
357
+					$result['latitude'] -= $lat_off;
358
+				} else {
359
+					$result['latitude'] += $lat_off;
360
+				}
361
+				if ($result['longitude'] < 0) {
362
+					$result['longitude'] -= $lon_off;
363
+				} else {
364
+					$result['longitude'] += $lon_off;
365
+				}
334 366
 			    }
335 367
 			    
336 368
 		            $body_parse = substr($body_parse,6);
@@ -369,27 +401,48 @@  discard block
 block discarded – undo
369 401
 			$address = substr($id,2);
370 402
 			//print_r($matches);
371 403
 			$addressType = (intval(substr($id,0,2),16))&3;
372
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
373
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
374
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
375
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
404
+			if ($addressType == 0) {
405
+				$result['addresstype'] = "RANDOM";
406
+			} elseif ($addressType == 1) {
407
+				$result['addresstype'] = "ICAO";
408
+			} elseif ($addressType == 2) {
409
+				$result['addresstype'] = "FLARM";
410
+			} elseif ($addressType == 3) {
411
+				$result['addresstype'] = "OGN";
412
+			}
376 413
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
377 414
 			$result['aircrafttype_code'] = $aircraftType;
378
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
379
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
380
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
381
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
382
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
383
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
384
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
385
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
386
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
387
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
388
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
389
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
390
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
391
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
392
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
415
+			if ($aircraftType == 0) {
416
+				$result['aircrafttype'] = "UNKNOWN";
417
+			} elseif ($aircraftType == 1) {
418
+				$result['aircrafttype'] = "GLIDER";
419
+			} elseif ($aircraftType == 2) {
420
+				$result['aircrafttype'] = "TOW_PLANE";
421
+			} elseif ($aircraftType == 3) {
422
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
423
+			} elseif ($aircraftType == 4) {
424
+				$result['aircrafttype'] = "PARACHUTE";
425
+			} elseif ($aircraftType == 5) {
426
+				$result['aircrafttype'] = "DROP_PLANE";
427
+			} elseif ($aircraftType == 6) {
428
+				$result['aircrafttype'] = "HANG_GLIDER";
429
+			} elseif ($aircraftType == 7) {
430
+				$result['aircrafttype'] = "PARA_GLIDER";
431
+			} elseif ($aircraftType == 8) {
432
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
433
+			} elseif ($aircraftType == 9) {
434
+				$result['aircrafttype'] = "JET_AIRCRAFT";
435
+			} elseif ($aircraftType == 10) {
436
+				$result['aircrafttype'] = "UFO";
437
+			} elseif ($aircraftType == 11) {
438
+				$result['aircrafttype'] = "BALLOON";
439
+			} elseif ($aircraftType == 12) {
440
+				$result['aircrafttype'] = "AIRSHIP";
441
+			} elseif ($aircraftType == 13) {
442
+				$result['aircrafttype'] = "UAV";
443
+			} elseif ($aircraftType == 15) {
444
+				$result['aircrafttype'] = "STATIC_OBJECT";
445
+			}
393 446
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
394 447
 			$result['stealth'] = $stealth;
395 448
 			$result['address'] = $address;
@@ -429,13 +482,21 @@  discard block
 block discarded – undo
429 482
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
430 483
 		    }
431 484
 		}
432
-		} else $result['comment'] = trim($body_parse);
485
+		} else {
486
+			$result['comment'] = trim($body_parse);
487
+		}
433 488
 
434 489
 	    }
435 490
 	//}
436
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
437
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
438
-	if ($debug) print_r($result);
491
+	if (isset($result['latitude'])) {
492
+		$result['latitude'] = round($result['latitude'],4);
493
+	}
494
+	if (isset($result['longitude'])) {
495
+		$result['longitude'] = round($result['longitude'],4);
496
+	}
497
+	if ($debug) {
498
+		print_r($result);
499
+	}
439 500
 	return $result;
440 501
     }
441 502
     
@@ -444,12 +505,21 @@  discard block
 block discarded – undo
444 505
 	$aprs_connect = 0;
445 506
 	$aprs_keep = 120;
446 507
 	$aprs_last_tx = time();
447
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
448
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
449
-	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
450
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
451
-	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
452
-	else $aprs_pass = '-1';
508
+	if (isset($globalAPRSversion)) {
509
+		$aprs_version = $globalAPRSversion;
510
+	} else {
511
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
512
+	}
513
+	if (isset($globalServerAPRSssid)) {
514
+		$aprs_ssid = $globalServerAPRSssid;
515
+	} else {
516
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
517
+	}
518
+	if (isset($globalServerAPRSpass)) {
519
+		$aprs_pass = $globalServerAPRSpass;
520
+	} else {
521
+		$aprs_pass = '-1';
522
+	}
453 523
 	
454 524
 	$aprs_filter  = '';
455 525
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
@@ -481,7 +551,9 @@  discard block
 block discarded – undo
481 551
     }
482 552
     
483 553
     public function send($data) {
484
-	if ($this->connected === false) $this->connect();
554
+	if ($this->connected === false) {
555
+		$this->connect();
556
+	}
485 557
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
486 558
 	if ($send === FALSE) {
487 559
 		socket_close($this->socket);
@@ -503,18 +575,26 @@  discard block
 block discarded – undo
503 575
 			//$w = '00';
504 576
 			$custom = '';
505 577
 			if ($ident != '') {
506
-				if ($custom != '') $custom .= '/';
578
+				if ($custom != '') {
579
+					$custom .= '/';
580
+				}
507 581
 				$custom .= 'CS='.$ident;
508 582
 			}
509 583
 			if ($squawk != '') {
510
-				if ($custom != '') $custom .= '/';
584
+				if ($custom != '') {
585
+					$custom .= '/';
586
+				}
511 587
 				$custom .= 'SQ='.$squawk;
512 588
 			}
513 589
 			if ($aircraft_icao != '' && $aircraft_icao != 'NA') {
514
-				if ($custom != '') $custom .= '/';
590
+				if ($custom != '') {
591
+					$custom .= '/';
592
+				}
515 593
 				$custom .= 'AI='.$aircraft_icao;
516 594
 			}
517
-			if ($custom != '') $custom = ' '.$custom;
595
+			if ($custom != '') {
596
+				$custom = ' '.$custom;
597
+			}
518 598
 			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
519 599
 		}
520 600
 	}
@@ -532,30 +612,44 @@  discard block
 block discarded – undo
532 612
 			//$w = '00';
533 613
 			$custom = '';
534 614
 			if ($ident != '') {
535
-				if ($custom != '') $custom .= '/';
615
+				if ($custom != '') {
616
+					$custom .= '/';
617
+				}
536 618
 				$custom .= 'CS='.str_replace(' ','_',$ident);
537 619
 			}
538 620
 			if ($typeid != '') {
539
-				if ($custom != '') $custom .= '/';
621
+				if ($custom != '') {
622
+					$custom .= '/';
623
+				}
540 624
 				$custom .= 'TI='.$typeid;
541 625
 			}
542 626
 			if ($statusid != '') {
543
-				if ($custom != '') $custom .= '/';
627
+				if ($custom != '') {
628
+					$custom .= '/';
629
+				}
544 630
 				$custom .= 'SI='.$statusid;
545 631
 			}
546 632
 			if ($imo != '') {
547
-				if ($custom != '') $custom .= '/';
633
+				if ($custom != '') {
634
+					$custom .= '/';
635
+				}
548 636
 				$custom .= 'IMO='.$imo;
549 637
 			}
550 638
 			if ($arrival_date != '') {
551
-				if ($custom != '') $custom .= '/';
639
+				if ($custom != '') {
640
+					$custom .= '/';
641
+				}
552 642
 				$custom .= 'AD='.strtotime($arrival_date);
553 643
 			}
554 644
 			if ($arrival_code != '') {
555
-				if ($custom != '') $custom .= '/';
645
+				if ($custom != '') {
646
+					$custom .= '/';
647
+				}
556 648
 				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
557 649
 			}
558
-			if ($custom != '') $custom = ' '.$custom;
650
+			if ($custom != '') {
651
+				$custom = ' '.$custom;
652
+			}
559 653
 			$altitude = 0;
560 654
 			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
561 655
 		}
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Braces   +83 added lines, -28 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -118,8 +120,11 @@  discard block
 block discarded – undo
118 120
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
119 121
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
120 122
 		}
121
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
122
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
123
+		if ($filter_query_where == '' && $where) {
124
+			$filter_query_where = ' WHERE';
125
+		} elseif ($filter_query_where != '' && $and) {
126
+			$filter_query_where .= ' AND';
127
+		}
123 128
 		if ($filter_query_where != '') {
124 129
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
125 130
 		}
@@ -160,9 +165,13 @@  discard block
 block discarded – undo
160 165
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
161 166
 			}
162 167
 		}
163
-		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
168
+		if ($orderby_query == '') {
169
+			$orderby_query = ' ORDER BY date DESC';
170
+		}
164 171
 
165
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
172
+		if (!isset($globalLiveInterval)) {
173
+			$globalLiveInterval = '200';
174
+		}
166 175
 		if ($globalDBdriver == 'mysql') {
167 176
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
168 177
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -185,7 +194,9 @@  discard block
 block discarded – undo
185 194
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
186 195
 		date_default_timezone_set('UTC');
187 196
 		$filter_query = $this->getFilter($filter,true,true);
188
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
197
+		if (!isset($globalLiveInterval)) {
198
+			$globalLiveInterval = '200';
199
+		}
189 200
 		if ($globalDBdriver == 'mysql') {
190 201
 			if (isset($globalArchive) && $globalArchive === TRUE) {
191 202
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -228,7 +239,9 @@  discard block
 block discarded – undo
228 239
 
229 240
 		$filter_query = $this->getFilter($filter,true,true);
230 241
 
231
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
242
+		if (!isset($globalLiveInterval)) {
243
+			$globalLiveInterval = '200';
244
+		}
232 245
 		if ($globalDBdriver == 'mysql') {
233 246
 			if (isset($globalArchive) && $globalArchive === TRUE) {
234 247
 				$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
@@ -273,7 +286,9 @@  discard block
 block discarded – undo
273 286
 		global $globalDBdriver, $globalLiveInterval;
274 287
 		$filter_query = $this->getFilter($filter,true,true);
275 288
 
276
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
289
+		if (!isset($globalLiveInterval)) {
290
+			$globalLiveInterval = '200';
291
+		}
277 292
 		if ($globalDBdriver == 'mysql') {
278 293
 			//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
279 294
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -303,7 +318,9 @@  discard block
 block discarded – undo
303 318
 	{
304 319
 		global $globalDBdriver, $globalLiveInterval;
305 320
 		$Spotter = new Spotter($this->db);
306
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
321
+		if (!isset($globalLiveInterval)) {
322
+			$globalLiveInterval = '200';
323
+		}
307 324
 		$filter_query = $this->getFilter($filter);
308 325
 
309 326
 		if (is_array($coord)) {
@@ -311,7 +328,9 @@  discard block
 block discarded – undo
311 328
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
312 329
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
313 330
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
314
-		} else return array();
331
+		} else {
332
+			return array();
333
+		}
315 334
 		if ($globalDBdriver == 'mysql') {
316 335
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
317 336
 		} else {
@@ -332,7 +351,9 @@  discard block
 block discarded – undo
332 351
 	{
333 352
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
334 353
 		$Spotter = new Spotter($this->db);
335
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
354
+		if (!isset($globalLiveInterval)) {
355
+			$globalLiveInterval = '200';
356
+		}
336 357
 		$filter_query = $this->getFilter($filter,true,true);
337 358
 
338 359
 		if (is_array($coord)) {
@@ -340,7 +361,9 @@  discard block
 block discarded – undo
340 361
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
341 362
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
342 363
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
343
-		} else return array();
364
+		} else {
365
+			return array();
366
+		}
344 367
 		if ($globalDBdriver == 'mysql') {
345 368
 			if (isset($globalArchive) && $globalArchive === TRUE) {
346 369
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -571,11 +594,15 @@  discard block
 block discarded – undo
571 594
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
572 595
 		if ($globalDBdriver == 'mysql') {
573 596
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
574
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
597
+			if ($liveinterval) {
598
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
599
+			}
575 600
 			$query .= ' ORDER BY date';
576 601
 		} else {
577 602
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
578
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
603
+			if ($liveinterval) {
604
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
605
+			}
579 606
 			$query .= ' ORDER BY date';
580 607
 		}
581 608
 
@@ -670,7 +697,9 @@  discard block
 block discarded – undo
670 697
 				$i++;
671 698
 				$j++;
672 699
 				if ($j == 30) {
673
-					if ($globalDebug) echo ".";
700
+					if ($globalDebug) {
701
+						echo ".";
702
+					}
674 703
 				    	try {
675 704
 						
676 705
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -977,7 +1006,9 @@  discard block
 block discarded – undo
977 1006
 			{
978 1007
 				return false;
979 1008
 			}
980
-		} else return '';
1009
+		} else {
1010
+			return '';
1011
+		}
981 1012
 
982 1013
 		if ($longitude != '')
983 1014
 		{
@@ -985,7 +1016,9 @@  discard block
 block discarded – undo
985 1016
 			{
986 1017
 				return false;
987 1018
 			}
988
-		} else return '';
1019
+		} else {
1020
+			return '';
1021
+		}
989 1022
 
990 1023
 		if ($waypoints != '')
991 1024
 		{
@@ -1001,7 +1034,9 @@  discard block
 block discarded – undo
1001 1034
 			{
1002 1035
 				return false;
1003 1036
 			}
1004
-		} else $altitude = 0;
1037
+		} else {
1038
+			$altitude = 0;
1039
+		}
1005 1040
 
1006 1041
 		if ($heading != '')
1007 1042
 		{
@@ -1009,7 +1044,9 @@  discard block
 block discarded – undo
1009 1044
 			{
1010 1045
 				return false;
1011 1046
 			}
1012
-		} else $heading = 0;
1047
+		} else {
1048
+			$heading = 0;
1049
+		}
1013 1050
 
1014 1051
 		if ($groundspeed != '')
1015 1052
 		{
@@ -1017,9 +1054,13 @@  discard block
 block discarded – undo
1017 1054
 			{
1018 1055
 				return false;
1019 1056
 			}
1020
-		} else $groundspeed = 0;
1057
+		} else {
1058
+			$groundspeed = 0;
1059
+		}
1021 1060
 		date_default_timezone_set('UTC');
1022
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1061
+		if ($date == '') {
1062
+			$date = date("Y-m-d H:i:s", time());
1063
+		}
1023 1064
 
1024 1065
         
1025 1066
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1063,14 +1104,24 @@  discard block
 block discarded – undo
1063 1104
 		$arrival_airport_country = '';
1064 1105
 		
1065 1106
             	
1066
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1067
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1068
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1069
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1107
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1108
+            		$squawk = NULL;
1109
+            	}
1110
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1111
+            		$verticalrate = NULL;
1112
+            	}
1113
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1114
+            		$groundspeed = 0;
1115
+            	}
1116
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1117
+            		$heading = 0;
1118
+            	}
1070 1119
 		
1071 1120
 		$query = '';
1072 1121
 		if ($globalArchive) {
1073
-			if ($globalDebug) echo '-- Delete previous data -- ';
1122
+			if ($globalDebug) {
1123
+				echo '-- Delete previous data -- ';
1124
+			}
1074 1125
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1075 1126
 		}
1076 1127
 
@@ -1087,10 +1138,14 @@  discard block
 block discarded – undo
1087 1138
 			return "error : ".$e->getMessage();
1088 1139
 		}
1089 1140
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1090
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1141
+		    if ($globalDebug) {
1142
+		    	echo '(Add to SBS archive : ';
1143
+		    }
1091 1144
 		    $SpotterArchive = new SpotterArchive($this->db);
1092 1145
 		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1093
-		    if ($globalDebug) echo $result.')';
1146
+		    if ($globalDebug) {
1147
+		    	echo $result.')';
1148
+		    }
1094 1149
 		}
1095 1150
 		return "success";
1096 1151
 
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Braces   +156 added lines, -56 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -68,8 +70,11 @@  discard block
 block discarded – undo
68 70
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
69 71
 			}
70 72
 		}
71
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73
+		if ($filter_query_where == '' && $where) {
74
+			$filter_query_where = ' WHERE';
75
+		} elseif ($filter_query_where != '' && $and) {
76
+			$filter_query_where .= ' AND';
77
+		}
73 78
 		if ($filter_query_where != '') {
74 79
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
75 80
 		}
@@ -123,32 +128,54 @@  discard block
 block discarded – undo
123 128
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
124 129
 			} elseif (isset($row['spotter_archive_output_id'])) {
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
126
-			*/} 
127
-			elseif (isset($row['marineid'])) {
131
+			*/} elseif (isset($row['marineid'])) {
128 132
 				$temp_array['marine_id'] = $row['marineid'];
129 133
 			} else {
130 134
 				$temp_array['marine_id'] = '';
131 135
 			}
132
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
133
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
134
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
135
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
136
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
137
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
138
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
139
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
136
+			if (isset($row['fammarine_id'])) {
137
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
138
+			}
139
+			if (isset($row['mmsi'])) {
140
+				$temp_array['mmsi'] = $row['mmsi'];
141
+			}
142
+			if (isset($row['type'])) {
143
+				$temp_array['type'] = $row['type'];
144
+			}
145
+			if (isset($row['type_id'])) {
146
+				$temp_array['type_id'] = $row['type_id'];
147
+			}
148
+			if (isset($row['ident'])) {
149
+				$temp_array['ident'] = $row['ident'];
150
+			}
151
+			if (isset($row['latitude'])) {
152
+				$temp_array['latitude'] = $row['latitude'];
153
+			}
154
+			if (isset($row['longitude'])) {
155
+				$temp_array['longitude'] = $row['longitude'];
156
+			}
157
+			if (isset($row['format_source'])) {
158
+				$temp_array['format_source'] = $row['format_source'];
159
+			}
140 160
 			if (isset($row['heading'])) {
141 161
 				$temp_array['heading'] = $row['heading'];
142 162
 				$heading_direction = $this->parseDirection($row['heading']);
143
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
163
+				if (isset($heading_direction[0]['direction_fullname'])) {
164
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
165
+				}
166
+			}
167
+			if (isset($row['ground_speed'])) {
168
+				$temp_array['ground_speed'] = $row['ground_speed'];
144 169
 			}
145
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
146 170
 
147 171
 			if($temp_array['mmsi'] != "")
148 172
 			{
149 173
 				$Image = new Image($this->db);
150
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
151
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
174
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
175
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
176
+				} else {
177
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
178
+				}
152 179
 				unset($Image);
153 180
 				if (count($image_array) > 0) {
154 181
 					$temp_array['image'] = $image_array[0]['image'];
@@ -200,13 +227,21 @@  discard block
 block discarded – undo
200 227
 			}
201 228
 			
202 229
 			$fromsource = NULL;
203
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
204
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
205
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
230
+			if (isset($row['source_name']) && $row['source_name'] != '') {
231
+				$temp_array['source_name'] = $row['source_name'];
232
+			}
233
+			if (isset($row['over_country']) && $row['over_country'] != '') {
234
+				$temp_array['over_country'] = $row['over_country'];
235
+			}
236
+			if (isset($row['distance']) && $row['distance'] != '') {
237
+				$temp_array['distance'] = $row['distance'];
238
+			}
206 239
 			$temp_array['query_number_rows'] = $num_rows;
207 240
 			$spotter_array[] = $temp_array;
208 241
 		}
209
-		if ($num_rows == 0) return array();
242
+		if ($num_rows == 0) {
243
+			return array();
244
+		}
210 245
 		$spotter_array[0]['query_number_rows'] = $num_rows;
211 246
 		return $spotter_array;
212 247
 	}	
@@ -232,8 +267,12 @@  discard block
 block discarded – undo
232 267
 			{
233 268
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
234 269
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
235
-			} else $limit_query = "";
236
-		} else $limit_query = "";
270
+			} else {
271
+				$limit_query = "";
272
+			}
273
+		} else {
274
+			$limit_query = "";
275
+		}
237 276
 		if ($sort != "")
238 277
 		{
239 278
 			$search_orderby_array = $this->getOrderBy();
@@ -257,7 +296,9 @@  discard block
 block discarded – undo
257 296
 		global $global_query;
258 297
 		
259 298
 		date_default_timezone_set('UTC');
260
-		if ($id == '') return array();
299
+		if ($id == '') {
300
+			return array();
301
+		}
261 302
 		$additional_query = "marine_output.fammarine_id = :id";
262 303
 		$query_values = array(':id' => $id);
263 304
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -400,8 +441,11 @@  discard block
 block discarded – undo
400 441
 		$query .= " ORDER BY marine_output.source_name ASC";
401 442
 
402 443
 		$sth = $this->db->prepare($query);
403
-		if (!empty($query_values)) $sth->execute($query_values);
404
-		else $sth->execute();
444
+		if (!empty($query_values)) {
445
+			$sth->execute($query_values);
446
+		} else {
447
+			$sth->execute();
448
+		}
405 449
 
406 450
 		$source_array = array();
407 451
 		$temp_array = array();
@@ -456,8 +500,11 @@  discard block
 block discarded – undo
456 500
 		$sth = $this->db->prepare($query);
457 501
 		$sth->execute(array(':mmsi' => $mmsi));
458 502
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
459
-		if (isset($result[0])) return $result[0];
460
-		else return array();
503
+		if (isset($result[0])) {
504
+			return $result[0];
505
+		} else {
506
+			return array();
507
+		}
461 508
 	}
462 509
 
463 510
 	/*
@@ -473,7 +520,9 @@  discard block
 block discarded – undo
473 520
 			date_default_timezone_set($globalTimezone);
474 521
 			$datetime = new DateTime();
475 522
 			$offset = $datetime->format('P');
476
-		} else $offset = '+00:00';
523
+		} else {
524
+			$offset = '+00:00';
525
+		}
477 526
 
478 527
 		if ($globalDBdriver == 'mysql') {
479 528
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -677,9 +726,15 @@  discard block
 block discarded – undo
677 726
             		$latitude = 0;
678 727
             		$longitude = 0;
679 728
             	}
680
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
681
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
682
-                if ($arrival_date == '') $arrival_date = NULL;
729
+                if ($heading == '' || $Common->isInteger($heading) === false) {
730
+                	$heading = 0;
731
+                }
732
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
733
+                	$groundspeed = 0;
734
+                }
735
+                if ($arrival_date == '') {
736
+                	$arrival_date = NULL;
737
+                }
683 738
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
684 739
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
685 740
 
@@ -843,12 +898,18 @@  discard block
 block discarded – undo
843 898
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
844 899
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
845 900
 		 if ($olderthanmonths > 0) {
846
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
847
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
901
+			if ($globalDBdriver == 'mysql') {
902
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
903
+			} else {
904
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
905
+			}
848 906
 		}
849 907
 		if ($sincedate != '') {
850
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
851
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
908
+			if ($globalDBdriver == 'mysql') {
909
+				$query .= " AND marine_output.date > '".$sincedate."'";
910
+			} else {
911
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
912
+			}
852 913
 		}
853 914
 		$query_values = array();
854 915
 		if ($year != '') {
@@ -879,7 +940,9 @@  discard block
 block discarded – undo
879 940
 			}
880 941
 		}
881 942
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
882
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
943
+		if ($limit) {
944
+			$query .= " LIMIT 10 OFFSET 0";
945
+		}
883 946
       		
884 947
 		$sth = $this->db->prepare($query);
885 948
 		$sth->execute($query_values);
@@ -914,7 +977,9 @@  discard block
 block discarded – undo
914 977
 			date_default_timezone_set($globalTimezone);
915 978
 			$datetime = new DateTime();
916 979
 			$offset = $datetime->format('P');
917
-		} else $offset = '+00:00';
980
+		} else {
981
+			$offset = '+00:00';
982
+		}
918 983
 
919 984
 		if ($globalDBdriver == 'mysql') {
920 985
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -964,7 +1029,9 @@  discard block
 block discarded – undo
964 1029
 			date_default_timezone_set($globalTimezone);
965 1030
 			$datetime = new DateTime();
966 1031
 			$offset = $datetime->format('P');
967
-		} else $offset = '+00:00';
1032
+		} else {
1033
+			$offset = '+00:00';
1034
+		}
968 1035
 		$filter_query = $this->getFilter($filters,true,true);
969 1036
 		if ($globalDBdriver == 'mysql') {
970 1037
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1010,7 +1077,9 @@  discard block
 block discarded – undo
1010 1077
 			date_default_timezone_set($globalTimezone);
1011 1078
 			$datetime = new DateTime();
1012 1079
 			$offset = $datetime->format('P');
1013
-		} else $offset = '+00:00';
1080
+		} else {
1081
+			$offset = '+00:00';
1082
+		}
1014 1083
 		$filter_query = $this->getFilter($filters,true,true);
1015 1084
 		if ($globalDBdriver == 'mysql') {
1016 1085
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1058,7 +1127,9 @@  discard block
 block discarded – undo
1058 1127
 			date_default_timezone_set($globalTimezone);
1059 1128
 			$datetime = new DateTime();
1060 1129
 			$offset = $datetime->format('P');
1061
-		} else $offset = '+00:00';
1130
+		} else {
1131
+			$offset = '+00:00';
1132
+		}
1062 1133
 
1063 1134
 		if ($globalDBdriver == 'mysql') {
1064 1135
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1107,7 +1178,9 @@  discard block
 block discarded – undo
1107 1178
 			date_default_timezone_set($globalTimezone);
1108 1179
 			$datetime = new DateTime();
1109 1180
 			$offset = $datetime->format('P');
1110
-		} else $offset = '+00:00';
1181
+		} else {
1182
+			$offset = '+00:00';
1183
+		}
1111 1184
 		$filter_query = $this->getFilter($filters,true,true);
1112 1185
 		if ($globalDBdriver == 'mysql') {
1113 1186
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1156,7 +1229,9 @@  discard block
 block discarded – undo
1156 1229
 			date_default_timezone_set($globalTimezone);
1157 1230
 			$datetime = new DateTime();
1158 1231
 			$offset = $datetime->format('P');
1159
-		} else $offset = '+00:00';
1232
+		} else {
1233
+			$offset = '+00:00';
1234
+		}
1160 1235
 
1161 1236
 		$orderby_sql = '';
1162 1237
 		if ($orderby == "hour")
@@ -1225,7 +1300,9 @@  discard block
 block discarded – undo
1225 1300
 			date_default_timezone_set($globalTimezone);
1226 1301
 			$datetime = new DateTime($date);
1227 1302
 			$offset = $datetime->format('P');
1228
-		} else $offset = '+00:00';
1303
+		} else {
1304
+			$offset = '+00:00';
1305
+		}
1229 1306
 
1230 1307
 		if ($globalDBdriver == 'mysql') {
1231 1308
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1273,7 +1350,9 @@  discard block
 block discarded – undo
1273 1350
 			date_default_timezone_set($globalTimezone);
1274 1351
 			$datetime = new DateTime();
1275 1352
 			$offset = $datetime->format('P');
1276
-		} else $offset = '+00:00';
1353
+		} else {
1354
+			$offset = '+00:00';
1355
+		}
1277 1356
 
1278 1357
 		if ($globalDBdriver == 'mysql') {
1279 1358
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1337,8 +1416,11 @@  discard block
 block discarded – undo
1337 1416
 				$query_values = array_merge($query_values,array(':month' => $month));
1338 1417
 			}
1339 1418
 		}
1340
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1341
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1419
+		if (empty($query_values)) {
1420
+			$queryi .= $this->getFilter($filters);
1421
+		} else {
1422
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1423
+		}
1342 1424
 		
1343 1425
 		$sth = $this->db->prepare($queryi);
1344 1426
 		$sth->execute($query_values);
@@ -1360,7 +1442,9 @@  discard block
 block discarded – undo
1360 1442
 			date_default_timezone_set($globalTimezone);
1361 1443
 			$datetime = new DateTime();
1362 1444
 			$offset = $datetime->format('P');
1363
-		} else $offset = '+00:00';
1445
+		} else {
1446
+			$offset = '+00:00';
1447
+		}
1364 1448
 
1365 1449
 		if ($globalDBdriver == 'mysql') {
1366 1450
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1464,7 +1548,9 @@  discard block
 block discarded – undo
1464 1548
 	*/
1465 1549
 	public function parseDirection($direction = 0)
1466 1550
 	{
1467
-		if ($direction == '') $direction = 0;
1551
+		if ($direction == '') {
1552
+			$direction = 0;
1553
+		}
1468 1554
 		$direction_array = array();
1469 1555
 		$temp_array = array();
1470 1556
 
@@ -1553,7 +1639,9 @@  discard block
 block discarded – undo
1553 1639
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1554 1640
 	
1555 1641
 		$Connection = new Connection($this->db);
1556
-		if (!$Connection->tableExists('countries')) return '';
1642
+		if (!$Connection->tableExists('countries')) {
1643
+			return '';
1644
+		}
1557 1645
 	
1558 1646
 		try {
1559 1647
 			/*
@@ -1573,9 +1661,13 @@  discard block
 block discarded – undo
1573 1661
 			$sth->closeCursor();
1574 1662
 			if (count($row) > 0) {
1575 1663
 				return $row;
1576
-			} else return '';
1664
+			} else {
1665
+				return '';
1666
+			}
1577 1667
 		} catch (PDOException $e) {
1578
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1668
+			if (isset($globalDebug) && $globalDebug) {
1669
+				echo 'Error : '.$e->getMessage()."\n";
1670
+			}
1579 1671
 			return '';
1580 1672
 		}
1581 1673
 	
@@ -1593,7 +1685,9 @@  discard block
 block discarded – undo
1593 1685
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1594 1686
 	
1595 1687
 		$Connection = new Connection($this->db);
1596
-		if (!$Connection->tableExists('countries')) return '';
1688
+		if (!$Connection->tableExists('countries')) {
1689
+			return '';
1690
+		}
1597 1691
 	
1598 1692
 		try {
1599 1693
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1605,9 +1699,13 @@  discard block
 block discarded – undo
1605 1699
 			$sth->closeCursor();
1606 1700
 			if (count($row) > 0) {
1607 1701
 				return $row;
1608
-			} else return '';
1702
+			} else {
1703
+				return '';
1704
+			}
1609 1705
 		} catch (PDOException $e) {
1610
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1706
+			if (isset($globalDebug) && $globalDebug) {
1707
+				echo 'Error : '.$e->getMessage()."\n";
1708
+			}
1611 1709
 			return '';
1612 1710
 		}
1613 1711
 	
@@ -1625,7 +1723,9 @@  discard block
 block discarded – undo
1625 1723
 	{
1626 1724
 		global $globalBitlyAccessToken;
1627 1725
 		
1628
-		if ($globalBitlyAccessToken == '') return $url;
1726
+		if ($globalBitlyAccessToken == '') {
1727
+			return $url;
1728
+		}
1629 1729
         
1630 1730
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1631 1731
 		
Please login to merge, or discard this patch.
require/class.AIS.php 1 patch
Braces   +331 added lines, -143 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@  discard block
 block discarded – undo
35 35
 			$temp += 1;
36 36
 			$flat = (float)($temp / (60.0 * 10000.0));
37 37
 			$flat *= -1.0;
38
-		} else $flat = (float)($temp / (60.0 * 10000.0));
38
+		} else {
39
+			$flat = (float)($temp / (60.0 * 10000.0));
40
+		}
39 41
 		return $flat; // float
40 42
 	}
41 43
 
@@ -47,7 +49,9 @@  discard block
 block discarded – undo
47 49
 			$temp += 1;
48 50
 			$flon = (float)($temp / (60.0 * 10000.0));
49 51
 			$flon *= -1.0;
50
-		} else $flon = (float)($temp / (60.0 * 10000.0));
52
+		} else {
53
+			$flon = (float)($temp / (60.0 * 10000.0));
54
+		}
51 55
 		return $flon;
52 56
 	}
53 57
 
@@ -70,10 +74,8 @@  discard block
 block discarded – undo
70 74
     */
71 75
 	private function asciidec_2_8bit($ascii) {
72 76
 		//only process in the following range: 48-87, 96-119
73
-		if ($ascii < 48) { }
74
-		else {
75
-			if($ascii>119) { }
76
-			else {
77
+		if ($ascii < 48) { } else {
78
+			if($ascii>119) { } else {
77 79
 				if ($ascii>87 && $ascii<96) ;
78 80
 				else {
79 81
 					$ascii=$ascii+40;
@@ -175,7 +177,9 @@  discard block
 block discarded – undo
175 177
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
176 178
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
177 179
 			$ro->heading = bindec(substr($_aisdata,124,9));
178
-			if ($ro->heading == 511) $ro->heading = '';
180
+			if ($ro->heading == 511) {
181
+				$ro->heading = '';
182
+			}
179 183
 			$ro->cls = 2; // class B
180 184
 		} else if ($ro->id == 19) {
181 185
 			$ro->cog = bindec(substr($_aisdata,112,12))/10;
@@ -185,7 +189,9 @@  discard block
 block discarded – undo
185 189
 			$ro->name = $this->binchar($_aisdata,143,120);
186 190
 			$ro->cls = 2; // class B
187 191
 			$ro->heading = bindec(substr($_aisdata,124,9));
188
-			if ($ro->heading == 511) $ro->heading = '';
192
+			if ($ro->heading == 511) {
193
+				$ro->heading = '';
194
+			}
189 195
 			$ro->typeid = bindec(substr($_aisdata,263,8));
190 196
 			$ro->type = $this->getShipType($ro->typeid);
191 197
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
@@ -216,9 +222,13 @@  discard block
 block discarded – undo
216 222
 			$ro->cls = 2; // class B
217 223
 		} else if ($ro->id == 27) {
218 224
 			$ro->cog = bindec(substr($_aisdata,85,9));
219
-			if ($ro->cog == 511) $ro->cog = 0.0;
225
+			if ($ro->cog == 511) {
226
+				$ro->cog = 0.0;
227
+			}
220 228
 			$ro->sog = bindec(substr($_aisdata,79,6));
221
-			if ($ro->sog == 63) $ro->sog = 0.0;
229
+			if ($ro->sog == 63) {
230
+				$ro->sog = 0.0;
231
+			}
222 232
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
223 233
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
224 234
 			$ro->cls = 1; // class A
@@ -267,88 +277,171 @@  discard block
 block discarded – undo
267 277
 	}
268 278
 	
269 279
 	public function getShipType($code) {
270
-		if ($code == 0) return 'Not available (default)';
271
-		elseif ($code >= 1 && $code <= 19) return 'Reserved for future use';
272
-		elseif ($code == 20) return 'Wing in ground (WIG), all ships of this type';
273
-		elseif ($code == 21) return 'Wing in ground (WIG), Hazardous category A';
274
-		elseif ($code == 22) return 'Wing in ground (WIG), Hazardous category B';
275
-		elseif ($code == 23) return 'Wing in ground (WIG), Hazardous category C';
276
-		elseif ($code == 24) return 'Wing in ground (WIG), Hazardous category D';
277
-		elseif ($code == 25) return 'Wing in ground (WIG), Reserved for future use';
278
-		elseif ($code == 26) return 'Wing in ground (WIG), Reserved for future use';
279
-		elseif ($code == 27) return 'Wing in ground (WIG), Reserved for future use';
280
-		elseif ($code == 28) return 'Wing in ground (WIG), Reserved for future use';
281
-		elseif ($code == 29) return 'Wing in ground (WIG), Reserved for future use';
282
-		elseif ($code == 30) return 'Fishing';
283
-		elseif ($code == 31) return 'Towing';
284
-		elseif ($code == 32) return 'Towing: length exceeds 200m or breadth exceeds 25m';
285
-		elseif ($code == 33) return 'Dredging or underwater ops';
286
-		elseif ($code == 34) return 'Diving ops';
287
-		elseif ($code == 35) return 'Military ops';
288
-		elseif ($code == 36) return 'Sailing';
289
-		elseif ($code == 37) return 'Pleasure Craft';
290
-		elseif ($code == 38) return 'Reserved';
291
-		elseif ($code == 39) return 'Reserved';
292
-		elseif ($code == 40) return 'High speed craft (HSC), all ships of this type';
293
-		elseif ($code == 41) return 'High speed craft (HSC), Hazardous category A';
294
-		elseif ($code == 42) return 'High speed craft (HSC), Hazardous category B';
295
-		elseif ($code == 43) return 'High speed craft (HSC), Hazardous category C';
296
-		elseif ($code == 44) return 'High speed craft (HSC), Hazardous category D';
297
-		elseif ($code == 45) return 'High speed craft (HSC), Reserved for future use';
298
-		elseif ($code == 46) return 'High speed craft (HSC), Reserved for future use';
299
-		elseif ($code == 47) return 'High speed craft (HSC), Reserved for future use';
300
-		elseif ($code == 48) return 'High speed craft (HSC), Reserved for future use';
301
-		elseif ($code == 49) return 'High speed craft (HSC), No additional information';
302
-		elseif ($code == 50) return 'Pilot Vessel';
303
-		elseif ($code == 51) return 'Search and Rescue vessel';
304
-		elseif ($code == 52) return 'Tug';
305
-		elseif ($code == 53) return 'Port Tender';
306
-		elseif ($code == 54) return 'Anti-pollution equipment';
307
-		elseif ($code == 55) return 'Law Enforcement';
308
-		elseif ($code == 56) return 'Spare - Local Vessel';
309
-		elseif ($code == 57) return 'Spare - Local Vessel';
310
-		elseif ($code == 58) return 'Medical Transport';
311
-		elseif ($code == 59) return 'Noncombatant ship according to RR Resolution No. 18';
312
-		elseif ($code == 60) return 'Passenger, all ships of this type';
313
-		elseif ($code == 61) return 'Passenger, Hazardous category A';
314
-		elseif ($code == 62) return 'Passenger, Hazardous category B';
315
-		elseif ($code == 63) return 'Passenger, Hazardous category C';
316
-		elseif ($code == 64) return 'Passenger, Hazardous category D';
317
-		elseif ($code == 65) return 'Passenger, Reserved for future use';
318
-		elseif ($code == 66) return 'Passenger, Reserved for future use';
319
-		elseif ($code == 67) return 'Passenger, Reserved for future use';
320
-		elseif ($code == 68) return 'Passenger, Reserved for future use';
321
-		elseif ($code == 69) return 'Passenger, No additional information';
322
-		elseif ($code == 70) return 'Cargo, all ships of this type';
323
-		elseif ($code == 71) return 'Cargo, Hazardous category A';
324
-		elseif ($code == 72) return 'Cargo, Hazardous category B';
325
-		elseif ($code == 73) return 'Cargo, Hazardous category C';
326
-		elseif ($code == 74) return 'Cargo, Hazardous category D';
327
-		elseif ($code == 75) return 'Cargo, Reserved for future use';
328
-		elseif ($code == 76) return 'Cargo, Reserved for future use';
329
-		elseif ($code == 77) return 'Cargo, Reserved for future use';
330
-		elseif ($code == 78) return 'Cargo, Reserved for future use';
331
-		elseif ($code == 79) return 'Cargo, No additional information';
332
-		elseif ($code == 80) return 'Tanker, all ships of this type';
333
-		elseif ($code == 81) return 'Tanker, Hazardous category A';
334
-		elseif ($code == 82) return 'Tanker, Hazardous category B';
335
-		elseif ($code == 83) return 'Tanker, Hazardous category C';
336
-		elseif ($code == 84) return 'Tanker, Hazardous category D';
337
-		elseif ($code == 85) return 'Tanker, Reserved for future use';
338
-		elseif ($code == 86) return 'Tanker, Reserved for future use';
339
-		elseif ($code == 87) return 'Tanker, Reserved for future use';
340
-		elseif ($code == 88) return 'Tanker, Reserved for future use';
341
-		elseif ($code == 89) return 'Tanker, No additional information';
342
-		elseif ($code == 90) return 'Other Type, all ships of this type';
343
-		elseif ($code == 91) return 'Other Type, Hazardous category A';
344
-		elseif ($code == 92) return 'Other Type, Hazardous category B';
345
-		elseif ($code == 93) return 'Other Type, Hazardous category C';
346
-		elseif ($code == 94) return 'Other Type, Hazardous category D';
347
-		elseif ($code == 95) return 'Other Type, Reserved for future use';
348
-		elseif ($code == 96) return 'Other Type, Reserved for future use';
349
-		elseif ($code == 97) return 'Other Type, Reserved for future use';
350
-		elseif ($code == 98) return 'Other Type, Reserved for future use';
351
-		elseif ($code == 99) return 'Other Type, no additional information';
280
+		if ($code == 0) {
281
+			return 'Not available (default)';
282
+		} elseif ($code >= 1 && $code <= 19) {
283
+			return 'Reserved for future use';
284
+		} elseif ($code == 20) {
285
+			return 'Wing in ground (WIG), all ships of this type';
286
+		} elseif ($code == 21) {
287
+			return 'Wing in ground (WIG), Hazardous category A';
288
+		} elseif ($code == 22) {
289
+			return 'Wing in ground (WIG), Hazardous category B';
290
+		} elseif ($code == 23) {
291
+			return 'Wing in ground (WIG), Hazardous category C';
292
+		} elseif ($code == 24) {
293
+			return 'Wing in ground (WIG), Hazardous category D';
294
+		} elseif ($code == 25) {
295
+			return 'Wing in ground (WIG), Reserved for future use';
296
+		} elseif ($code == 26) {
297
+			return 'Wing in ground (WIG), Reserved for future use';
298
+		} elseif ($code == 27) {
299
+			return 'Wing in ground (WIG), Reserved for future use';
300
+		} elseif ($code == 28) {
301
+			return 'Wing in ground (WIG), Reserved for future use';
302
+		} elseif ($code == 29) {
303
+			return 'Wing in ground (WIG), Reserved for future use';
304
+		} elseif ($code == 30) {
305
+			return 'Fishing';
306
+		} elseif ($code == 31) {
307
+			return 'Towing';
308
+		} elseif ($code == 32) {
309
+			return 'Towing: length exceeds 200m or breadth exceeds 25m';
310
+		} elseif ($code == 33) {
311
+			return 'Dredging or underwater ops';
312
+		} elseif ($code == 34) {
313
+			return 'Diving ops';
314
+		} elseif ($code == 35) {
315
+			return 'Military ops';
316
+		} elseif ($code == 36) {
317
+			return 'Sailing';
318
+		} elseif ($code == 37) {
319
+			return 'Pleasure Craft';
320
+		} elseif ($code == 38) {
321
+			return 'Reserved';
322
+		} elseif ($code == 39) {
323
+			return 'Reserved';
324
+		} elseif ($code == 40) {
325
+			return 'High speed craft (HSC), all ships of this type';
326
+		} elseif ($code == 41) {
327
+			return 'High speed craft (HSC), Hazardous category A';
328
+		} elseif ($code == 42) {
329
+			return 'High speed craft (HSC), Hazardous category B';
330
+		} elseif ($code == 43) {
331
+			return 'High speed craft (HSC), Hazardous category C';
332
+		} elseif ($code == 44) {
333
+			return 'High speed craft (HSC), Hazardous category D';
334
+		} elseif ($code == 45) {
335
+			return 'High speed craft (HSC), Reserved for future use';
336
+		} elseif ($code == 46) {
337
+			return 'High speed craft (HSC), Reserved for future use';
338
+		} elseif ($code == 47) {
339
+			return 'High speed craft (HSC), Reserved for future use';
340
+		} elseif ($code == 48) {
341
+			return 'High speed craft (HSC), Reserved for future use';
342
+		} elseif ($code == 49) {
343
+			return 'High speed craft (HSC), No additional information';
344
+		} elseif ($code == 50) {
345
+			return 'Pilot Vessel';
346
+		} elseif ($code == 51) {
347
+			return 'Search and Rescue vessel';
348
+		} elseif ($code == 52) {
349
+			return 'Tug';
350
+		} elseif ($code == 53) {
351
+			return 'Port Tender';
352
+		} elseif ($code == 54) {
353
+			return 'Anti-pollution equipment';
354
+		} elseif ($code == 55) {
355
+			return 'Law Enforcement';
356
+		} elseif ($code == 56) {
357
+			return 'Spare - Local Vessel';
358
+		} elseif ($code == 57) {
359
+			return 'Spare - Local Vessel';
360
+		} elseif ($code == 58) {
361
+			return 'Medical Transport';
362
+		} elseif ($code == 59) {
363
+			return 'Noncombatant ship according to RR Resolution No. 18';
364
+		} elseif ($code == 60) {
365
+			return 'Passenger, all ships of this type';
366
+		} elseif ($code == 61) {
367
+			return 'Passenger, Hazardous category A';
368
+		} elseif ($code == 62) {
369
+			return 'Passenger, Hazardous category B';
370
+		} elseif ($code == 63) {
371
+			return 'Passenger, Hazardous category C';
372
+		} elseif ($code == 64) {
373
+			return 'Passenger, Hazardous category D';
374
+		} elseif ($code == 65) {
375
+			return 'Passenger, Reserved for future use';
376
+		} elseif ($code == 66) {
377
+			return 'Passenger, Reserved for future use';
378
+		} elseif ($code == 67) {
379
+			return 'Passenger, Reserved for future use';
380
+		} elseif ($code == 68) {
381
+			return 'Passenger, Reserved for future use';
382
+		} elseif ($code == 69) {
383
+			return 'Passenger, No additional information';
384
+		} elseif ($code == 70) {
385
+			return 'Cargo, all ships of this type';
386
+		} elseif ($code == 71) {
387
+			return 'Cargo, Hazardous category A';
388
+		} elseif ($code == 72) {
389
+			return 'Cargo, Hazardous category B';
390
+		} elseif ($code == 73) {
391
+			return 'Cargo, Hazardous category C';
392
+		} elseif ($code == 74) {
393
+			return 'Cargo, Hazardous category D';
394
+		} elseif ($code == 75) {
395
+			return 'Cargo, Reserved for future use';
396
+		} elseif ($code == 76) {
397
+			return 'Cargo, Reserved for future use';
398
+		} elseif ($code == 77) {
399
+			return 'Cargo, Reserved for future use';
400
+		} elseif ($code == 78) {
401
+			return 'Cargo, Reserved for future use';
402
+		} elseif ($code == 79) {
403
+			return 'Cargo, No additional information';
404
+		} elseif ($code == 80) {
405
+			return 'Tanker, all ships of this type';
406
+		} elseif ($code == 81) {
407
+			return 'Tanker, Hazardous category A';
408
+		} elseif ($code == 82) {
409
+			return 'Tanker, Hazardous category B';
410
+		} elseif ($code == 83) {
411
+			return 'Tanker, Hazardous category C';
412
+		} elseif ($code == 84) {
413
+			return 'Tanker, Hazardous category D';
414
+		} elseif ($code == 85) {
415
+			return 'Tanker, Reserved for future use';
416
+		} elseif ($code == 86) {
417
+			return 'Tanker, Reserved for future use';
418
+		} elseif ($code == 87) {
419
+			return 'Tanker, Reserved for future use';
420
+		} elseif ($code == 88) {
421
+			return 'Tanker, Reserved for future use';
422
+		} elseif ($code == 89) {
423
+			return 'Tanker, No additional information';
424
+		} elseif ($code == 90) {
425
+			return 'Other Type, all ships of this type';
426
+		} elseif ($code == 91) {
427
+			return 'Other Type, Hazardous category A';
428
+		} elseif ($code == 92) {
429
+			return 'Other Type, Hazardous category B';
430
+		} elseif ($code == 93) {
431
+			return 'Other Type, Hazardous category C';
432
+		} elseif ($code == 94) {
433
+			return 'Other Type, Hazardous category D';
434
+		} elseif ($code == 95) {
435
+			return 'Other Type, Reserved for future use';
436
+		} elseif ($code == 96) {
437
+			return 'Other Type, Reserved for future use';
438
+		} elseif ($code == 97) {
439
+			return 'Other Type, Reserved for future use';
440
+		} elseif ($code == 98) {
441
+			return 'Other Type, Reserved for future use';
442
+		} elseif ($code == 99) {
443
+			return 'Other Type, no additional information';
444
+		}
352 445
 	}
353 446
 
354 447
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
@@ -386,19 +479,34 @@  discard block
 block discarded – undo
386 479
 		// assume 1st ! is valid
387 480
 		// find * ensure that it is at correct position
388 481
 		$end = strrpos ( $rawdata , '*' );
389
-		if ($end === FALSE) return -1; // check for NULLS!!!
482
+		if ($end === FALSE) {
483
+			return -1;
484
+		}
485
+		// check for NULLS!!!
390 486
 		$cs = substr( $rawdata, $end + 1 );
391
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
487
+		if ( strlen($cs) != 2 ) {
488
+			return -1;
489
+		}
490
+		// correct cs length
392 491
 		$dcs = (int)hexdec( $cs );
393
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
492
+		for ( $alias=1; $alias<$end; $alias++) {
493
+			$chksum ^= ord( $rawdata[$alias] );
494
+		}
495
+		// perform XOR for NMEA checksum
394 496
 		if ( $chksum == $dcs ) { // NMEA checksum pass
395 497
 			$pcs = explode(',', $rawdata);
396 498
 			// !AI??? identifier
397 499
 			$num_seq = (int)$pcs[1]; // number of sequences
398 500
 			$seq = (int)$pcs[2]; // get sequence
399 501
 			// get msg sequence id
400
-			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
401
-			else $msg_sid = (int)$pcs[3]; // multipart message
502
+			if ($pcs[3] == '') {
503
+				$msg_sid = -1;
504
+			}
505
+			// non-multipart message, set to -1
506
+			else {
507
+				$msg_sid = (int)$pcs[3];
508
+			}
509
+			// multipart message
402 510
 			$ais_ch = $pcs[4]; // get AIS channel
403 511
 			// message sequence checking
404 512
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -459,10 +567,18 @@  discard block
 block discarded – undo
459 567
 				//DEBUG echo "[$start $end $tst]\n";
460 568
 				$result = $this->process_ais_raw( $tst, "" );
461 569
 				$last_pos = $end + 1;
462
-			} else break;
570
+			} else {
571
+				break;
572
+			}
573
+		}
574
+		if ($last_pos > 0) {
575
+			$cbuf = substr($cbuf, $last_pos);
576
+		}
577
+		// move...
578
+		if (strlen($cbuf) > 1024) {
579
+			$cbuf = "";
463 580
 		}
464
-		if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move...
465
-		if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode...
581
+		// prevent overflow simple mode...
466 582
 		return $result;
467 583
 	}
468 584
 
@@ -482,7 +598,9 @@  discard block
 block discarded – undo
482 598
 		if ($lat<0.0) {
483 599
 			$lat = -$lat;
484 600
 			$neg=true;
485
-		} else $neg=false;
601
+		} else {
602
+			$neg=false;
603
+		}
486 604
 		$latd = 0x00000000;
487 605
 		$latd = intval ($lat * 600000.0);
488 606
 		if ($neg==true) {
@@ -498,7 +616,9 @@  discard block
 block discarded – undo
498 616
 		if ($lon<0.0) {
499 617
 			$lon = -$lon;
500 618
 			$neg=true;
501
-		} else $neg=false;
619
+		} else {
620
+			$neg=false;
621
+		}
502 622
 		$lond = 0x00000000;
503 623
 		$lond = intval ($lon * 600000.0);
504 624
 		if ($neg==true) {
@@ -511,9 +631,14 @@  discard block
 block discarded – undo
511 631
 
512 632
 	private function char2bin($name, $max_len) {
513 633
 		$len = strlen($name);
514
-		if ($len > $max_len) $name = substr($name,0,$max_len);
515
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
516
-		else $pad = '';
634
+		if ($len > $max_len) {
635
+			$name = substr($name,0,$max_len);
636
+		}
637
+		if ($len < $max_len) {
638
+			$pad = str_repeat('0', ($max_len - $len) * 6);
639
+		} else {
640
+			$pad = '';
641
+		}
517 642
 		$rv = '';
518 643
 		$ais_chars = array(
519 644
 		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
@@ -526,9 +651,12 @@  discard block
 block discarded – undo
526 651
 		);
527 652
 		// "
528 653
 		$_a = str_split($name);
529
-		if ($_a) foreach ($_a as $_1) {
654
+		if ($_a) {
655
+			foreach ($_a as $_1) {
530 656
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
531
-			else $dec = 0;
657
+		} else {
658
+				$dec = 0;
659
+			}
532 660
 			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
533 661
 			$rv .= $bin;
534 662
 			//echo "$_1 $dec ($bin)<br/>";
@@ -540,7 +668,9 @@  discard block
 block discarded – undo
540 668
 		$len_bit = strlen($_enc);
541 669
 		$rem6 = $len_bit % 6;
542 670
 		$pad6_len = 0;
543
-		if ($rem6) $pad6_len = 6 - $rem6;
671
+		if ($rem6) {
672
+			$pad6_len = 6 - $rem6;
673
+		}
544 674
 		//echo  $pad6_len.'<br>';
545 675
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
546 676
 		$len_enc = strlen($_enc) / 6;
@@ -549,8 +679,11 @@  discard block
 block discarded – undo
549 679
 		for ($i=0; $i<$len_enc; $i++) {
550 680
 			$offset = $i * 6;
551 681
 			$dec = bindec(substr($_enc,$offset,6));
552
-			if ($dec < 40) $dec += 48;
553
-			else $dec += 56;
682
+			if ($dec < 40) {
683
+				$dec += 48;
684
+			} else {
685
+				$dec += 56;
686
+			}
554 687
 			//echo chr($dec)." $dec<br/>";
555 688
 			$itu .= chr($dec);
556 689
 		}
@@ -563,25 +696,41 @@  discard block
 block discarded – undo
563 696
 		}
564 697
 		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
565 698
 		$lsb = $chksum & 0x0F;
566
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
567
-		else $lsbc = '0';
699
+		if ($lsb >=0 && $lsb <= 15 ) {
700
+			$lsbc = $hex_arr[$lsb];
701
+		} else {
702
+			$lsbc = '0';
703
+		}
568 704
 		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
569
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
570
-		else $msbc = '0';
705
+		if ($msb >=0 && $msb <= 15 ) {
706
+			$msbc = $hex_arr[$msb];
707
+		} else {
708
+			$msbc = '0';
709
+		}
571 710
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
572 711
 		return $itu;
573 712
 	}
574 713
 
575 714
 	public function parse($buffer) {
576 715
 		$data = $this->process_ais_buf($buffer);
577
-		if (!is_object($data)) return array();
578
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
579
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
716
+		if (!is_object($data)) {
717
+			return array();
718
+		}
719
+		if ($data->lon != 0) {
720
+			$result['longitude'] = $data->lon;
721
+		}
722
+		if ($data->lat != 0) {
723
+			$result['latitude'] = $data->lat;
724
+		}
580 725
 		$result['ident'] = trim($data->name);
581 726
 		$result['timestamp'] = $data->ts;
582 727
 		$result['mmsi'] = $data->mmsi;
583
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
584
-		if ($data->cog != 0) $result['heading'] = $data->cog;
728
+		if ($data->sog != -1.0) {
729
+			$result['speed'] = $data->sog;
730
+		}
731
+		if ($data->cog != 0) {
732
+			$result['heading'] = $data->cog;
733
+		}
585 734
 		/*
586 735
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
587 736
 		    $ro->id = bindec(substr($_aisdata,0,6));
@@ -591,15 +740,25 @@  discard block
 block discarded – undo
591 740
 
592 741
 	public function mmsitype($mmsi) {
593 742
 		if (strlen($mmsi) == 9) {
594
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
595
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
596
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
597
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
598
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
599
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
600
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
601
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
602
-			else return 'Ship';
743
+			if (substr($mmsi,0,3) == '974') {
744
+				return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
745
+			} elseif (substr($mmsi,0,3) == '972') {
746
+				return 'MOB (Man Overboard) device';
747
+			} elseif (substr($mmsi,0,3) == '970') {
748
+				return 'AIS SART (Search and Rescue Transmitter)';
749
+			} elseif (substr($mmsi,0,3) == '111') {
750
+				return 'SAR (Search and Rescue) aircraft';
751
+			} elseif (substr($mmsi,0,2) == '98') {
752
+				return 'Auxiliary craft associated with a parent ship';
753
+			} elseif (substr($mmsi,0,2) == '99') {
754
+				return 'Aids to Navigation';
755
+			} elseif (substr($mmsi,0,2) == '00') {
756
+				return 'Coastal stations';
757
+			} elseif (substr($mmsi,0,1) == '0') {
758
+				return 'Group of ships';
759
+			} else {
760
+				return 'Ship';
761
+			}
603 762
 		}
604 763
 
605 764
 	
@@ -616,32 +775,61 @@  discard block
 block discarded – undo
616 775
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
617 776
 			return array();
618 777
 		}
619
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
620
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
778
+		if ($data->lon != 0) {
779
+			$result['longitude'] = $data->lon;
780
+		}
781
+		if ($data->lat != 0) {
782
+			$result['latitude'] = $data->lat;
783
+		}
621 784
 		$result['ident'] = trim(str_replace('@','',$data->name));
622 785
 		$result['timestamp'] = $data->ts;
623 786
 		$result['mmsi'] = $data->mmsi;
624
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
787
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') {
788
+			$result['mmsi'] = '3'.$result['mmsi'];
789
+		}
625 790
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
626
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
627
-		if ($data->heading !== '') $result['heading'] = $data->heading;
628
-		elseif ($data->cog != 0) $result['heading'] = $data->cog;
629
-		if ($data->status != '') $result['status'] = $data->status;
630
-		if ($data->statusid !== '') $result['statusid'] = $data->statusid;
631
-		if ($data->type !== '') $result['type'] = $data->type;
632
-		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
633
-		if ($data->imo !== '') $result['imo'] = $data->imo;
634
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
791
+		if ($data->sog != -1.0) {
792
+			$result['speed'] = $data->sog;
793
+		}
794
+		if ($data->heading !== '') {
795
+			$result['heading'] = $data->heading;
796
+		} elseif ($data->cog != 0) {
797
+			$result['heading'] = $data->cog;
798
+		}
799
+		if ($data->status != '') {
800
+			$result['status'] = $data->status;
801
+		}
802
+		if ($data->statusid !== '') {
803
+			$result['statusid'] = $data->statusid;
804
+		}
805
+		if ($data->type !== '') {
806
+			$result['type'] = $data->type;
807
+		}
808
+		if ($data->typeid !== '') {
809
+			$result['typeid'] = $data->typeid;
810
+		}
811
+		if ($data->imo !== '') {
812
+			$result['imo'] = $data->imo;
813
+		}
814
+		if ($data->callsign !== '') {
815
+			$result['callsign'] = trim(str_replace('@','',$data->callsign));
816
+		}
635 817
 		if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') {
636 818
 			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
637
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
819
+			if ($eta_ts != '') {
820
+				$result['eta_ts'] = $eta_ts;
821
+			}
638 822
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
639 823
 			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
640
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
824
+			if ($eta_ts != '') {
825
+				$result['eta_ts'] = $eta_ts;
826
+			}
641 827
 		}
642 828
 		if ($data->destination != '') {
643 829
 			$dest = trim(str_replace('@','',$data->destination));
644
-			if ($dest != '') $result['destination'] = $dest;
830
+			if ($dest != '') {
831
+				$result['destination'] = $dest;
832
+			}
645 833
 		}
646 834
 		$result['all'] = (array) $data;
647 835
 		/*
Please login to merge, or discard this patch.