Completed
Push — master ( e14a40...cfb98e )
by Yannick
54:46 queued 27:34
created
install/class.update_schema.php 1 patch
Spacing   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
             try {
15 15
             	$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+    	    } catch (PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19 19
     	    }
20 20
     	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
21
+    		$Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']);
22 22
     	    }
23 23
 	
24 24
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         	try {
51 51
             	    $sth = $Connection->db->prepare($query);
52 52
 		    $sth->execute();
53
-    		} catch(PDOException $e) {
53
+    		} catch (PDOException $e) {
54 54
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55 55
     		}
56 56
     		// Copy schedules data to routes table
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         	try {
61 61
             	    $sth = $Connection->db->prepare($query);
62 62
 		    $sth->execute();
63
-    		} catch(PDOException $e) {
63
+    		} catch (PDOException $e) {
64 64
 		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65 65
     		}
66 66
     		// Add source column
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     		try {
69 69
             	    $sth = $Connection->db->prepare($query);
70 70
 		    $sth->execute();
71
-    		} catch(PDOException $e) {
71
+    		} catch (PDOException $e) {
72 72
 		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73 73
     		}
74 74
 		// Delete unused column
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     		try {
77 77
             	    $sth = $Connection->db->prepare($query);
78 78
 		    $sth->execute();
79
-    		} catch(PDOException $e) {
79
+    		} catch (PDOException $e) {
80 80
 		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81 81
     		}
82 82
 		// Add ModeS column
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
     		try {
85 85
             	    $sth = $Connection->db->prepare($query);
86 86
 		    $sth->execute();
87
-    		} catch(PDOException $e) {
87
+    		} catch (PDOException $e) {
88 88
 		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89 89
     		}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91 91
     		try {
92 92
             	    $sth = $Connection->db->prepare($query);
93 93
 		    $sth->execute();
94
-    		} catch(PDOException $e) {
94
+    		} catch (PDOException $e) {
95 95
 		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96 96
     		}
97 97
     		// Add auto_increment for aircraft_modes
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     		try {
100 100
             	    $sth = $Connection->db->prepare($query);
101 101
 		    $sth->execute();
102
-    		} catch(PDOException $e) {
102
+    		} catch (PDOException $e) {
103 103
 		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104 104
     		}
105 105
     		$error = '';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         	try {
111 111
             	    $sth = $Connection->db->prepare($query);
112 112
 		    $sth->execute();
113
-    		} catch(PDOException $e) {
113
+    		} catch (PDOException $e) {
114 114
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
115 115
     		}
116 116
 		return $error;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         	try {
124 124
             	    $sth = $Connection->db->prepare($query);
125 125
 		    $sth->execute();
126
-    		} catch(PDOException $e) {
126
+    		} catch (PDOException $e) {
127 127
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128 128
     		}
129 129
     		$error = '';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         	try {
135 135
             	    $sth = $Connection->db->prepare($query);
136 136
 		    $sth->execute();
137
-    		} catch(PDOException $e) {
137
+    		} catch (PDOException $e) {
138 138
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
139 139
     		}
140 140
 		return $error;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         	try {
148 148
             	    $sth = $Connection->db->prepare($query);
149 149
 		    $sth->execute();
150
-    		} catch(PDOException $e) {
150
+    		} catch (PDOException $e) {
151 151
 		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152 152
     		}
153 153
     		// Add image_source_website column to spotter_image
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         	try {
156 156
             	    $sth = $Connection->db->prepare($query);
157 157
 		    $sth->execute();
158
-    		} catch(PDOException $e) {
158
+    		} catch (PDOException $e) {
159 159
 		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160 160
     		}
161 161
     		$error = '';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         	try {
165 165
             	    $sth = $Connection->db->prepare($query);
166 166
 		    $sth->execute();
167
-    		} catch(PDOException $e) {
167
+    		} catch (PDOException $e) {
168 168
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
169 169
     		}
170 170
 		return $error;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         	    try {
183 183
             		$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+    		    } catch (PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187 187
     		    }
188 188
     		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	try {
197 197
             	    $sth = $Connection->db->prepare($query);
198 198
 		    $sth->execute();
199
-    		} catch(PDOException $e) {
199
+    		} catch (PDOException $e) {
200 200
 		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201 201
     		}
202 202
     		// Add aircraft_shadow column to aircraft
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         	try {
205 205
             	    $sth = $Connection->db->prepare($query);
206 206
 		    $sth->execute();
207
-    		} catch(PDOException $e) {
207
+    		} catch (PDOException $e) {
208 208
 		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209 209
     		}
210 210
     		// Add aircraft_shadow column to spotter_live
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         	try {
213 213
             	    $sth = $Connection->db->prepare($query);
214 214
 		    $sth->execute();
215
-    		} catch(PDOException $e) {
215
+    		} catch (PDOException $e) {
216 216
 		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217 217
     		}
218 218
     		$error = '';
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         	try {
226 226
             	    $sth = $Connection->db->prepare($query);
227 227
 		    $sth->execute();
228
-    		} catch(PDOException $e) {
228
+    		} catch (PDOException $e) {
229 229
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
230 230
     		}
231 231
 		return $error;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 	private static function update_from_6() {
235 235
     		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
236
+    		if (!$Connection->indexExists('spotter_output', 'flightaware_id')) {
237 237
     		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         	    try {
251 251
             		$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+    		    } catch (PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255 255
     		    }
256 256
     		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         	try {
266 266
             	    $sth = $Connection->db->prepare($query);
267 267
 		    $sth->execute();
268
-    		} catch(PDOException $e) {
268
+    		} catch (PDOException $e) {
269 269
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
270 270
     		}
271 271
 		return $error;
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276 276
     		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
277
+    		$query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279 279
         	try {
280 280
             	    $sth = $Connection->db->prepare($query);
281 281
 		    $sth->execute();
282
-    		} catch(PDOException $e) {
282
+    		} catch (PDOException $e) {
283 283
 		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284 284
     		}
285 285
     		if ($globalDBdriver == 'mysql') {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		    try {
288 288
             		$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+    		    } catch (PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292 292
     		    }
293 293
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301 301
             	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
302
+    			$query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303 303
             	    }
304 304
                 } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
305
+    		    $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306 306
                 }
307 307
         	try {
308 308
             	    $sth = $Connection->db->prepare($query);
309 309
 		    $sth->execute();
310
-    		} catch(PDOException $e) {
310
+    		} catch (PDOException $e) {
311 311
 		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312 312
     		}
313 313
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         	try {
321 321
             	    $sth = $Connection->db->prepare($query);
322 322
 		    $sth->execute();
323
-    		} catch(PDOException $e) {
323
+    		} catch (PDOException $e) {
324 324
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
325 325
     		}
326 326
 		return $error;
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
         	try {
340 340
             	    $sth = $Connection->db->prepare($query);
341 341
 		    $sth->execute();
342
-    		} catch(PDOException $e) {
342
+    		} catch (PDOException $e) {
343 343
 		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344 344
     		}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346 346
         	try {
347 347
             	    $sth = $Connection->db->prepare($query);
348 348
 		    $sth->execute();
349
-    		} catch(PDOException $e) {
349
+    		} catch (PDOException $e) {
350 350
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
351 351
     		}
352 352
 		return $error;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 
355 355
 	private static function update_from_9() {
356 356
     		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
357
+    		$query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359 359
         	try {
360 360
             	    $sth = $Connection->db->prepare($query);
361 361
 		    $sth->execute();
362
-    		} catch(PDOException $e) {
362
+    		} catch (PDOException $e) {
363 363
 		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364 364
     		}
365 365
 		$error = '';
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         	try {
372 372
             	    $sth = $Connection->db->prepare($query);
373 373
 		    $sth->execute();
374
-    		} catch(PDOException $e) {
374
+    		} catch (PDOException $e) {
375 375
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
376 376
     		}
377 377
 		return $error;
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
 
380 380
 	private static function update_from_10() {
381 381
     		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
382
+    		$query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383 383
         	try {
384 384
             	    $sth = $Connection->db->prepare($query);
385 385
 		    $sth->execute();
386
-    		} catch(PDOException $e) {
386
+    		} catch (PDOException $e) {
387 387
 		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388 388
     		}
389 389
 		$error = '';
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         	try {
402 402
             	    $sth = $Connection->db->prepare($query);
403 403
 		    $sth->execute();
404
-    		} catch(PDOException $e) {
404
+    		} catch (PDOException $e) {
405 405
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
406 406
     		}
407 407
 		return $error;
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412 412
     		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
413
+    		$query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414 414
         	try {
415 415
             	    $sth = $Connection->db->prepare($query);
416 416
 		    $sth->execute();
417
-    		} catch(PDOException $e) {
417
+    		} catch (PDOException $e) {
418 418
 		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419 419
     		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
420
+    		$query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421 421
         	try {
422 422
             	    $sth = $Connection->db->prepare($query);
423 423
 		    $sth->execute();
424
-    		} catch(PDOException $e) {
424
+    		} catch (PDOException $e) {
425 425
 		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426 426
     		}
427 427
     		if ($globalDBdriver == 'mysql') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		    try {
430 430
             		$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+    		    } catch (PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434 434
     		    }
435 435
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443 443
             	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
444
+    			$query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445 445
             	    }
446 446
                 } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
447
+    		    $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448 448
                 }
449 449
         	try {
450 450
             	    $sth = $Connection->db->prepare($query);
451 451
 		    $sth->execute();
452
-    		} catch(PDOException $e) {
452
+    		} catch (PDOException $e) {
453 453
 		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454 454
     		}
455 455
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         	try {
460 460
             	    $sth = $Connection->db->prepare($query);
461 461
 		    $sth->execute();
462
-    		} catch(PDOException $e) {
462
+    		} catch (PDOException $e) {
463 463
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
464 464
     		}
465 465
 		return $error;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         	try {
488 488
             	    $sth = $Connection->db->prepare($query);
489 489
 		    $sth->execute();
490
-    		} catch(PDOException $e) {
490
+    		} catch (PDOException $e) {
491 491
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
492 492
     		}
493 493
 		return $error;
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 
496 496
 	private static function update_from_13() {
497 497
     		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
498
+    		if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) {
499
+    			$query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+	    		} catch (PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505 505
     			}
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         	try {
510 510
             	    $sth = $Connection->db->prepare($query);
511 511
 		    $sth->execute();
512
-    		} catch(PDOException $e) {
512
+    		} catch (PDOException $e) {
513 513
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
514 514
     		}
515 515
 		return $error;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         	try {
528 528
             	    $sth = $Connection->db->prepare($query);
529 529
 		    $sth->execute();
530
-    		} catch(PDOException $e) {
530
+    		} catch (PDOException $e) {
531 531
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
532 532
     		}
533 533
 		return $error;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     		$Connection = new Connection();
539 539
 		$error = '';
540 540
     		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
541
+    		$query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542 542
         	try {
543 543
             	    $sth = $Connection->db->prepare($query);
544 544
 		    $sth->execute();
545
-    		} catch(PDOException $e) {
545
+    		} catch (PDOException $e) {
546 546
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 547
     		}
548 548
 		if ($error != '') return $error;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         	try {
551 551
             	    $sth = $Connection->db->prepare($query);
552 552
 		    $sth->execute();
553
-    		} catch(PDOException $e) {
553
+    		} catch (PDOException $e) {
554 554
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
555 555
     		}
556 556
 		return $error;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         	try {
572 572
             	    $sth = $Connection->db->prepare($query);
573 573
 		    $sth->execute();
574
-    		} catch(PDOException $e) {
574
+    		} catch (PDOException $e) {
575 575
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
576 576
     		}
577 577
 		return $error;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         	try {
590 590
             	    $sth = $Connection->db->prepare($query);
591 591
 		    $sth->execute();
592
-    		} catch(PDOException $e) {
592
+    		} catch (PDOException $e) {
593 593
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
594 594
     		}
595 595
 		return $error;
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
     		$Connection = new Connection();
599 599
 		$error = '';
600 600
     		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
601
+    		if (!$Connection->checkColumnName('stats_airport', 'airport_name')) {
602 602
     			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603 603
     	        	try {
604 604
 	            	    $sth = $Connection->db->prepare($query);
605 605
 			    $sth->execute();
606
-    			} catch(PDOException $e) {
606
+    			} catch (PDOException $e) {
607 607
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 608
     			}
609 609
     		}
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
         	try {
613 613
             	    $sth = $Connection->db->prepare($query);
614 614
 		    $sth->execute();
615
-    		} catch(PDOException $e) {
615
+    		} catch (PDOException $e) {
616 616
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
617 617
     		}
618 618
 		return $error;
@@ -629,73 +629,73 @@  discard block
 block discarded – undo
629 629
         	try {
630 630
             	    $sth = $Connection->db->prepare($query);
631 631
 		    $sth->execute();
632
-    		} catch(PDOException $e) {
632
+    		} catch (PDOException $e) {
633 633
 		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634 634
     		}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636 636
         	try {
637 637
             	    $sth = $Connection->db->prepare($query);
638 638
 		    $sth->execute();
639
-    		} catch(PDOException $e) {
639
+    		} catch (PDOException $e) {
640 640
 		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641 641
     		}
642
-		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
642
+		if (!$Connection->checkColumnName('spotter_archive', 'over_country')) {
643 643
 			// Add column over_country
644 644
     			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646 646
             			$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
650 650
 			}
651 651
 		}
652
-		if (!$Connection->checkColumnName('spotter_live','over_country')) {
652
+		if (!$Connection->checkColumnName('spotter_live', 'over_country')) {
653 653
 			// Add column over_country
654 654
     			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656 656
             			$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
660 660
 			}
661 661
 		}
662
-		if (!$Connection->checkColumnName('spotter_output','source_name')) {
662
+		if (!$Connection->checkColumnName('spotter_output', 'source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664 664
     			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668
-			} catch(PDOException $e) {
668
+			} catch (PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670 670
     			}
671 671
     		}
672
-		if (!$Connection->checkColumnName('spotter_live','source_name')) {
672
+		if (!$Connection->checkColumnName('spotter_live', 'source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674 674
     			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678
-			} catch(PDOException $e) {
678
+			} catch (PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680 680
     			}
681 681
     		}
682
-		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
682
+		if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684 684
     			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688
-			} catch(PDOException $e) {
688
+			} catch (PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690 690
     			}
691 691
     		}
692
-		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
692
+		if (!$Connection->checkColumnName('spotter_archive', 'source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694 694
     			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698
-			} catch(PDOException $e) {
698
+			} catch (PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 700
     			}
701 701
     		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         	try {
705 705
             	    $sth = $Connection->db->prepare($query);
706 706
 		    $sth->execute();
707
-    		} catch(PDOException $e) {
707
+    		} catch (PDOException $e) {
708 708
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
709 709
     		}
710 710
 		return $error;
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722
-		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
722
+		if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) {
723 723
 			// Add column over_country
724 724
     			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725 725
         		try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728
-			} catch(PDOException $e) {
728
+			} catch (PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 730
     			}
731 731
     		}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         	try {
742 742
             	    $sth = $Connection->db->prepare($query);
743 743
 		    $sth->execute();
744
-    		} catch(PDOException $e) {
744
+    		} catch (PDOException $e) {
745 745
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
746 746
     		}
747 747
 		return $error;
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	private static function update_from_21() {
751 751
 		$Connection = new Connection();
752 752
 		$error = '';
753
-		if (!$Connection->checkColumnName('stats_airport','stats_type')) {
753
+		if (!$Connection->checkColumnName('stats_airport', 'stats_type')) {
754 754
 			// Rename type to stats_type
755 755
 			$query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);";
756 756
 			try {
757 757
 				$sth = $Connection->db->prepare($query);
758 758
 				$sth->execute();
759
-			} catch(PDOException $e) {
759
+			} catch (PDOException $e) {
760 760
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 761
 			}
762 762
 			if ($error != '') return $error;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
         	try {
766 766
             	    $sth = $Connection->db->prepare($query);
767 767
 		    $sth->execute();
768
-    		} catch(PDOException $e) {
768
+    		} catch (PDOException $e) {
769 769
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
770 770
     		}
771 771
 		return $error;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         	try {
789 789
             	    $sth = $Connection->db->prepare($query);
790 790
 		    $sth->execute();
791
-    		} catch(PDOException $e) {
791
+    		} catch (PDOException $e) {
792 792
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
793 793
     		}
794 794
 		return $error;
@@ -814,17 +814,17 @@  discard block
 block discarded – undo
814 814
 			try {
815 815
 				$sth = $Connection->db->prepare($query);
816 816
 				$sth->execute();
817
-			} catch(PDOException $e) {
817
+			} catch (PDOException $e) {
818 818
 				return "error (create index on spotter_archive) : ".$e->getMessage()."\n";
819 819
 			}
820 820
 		}
821
-		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
821
+		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) {
822 822
 			// Add aircraft_manufacturer to stats_aircraft
823 823
     			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824 824
 			try {
825 825
 				$sth = $Connection->db->prepare($query);
826 826
 				$sth->execute();
827
-			} catch(PDOException $e) {
827
+			} catch (PDOException $e) {
828 828
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
829 829
     			}
830 830
     		}
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 		try {
834 834
 			$sth = $Connection->db->prepare($query);
835 835
 			$sth->execute();
836
-		} catch(PDOException $e) {
836
+		} catch (PDOException $e) {
837 837
 			return "error (update schema_version) : ".$e->getMessage()."\n";
838 838
 		}
839 839
 		return $error;
@@ -849,23 +849,23 @@  discard block
 block discarded – undo
849 849
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 850
 		}
851 851
 		if ($error != '') return 'Import airlines.sql : '.$error;
852
-		if (!$Connection->checkColumnName('airlines','forsource')) {
852
+		if (!$Connection->checkColumnName('airlines', 'forsource')) {
853 853
 			// Add forsource to airlines
854 854
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
855 855
 			try {
856 856
 				$sth = $Connection->db->prepare($query);
857 857
 				$sth->execute();
858
-			} catch(PDOException $e) {
858
+			} catch (PDOException $e) {
859 859
 				return "error (add forsource column) : ".$e->getMessage()."\n";
860 860
 			}
861 861
 		}
862
-		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
862
+		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) {
863 863
 			// Add forsource to airlines
864 864
 			$query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
865 865
 			try {
866 866
 				$sth = $Connection->db->prepare($query);
867 867
 				$sth->execute();
868
-			} catch(PDOException $e) {
868
+			} catch (PDOException $e) {
869 869
 				return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n";
870 870
 			}
871 871
 			// Add unique key
@@ -877,17 +877,17 @@  discard block
 block discarded – undo
877 877
 			try {
878 878
 				$sth = $Connection->db->prepare($query);
879 879
 				$sth->execute();
880
-			} catch(PDOException $e) {
880
+			} catch (PDOException $e) {
881 881
 				return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n";
882 882
 			}
883 883
 		}
884
-		if (!$Connection->checkColumnName('stats_airport','stats_airline')) {
884
+		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) {
885 885
 			// Add forsource to airlines
886 886
 			$query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
887 887
 			try {
888 888
 				$sth = $Connection->db->prepare($query);
889 889
 				$sth->execute();
890
-			} catch(PDOException $e) {
890
+			} catch (PDOException $e) {
891 891
 				return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n";
892 892
 			}
893 893
 			// Add unique key
@@ -899,17 +899,17 @@  discard block
 block discarded – undo
899 899
 			try {
900 900
 				$sth = $Connection->db->prepare($query);
901 901
 				$sth->execute();
902
-			} catch(PDOException $e) {
902
+			} catch (PDOException $e) {
903 903
 				return "error (add unique key in stats_airport) : ".$e->getMessage()."\n";
904 904
 			}
905 905
 		}
906
-		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
906
+		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) {
907 907
 			// Add forsource to airlines
908 908
 			$query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
909 909
 			try {
910 910
 				$sth = $Connection->db->prepare($query);
911 911
 				$sth->execute();
912
-			} catch(PDOException $e) {
912
+			} catch (PDOException $e) {
913 913
 				return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n";
914 914
 			}
915 915
 			// Add unique key
@@ -921,36 +921,36 @@  discard block
 block discarded – undo
921 921
 			try {
922 922
 				$sth = $Connection->db->prepare($query);
923 923
 				$sth->execute();
924
-			} catch(PDOException $e) {
924
+			} catch (PDOException $e) {
925 925
 				return "error (add unique key in stats_airline) : ".$e->getMessage()."\n";
926 926
 			}
927 927
 		}
928
-		if (!$Connection->checkColumnName('stats_flight','stats_airline')) {
928
+		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) {
929 929
 			// Add forsource to airlines
930 930
 			$query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
931 931
 			try {
932 932
 				$sth = $Connection->db->prepare($query);
933 933
 				$sth->execute();
934
-			} catch(PDOException $e) {
934
+			} catch (PDOException $e) {
935 935
 				return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n";
936 936
 			}
937 937
 		}
938
-		if (!$Connection->checkColumnName('stats','stats_airline')) {
938
+		if (!$Connection->checkColumnName('stats', 'stats_airline')) {
939 939
 			// Add forsource to airlines
940 940
 			$query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
941 941
 			try {
942 942
 				$sth = $Connection->db->prepare($query);
943 943
 				$sth->execute();
944
-			} catch(PDOException $e) {
944
+			} catch (PDOException $e) {
945 945
 				return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n";
946 946
 			}
947
-			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) {
947
+			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) {
948 948
 				// Add unique key
949 949
 				$query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);";
950 950
 				try {
951 951
 					$sth = $Connection->db->prepare($query);
952 952
 					$sth->execute();
953
-				} catch(PDOException $e) {
953
+				} catch (PDOException $e) {
954 954
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
955 955
 				}
956 956
 			} else {
@@ -963,18 +963,18 @@  discard block
 block discarded – undo
963 963
 				try {
964 964
 					$sth = $Connection->db->prepare($query);
965 965
 					$sth->execute();
966
-				} catch(PDOException $e) {
966
+				} catch (PDOException $e) {
967 967
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
968 968
 				}
969 969
 			}
970 970
 		}
971
-		if (!$Connection->checkColumnName('stats_registration','stats_airline')) {
971
+		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) {
972 972
 			// Add forsource to airlines
973 973
 			$query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
974 974
 			try {
975 975
 				$sth = $Connection->db->prepare($query);
976 976
 				$sth->execute();
977
-			} catch(PDOException $e) {
977
+			} catch (PDOException $e) {
978 978
 				return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n";
979 979
 			}
980 980
 			// Add unique key
@@ -986,17 +986,17 @@  discard block
 block discarded – undo
986 986
 			try {
987 987
 				$sth = $Connection->db->prepare($query);
988 988
 				$sth->execute();
989
-			} catch(PDOException $e) {
989
+			} catch (PDOException $e) {
990 990
 				return "error (add unique key in stats_registration) : ".$e->getMessage()."\n";
991 991
 			}
992 992
 		}
993
-		if (!$Connection->checkColumnName('stats_callsign','filter_name')) {
993
+		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) {
994 994
 			// Add forsource to airlines
995 995
 			$query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''";
996 996
 			try {
997 997
 				$sth = $Connection->db->prepare($query);
998 998
 				$sth->execute();
999
-			} catch(PDOException $e) {
999
+			} catch (PDOException $e) {
1000 1000
 				return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n";
1001 1001
 			}
1002 1002
 			// Add unique key
@@ -1008,17 +1008,17 @@  discard block
 block discarded – undo
1008 1008
 			try {
1009 1009
 				$sth = $Connection->db->prepare($query);
1010 1010
 				$sth->execute();
1011
-			} catch(PDOException $e) {
1011
+			} catch (PDOException $e) {
1012 1012
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1013 1013
 			}
1014 1014
 		}
1015
-		if (!$Connection->checkColumnName('stats_airline','filter_name')) {
1015
+		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) {
1016 1016
 			// Add forsource to airlines
1017 1017
 			$query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1018 1018
 			try {
1019 1019
 				$sth = $Connection->db->prepare($query);
1020 1020
 				$sth->execute();
1021
-			} catch(PDOException $e) {
1021
+			} catch (PDOException $e) {
1022 1022
 				return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n";
1023 1023
 			}
1024 1024
 			// Add unique key
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 			try {
1031 1031
 				$sth = $Connection->db->prepare($query);
1032 1032
 				$sth->execute();
1033
-			} catch(PDOException $e) {
1033
+			} catch (PDOException $e) {
1034 1034
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1035 1035
 			}
1036 1036
 		}
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 		try {
1040 1040
 			$sth = $Connection->db->prepare($query);
1041 1041
 			$sth->execute();
1042
-		} catch(PDOException $e) {
1042
+		} catch (PDOException $e) {
1043 1043
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1044 1044
 		}
1045 1045
 		return $error;
@@ -1049,13 +1049,13 @@  discard block
 block discarded – undo
1049 1049
 		global $globalDBdriver;
1050 1050
 		$Connection = new Connection();
1051 1051
 		$error = '';
1052
-		if (!$Connection->checkColumnName('stats_owner','stats_airline')) {
1052
+		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) {
1053 1053
 			// Add forsource to airlines
1054 1054
 			$query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1055 1055
 			try {
1056 1056
 				$sth = $Connection->db->prepare($query);
1057 1057
 				$sth->execute();
1058
-			} catch(PDOException $e) {
1058
+			} catch (PDOException $e) {
1059 1059
 				return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n";
1060 1060
 			}
1061 1061
 			// Add unique key
@@ -1067,17 +1067,17 @@  discard block
 block discarded – undo
1067 1067
 			try {
1068 1068
 				$sth = $Connection->db->prepare($query);
1069 1069
 				$sth->execute();
1070
-			} catch(PDOException $e) {
1070
+			} catch (PDOException $e) {
1071 1071
 				return "error (add unique key in stats_owner) : ".$e->getMessage()."\n";
1072 1072
 			}
1073 1073
 		}
1074
-		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) {
1074
+		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) {
1075 1075
 			// Add forsource to airlines
1076 1076
 			$query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1077 1077
 			try {
1078 1078
 				$sth = $Connection->db->prepare($query);
1079 1079
 				$sth->execute();
1080
-			} catch(PDOException $e) {
1080
+			} catch (PDOException $e) {
1081 1081
 				return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n";
1082 1082
 			}
1083 1083
 			// Add unique key
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 			try {
1090 1090
 				$sth = $Connection->db->prepare($query);
1091 1091
 				$sth->execute();
1092
-			} catch(PDOException $e) {
1092
+			} catch (PDOException $e) {
1093 1093
 				return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n";
1094 1094
 			}
1095 1095
 		}
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 		try {
1098 1098
 			$sth = $Connection->db->prepare($query);
1099 1099
 			$sth->execute();
1100
-		} catch(PDOException $e) {
1100
+		} catch (PDOException $e) {
1101 1101
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1102 1102
 		}
1103 1103
 		return $error;
@@ -1107,12 +1107,12 @@  discard block
 block discarded – undo
1107 1107
 		global $globalDBdriver;
1108 1108
 		$Connection = new Connection();
1109 1109
 		$error = '';
1110
-		if (!$Connection->checkColumnName('atc','format_source')) {
1110
+		if (!$Connection->checkColumnName('atc', 'format_source')) {
1111 1111
 			$query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL";
1112 1112
 			try {
1113 1113
 				$sth = $Connection->db->prepare($query);
1114 1114
 				$sth->execute();
1115
-			} catch(PDOException $e) {
1115
+			} catch (PDOException $e) {
1116 1116
 				return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n";
1117 1117
 			}
1118 1118
 		}
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
 		try {
1121 1121
 			$sth = $Connection->db->prepare($query);
1122 1122
 			$sth->execute();
1123
-		} catch(PDOException $e) {
1123
+		} catch (PDOException $e) {
1124 1124
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1125 1125
 		}
1126 1126
 		return $error;
@@ -1130,13 +1130,13 @@  discard block
 block discarded – undo
1130 1130
 		global $globalDBdriver;
1131 1131
 		$Connection = new Connection();
1132 1132
 		$error = '';
1133
-		if (!$Connection->checkColumnName('stats_pilot','format_source')) {
1133
+		if (!$Connection->checkColumnName('stats_pilot', 'format_source')) {
1134 1134
 			// Add forsource to airlines
1135 1135
 			$query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''";
1136 1136
 			try {
1137 1137
 				$sth = $Connection->db->prepare($query);
1138 1138
 				$sth->execute();
1139
-			} catch(PDOException $e) {
1139
+			} catch (PDOException $e) {
1140 1140
 				return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n";
1141 1141
 			}
1142 1142
 			// Add unique key
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
 			try {
1149 1149
 				$sth = $Connection->db->prepare($query);
1150 1150
 				$sth->execute();
1151
-			} catch(PDOException $e) {
1151
+			} catch (PDOException $e) {
1152 1152
 				return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n";
1153 1153
 			}
1154 1154
 		}
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 		try {
1157 1157
 			$sth = $Connection->db->prepare($query);
1158 1158
 			$sth->execute();
1159
-		} catch(PDOException $e) {
1159
+		} catch (PDOException $e) {
1160 1160
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1161 1161
 		}
1162 1162
 		return $error;
@@ -1166,23 +1166,23 @@  discard block
 block discarded – undo
1166 1166
 		global $globalDBdriver;
1167 1167
 		$Connection = new Connection();
1168 1168
 		$error = '';
1169
-		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) {
1169
+		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) {
1170 1170
 			// Add unique key
1171 1171
 			$query = "alter table spotter_live add index(latitude,longitude)";
1172 1172
 			try {
1173 1173
 				$sth = $Connection->db->prepare($query);
1174 1174
 				$sth->execute();
1175
-			} catch(PDOException $e) {
1175
+			} catch (PDOException $e) {
1176 1176
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1177 1177
 			}
1178 1178
                 }
1179
-		if (!$Connection->checkColumnName('aircraft','mfr')) {
1179
+		if (!$Connection->checkColumnName('aircraft', 'mfr')) {
1180 1180
 			// Add mfr to aircraft
1181 1181
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
1182 1182
 			try {
1183 1183
 				$sth = $Connection->db->prepare($query);
1184 1184
 				$sth->execute();
1185
-			} catch(PDOException $e) {
1185
+			} catch (PDOException $e) {
1186 1186
 				return "error (add mfr column in aircraft) : ".$e->getMessage()."\n";
1187 1187
 			}
1188 1188
 		}
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
 		try {
1199 1199
 			$sth = $Connection->db->prepare($query);
1200 1200
 			$sth->execute();
1201
-		} catch(PDOException $e) {
1201
+		} catch (PDOException $e) {
1202 1202
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1203 1203
 		}
1204 1204
 		return $error;
@@ -1208,13 +1208,13 @@  discard block
 block discarded – undo
1208 1208
 		global $globalDBdriver;
1209 1209
 		$Connection = new Connection();
1210 1210
 		$error = '';
1211
-		if ($Connection->checkColumnName('aircraft','mfr')) {
1211
+		if ($Connection->checkColumnName('aircraft', 'mfr')) {
1212 1212
 			// drop mfr to aircraft
1213 1213
 			$query = "ALTER TABLE aircraft DROP COLUMN mfr";
1214 1214
 			try {
1215 1215
 				$sth = $Connection->db->prepare($query);
1216 1216
 				$sth->execute();
1217
-			} catch(PDOException $e) {
1217
+			} catch (PDOException $e) {
1218 1218
 				return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n";
1219 1219
 			}
1220 1220
 		}
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
 		try {
1231 1231
 			$sth = $Connection->db->prepare($query);
1232 1232
 			$sth->execute();
1233
-		} catch(PDOException $e) {
1233
+		} catch (PDOException $e) {
1234 1234
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1235 1235
 		}
1236 1236
 		return $error;
@@ -1240,33 +1240,33 @@  discard block
 block discarded – undo
1240 1240
 		global $globalDBdriver;
1241 1241
 		$Connection = new Connection();
1242 1242
 		$error = '';
1243
-		if (!$Connection->indexExists('notam','ref_idx')) {
1243
+		if (!$Connection->indexExists('notam', 'ref_idx')) {
1244 1244
 			// Add index key
1245 1245
 			$query = "create index ref_idx on notam (ref)";
1246 1246
 			try {
1247 1247
 				$sth = $Connection->db->prepare($query);
1248 1248
 				$sth->execute();
1249
-			} catch(PDOException $e) {
1249
+			} catch (PDOException $e) {
1250 1250
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1251 1251
 			}
1252 1252
                 }
1253
-		if (!$Connection->indexExists('accidents','registration_idx')) {
1253
+		if (!$Connection->indexExists('accidents', 'registration_idx')) {
1254 1254
 			// Add index key
1255 1255
 			$query = "create index registration_idx on accidents (registration)";
1256 1256
 			try {
1257 1257
 				$sth = $Connection->db->prepare($query);
1258 1258
 				$sth->execute();
1259
-			} catch(PDOException $e) {
1259
+			} catch (PDOException $e) {
1260 1260
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1261 1261
 			}
1262 1262
                 }
1263
-		if (!$Connection->indexExists('accidents','rdts')) {
1263
+		if (!$Connection->indexExists('accidents', 'rdts')) {
1264 1264
 			// Add index key
1265 1265
 			$query = "create index rdts on accidents (registration,date,type,source)";
1266 1266
 			try {
1267 1267
 				$sth = $Connection->db->prepare($query);
1268 1268
 				$sth->execute();
1269
-			} catch(PDOException $e) {
1269
+			} catch (PDOException $e) {
1270 1270
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1271 1271
 			}
1272 1272
                 }
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
 		try {
1276 1276
 			$sth = $Connection->db->prepare($query);
1277 1277
 			$sth->execute();
1278
-		} catch(PDOException $e) {
1278
+		} catch (PDOException $e) {
1279 1279
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1280 1280
 		}
1281 1281
 		return $error;
@@ -1285,23 +1285,23 @@  discard block
 block discarded – undo
1285 1285
 		global $globalDBdriver;
1286 1286
 		$Connection = new Connection();
1287 1287
 		$error = '';
1288
-		if (!$Connection->checkColumnName('accidents','airline_name')) {
1288
+		if (!$Connection->checkColumnName('accidents', 'airline_name')) {
1289 1289
 			// Add airline_name to accidents
1290 1290
 			$query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL";
1291 1291
 			try {
1292 1292
 				$sth = $Connection->db->prepare($query);
1293 1293
 				$sth->execute();
1294
-			} catch(PDOException $e) {
1294
+			} catch (PDOException $e) {
1295 1295
 				return "error (add airline_name column in accidents) : ".$e->getMessage()."\n";
1296 1296
 			}
1297 1297
 		}
1298
-		if (!$Connection->checkColumnName('accidents','airline_icao')) {
1298
+		if (!$Connection->checkColumnName('accidents', 'airline_icao')) {
1299 1299
 			// Add airline_icao to accidents
1300 1300
 			$query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL";
1301 1301
 			try {
1302 1302
 				$sth = $Connection->db->prepare($query);
1303 1303
 				$sth->execute();
1304
-			} catch(PDOException $e) {
1304
+			} catch (PDOException $e) {
1305 1305
 				return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n";
1306 1306
 			}
1307 1307
 		}
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
 		try {
1310 1310
 			$sth = $Connection->db->prepare($query);
1311 1311
 			$sth->execute();
1312
-		} catch(PDOException $e) {
1312
+		} catch (PDOException $e) {
1313 1313
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1314 1314
 		}
1315 1315
 		return $error;
@@ -1319,13 +1319,13 @@  discard block
 block discarded – undo
1319 1319
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1320 1320
 		$Connection = new Connection();
1321 1321
 		$error = '';
1322
-		if (!$Connection->checkColumnName('airlines','alliance')) {
1322
+		if (!$Connection->checkColumnName('airlines', 'alliance')) {
1323 1323
 			// Add alliance to airlines
1324 1324
 			$query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL";
1325 1325
 			try {
1326 1326
 				$sth = $Connection->db->prepare($query);
1327 1327
 				$sth->execute();
1328
-			} catch(PDOException $e) {
1328
+			} catch (PDOException $e) {
1329 1329
 				return "error (add alliance column in airlines) : ".$e->getMessage()."\n";
1330 1330
 			}
1331 1331
 		}
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
 		try {
1353 1353
 			$sth = $Connection->db->prepare($query);
1354 1354
 			$sth->execute();
1355
-		} catch(PDOException $e) {
1355
+		} catch (PDOException $e) {
1356 1356
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1357 1357
 		}
1358 1358
 		return $error;
@@ -1362,13 +1362,13 @@  discard block
 block discarded – undo
1362 1362
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1363 1363
 		$Connection = new Connection();
1364 1364
 		$error = '';
1365
-		if (!$Connection->checkColumnName('airlines','ban_eu')) {
1365
+		if (!$Connection->checkColumnName('airlines', 'ban_eu')) {
1366 1366
 			// Add ban_eu to airlines
1367 1367
 			$query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'";
1368 1368
 			try {
1369 1369
 				$sth = $Connection->db->prepare($query);
1370 1370
 				$sth->execute();
1371
-			} catch(PDOException $e) {
1371
+			} catch (PDOException $e) {
1372 1372
 				return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n";
1373 1373
 			}
1374 1374
 		}
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 		try {
1377 1377
 			$sth = $Connection->db->prepare($query);
1378 1378
 			$sth->execute();
1379
-		} catch(PDOException $e) {
1379
+		} catch (PDOException $e) {
1380 1380
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1381 1381
 		}
1382 1382
 		return $error;
@@ -1387,19 +1387,19 @@  discard block
 block discarded – undo
1387 1387
 		$Connection = new Connection();
1388 1388
 		$error = '';
1389 1389
 		if ($globalDBdriver == 'mysql') {
1390
-			if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') {
1390
+			if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') {
1391 1391
 				$query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL";
1392 1392
 				try {
1393 1393
 					$sth = $Connection->db->prepare($query);
1394 1394
 					$sth->execute();
1395
-				} catch(PDOException $e) {
1395
+				} catch (PDOException $e) {
1396 1396
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1397 1397
 				}
1398 1398
 				$query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()";
1399 1399
 				try {
1400 1400
 					$sth = $Connection->db->prepare($query);
1401 1401
 					$sth->execute();
1402
-				} catch(PDOException $e) {
1402
+				} catch (PDOException $e) {
1403 1403
 					return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n";
1404 1404
 				}
1405 1405
 				
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 				try {
1408 1408
 					$sth = $Connection->db->prepare($query);
1409 1409
 					$sth->execute();
1410
-				} catch(PDOException $e) {
1410
+				} catch (PDOException $e) {
1411 1411
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1412 1412
 				}
1413 1413
 				/*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150";
@@ -1458,7 +1458,7 @@  discard block
 block discarded – undo
1458 1458
 				try {
1459 1459
 					$sth = $Connection->db->prepare($query);
1460 1460
 					$sth->execute();
1461
-				} catch(PDOException $e) {
1461
+				} catch (PDOException $e) {
1462 1462
 					return "error (fix date) : ".$e->getMessage()."\n";
1463 1463
 				}
1464 1464
 			}
@@ -1543,7 +1543,7 @@  discard block
 block discarded – undo
1543 1543
 		try {
1544 1544
 			$sth = $Connection->db->prepare($query);
1545 1545
 			$sth->execute();
1546
-		} catch(PDOException $e) {
1546
+		} catch (PDOException $e) {
1547 1547
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1548 1548
 		}
1549 1549
 		return $error;
@@ -1552,13 +1552,13 @@  discard block
 block discarded – undo
1552 1552
 		global $globalDBdriver;
1553 1553
 		$Connection = new Connection();
1554 1554
 		$error = '';
1555
-		if (!$Connection->indexExists('accidents','type')) {
1555
+		if (!$Connection->indexExists('accidents', 'type')) {
1556 1556
 			// Add index key
1557 1557
 			$query = "create index type on accidents (type,date)";
1558 1558
 			try {
1559 1559
 				$sth = $Connection->db->prepare($query);
1560 1560
 				$sth->execute();
1561
-			} catch(PDOException $e) {
1561
+			} catch (PDOException $e) {
1562 1562
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1563 1563
 			}
1564 1564
                 }
@@ -1566,7 +1566,7 @@  discard block
 block discarded – undo
1566 1566
 		try {
1567 1567
 			$sth = $Connection->db->prepare($query);
1568 1568
 			$sth->execute();
1569
-		} catch(PDOException $e) {
1569
+		} catch (PDOException $e) {
1570 1570
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1571 1571
 		}
1572 1572
 		return $error;
@@ -1576,12 +1576,12 @@  discard block
 block discarded – undo
1576 1576
 		global $globalDBdriver;
1577 1577
 		$Connection = new Connection();
1578 1578
 		$error = '';
1579
-		if (!$Connection->checkColumnName('aircraft_modes','source_type')) {
1579
+		if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) {
1580 1580
 			$query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'";
1581 1581
 			try {
1582 1582
 				$sth = $Connection->db->prepare($query);
1583 1583
 				$sth->execute();
1584
-			} catch(PDOException $e) {
1584
+			} catch (PDOException $e) {
1585 1585
 				return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n";
1586 1586
 			}
1587 1587
 		}
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
 		try {
1648 1648
 			$sth = $Connection->db->prepare($query);
1649 1649
 			$sth->execute();
1650
-		} catch(PDOException $e) {
1650
+		} catch (PDOException $e) {
1651 1651
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1652 1652
 		}
1653 1653
 		return $error;
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
 			try {
1700 1700
 				$sth = $Connection->db->prepare($query);
1701 1701
 				$sth->execute();
1702
-			} catch(PDOException $e) {
1702
+			} catch (PDOException $e) {
1703 1703
 				return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
1704 1704
 			}
1705 1705
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -1708,18 +1708,18 @@  discard block
 block discarded – undo
1708 1708
 				try {
1709 1709
 					$sth = $Connection->db->prepare($query);
1710 1710
 					$sth->execute();
1711
-				} catch(PDOException $e) {
1711
+				} catch (PDOException $e) {
1712 1712
 					return "error (Change table format from archive to InnoDB for spotter_archive) : ".$e->getMessage()."\n";
1713 1713
 				}
1714 1714
 			}
1715 1715
 		}
1716
-		if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) {
1716
+		if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) {
1717 1717
 			// Add index key
1718 1718
 			$query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)";
1719 1719
 			try {
1720 1720
 				$sth = $Connection->db->prepare($query);
1721 1721
 				$sth->execute();
1722
-			} catch(PDOException $e) {
1722
+			} catch (PDOException $e) {
1723 1723
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1724 1724
 			}
1725 1725
                 }
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
 		try {
1728 1728
 			$sth = $Connection->db->prepare($query);
1729 1729
 			$sth->execute();
1730
-		} catch(PDOException $e) {
1730
+		} catch (PDOException $e) {
1731 1731
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1732 1732
 		}
1733 1733
 		return $error;
@@ -1738,148 +1738,148 @@  discard block
 block discarded – undo
1738 1738
 		$Connection = new Connection();
1739 1739
 		$error = '';
1740 1740
 		if ($globalDBdriver == 'mysql') {
1741
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1741
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1742 1742
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL";
1743 1743
 				try {
1744 1744
 					$sth = $Connection->db->prepare($query);
1745 1745
 					$sth->execute();
1746
-				} catch(PDOException $e) {
1746
+				} catch (PDOException $e) {
1747 1747
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1748 1748
 				}
1749 1749
 			}
1750
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1750
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1751 1751
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL";
1752 1752
 				try {
1753 1753
 					$sth = $Connection->db->prepare($query);
1754 1754
 					$sth->execute();
1755
-				} catch(PDOException $e) {
1755
+				} catch (PDOException $e) {
1756 1756
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1757 1757
 				}
1758 1758
 			}
1759
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1759
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1760 1760
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL";
1761 1761
 				try {
1762 1762
 					$sth = $Connection->db->prepare($query);
1763 1763
 					$sth->execute();
1764
-				} catch(PDOException $e) {
1764
+				} catch (PDOException $e) {
1765 1765
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1766 1766
 				}
1767 1767
 			}
1768
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1768
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1769 1769
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL";
1770 1770
 				try {
1771 1771
 					$sth = $Connection->db->prepare($query);
1772 1772
 					$sth->execute();
1773
-				} catch(PDOException $e) {
1773
+				} catch (PDOException $e) {
1774 1774
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1775 1775
 				}
1776 1776
 			}
1777
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1777
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1778 1778
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL";
1779 1779
 				try {
1780 1780
 					$sth = $Connection->db->prepare($query);
1781 1781
 					$sth->execute();
1782
-				} catch(PDOException $e) {
1782
+				} catch (PDOException $e) {
1783 1783
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1784 1784
 				}
1785 1785
 			}
1786
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1786
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1787 1787
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL";
1788 1788
 				try {
1789 1789
 					$sth = $Connection->db->prepare($query);
1790 1790
 					$sth->execute();
1791
-				} catch(PDOException $e) {
1791
+				} catch (PDOException $e) {
1792 1792
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1793 1793
 				}
1794 1794
 			}
1795
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1795
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1796 1796
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL";
1797 1797
 				try {
1798 1798
 					$sth = $Connection->db->prepare($query);
1799 1799
 					$sth->execute();
1800
-				} catch(PDOException $e) {
1800
+				} catch (PDOException $e) {
1801 1801
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1802 1802
 				}
1803 1803
 			}
1804
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1804
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1805 1805
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL";
1806 1806
 				try {
1807 1807
 					$sth = $Connection->db->prepare($query);
1808 1808
 					$sth->execute();
1809
-				} catch(PDOException $e) {
1809
+				} catch (PDOException $e) {
1810 1810
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1811 1811
 				}
1812 1812
 			}
1813 1813
 		} else {
1814
-			if (!$Connection->checkColumnName('marine_output','type_id')) {
1814
+			if (!$Connection->checkColumnName('marine_output', 'type_id')) {
1815 1815
 				$query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL";
1816 1816
 				try {
1817 1817
 					$sth = $Connection->db->prepare($query);
1818 1818
 					$sth->execute();
1819
-				} catch(PDOException $e) {
1819
+				} catch (PDOException $e) {
1820 1820
 					return "error (add column type_id in marine_output) : ".$e->getMessage()."\n";
1821 1821
 				}
1822 1822
 			}
1823
-			if (!$Connection->checkColumnName('marine_live','type_id')) {
1823
+			if (!$Connection->checkColumnName('marine_live', 'type_id')) {
1824 1824
 				$query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL";
1825 1825
 				try {
1826 1826
 					$sth = $Connection->db->prepare($query);
1827 1827
 					$sth->execute();
1828
-				} catch(PDOException $e) {
1828
+				} catch (PDOException $e) {
1829 1829
 					return "error (add column type_id in marine_live) : ".$e->getMessage()."\n";
1830 1830
 				}
1831 1831
 			}
1832
-			if (!$Connection->checkColumnName('marine_archive','type_id')) {
1832
+			if (!$Connection->checkColumnName('marine_archive', 'type_id')) {
1833 1833
 				$query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL";
1834 1834
 				try {
1835 1835
 					$sth = $Connection->db->prepare($query);
1836 1836
 					$sth->execute();
1837
-				} catch(PDOException $e) {
1837
+				} catch (PDOException $e) {
1838 1838
 					return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n";
1839 1839
 				}
1840 1840
 			}
1841
-			if (!$Connection->checkColumnName('marine_archive_output','type_id')) {
1841
+			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) {
1842 1842
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL";
1843 1843
 				try {
1844 1844
 					$sth = $Connection->db->prepare($query);
1845 1845
 					$sth->execute();
1846
-				} catch(PDOException $e) {
1846
+				} catch (PDOException $e) {
1847 1847
 					return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n";
1848 1848
 				}
1849 1849
 			}
1850
-			if (!$Connection->checkColumnName('marine_output','status_id')) {
1850
+			if (!$Connection->checkColumnName('marine_output', 'status_id')) {
1851 1851
 				$query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL";
1852 1852
 				try {
1853 1853
 					$sth = $Connection->db->prepare($query);
1854 1854
 					$sth->execute();
1855
-				} catch(PDOException $e) {
1855
+				} catch (PDOException $e) {
1856 1856
 					return "error (add column status_id in marine_output) : ".$e->getMessage()."\n";
1857 1857
 				}
1858 1858
 			}
1859
-			if (!$Connection->checkColumnName('marine_live','status_id')) {
1859
+			if (!$Connection->checkColumnName('marine_live', 'status_id')) {
1860 1860
 				$query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL";
1861 1861
 				try {
1862 1862
 					$sth = $Connection->db->prepare($query);
1863 1863
 					$sth->execute();
1864
-				} catch(PDOException $e) {
1864
+				} catch (PDOException $e) {
1865 1865
 					return "error (add column status_id in marine_live) : ".$e->getMessage()."\n";
1866 1866
 				}
1867 1867
 			}
1868
-			if (!$Connection->checkColumnName('marine_archive','status_id')) {
1868
+			if (!$Connection->checkColumnName('marine_archive', 'status_id')) {
1869 1869
 				$query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL";
1870 1870
 				try {
1871 1871
 					$sth = $Connection->db->prepare($query);
1872 1872
 					$sth->execute();
1873
-				} catch(PDOException $e) {
1873
+				} catch (PDOException $e) {
1874 1874
 					return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n";
1875 1875
 				}
1876 1876
 			}
1877
-			if (!$Connection->checkColumnName('marine_archive_output','status_id')) {
1877
+			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) {
1878 1878
 				$query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL";
1879 1879
 				try {
1880 1880
 					$sth = $Connection->db->prepare($query);
1881 1881
 					$sth->execute();
1882
-				} catch(PDOException $e) {
1882
+				} catch (PDOException $e) {
1883 1883
 					return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n";
1884 1884
 				}
1885 1885
 			}
@@ -1888,7 +1888,7 @@  discard block
 block discarded – undo
1888 1888
 		try {
1889 1889
 			$sth = $Connection->db->prepare($query);
1890 1890
 			$sth->execute();
1891
-		} catch(PDOException $e) {
1891
+		} catch (PDOException $e) {
1892 1892
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1893 1893
 		}
1894 1894
 		return $error;
@@ -1903,14 +1903,14 @@  discard block
 block discarded – undo
1903 1903
 			try {
1904 1904
 				$sth = $Connection->db->prepare($query);
1905 1905
 				$sth->execute();
1906
-			} catch(PDOException $e) {
1906
+			} catch (PDOException $e) {
1907 1907
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1908 1908
 			}
1909 1909
 			$query = "ALTER TABLE marine_identity MODIFY COLUMN mmsi varchar(255) DEFAULT NULL";
1910 1910
 			try {
1911 1911
 				$sth = $Connection->db->prepare($query);
1912 1912
 				$sth->execute();
1913
-			} catch(PDOException $e) {
1913
+			} catch (PDOException $e) {
1914 1914
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1915 1915
 			}
1916 1916
 		} else {
@@ -1918,14 +1918,14 @@  discard block
 block discarded – undo
1918 1918
 			try {
1919 1919
 				$sth = $Connection->db->prepare($query);
1920 1920
 				$sth->execute();
1921
-			} catch(PDOException $e) {
1921
+			} catch (PDOException $e) {
1922 1922
 				return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n";
1923 1923
 			}
1924 1924
 			$query = "alter table marine_identity alter column mmsi type varchar(255)";
1925 1925
 			try {
1926 1926
 				$sth = $Connection->db->prepare($query);
1927 1927
 				$sth->execute();
1928
-			} catch(PDOException $e) {
1928
+			} catch (PDOException $e) {
1929 1929
 				return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n";
1930 1930
 			}
1931 1931
 		}
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
 		try {
1934 1934
 			$sth = $Connection->db->prepare($query);
1935 1935
 			$sth->execute();
1936
-		} catch(PDOException $e) {
1936
+		} catch (PDOException $e) {
1937 1937
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1938 1938
 		}
1939 1939
 		return $error;
@@ -1943,32 +1943,32 @@  discard block
 block discarded – undo
1943 1943
 		global $globalDBdriver;
1944 1944
 		$Connection = new Connection();
1945 1945
 		$error = '';
1946
-		if (!$Connection->checkColumnName('source_location','last_seen')) {
1946
+		if (!$Connection->checkColumnName('source_location', 'last_seen')) {
1947 1947
 			$query = "ALTER TABLE source_location ADD COLUMN last_seen timestamp NULL DEFAULT NULL";
1948 1948
 			try {
1949 1949
 				$sth = $Connection->db->prepare($query);
1950 1950
 				$sth->execute();
1951
-			} catch(PDOException $e) {
1951
+			} catch (PDOException $e) {
1952 1952
 				return "error (add column last_seen in source_location) : ".$e->getMessage()."\n";
1953 1953
 			}
1954 1954
 		}
1955 1955
 		if ($globalDBdriver == 'mysql') {
1956
-			if (!$Connection->checkColumnName('source_location','location_id')) {
1956
+			if (!$Connection->checkColumnName('source_location', 'location_id')) {
1957 1957
 				$query = "ALTER TABLE source_location ADD COLUMN location_id int(11) DEFAULT NULL";
1958 1958
 				try {
1959 1959
 					$sth = $Connection->db->prepare($query);
1960 1960
 					$sth->execute();
1961
-				} catch(PDOException $e) {
1961
+				} catch (PDOException $e) {
1962 1962
 					return "error (add column location_id in source_location) : ".$e->getMessage()."\n";
1963 1963
 				}
1964 1964
 			}
1965 1965
 		} else {
1966
-			if (!$Connection->checkColumnName('source_location','location_id')) {
1966
+			if (!$Connection->checkColumnName('source_location', 'location_id')) {
1967 1967
 				$query = "ALTER TABLE source_location ADD COLUMN location_id integer DEFAULT NULL";
1968 1968
 				try {
1969 1969
 					$sth = $Connection->db->prepare($query);
1970 1970
 					$sth->execute();
1971
-				} catch(PDOException $e) {
1971
+				} catch (PDOException $e) {
1972 1972
 					return "error (add column location_id in source_location) : ".$e->getMessage()."\n";
1973 1973
 				}
1974 1974
 			}
@@ -1977,7 +1977,7 @@  discard block
 block discarded – undo
1977 1977
 		try {
1978 1978
 			$sth = $Connection->db->prepare($query);
1979 1979
 			$sth->execute();
1980
-		} catch(PDOException $e) {
1980
+		} catch (PDOException $e) {
1981 1981
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1982 1982
 		}
1983 1983
 		return $error;
@@ -1987,12 +1987,12 @@  discard block
 block discarded – undo
1987 1987
 		global $globalDBdriver;
1988 1988
 		$Connection = new Connection();
1989 1989
 		$error = '';
1990
-		if (!$Connection->checkColumnName('source_location','description')) {
1990
+		if (!$Connection->checkColumnName('source_location', 'description')) {
1991 1991
 			$query = "ALTER TABLE source_location ADD COLUMN description text DEFAULT NULL";
1992 1992
 			try {
1993 1993
 				$sth = $Connection->db->prepare($query);
1994 1994
 				$sth->execute();
1995
-			} catch(PDOException $e) {
1995
+			} catch (PDOException $e) {
1996 1996
 				return "error (add column description in source_location) : ".$e->getMessage()."\n";
1997 1997
 			}
1998 1998
 		}
@@ -2000,7 +2000,7 @@  discard block
 block discarded – undo
2000 2000
 		try {
2001 2001
 			$sth = $Connection->db->prepare($query);
2002 2002
 			$sth->execute();
2003
-		} catch(PDOException $e) {
2003
+		} catch (PDOException $e) {
2004 2004
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2005 2005
 		}
2006 2006
 		return $error;
@@ -2010,39 +2010,39 @@  discard block
 block discarded – undo
2010 2010
 		global $globalDBdriver;
2011 2011
 		$Connection = new Connection();
2012 2012
 		$error = '';
2013
-		if (!$Connection->checkColumnName('spotter_live','real_altitude')) {
2013
+		if (!$Connection->checkColumnName('spotter_live', 'real_altitude')) {
2014 2014
 			$query = "ALTER TABLE spotter_live ADD COLUMN real_altitude float DEFAULT NULL";
2015 2015
 			try {
2016 2016
 				$sth = $Connection->db->prepare($query);
2017 2017
 				$sth->execute();
2018
-			} catch(PDOException $e) {
2018
+			} catch (PDOException $e) {
2019 2019
 				return "error (add column real_altitude in spotter_live) : ".$e->getMessage()."\n";
2020 2020
 			}
2021 2021
 		}
2022
-		if (!$Connection->checkColumnName('spotter_output','real_altitude')) {
2022
+		if (!$Connection->checkColumnName('spotter_output', 'real_altitude')) {
2023 2023
 			$query = "ALTER TABLE spotter_output ADD COLUMN real_altitude float DEFAULT NULL";
2024 2024
 			try {
2025 2025
 				$sth = $Connection->db->prepare($query);
2026 2026
 				$sth->execute();
2027
-			} catch(PDOException $e) {
2027
+			} catch (PDOException $e) {
2028 2028
 				return "error (add column real_altitude in spotter_output) : ".$e->getMessage()."\n";
2029 2029
 			}
2030 2030
 		}
2031
-		if (!$Connection->checkColumnName('spotter_archive_output','real_altitude')) {
2031
+		if (!$Connection->checkColumnName('spotter_archive_output', 'real_altitude')) {
2032 2032
 			$query = "ALTER TABLE spotter_archive_output ADD COLUMN real_altitude float DEFAULT NULL";
2033 2033
 			try {
2034 2034
 				$sth = $Connection->db->prepare($query);
2035 2035
 				$sth->execute();
2036
-			} catch(PDOException $e) {
2036
+			} catch (PDOException $e) {
2037 2037
 				return "error (add column real_altitude in spotter_archive_output) : ".$e->getMessage()."\n";
2038 2038
 			}
2039 2039
 		}
2040
-		if (!$Connection->checkColumnName('spotter_archive','real_altitude')) {
2040
+		if (!$Connection->checkColumnName('spotter_archive', 'real_altitude')) {
2041 2041
 			$query = "ALTER TABLE spotter_archive ADD COLUMN real_altitude float DEFAULT NULL";
2042 2042
 			try {
2043 2043
 				$sth = $Connection->db->prepare($query);
2044 2044
 				$sth->execute();
2045
-			} catch(PDOException $e) {
2045
+			} catch (PDOException $e) {
2046 2046
 				return "error (add column real_altitude in spotter_archive) : ".$e->getMessage()."\n";
2047 2047
 			}
2048 2048
 		}
@@ -2050,7 +2050,7 @@  discard block
 block discarded – undo
2050 2050
 		try {
2051 2051
 			$sth = $Connection->db->prepare($query);
2052 2052
 			$sth->execute();
2053
-		} catch(PDOException $e) {
2053
+		} catch (PDOException $e) {
2054 2054
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2055 2055
 		}
2056 2056
 		return $error;
@@ -2072,14 +2072,14 @@  discard block
 block discarded – undo
2072 2072
 		try {
2073 2073
 			$sth = $Connection->db->prepare($query);
2074 2074
 			$sth->execute();
2075
-		} catch(PDOException $e) {
2075
+		} catch (PDOException $e) {
2076 2076
 			return "error (modify column altitude in tracker_*) : ".$e->getMessage()."\n";
2077 2077
 		}
2078 2078
 		$query = "UPDATE config SET value = '44' WHERE name = 'schema_version'";
2079 2079
 		try {
2080 2080
 			$sth = $Connection->db->prepare($query);
2081 2081
 			$sth->execute();
2082
-		} catch(PDOException $e) {
2082
+		} catch (PDOException $e) {
2083 2083
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2084 2084
 		}
2085 2085
 		return $error;
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
 		try {
2121 2121
 			$sth = $Connection->db->prepare($query);
2122 2122
 			$sth->execute();
2123
-		} catch(PDOException $e) {
2123
+		} catch (PDOException $e) {
2124 2124
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2125 2125
 		}
2126 2126
 		return $error;
@@ -2143,7 +2143,7 @@  discard block
 block discarded – undo
2143 2143
 		try {
2144 2144
 			$sth = $Connection->db->prepare($query);
2145 2145
 			$sth->execute();
2146
-		} catch(PDOException $e) {
2146
+		} catch (PDOException $e) {
2147 2147
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2148 2148
 		}
2149 2149
 		return $error;
@@ -2193,7 +2193,7 @@  discard block
 block discarded – undo
2193 2193
 		try {
2194 2194
 			$sth = $Connection->db->prepare($query);
2195 2195
 			$sth->execute();
2196
-		} catch(PDOException $e) {
2196
+		} catch (PDOException $e) {
2197 2197
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2198 2198
 		}
2199 2199
 		return $error;
@@ -2216,7 +2216,7 @@  discard block
 block discarded – undo
2216 2216
 		try {
2217 2217
 			$sth = $Connection->db->prepare($query);
2218 2218
 			$sth->execute();
2219
-		} catch(PDOException $e) {
2219
+		} catch (PDOException $e) {
2220 2220
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2221 2221
 		}
2222 2222
 		return $error;
@@ -2239,7 +2239,7 @@  discard block
 block discarded – undo
2239 2239
 		try {
2240 2240
 			$sth = $Connection->db->prepare($query);
2241 2241
 			$sth->execute();
2242
-		} catch(PDOException $e) {
2242
+		} catch (PDOException $e) {
2243 2243
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2244 2244
 		}
2245 2245
 		return $error;
@@ -2260,7 +2260,7 @@  discard block
 block discarded – undo
2260 2260
 		try {
2261 2261
 			$sth = $Connection->db->prepare($query);
2262 2262
 			$sth->execute();
2263
-		} catch(PDOException $e) {
2263
+		} catch (PDOException $e) {
2264 2264
 			return "error (update schema_version) : ".$e->getMessage()."\n";
2265 2265
 		}
2266 2266
 		return $error;
@@ -2283,7 +2283,7 @@  discard block
 block discarded – undo
2283 2283
 					try {
2284 2284
 						$sth = $Connection->db->prepare($query);
2285 2285
 						$sth->execute();
2286
-					} catch(PDOException $e) {
2286
+					} catch (PDOException $e) {
2287 2287
 						return "error (check_version): ".$e->getMessage()."\n";
2288 2288
 					}
2289 2289
 					$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
polar-geojson.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 header('Content-Type: text/javascript');
18 18
 
19 19
 
20
-$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
20
+$polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
21 21
 $output = '{"type": "FeatureCollection","features": [';
22 22
 if (!empty($polar)) {
23
-	foreach($polar as $eachpolar) {
23
+	foreach ($polar as $eachpolar) {
24 24
 		$data = json_decode($eachpolar['source_data']);
25 25
 		$name = $eachpolar['source_name'];
26 26
 		$coord = $Location->getLocationInfobySourceName($name);
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 			$initial_longitude = $globalCenterLongitude;
34 34
 		}
35 35
 		$first = '';
36
-		foreach($data as $value => $key) {
37
-			$final_coord = $Common->getCoordfromDistanceBearing($initial_latitude,$initial_longitude,$value*22.5,$key);
38
-			if ($first == '') $first = '['.round($final_coord['longitude'],5).','.round($final_coord['latitude'],5).']';
36
+		foreach ($data as $value => $key) {
37
+			$final_coord = $Common->getCoordfromDistanceBearing($initial_latitude, $initial_longitude, $value*22.5, $key);
38
+			if ($first == '') $first = '['.round($final_coord['longitude'], 5).','.round($final_coord['latitude'], 5).']';
39 39
 			$output .= '['.$final_coord['longitude'].','.$final_coord['latitude'].'],';
40 40
 		}
41 41
 		$output .= $first;
42 42
 		$output .= ']]}},';
43 43
 	}
44
-	$output  = substr($output, 0, -1);
44
+	$output = substr($output, 0, -1);
45 45
 }
46 46
 $output .= ']}';
47 47
 print $output;
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Spacing   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 	    die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
53
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
54 54
     }
55 55
 }
56 56
 
57
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
57
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65 65
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
66
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
67 67
     else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106 106
     if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
107
+    $SI = new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
111 111
     $SI->connect();
112 112
 */
113
-} else $SI=new SpotterImport($Connection->db);
113
+} else $SI = new SpotterImport($Connection->db);
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
     $MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127
-$SBS=new SBS();
127
+$SBS = new SBS();
128 128
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
129
-	$ACARS=new ACARS($Connection->db,true);
130
-	$Source=new Source($Connection->db);
129
+	$ACARS = new ACARS($Connection->db, true);
130
+	$Source = new Source($Connection->db);
131 131
 }
132
-$Common=new Common();
132
+$Common = new Common();
133 133
 date_default_timezone_set('UTC');
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
137
+    pcntl_signal(SIGINT, function() {
138 138
         global $sockets;
139 139
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140 140
         die("Bye!\n");
@@ -150,35 +150,35 @@  discard block
 block discarded – undo
150 150
 
151 151
 function connect_all($hosts) {
152 152
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
153
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
154 154
     $reset++;
155 155
     if ($globalDebug) echo 'Connect to all...'."\n";
156 156
     foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
160
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
+            if (preg_match('/deltadb.txt$/i', $host)) {
162 162
         	//$formats[$id] = 'deltadbtxt';
163 163
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 164
         	//$last_exec['deltadbtxt'] = 0;
165 165
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
166
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
167 167
         	//$formats[$id] = 'vatsimtxt';
168 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 169
         	//$last_exec['vatsimtxt'] = 0;
170 170
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
171
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
172 172
         	//$formats[$id] = 'aircraftlistjson';
173 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 174
         	//$last_exec['aircraftlistjson'] = 0;
175 175
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
176
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
177 177
         	//$formats[$id] = 'aircraftjson';
178 178
         	$globalSources[$id]['format'] = 'aircraftjson';
179 179
         	//$last_exec['aircraftlistjson'] = 0;
180 180
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/opensky/i',$host)) {
181
+    	    } else if (preg_match('/opensky/i', $host)) {
182 182
         	//$formats[$id] = 'aircraftlistjson';
183 183
         	$globalSources[$id]['format'] = 'opensky';
184 184
         	//$last_exec['aircraftlistjson'] = 0;
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         	    exit(0);
196 196
         	}
197 197
     	    */
198
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
198
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
199 199
         	//$formats[$id] = 'planeupdatefaa';
200 200
         	$globalSources[$id]['format'] = 'planeupdatefaa';
201 201
         	//$last_exec['planeupdatefaa'] = 0;
@@ -204,37 +204,37 @@  discard block
 block discarded – undo
204 204
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
205 205
         	    exit(0);
206 206
         	}
207
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
207
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
208 208
         	//$formats[$id] = 'phpvmacars';
209 209
         	$globalSources[$id]['format'] = 'phpvmacars';
210 210
         	//$last_exec['phpvmacars'] = 0;
211 211
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
212
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
212
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
213 213
         	//$formats[$id] = 'phpvmacars';
214 214
         	$globalSources[$id]['format'] = 'vaos';
215 215
         	//$last_exec['phpvmacars'] = 0;
216 216
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
217
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
217
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
218 218
         	//$formats[$id] = 'phpvmacars';
219 219
         	$globalSources[$id]['format'] = 'vam';
220 220
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
221
-            } else if (preg_match('/whazzup/i',$host)) {
221
+            } else if (preg_match('/whazzup/i', $host)) {
222 222
         	//$formats[$id] = 'whazzup';
223 223
         	$globalSources[$id]['format'] = 'whazzup';
224 224
         	//$last_exec['whazzup'] = 0;
225 225
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
226
-            } else if (preg_match('/blitzortung/i',$host)) {
226
+            } else if (preg_match('/blitzortung/i', $host)) {
227 227
         	$globalSources[$id]['format'] = 'blitzortung';
228 228
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
229
-            } else if (preg_match('/airwhere/i',$host)) {
229
+            } else if (preg_match('/airwhere/i', $host)) {
230 230
         	$globalSources[$id]['format'] = 'airwhere';
231 231
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
232
-            } else if (preg_match('/recentpireps/i',$host)) {
232
+            } else if (preg_match('/recentpireps/i', $host)) {
233 233
         	//$formats[$id] = 'pirepsjson';
234 234
         	$globalSources[$id]['format'] = 'pirepsjson';
235 235
         	//$last_exec['pirepsjson'] = 0;
236 236
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
237
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
237
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
238 238
         	//$formats[$id] = 'fr24json';
239 239
         	$globalSources[$id]['format'] = 'fr24json';
240 240
         	//$last_exec['fr24json'] = 0;
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
244 244
         	    exit(0);
245 245
         	}
246
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
246
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
247 247
         	//$formats[$id] = 'fr24json';
248 248
         	$globalSources[$id]['format'] = 'myshiptracking';
249 249
         	//$last_exec['fr24json'] = 0;
@@ -253,21 +253,21 @@  discard block
 block discarded – undo
253 253
         	    exit(0);
254 254
         	}
255 255
             //} else if (preg_match('/10001/',$host)) {
256
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
256
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
257 257
         	//$formats[$id] = 'tsv';
258 258
         	$globalSources[$id]['format'] = 'tsv';
259 259
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
260 260
             }
261
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
261
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
262 262
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
263
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
263
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
264 264
     		    if ($idf !== false) {
265 265
     			$httpfeeds[$id] = $idf;
266 266
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
267 267
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
268 268
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
269
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
270
-	    $hostport = explode(':',$host);
269
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
270
+	    $hostport = explode(':', $host);
271 271
 	    if (isset($hostport[1])) {
272 272
 		$port = $hostport[1];
273 273
 		$hostn = $hostport[0];
@@ -277,19 +277,19 @@  discard block
 block discarded – undo
277 277
 	    }
278 278
 	    $Common = new Common();
279 279
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
280
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
280
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
281 281
     	    } else {
282
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
282
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
283 283
 	    }
284 284
 	    if ($s) {
285 285
     	        $sockets[$id] = $s;
286 286
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
287
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
287
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
288 288
 			//$formats[$id] = 'aprs';
289 289
 			$globalSources[$id]['format'] = 'aprs';
290 290
 			//$aprs_connect = 0;
291 291
 			//$use_aprs = true;
292
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
292
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
293 293
 			$globalSources[$id]['format'] = 'vrstcp';
294 294
     		    } elseif ($port == '10001') {
295 295
         		//$formats[$id] = 'tsv';
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
329 329
 else $timeout = 20;
330 330
 $errno = '';
331
-$errstr='';
331
+$errstr = '';
332 332
 
333 333
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
334 334
 /* Initiate connections to all the hosts simultaneously */
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 //connect_all($globalSources);
337 337
 
338 338
 if (isset($globalProxy) && $globalProxy) {
339
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
339
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
340 340
 } else {
341 341
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
342 342
 }
@@ -366,16 +366,16 @@  discard block
 block discarded – undo
366 366
 
367 367
 if ($use_aprs) {
368 368
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
369
-	$APRS=new APRS();
369
+	$APRS = new APRS();
370 370
 	$aprs_connect = 0;
371 371
 	$aprs_keep = 120;
372 372
 	$aprs_last_tx = time();
373 373
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
374
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
374
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
375 375
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
376
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
376
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
377 377
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
378
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
378
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
379 379
 	if ($aprs_full) $aprs_filter = '';
380 380
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
381 381
 	else $aprs_pass = '-1';
@@ -389,12 +389,12 @@  discard block
 block discarded – undo
389 389
 sleep(1);
390 390
 if ($globalDebug) echo "SCAN MODE \n\n";
391 391
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
392
-$endtime = time()+$globalCronEnd;
392
+$endtime = time() + $globalCronEnd;
393 393
 $i = 1;
394 394
 $tt = array();
395 395
 // Delete all ATC
396 396
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
397
-	$ATC=new ATC($Connection->db);
397
+	$ATC = new ATC($Connection->db);
398 398
 }
399 399
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
400 400
 	$ATC->deleteAll();
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 while ($i > 0) {
405 405
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
406 406
 
407
-    if (!$globalDaemon) $i = $endtime-time();
407
+    if (!$globalDaemon) $i = $endtime - time();
408 408
     // Delete old ATC
409 409
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
410 410
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	}
419 419
 	if ($max < $globalMinFetch) {
420 420
 	    if ($globalDebug) echo 'Sleeping...'."\n";
421
-	    sleep($globalMinFetch-$max+2);
421
+	    sleep($globalMinFetch - $max + 2);
422 422
 	}
423 423
     }
424 424
 
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 	    //$buffer = $Common->getData($hosts[$id]);
438 438
 	    $buffer = $Common->getData($value['host']);
439 439
 	    if ($buffer != '') $reset = 0;
440
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
441
-	    $buffer = explode('\n',$buffer);
440
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
441
+	    $buffer = explode('\n', $buffer);
442 442
 	    foreach ($buffer as $line) {
443 443
     		if ($line != '' && count($line) > 7) {
444 444
     		    $line = explode(',', $line);
@@ -471,11 +471,11 @@  discard block
 block discarded – undo
471 471
 	    )
472 472
 	) {
473 473
 	    date_default_timezone_set('CET');
474
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
474
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
475 475
 	    date_default_timezone_set('UTC');
476 476
 	    if ($buffer != '') $reset = 0;
477
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
478
-	    $buffer = explode('\n',$buffer);
477
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
478
+	    $buffer = explode('\n', $buffer);
479 479
 	    foreach ($buffer as $line) {
480 480
 		if ($line != '') {
481 481
 		    //echo "'".$line."'\n";
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 		    $ais_data = $AIS->parse_line(trim($line));
484 484
 		    $data = array();
485 485
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
486
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
486
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
487 487
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
488 488
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
489 489
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
496 496
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
497 497
 		    if (isset($ais_data['timestamp'])) {
498
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
498
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
499 499
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
500 500
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
501 501
 			    $add = true;
@@ -518,21 +518,21 @@  discard block
 block discarded – undo
518 518
 	    $w = $e = null;
519 519
 	    
520 520
 	    if (isset($arr[$id])) {
521
-		$nn = stream_select($arr,$w,$e,$timeout);
521
+		$nn = stream_select($arr, $w, $e, $timeout);
522 522
 		if ($nn > 0) {
523 523
 		    foreach ($httpfeeds as $feed) {
524
-			$buffer = stream_get_line($feed,2000,"\n");
524
+			$buffer = stream_get_line($feed, 2000, "\n");
525 525
 			if ($buffer === FALSE) {
526 526
 			    connect_all($globalSources);
527 527
 			}
528
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
529
-			$buffer = explode('\n',$buffer);
528
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
529
+			$buffer = explode('\n', $buffer);
530 530
 			foreach ($buffer as $line) {
531 531
 			    if ($line != '') {
532 532
 				$ais_data = $AIS->parse_line(trim($line));
533 533
 				$data = array();
534 534
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
535
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
535
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
536 536
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
537 537
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
538 538
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -544,9 +544,9 @@  discard block
 block discarded – undo
544 544
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
545 545
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
546 546
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
547
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
547
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
548 548
 				if (isset($ais_data['timestamp'])) {
549
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
549
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
550 550
 				} else {
551 551
 				    $data['datetime'] = date('Y-m-d H:i:s');
552 552
 				}
@@ -578,10 +578,10 @@  discard block
 block discarded – undo
578 578
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
579 579
 	    )
580 580
 	) {
581
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
581
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
582 582
 	    if ($buffer != '') {
583 583
 		//echo $buffer;
584
-		$all_data = json_decode($buffer,true);
584
+		$all_data = json_decode($buffer, true);
585 585
 		//print_r($all_data);
586 586
 		if (isset($all_data[0]['DATA'])) {
587 587
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 			    $data['ident'] = $line['NAME'];
591 591
 			    $data['mmsi'] = $line['MMSI'];
592 592
 			    if (strlen($data['mmsi']) > 9) {
593
-				$data['mmsi'] = substr($data['mmsi'],-9);
593
+				$data['mmsi'] = substr($data['mmsi'], -9);
594 594
 			    }
595 595
 			    $data['speed'] = $line['SOG'];
596 596
 			    $data['heading'] = $line['COG'];
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 			    //$data['type_id'] = $line['TYPE'];
601 601
 			    $data['imo'] = $line['IMO'];
602 602
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
603
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
604
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
603
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
604
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
605 605
 			    $data['format_source'] = 'myshiptracking';
606 606
 			    $data['id_source'] = $id_source;
607 607
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -618,16 +618,16 @@  discard block
 block discarded – undo
618 618
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
619 619
 	    )
620 620
 	) {
621
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
621
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
622 622
 	    if ($buffer != '') {
623
-		$all_data = json_decode($buffer,true);
623
+		$all_data = json_decode($buffer, true);
624 624
 		if (isset($all_data[0]['mmsi'])) {
625 625
 		    foreach ($all_data as $line) {
626 626
 			if ($line != '') {
627 627
 			    $data = array();
628 628
 			    $data['ident'] = $line['shipname'];
629 629
 			    $data['callsign'] = $line['callsign'];
630
-			    $data['mmsi'] = substr($line['mmsi'],-9);
630
+			    $data['mmsi'] = substr($line['mmsi'], -9);
631 631
 			    $data['speed'] = $line['sog'];
632 632
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
633 633
 			    $data['latitude'] = $line['latitude'];
@@ -654,14 +654,14 @@  discard block
 block discarded – undo
654 654
 	) {
655 655
 	    $buffer = $Common->getData($value['host']);
656 656
 	    if ($buffer != '') {
657
-		$all_data = json_decode($buffer,true);
657
+		$all_data = json_decode($buffer, true);
658 658
 		if (isset($all_data['features'][0]['id'])) {
659 659
 		    foreach ($all_data['features'] as $line) {
660 660
 			print_r($line);
661 661
 			$data = array();
662 662
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
663 663
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
664
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
664
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
665 665
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
666 666
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
667 667
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -688,31 +688,31 @@  discard block
 block discarded – undo
688 688
 	    )
689 689
 	) {
690 690
 	    echo 'download...';
691
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
691
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
692 692
 	    echo 'done !'."\n";
693 693
 	    // FIXME: Need more work
694 694
 	    if ($buffer != '') $reset = 0;
695
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
696
-	    $buffer = explode('\n',$buffer);
695
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
696
+	    $buffer = explode('\n', $buffer);
697 697
 	    foreach ($buffer as $line) {
698 698
 		if ($line != '') {
699 699
 		    $data = array();
700 700
 		    echo $line."\n";
701
-		    $data['mmsi'] = (int)substr($line,0,9);
702
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
703
-		    $data['status_id'] = substr($line,21,2);
704
-		    $data['type_id'] = substr($line,24,3);
705
-		    $data['latitude'] = substr($line,29,9);
706
-		    $data['longitude'] = substr($line,41,9);
707
-		    $data['speed'] = round(substr($line,51,5));
701
+		    $data['mmsi'] = (int) substr($line, 0, 9);
702
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
703
+		    $data['status_id'] = substr($line, 21, 2);
704
+		    $data['type_id'] = substr($line, 24, 3);
705
+		    $data['latitude'] = substr($line, 29, 9);
706
+		    $data['longitude'] = substr($line, 41, 9);
707
+		    $data['speed'] = round(substr($line, 51, 5));
708 708
 		    //$data['course'] = substr($line,57,5);
709
-		    $data['heading'] = round(substr($line,63,3));
709
+		    $data['heading'] = round(substr($line, 63, 3));
710 710
 		    //$data['draft'] = substr($line,67,4);
711 711
 		    //$data['length'] = substr($line,72,3);
712 712
 		    //$data['beam'] = substr($line,76,2);
713
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
713
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
714 714
 		    //$data['callsign'] = trim(substr($line,100,7);
715
-		    $data['arrival_code'] = substr($line,108,20);
715
+		    $data['arrival_code'] = substr($line, 108, 20);
716 716
 		    //$data['etaDate'] = substr($line,129,5);
717 717
 		    //$data['etaTime'] = substr($line,135,5);
718 718
 		    $data['format_source'] = 'shipplotter';
@@ -743,8 +743,8 @@  discard block
 block discarded – undo
743 743
 	) {
744 744
 	    //$buffer = $Common->getData($hosts[$id]);
745 745
 	    $buffer = $Common->getData($value['host']);
746
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
747
-	    $buffer = explode('\n',$buffer);
746
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
747
+	    $buffer = explode('\n', $buffer);
748 748
 	    $reset = 0;
749 749
 	    foreach ($buffer as $line) {
750 750
     		if ($line != '') {
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
756 756
 			$data['pilot_id'] = $line[1];
757 757
 			$data['pilot_name'] = $line[2];
758
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
758
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
759 759
 			$data['ident'] = $line[0]; // ident
760 760
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
761 761
 			$data['speed'] = $line[8]; // speed
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
772 772
 			//if (isset($line[37])) $data['last_update'] = $line[37];
773 773
 		        $data['departure_airport_icao'] = $line[11];
774
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
774
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
775 775
 		        $data['arrival_airport_icao'] = $line[13];
776 776
 			$data['frequency'] = $line[4];
777 777
 			$data['type'] = $line[18];
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
     			$data['id_source'] = $id_source;
781 781
 	    		//$data['arrival_airport_time'] = ;
782 782
 	    		if ($line[9] != '') {
783
-	    		    $aircraft_data = explode('/',$line[9]);
783
+	    		    $aircraft_data = explode('/', $line[9]);
784 784
 	    		    if (isset($aircraft_data[1])) {
785 785
 	    			$data['aircraft_icao'] = $aircraft_data[1];
786 786
 	    		    }
@@ -795,9 +795,9 @@  discard block
 block discarded – undo
795 795
     			if ($line[3] === 'PILOT') $SI->add($data);
796 796
 			elseif ($line[3] === 'ATC') {
797 797
 				//print_r($data);
798
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
799
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
800
-				$typec = substr($data['ident'],-3);
798
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
799
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
800
+				$typec = substr($data['ident'], -3);
801 801
 				if ($typec === 'APP') $data['type'] = 'Approach';
802 802
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
803 803
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
810 810
 				if (!isset($data['source_name'])) $data['source_name'] = '';
811 811
 				if (isset($ATC)) {
812
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
813
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
812
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
813
+					else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
814 814
 				}
815 815
 			}
816 816
     			unset($data);
@@ -826,24 +826,24 @@  discard block
 block discarded – undo
826 826
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
827 827
     	    )
828 828
     	) {
829
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
829
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
830 830
 	    if ($buffer != '') {
831 831
 		$all_data = simplexml_load_string($buffer);
832
-		foreach($all_data->children() as $childdata) {
832
+		foreach ($all_data->children() as $childdata) {
833 833
 			$data = array();
834 834
 			$line = $childdata;
835 835
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
836
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
837
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
838
-			$data['latitude'] = (float)$line['pktLatitude'];
839
-			$data['longitude'] = (float)$line['pktLongitude'];
840
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
841
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
842
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
836
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
837
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
838
+			$data['latitude'] = (float) $line['pktLatitude'];
839
+			$data['longitude'] = (float) $line['pktLongitude'];
840
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
841
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
842
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
843 843
 			$data['altitude_relative'] = 'AMSL';
844
-			$data['pilot_id'] = (int)$line['pktPilotID'];
844
+			$data['pilot_id'] = (int) $line['pktPilotID'];
845 845
 			$data['aircraft_icao'] = 'PARAGLIDER';
846
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
846
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
847 847
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
848 848
 			$data['format_source'] = $value['format'];
849 849
 			$SI->add($data);
@@ -851,22 +851,22 @@  discard block
 block discarded – undo
851 851
 		}
852 852
 	    }
853 853
 	    $Source->deleteOldLocationByType('gs');
854
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
854
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
855 855
 	    if ($buffer != '') {
856 856
 		$all_data = simplexml_load_string($buffer);
857
-		foreach($all_data->children() as $childdata) {
857
+		foreach ($all_data->children() as $childdata) {
858 858
 			$data = array();
859 859
 			$line = $childdata;
860
-			$data['id'] = (int)$line['gsID'];
861
-			$data['latitude'] = (float)$line['gsLatitude'];
862
-			$data['longitude'] = (float)$line['gsLongitude'];
863
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
860
+			$data['id'] = (int) $line['gsID'];
861
+			$data['latitude'] = (float) $line['gsLatitude'];
862
+			$data['longitude'] = (float) $line['gsLongitude'];
863
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
864 864
 			$data['altitude_relative'] = 'AMSL';
865
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
865
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
866 866
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
867
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
867
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
868 868
 			} else {
869
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
869
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
870 870
 			}
871 871
 			unset($data);
872 872
 		}
@@ -884,9 +884,9 @@  discard block
 block discarded – undo
884 884
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
885 885
 	    )
886 886
 	) {
887
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
887
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
888 888
 	    if ($buffer != '') {
889
-	        $all_data = json_decode($buffer,true);
889
+	        $all_data = json_decode($buffer, true);
890 890
 		if (isset($all_data['acList'])) {
891 891
 		    $reset = 0;
892 892
 		    foreach ($all_data['acList'] as $line) {
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
903 903
 			$data['emergency'] = ''; // emergency
904 904
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
905
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
905
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
906 906
 			else $data['datetime'] = date('Y-m-d H:i:s');
907 907
 			//$data['datetime'] = date('Y-m-d H:i:s');
908 908
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 			$data['verticalrate'] = $line['vrt']; // verticale rate
928 928
 			$data['squawk'] = $line['squawk']; // squawk
929 929
 			$data['emergency'] = ''; // emergency
930
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
930
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
931 931
 			else $data['datetime'] = date('Y-m-d H:i:s');
932 932
 			$data['format_source'] = 'aircraftlistjson';
933 933
 			$data['id_source'] = $id_source;
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
     	    )
949 949
     	) {
950 950
 	    $buffer = $Common->getData($value['host']);
951
-	    $all_data = json_decode($buffer,true);
951
+	    $all_data = json_decode($buffer, true);
952 952
 	    if (isset($all_data['planes'])) {
953 953
 		$reset = 0;
954 954
 		foreach ($all_data['planes'] as $key => $line) {
@@ -965,12 +965,12 @@  discard block
 block discarded – undo
965 965
 		    $data['emergency'] = ''; // emergency
966 966
 		    $data['registration'] = $line[2];
967 967
 		    $data['aircraft_icao'] = $line[0];
968
-		    $deparr = explode('-',$line[1]);
968
+		    $deparr = explode('-', $line[1]);
969 969
 		    if (count($deparr) === 2) {
970 970
 			$data['departure_airport_icao'] = $deparr[0];
971 971
 			$data['arrival_airport_icao'] = $deparr[1];
972 972
 		    }
973
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
973
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
974 974
 	    	    $data['format_source'] = 'planeupdatefaa';
975 975
     		    $data['id_source'] = $id_source;
976 976
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 	    )
989 989
 	) {
990 990
 	    $buffer = $Common->getData($value['host']);
991
-	    $all_data = json_decode($buffer,true);
991
+	    $all_data = json_decode($buffer, true);
992 992
 	    if (isset($all_data['states'])) {
993 993
 		$reset = 0;
994 994
 		foreach ($all_data['states'] as $key => $line) {
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 		    //$data['emergency'] = ''; // emergency
1006 1006
 		    //$data['registration'] = $line[2];
1007 1007
 		    //$data['aircraft_icao'] = $line[0];
1008
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1008
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1009 1009
 		    $data['format_source'] = 'opensky';
1010 1010
 		    $data['id_source'] = $id_source;
1011 1011
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
 	    )
1023 1023
 	) {
1024 1024
 	    $buffer = $Common->getData($value['host']);
1025
-	    $all_data = json_decode($buffer,true);
1025
+	    $all_data = json_decode($buffer, true);
1026 1026
 	    if (isset($all_data['aircraft'])) {
1027 1027
 		$reset = 0;
1028 1028
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 	) {
1059 1059
 	    //$buffer = $Common->getData($hosts[$id]);
1060 1060
 	    $buffer = $Common->getData($value['host']);
1061
-	    $all_data = json_decode($buffer,true);
1061
+	    $all_data = json_decode($buffer, true);
1062 1062
 	    if (!empty($all_data)) $reset = 0;
1063 1063
 	    foreach ($all_data as $key => $line) {
1064 1064
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1096,11 +1096,11 @@  discard block
 block discarded – undo
1096 1096
 	    )
1097 1097
 	) {
1098 1098
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1099
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1099
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1100 1100
 	    //echo $buffer;
1101
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1102
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1103
-	    $all_data = json_decode($buffer,true);
1101
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1102
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1103
+	    $all_data = json_decode($buffer, true);
1104 1104
 	    if (json_last_error() != JSON_ERROR_NONE) {
1105 1105
 		die(json_last_error_msg());
1106 1106
 	    }
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 			//$data['departure_airport_iata'] = $line[11];
1124 1124
 			//$data['arrival_airport_iata'] = $line[12];
1125 1125
 	    		//$data['emergency'] = ''; // emergency
1126
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1126
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1127 1127
 	    		$data['format_source'] = 'radarvirtueljson';
1128 1128
     			$data['id_source'] = $id_source;
1129 1129
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1144,14 +1144,14 @@  discard block
 block discarded – undo
1144 1144
 	) {
1145 1145
 	    //$buffer = $Common->getData($hosts[$id]);
1146 1146
 	    $buffer = $Common->getData($value['host'].'?'.time());
1147
-	    $all_data = json_decode(utf8_encode($buffer),true);
1147
+	    $all_data = json_decode(utf8_encode($buffer), true);
1148 1148
 	    
1149 1149
 	    if (isset($all_data['pireps'])) {
1150 1150
 		$reset = 0;
1151 1151
 	        foreach ($all_data['pireps'] as $line) {
1152 1152
 		    $data = array();
1153 1153
 		    $data['id'] = $line['id'];
1154
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1154
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1155 1155
 		    $data['ident'] = $line['callsign']; // ident
1156 1156
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1157 1157
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1181,9 +1181,9 @@  discard block
 block discarded – undo
1181 1181
 			$SI->add($data);
1182 1182
 		    //    print_r($data);
1183 1183
     		    } elseif ($line['icon'] === 'ct') {
1184
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1185
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1186
-			$typec = substr($data['ident'],-3);
1184
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1185
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1186
+			$typec = substr($data['ident'], -3);
1187 1187
 			$data['type'] = '';
1188 1188
 			if ($typec === 'APP') $data['type'] = 'Approach';
1189 1189
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1195 1195
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1196 1196
 			else $data['type'] = 'Observer';
1197
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1197
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
1198 1198
 		    }
1199 1199
 		    unset($data);
1200 1200
 		}
@@ -1211,14 +1211,14 @@  discard block
 block discarded – undo
1211 1211
 	    //$buffer = $Common->getData($hosts[$id]);
1212 1212
 	    if ($globalDebug) echo 'Get Data...'."\n";
1213 1213
 	    $buffer = $Common->getData($value['host']);
1214
-	    $all_data = json_decode($buffer,true);
1214
+	    $all_data = json_decode($buffer, true);
1215 1215
 	    if ($buffer != '' && is_array($all_data)) {
1216 1216
 		$reset = 0;
1217 1217
 		foreach ($all_data as $line) {
1218 1218
 	    	    $data = array();
1219 1219
 	    	    //$data['id'] = $line['id']; // id not usable
1220 1220
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1221
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1221
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1222 1222
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1223 1223
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1224 1224
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 	    	    //$data['datetime'] = $line['lastupdate'];
1234 1234
 	    	    //$data['last_update'] = $line['lastupdate'];
1235 1235
 	    	    if (isset($value['timezone'])) {
1236
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1236
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1237 1237
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1238 1238
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1239 1239
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1249,14 +1249,14 @@  discard block
 block discarded – undo
1249 1249
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1250 1250
 		    if (isset($line['aircraftname'])) {
1251 1251
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1252
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1253
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1252
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1253
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1254 1254
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1255 1255
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1256 1256
 	    		else {
1257
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1258
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1259
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1257
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1258
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1259
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1260 1260
 	    		}
1261 1261
 	    	    }
1262 1262
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
 	    //$buffer = $Common->getData($hosts[$id]);
1282 1282
 	    if ($globalDebug) echo 'Get Data...'."\n";
1283 1283
 	    $buffer = $Common->getData($value['host']);
1284
-	    $all_data = json_decode($buffer,true);
1284
+	    $all_data = json_decode($buffer, true);
1285 1285
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1286 1286
 		$reset = 0;
1287 1287
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1292,7 +1292,7 @@  discard block
 block discarded – undo
1292 1292
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1293 1293
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1294 1294
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1295
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1295
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1296 1296
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1297 1297
 	    	    $data['altitude'] = $line['altitude']; // altitude
1298 1298
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
 	    	    //$data['squawk'] = ''; // squawk
1304 1304
 	    	    //$data['emergency'] = ''; // emergency
1305 1305
 	    	    if (isset($value['timezone'])) {
1306
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1306
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1307 1307
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1308 1308
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1309 1309
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1339,14 +1339,14 @@  discard block
 block discarded – undo
1339 1339
 	    //$buffer = $Common->getData($hosts[$id]);
1340 1340
 	    if ($globalDebug) echo 'Get Data...'."\n";
1341 1341
 	    $buffer = $Common->getData($value['host']);
1342
-	    $all_data = json_decode($buffer,true);
1342
+	    $all_data = json_decode($buffer, true);
1343 1343
 	    if ($buffer != '' && is_array($all_data)) {
1344 1344
 		$reset = 0;
1345 1345
 		foreach ($all_data as $line) {
1346 1346
 	    	    $data = array();
1347 1347
 	    	    //$data['id'] = $line['id']; // id not usable
1348 1348
 	    	    $data['id'] = trim($line['flight_id']);
1349
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1349
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1350 1350
 	    	    $data['pilot_name'] = $line['pilot_name'];
1351 1351
 	    	    $data['pilot_id'] = $line['pilot_id'];
1352 1352
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1390,24 +1390,24 @@  discard block
 block discarded – undo
1390 1390
 	    //$buffer = $Common->getData($hosts[$id]);
1391 1391
 	    if ($globalDebug) echo 'Get Data...'."\n";
1392 1392
 	    $buffer = $Common->getData($value['host']);
1393
-	    $all_data = json_decode($buffer,true);
1393
+	    $all_data = json_decode($buffer, true);
1394 1394
 	    if ($buffer != '') {
1395 1395
 		$Source->deleteLocationBySource('blitzortung');
1396
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1397
-		$buffer = explode('\n',$buffer);
1396
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1397
+		$buffer = explode('\n', $buffer);
1398 1398
 		foreach ($buffer as $buffer_line) {
1399
-		    $line = json_decode($buffer_line,true);
1399
+		    $line = json_decode($buffer_line, true);
1400 1400
 		    if (isset($line['time'])) {
1401 1401
 			$data = array();
1402 1402
 			$data['altitude'] = $line['alt']; // altitude
1403 1403
 			$data['latitude'] = $line['lat']; // lat
1404 1404
 			$data['longitude'] = $line['lon']; // long
1405
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1405
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1406 1406
 			$data['id_source'] = $id_source;
1407 1407
 			$data['format_source'] = 'blitzortung';
1408 1408
 			$SI->add($data);
1409 1409
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1410
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1410
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1411 1411
 			unset($data);
1412 1412
 		    }
1413 1413
 		}
@@ -1430,11 +1430,11 @@  discard block
 block discarded – undo
1430 1430
 		    //$value = $formats[$nb];
1431 1431
 		    $format = $globalSources[$nb]['format'];
1432 1432
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1433
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1433
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1434 1434
 		    } elseif ($format === 'vrstcp') {
1435 1435
 			$buffer = @socket_read($r, 6000);
1436 1436
 		    } else {
1437
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1437
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1438 1438
 		    }
1439 1439
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1440 1440
 		    //echo $buffer."\n";
@@ -1444,8 +1444,8 @@  discard block
 block discarded – undo
1444 1444
 		    //$SI::del();
1445 1445
 		    if ($buffer !== FALSE) {
1446 1446
 			if ($format === 'vrstcp') {
1447
-			    $buffer = explode('},{',$buffer);
1448
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1447
+			    $buffer = explode('},{', $buffer);
1448
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1449 1449
 		    }
1450 1450
 		    // SBS format is CSV format
1451 1451
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 			    $ais_data = $AIS->parse_line(trim($buffer));
1470 1470
 			    $data = array();
1471 1471
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1472
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1472
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1473 1473
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1474 1474
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1475 1475
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1480,13 +1480,13 @@  discard block
 block discarded – undo
1480 1480
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1481 1481
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1482 1482
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1483
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1483
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1484 1484
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1485 1485
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1486 1486
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1487 1487
 
1488 1488
 			    if (isset($ais_data['timestamp'])) {
1489
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1489
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1490 1490
 			    } else {
1491 1491
 				$data['datetime'] = date('Y-m-d H:i:s');
1492 1492
 			    }
@@ -1497,10 +1497,10 @@  discard block
 block discarded – undo
1497 1497
                         } elseif ($format === 'flightgearsp') {
1498 1498
                     	    //echo $buffer."\n";
1499 1499
                     	    if (strlen($buffer) > 5) {
1500
-				$line = explode(',',$buffer);
1500
+				$line = explode(',', $buffer);
1501 1501
 				$data = array();
1502 1502
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1503
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1503
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1504 1504
 				$data['ident'] = $line[6];
1505 1505
 				$data['aircraft_name'] = $line[7];
1506 1506
 				$data['longitude'] = $line[1];
@@ -1517,16 +1517,16 @@  discard block
 block discarded – undo
1517 1517
                         } elseif ($format === 'acars') {
1518 1518
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1519 1519
 			    $ACARS->add(trim($buffer));
1520
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1520
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1521 1521
 			    $ACARS->deleteLiveAcarsData();
1522 1522
 			} elseif ($format === 'flightgearmp') {
1523
-			    if (substr($buffer,0,1) != '#') {
1523
+			    if (substr($buffer, 0, 1) != '#') {
1524 1524
 				$data = array();
1525 1525
 				//echo $buffer."\n";
1526
-				$line = explode(' ',$buffer);
1526
+				$line = explode(' ', $buffer);
1527 1527
 				if (count($line) === 11) {
1528
-				    $userserver = explode('@',$line[0]);
1529
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1528
+				    $userserver = explode('@', $line[0]);
1529
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1530 1530
 				    $data['ident'] = $userserver[0];
1531 1531
 				    $data['registration'] = $userserver[0];
1532 1532
 				    $data['latitude'] = $line[4];
@@ -1534,8 +1534,8 @@  discard block
 block discarded – undo
1534 1534
 				    $data['altitude'] = $line[6];
1535 1535
 				    $data['datetime'] = date('Y-m-d H:i:s');
1536 1536
 				    $aircraft_type = $line[10];
1537
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1538
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1537
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1538
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1539 1539
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1540 1540
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1541 1541
 				}
@@ -1544,8 +1544,8 @@  discard block
 block discarded – undo
1544 1544
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1545 1545
 			    die;
1546 1546
 			} elseif ($format === 'vrstcp') {
1547
-			    foreach($buffer as $all_data) {
1548
-				$line = json_decode('{'.$all_data.'}',true);
1547
+			    foreach ($buffer as $all_data) {
1548
+				$line = json_decode('{'.$all_data.'}', true);
1549 1549
 				$data = array();
1550 1550
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1551 1551
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1571,16 +1571,16 @@  discard block
 block discarded – undo
1571 1571
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1572 1572
 				unset($data);
1573 1573
 			    }
1574
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1574
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1575 1575
 			    $line = explode("\t", $buffer);
1576
-			    for($k = 0; $k < count($line); $k=$k+2) {
1576
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1577 1577
 				$key = $line[$k];
1578
-			        $lined[$key] = $line[$k+1];
1578
+			        $lined[$key] = $line[$k + 1];
1579 1579
 			    }
1580 1580
     			    if (count($lined) > 3) {
1581 1581
     				$data['hex'] = $lined['hexid'];
1582 1582
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1583
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1583
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1584 1584
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1585 1585
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1586 1586
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1599,23 +1599,23 @@  discard block
 block discarded – undo
1599 1599
     			    } else $error = true;
1600 1600
 			} elseif ($format === 'aprs' && $use_aprs) {
1601 1601
 			    if ($aprs_connect === 0) {
1602
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1602
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1603 1603
 				$aprs_connect = 1;
1604 1604
 			    }
1605 1605
 			    
1606
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1606
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1607 1607
 				$aprs_last_tx = time();
1608 1608
 				$data_aprs = "# Keep alive";
1609
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1609
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1610 1610
 			    }
1611 1611
 			    
1612 1612
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1613 1613
 			    //echo 'APRS data : '.$buffer."\n";
1614
-			    $buffer = str_replace('APRS <- ','',$buffer);
1615
-			    $buffer = str_replace('APRS -> ','',$buffer);
1614
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1615
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1616 1616
 			    //echo $buffer."\n";
1617 1617
 			    date_default_timezone_set('UTC');
1618
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1618
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1619 1619
 				$line = $APRS->parse($buffer);
1620 1620
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1621 1621
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1631 1631
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1632 1632
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1633
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1633
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1634 1634
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1635 1635
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1636 1636
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1713,29 +1713,29 @@  discard block
 block discarded – undo
1713 1713
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1714 1714
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1715 1715
 					$Source->deleteOldLocationByType('gs');
1716
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1717
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1716
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1717
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1718 1718
 					} else {
1719
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1719
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1720 1720
 					}
1721 1721
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1722 1722
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1723 1723
 					if ($globalDebug) echo '# Weather Station added'."\n";
1724 1724
 					$Source->deleteOldLocationByType('wx');
1725 1725
 					$weather_data = json_encode($line);
1726
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1727
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1726
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1727
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1728 1728
 					} else {
1729
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1729
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1730 1730
 					}
1731 1731
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1732 1732
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1733 1733
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1734 1734
 					$Source->deleteOldLocationByType('lightning');
1735
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1736
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1735
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1736
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1737 1737
 					} else {
1738
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1738
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1739 1739
 					}
1740 1740
 				    } elseif ($globalDebug) {
1741 1741
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1744,7 +1744,7 @@  discard block
 block discarded – undo
1744 1744
 				    unset($data);
1745 1745
 				}
1746 1746
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1747
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1747
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1748 1748
 				}
1749 1749
 				/*
1750 1750
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) {
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
 				*/
1754 1754
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1755 1755
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1756
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1756
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1757 1757
 					$Source->deleteOldLocationByType('lightning');
1758 1758
 					$Source->deleteOldLocationByType('wx');
1759 1759
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
 				connect_all($sourceee);
1839 1839
 				$sourceee = array();
1840 1840
 				//connect_all($globalSources);
1841
-				$tt[$format]=0;
1841
+				$tt[$format] = 0;
1842 1842
 				break;
1843 1843
 			    } 
1844 1844
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -1848,14 +1848,14 @@  discard block
 block discarded – undo
1848 1848
 	    } else {
1849 1849
 		$error = socket_strerror(socket_last_error());
1850 1850
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1851
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1851
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1852 1852
 			if (isset($globalDebug)) echo "Restarting...\n";
1853 1853
 			// Restart the script if possible
1854 1854
 			if (is_array($sockets)) {
1855 1855
 			    if ($globalDebug) echo "Shutdown all sockets...";
1856 1856
 			    
1857 1857
 			    foreach ($sockets as $sock) {
1858
-				@socket_shutdown($sock,2);
1858
+				@socket_shutdown($sock, 2);
1859 1859
 				@socket_close($sock);
1860 1860
 			    }
1861 1861
 			    
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 		$currentdate = date('Y-m-d');
35 35
 		$sourcestat = $Stats->getStatsSource($currentdate);
36 36
 		if (!empty($sourcestat)) {
37
-		    foreach($sourcestat as $srcst) {
37
+		    foreach ($sourcestat as $srcst) {
38 38
 		    	$type = $srcst['stats_type'];
39 39
 			if ($type == 'polar' || $type == 'hist') {
40 40
 			    $source = $srcst['source_name'];
41 41
 			    $data = $srcst['source_data'];
42
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
42
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
43 43
 	    		}
44 44
 		    }
45 45
 		}
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 	if (isset($globalGeoid) && $globalGeoid) {
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54
-		} catch(Exception $e) {
54
+		} catch (Exception $e) {
55 55
 			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
56 56
 			$GeoidClass = FALSE;
57 57
 		}
58 58
 	}
59 59
     }
60 60
 
61
-    public function get_Schedule($id,$ident) {
61
+    public function get_Schedule($id, $ident) {
62 62
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
63 63
 	// Get schedule here, so it's done only one time
64 64
 	
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 		$schedule = $Schedule->fetchSchedule($operator);
84 84
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85 85
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
86
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
87
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
88 88
 		    // Should also check if route schedule = route from DB
89 89
 		    if ($schedule['DepartureAirportIATA'] != '') {
90 90
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			    }
105 105
 			}
106 106
 		    }
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']);
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']);
108 108
 		}
109 109
 	    } else $scheduleexist = true;
110 110
 	} else $scheduleexist = true;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
        if ($scheduleexist) {
113 113
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
114 114
     		$sch = $Schedule->getSchedule($operator);
115
-		$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']));
115
+		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time']));
116 116
        }
117 117
 	$Spotter->db = null;
118 118
 	$Schedule->db = null;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140 140
     		    $Spotter = new Spotter($this->db);
141 141
         	    $real_arrival = $this->arrival($key);
142
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
142
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
143 143
         	}
144 144
 	    }
145 145
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         $airport_time = '';
154 154
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
155 155
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
156
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
156
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
157 157
     	    if (isset($closestAirports[0])) {
158 158
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159 159
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         		    break;
169 169
         		}
170 170
         	    }
171
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
171
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
172 172
         		$airport_icao = $closestAirports[0]['icao'];
173 173
         		$airport_time = $this->all_flights[$key]['datetime'];
174 174
         	} else {
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         } else {
182 182
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
183 183
         }
184
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
184
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
185 185
     }
186 186
 
187 187
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
193 193
 	foreach ($this->all_flights as $key => $flight) {
194 194
 	    if (isset($flight['lastupdate'])) {
195
-		if ($flight['lastupdate'] < (time()-1800)) {
195
+		if ($flight['lastupdate'] < (time() - 1800)) {
196 196
 		    $this->delKey($key);
197 197
 		}
198 198
 	    }
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$real_arrival = $this->arrival($key);
209 209
 			$Spotter = new Spotter($this->db);
210 210
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
211
-				$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']);
211
+				$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']);
212 212
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
213 213
 			}
214 214
 		}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	$send = false;
242 242
 	
243 243
 	// SBS format is CSV format
244
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
244
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
245 245
 	    //print_r($line);
246 246
 	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
247 247
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
@@ -277,25 +277,25 @@  discard block
 block discarded – undo
277 277
 		if (!isset($this->all_flights[$id])) {
278 278
 		    if ($globalDebug) echo 'New flight...'."\n";
279 279
 		    $this->all_flights[$id] = array();
280
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
282
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
281
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => ''));
282
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
283 283
 		    if (!isset($line['id'])) {
284 284
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
285 285
 //			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')));
286 286
 //			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')));
287
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
287
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
288 288
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
289
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
289
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
290 290
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
291 291
 		}
292 292
 		if (isset($line['source_type']) && $line['source_type'] != '') {
293
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
293
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
294 294
 		}
295 295
 		
296 296
 		//print_r($this->all_flights);
297 297
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
298
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
298
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
299 299
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
300 300
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
301 301
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -304,20 +304,20 @@  discard block
 block discarded – undo
304 304
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
305 305
 			    $Spotter = new Spotter($this->db);
306 306
 			    if (isset($this->all_flights[$id]['source_type'])) {
307
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
307
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
308 308
 			    } else {
309 309
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
310 310
 			    }
311 311
 			    $Spotter->db = null;
312
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
312
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
313
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
314 314
 			}
315 315
 		    }
316 316
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
317 317
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
318 318
 		}
319 319
 	        if (isset($line['id']) && !isset($line['hex'])) {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
320
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => ''));
321 321
 	        }
322 322
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
323 323
 			$icao = $line['aircraft_icao'];
@@ -326,14 +326,14 @@  discard block
 block discarded – undo
326 326
 				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
327 327
 				$Spotter->db = null;
328 328
 			}
329
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
329
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao));
330 330
 		} elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
331 331
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
332 332
 				// Get aircraft ICAO from aircraft name
333 333
 				$Spotter = new Spotter($this->db);
334 334
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
335 335
 				$Spotter->db = null;
336
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
336
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
337 337
 			}
338 338
 		}
339 339
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -341,15 +341,15 @@  discard block
 block discarded – undo
341 341
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
342 342
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
343 343
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
344
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
344
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
345 345
 		}
346 346
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
347
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
347
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
348 348
 		}
349 349
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
350
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
350
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
351 351
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
352
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
352
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
353 353
 		    } else {
354 354
 				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";
355 355
 				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";
@@ -360,31 +360,31 @@  discard block
 block discarded – undo
360 360
 				*/
361 361
 				return '';
362 362
 		    }
363
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
363
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
364 364
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
365 365
 			return '';
366
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
366
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
367 367
 			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
368 368
 			return '';
369 369
 		} elseif (!isset($line['datetime'])) {
370 370
 			date_default_timezone_set('UTC');
371
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
371
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
372 372
 		} else {
373 373
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
374 374
 			return '';
375 375
 		}
376 376
 
377 377
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') {
378
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
378
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
379 379
 		}
380 380
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
381
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
381
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
382 382
 		}
383 383
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
384
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
384
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id'])));
385 385
 		}
386 386
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
387
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
387
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name'])));
388 388
 		}
389 389
  
390 390
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
@@ -392,13 +392,13 @@  discard block
 block discarded – undo
392 392
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
393 393
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
394 394
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
395
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
396
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
397
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
398
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
399
-				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']));
395
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
396
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
397
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
398
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
399
+				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']));
400 400
 			} else {
401
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
401
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
402 402
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
403 403
 				$timeelapsed = microtime(true);
404 404
             			$Spotter = new Spotter($this->db);
@@ -408,13 +408,13 @@  discard block
 block discarded – undo
408 408
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
409 409
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
410 410
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
411
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
411
+            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
412 412
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
413 413
 				$Spotter->db = null;
414
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
414
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
415 415
 			    }
416 416
 			}
417
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
417
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
418 418
 		    
419 419
 /*
420 420
 		    if (!isset($line['id'])) {
@@ -424,25 +424,25 @@  discard block
 block discarded – undo
424 424
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
425 425
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
426 426
   */
427
-		    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']));
427
+		    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']));
428 428
 
429 429
 		    //$putinarchive = true;
430 430
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
431
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
431
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
432 432
 		    }
433 433
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
434
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
434
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
435 435
 		    }
436 436
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
437
-		    		$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' => ''));
437
+		    		$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' => ''));
438 438
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
439 439
 			$timeelapsed = microtime(true);
440 440
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
441 441
 				$Spotter = new Spotter($this->db);
442 442
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
443 443
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
444
-		    		$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' => ''));
445
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
444
+		    		$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' => ''));
445
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
446 446
                         }
447 447
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
448 448
 			$timeelapsed = microtime(true);
@@ -456,35 +456,35 @@  discard block
 block discarded – undo
456 456
 				$Translation->db = null;
457 457
 			    }
458 458
 			    $Spotter->db = null;
459
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
459
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
460 460
                     	}
461 461
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
462 462
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
463 463
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
464 464
 				//    $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']));
465
-		    		$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']));
465
+		    		$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']));
466 466
 		    	    }
467 467
 			}
468 468
 			if (!isset($globalFork)) $globalFork = TRUE;
469 469
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
470
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
470
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
471 471
 			}
472 472
 		    }
473 473
 		}
474 474
 
475 475
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
476 476
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
477
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
478
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
477
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
478
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
479 479
 		    //$dataFound = true;
480 480
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
481
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
481
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
482 482
 		    if ($distance > 1000 && $distance < 10000) {
483 483
 		    // use datetime
484 484
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
485 485
 			$speed = $speed*3.6;
486 486
 			if ($speed < 1000) {
487
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
487
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
488 488
 	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
489 489
 	  		} else {
490 490
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
@@ -499,9 +499,9 @@  discard block
 block discarded – undo
499 499
 	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
500 500
 	    	    	return false;
501 501
 	    	    }
502
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
502
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
503 503
 	    	    else unset($timediff);
504
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
504
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']);
505 505
 	    	    else unset($timediff_archive);
506 506
 	    	    if ($this->tmd > 5
507 507
 	    	        || (isset($line['format_source']) 
@@ -526,14 +526,14 @@  discard block
 block discarded – undo
526 526
 	    	    	|| ($timediff > 30 
527 527
 	    	    	    && isset($this->all_flights[$id]['latitude']) 
528 528
 	    	    	    && isset($this->all_flights[$id]['longitude']) 
529
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
529
+	    	    	    && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'))
530 530
 	    	    	    )
531 531
 	    	    	) {
532 532
 
533 533
 			if ((isset($timediff) && !isset($timediff_archive)) || (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']))) {
534 534
 			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
535 535
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
536
-				|| !$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'])) {
536
+				|| !$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'])) {
537 537
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
538 538
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
539 539
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -543,11 +543,11 @@  discard block
 block discarded – undo
543 543
 				    $timeelapsed = microtime(true);
544 544
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
545 545
 					$Spotter = new Spotter($this->db);
546
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
546
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
547 547
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
548 548
 					else $this->all_flights[$id]['over_country'] = '';
549 549
 					$Spotter->db = null;
550
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
550
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
551 551
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
552 552
 				    }
553 553
 				}
@@ -573,13 +573,13 @@  discard block
 block discarded – undo
573 573
 					$this->all_flights[$id]['time_last_coord'] = time();
574 574
 				}
575 575
 				//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' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
576
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
576
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) {
577 577
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
578 578
 				    $dataFound = true;
579 579
 				    $this->all_flights[$id]['time_last_coord'] = time();
580 580
 				}
581 581
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
582
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
582
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
583 583
 				/*
584 584
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
585 585
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -601,13 +601,13 @@  discard block
 block discarded – undo
601 601
 					$this->all_flights[$id]['time_last_coord'] = time();
602 602
 				}
603 603
 				//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' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
604
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
604
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) {
605 605
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
606 606
 				    $dataFound = true;
607 607
 				    $this->all_flights[$id]['time_last_coord'] = time();
608 608
 				}
609 609
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
610
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
610
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
611 611
 				/*
612 612
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
613 613
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -625,46 +625,46 @@  discard block
 block discarded – undo
625 625
 		    } else if ($globalDebug && $timediff > 30) {
626 626
 			$this->tmd = $this->tmd + 1;
627 627
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
628
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
629
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
628
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
629
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
630 630
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
631 631
 		    }
632 632
 		}
633 633
 		if (isset($line['last_update']) && $line['last_update'] != '') {
634 634
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
635
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
635
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
636 636
 		}
637 637
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
638
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
638
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
639 639
 		    //$dataFound = true;
640 640
 		}
641 641
 		if (isset($line['format_source']) && $line['format_source'] != '') {
642
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
642
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
643 643
 		}
644 644
 		if (isset($line['source_name']) && $line['source_name'] != '') {
645
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
645
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
646 646
 		}
647 647
 		if (isset($line['emergency']) && $line['emergency'] != '') {
648
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
648
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
649 649
 		    //$dataFound = true;
650 650
 		}
651 651
 		if (isset($line['ground']) && $line['ground'] != '') {
652 652
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
653 653
 			// Here we force archive of flight because after ground it's a new one (or should be)
654
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
655
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
656
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
657
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
658
-			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']));
654
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
655
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
656
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
657
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
658
+			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']));
659 659
 		    }
660 660
 		    if ($line['ground'] != 1) $line['ground'] = 0;
661
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
661
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
662 662
 		    //$dataFound = true;
663 663
 		}
664 664
 		if (isset($line['squawk']) && $line['squawk'] != '') {
665 665
 		    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'])) {
666 666
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
667
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
667
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
668 668
 			    $highlight = '';
669 669
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
670 670
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -673,66 +673,66 @@  discard block
 block discarded – undo
673 673
 				$timeelapsed = microtime(true);
674 674
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
675 675
 				    $Spotter = new Spotter($this->db);
676
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
676
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
677 677
 				    $Spotter->db = null;
678
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
678
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
679 679
 				}
680 680
 				//$putinarchive = true;
681 681
 				//$highlight = '';
682 682
 			    }
683 683
 			    
684
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
684
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
685 685
 		    //$dataFound = true;
686 686
 		}
687 687
 
688 688
 		if (isset($line['altitude']) && $line['altitude'] != '') {
689 689
 			if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) {
690 690
 				if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') {
691
-					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2);
691
+					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2);
692 692
 					//if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n";
693 693
 					$line['altitude'] = $line['altitude'] - $geoid;
694 694
 				}
695 695
 			}
696 696
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
697
-			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;
698
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
699
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
697
+			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;
698
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
699
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
700 700
 			//$dataFound = true;
701 701
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
702 702
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
703 703
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
704 704
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
705
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
706
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
707
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
708
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
709
-				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']));
705
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
706
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
707
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
708
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
709
+				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']));
710 710
 			}
711 711
 		    }
712
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
712
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude']));
713 713
 		}
714 714
 
715 715
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
716
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
716
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
717 717
 		}
718 718
 		
719 719
 		if (isset($line['heading']) && $line['heading'] != '') {
720
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
721
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
722
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
720
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
721
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
722
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
723 723
 		    //$dataFound = true;
724 724
   		} 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']) {
725
-  		    $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']);
726
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
727
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
725
+  		    $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']);
726
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
727
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
728 728
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
729 729
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
730 730
   		    // If not enough messages and ACARS set heading to 0
731
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
731
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
732 732
   		}
733
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
734
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
735
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
733
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
734
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
735
+		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
736 736
 
737 737
 //		print_r($this->all_flights[$id]);
738 738
 		//gets the callsign from the last hour
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
744 744
 		    $this->all_flights[$id]['lastupdate'] = time();
745 745
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
746
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
746
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
747 747
 			    //print_r($this->all_flights);
748 748
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
749 749
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -754,61 +754,61 @@  discard block
 block discarded – undo
754 754
 				    $SpotterLive = new SpotterLive($this->db);
755 755
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
756 756
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
757
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
757
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
758 758
 				    } elseif (isset($line['id'])) {
759 759
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
760
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
760
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
761 761
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
762 762
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
763
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
763
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
764 764
 				    } else $recent_ident = '';
765
-				    $SpotterLive->db=null;
765
+				    $SpotterLive->db = null;
766 766
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
767 767
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
768 768
 				} else $recent_ident = '';
769 769
 			    } else {
770 770
 				$recent_ident = '';
771
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
771
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
772 772
 			    }
773 773
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
774
-			    if($recent_ident == "")
774
+			    if ($recent_ident == "")
775 775
 			    {
776 776
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
777 777
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
778 778
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
779 779
 				//adds the spotter data for the archive
780 780
 				$ignoreImport = false;
781
-				foreach($globalAirportIgnore as $airportIgnore) {
781
+				foreach ($globalAirportIgnore as $airportIgnore) {
782 782
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
783 783
 					$ignoreImport = true;
784 784
 				    }
785 785
 				}
786 786
 				if (count($globalAirportAccept) > 0) {
787 787
 				    $ignoreImport = true;
788
-				    foreach($globalAirportIgnore as $airportIgnore) {
788
+				    foreach ($globalAirportIgnore as $airportIgnore) {
789 789
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
790 790
 					    $ignoreImport = false;
791 791
 					}
792 792
 				    }
793 793
 				}
794 794
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
795
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
796
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
795
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
796
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
797 797
 					    $ignoreImport = true;
798 798
 					}
799 799
 				    }
800 800
 				}
801 801
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
802 802
 				    $ignoreImport = true;
803
-				    foreach($globalAirlineAccept as $airlineAccept) {
804
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
803
+				    foreach ($globalAirlineAccept as $airlineAccept) {
804
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
805 805
 					    $ignoreImport = false;
806 806
 					}
807 807
 				    }
808 808
 				}
809 809
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
810 810
 				    $ignoreImport = true;
811
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
811
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
812 812
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
813 813
 					    $ignoreImport = false;
814 814
 					}
@@ -820,32 +820,32 @@  discard block
 block discarded – undo
820 820
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
821 821
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
822 822
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
823
-				    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')));
823
+				    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')));
824 824
 				    $timeelapsed = microtime(true);
825 825
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
826 826
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
827 827
 					    $Spotter = new Spotter($this->db);
828
-					    $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']);
828
+					    $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']);
829 829
 					    $Spotter->db = null;
830 830
 					    if ($globalDebug && isset($result)) echo $result."\n";
831 831
 					}
832 832
 				    }
833
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
833
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
834 834
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
835 835
 
836 836
 				    // Add source stat in DB
837 837
 				    $Stats = new Stats($this->db);
838 838
 				    if (!empty($this->stats)) {
839 839
 					if ($globalDebug) echo 'Add source stats : ';
840
-				        foreach($this->stats as $date => $data) {
841
-					    foreach($data as $source => $sourced) {
840
+				        foreach ($this->stats as $date => $data) {
841
+					    foreach ($data as $source => $sourced) {
842 842
 					        //print_r($sourced);
843
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
844
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
843
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
844
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
845 845
 				    		if (isset($sourced['msg'])) {
846 846
 				    		    if (time() - $sourced['msg']['date'] > 10) {
847 847
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
848
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
848
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
849 849
 			    			        unset($this->stats[$date][$source]['msg']);
850 850
 			    			    }
851 851
 			    			}
@@ -883,14 +883,14 @@  discard block
 block discarded – undo
883 883
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
884 884
 					    $SpotterLive = new SpotterLive($this->db);
885 885
 					    $SpotterLive->deleteLiveSpotterData();
886
-					    $SpotterLive->db=null;
886
+					    $SpotterLive->db = null;
887 887
 					}
888 888
 				    }
889 889
 				    if ($globalDebug) echo " Done\n";
890 890
 				    $this->last_delete = time();
891 891
 				}
892 892
 			    } else {
893
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
893
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
894 894
 				    $this->all_flights[$id]['id'] = $recent_ident;
895 895
 				    $this->all_flights[$id]['addedSpotter'] = 1;
896 896
 				}
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
899 899
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
900 900
 					    $Spotter = new Spotter($this->db);
901
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
901
+					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
902 902
 					    $Spotter->db = null;
903 903
 					}
904 904
 				    }
@@ -924,37 +924,37 @@  discard block
 block discarded – undo
924 924
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
925 925
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
926 926
 
927
-		    foreach($globalAirportIgnore as $airportIgnore) {
927
+		    foreach ($globalAirportIgnore as $airportIgnore) {
928 928
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
929 929
 			    $ignoreImport = true;
930 930
 			}
931 931
 		    }
932 932
 		    if (count($globalAirportAccept) > 0) {
933 933
 		        $ignoreImport = true;
934
-		        foreach($globalAirportIgnore as $airportIgnore) {
934
+		        foreach ($globalAirportIgnore as $airportIgnore) {
935 935
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
936 936
 				$ignoreImport = false;
937 937
 			    }
938 938
 			}
939 939
 		    }
940 940
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
941
-			foreach($globalAirlineIgnore as $airlineIgnore) {
942
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
941
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
942
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
943 943
 				$ignoreImport = true;
944 944
 			    }
945 945
 			}
946 946
 		    }
947 947
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
948 948
 			$ignoreImport = true;
949
-			foreach($globalAirlineAccept as $airlineAccept) {
950
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
949
+			foreach ($globalAirlineAccept as $airlineAccept) {
950
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
951 951
 				$ignoreImport = false;
952 952
 			    }
953 953
 			}
954 954
 		    }
955 955
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
956 956
 			$ignoreImport = true;
957
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
957
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
958 958
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
959 959
 			        $ignoreImport = false;
960 960
 			    }
@@ -962,23 +962,23 @@  discard block
 block discarded – undo
962 962
 		    }
963 963
 
964 964
 		    if (!$ignoreImport) {
965
-			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'])) {
966
-				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')));
965
+			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'])) {
966
+				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')));
967 967
 				$timeelapsed = microtime(true);
968 968
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
969 969
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
970 970
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
971 971
 					$SpotterLive = new SpotterLive($this->db);
972
-					$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']);
972
+					$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']);
973 973
 					$SpotterLive->db = null;
974 974
 					if ($globalDebug) echo $result."\n";
975 975
 				    }
976 976
 				}
977 977
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
978
-					$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']);
978
+					$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']);
979 979
 				}
980 980
 				$this->all_flights[$id]['putinarchive'] = false;
981
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
981
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
982 982
 
983 983
 				// Put statistics in $this->stats variable
984 984
 				//if ($line['format_source'] != 'aprs') {
@@ -997,19 +997,19 @@  discard block
 block discarded – undo
997 997
 							$latitude = $globalCenterLatitude;
998 998
 							$longitude = $globalCenterLongitude;
999 999
 						}
1000
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
1000
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
1001 1001
 					} else {
1002 1002
 						$latitude = $this->source_location[$source]['latitude'];
1003 1003
 						$longitude = $this->source_location[$source]['longitude'];
1004 1004
 					}
1005
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1005
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1006 1006
 					//$stats_heading = $stats_heading%22.5;
1007 1007
 					$stats_heading = round($stats_heading/22.5);
1008
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1008
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1009 1009
 					$current_date = date('Y-m-d');
1010 1010
 					if ($stats_heading == 16) $stats_heading = 0;
1011 1011
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1012
-						for ($i=0;$i<=15;$i++) {
1012
+						for ($i = 0; $i <= 15; $i++) {
1013 1013
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1014 1014
 						}
1015 1015
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -1024,9 +1024,9 @@  discard block
 block discarded – undo
1024 1024
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1025 1025
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1026 1026
 						    end($this->stats[$current_date][$source]['hist']);
1027
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1027
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
1028 1028
 						} else $mini = 0;
1029
-						for ($i=$mini;$i<=$distance;$i+=10) {
1029
+						for ($i = $mini; $i <= $distance; $i += 10) {
1030 1030
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1031 1031
 						}
1032 1032
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 				$this->all_flights[$id]['lastupdate'] = time();
1040 1040
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
1041 1041
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1042
-			} 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";
1042
+			} 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";
1043 1043
 			//$this->del();
1044 1044
 			
1045 1045
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.
require/class.AIS.php 1 patch
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -117,31 +117,31 @@  discard block
 block discarded – undo
117 117
 
118 118
 	private function make_latf($temp) { // unsigned long 
119 119
 		$flat = 0.0; // float
120
-		$temp = $temp & 0x07FFFFFF;
121
-		if ($temp & 0x04000000) {
122
-			$temp = $temp ^ 0x07FFFFFF;
120
+		$temp = $temp&0x07FFFFFF;
121
+		if ($temp&0x04000000) {
122
+			$temp = $temp^0x07FFFFFF;
123 123
 			$temp += 1;
124
-			$flat = (float)($temp / (60.0 * 10000.0));
124
+			$flat = (float) ($temp/(60.0*10000.0));
125 125
 			$flat *= -1.0;
126
-		} else $flat = (float)($temp / (60.0 * 10000.0));
126
+		} else $flat = (float) ($temp/(60.0*10000.0));
127 127
 		return $flat; // float
128 128
 	}
129 129
 
130 130
 	private function make_lonf($temp) { // unsigned long
131 131
 		$flon = 0.0; // float
132
-		$temp = $temp & 0x0FFFFFFF;
133
-		if ($temp & 0x08000000) {
134
-			$temp = $temp ^ 0x0FFFFFFF;
132
+		$temp = $temp&0x0FFFFFFF;
133
+		if ($temp&0x08000000) {
134
+			$temp = $temp^0x0FFFFFFF;
135 135
 			$temp += 1;
136
-			$flon = (float)($temp / (60.0 * 10000.0));
136
+			$flon = (float) ($temp/(60.0*10000.0));
137 137
 			$flon *= -1.0;
138
-		} else $flon = (float)($temp / (60.0 * 10000.0));
138
+		} else $flon = (float) ($temp/(60.0*10000.0));
139 139
 		return $flon;
140 140
 	}
141 141
 
142 142
 	private function ascii_2_dec($chr) {
143
-		$dec=ord($chr);//get decimal ascii code
144
-		$hex=dechex($dec);//convert decimal to hex
143
+		$dec = ord($chr); //get decimal ascii code
144
+		$hex = dechex($dec); //convert decimal to hex
145 145
 		return ($dec);
146 146
 	}
147 147
 	
@@ -160,15 +160,15 @@  discard block
 block discarded – undo
160 160
 		//only process in the following range: 48-87, 96-119
161 161
 		if ($ascii < 48) { }
162 162
 		else {
163
-			if($ascii>119) { }
163
+			if ($ascii > 119) { }
164 164
 			else {
165
-				if ($ascii>87 && $ascii<96) ;
165
+				if ($ascii > 87 && $ascii < 96);
166 166
 				else {
167
-					$ascii=$ascii+40;
168
-					if ($ascii>128){
169
-						$ascii=$ascii+32;
167
+					$ascii = $ascii + 40;
168
+					if ($ascii > 128) {
169
+						$ascii = $ascii + 32;
170 170
 					} else {
171
-						$ascii=$ascii+40;
171
+						$ascii = $ascii + 40;
172 172
 					}
173 173
 				}
174 174
 			}
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	}
178 178
 
179 179
 	private function dec_2_6bit($dec) {
180
-		$bin=decbin($dec);
180
+		$bin = decbin($dec);
181 181
 		return(substr($bin, -6)); 
182 182
 	}
183 183
 
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 		);
196 196
 		// "
197 197
 		$rv = '';
198
-		if ($_size % 6 == 0) {
199
-			$len = $_size / 6;
200
-			for ($i=0; $i<$len; $i++) {
201
-				$offset = $i * 6;
202
-				$rv .= $ais_chars[ bindec(substr($_str,$_start + $offset,6)) ];
198
+		if ($_size%6 == 0) {
199
+			$len = $_size/6;
200
+			for ($i = 0; $i < $len; $i++) {
201
+				$offset = $i*6;
202
+				$rv .= $ais_chars[bindec(substr($_str, $_start + $offset, 6))];
203 203
 			}
204 204
 		}
205 205
 		return $rv;
@@ -226,93 +226,93 @@  discard block
 block discarded – undo
226 226
 		$ro->eta_hour = '';
227 227
 		$ro->eta_minute = '';
228 228
 		$ro->ts = time();
229
-		$ro->id = bindec(substr($_aisdata,0,6));
230
-		$ro->mmsi = bindec(substr($_aisdata,8,30));
229
+		$ro->id = bindec(substr($_aisdata, 0, 6));
230
+		$ro->mmsi = bindec(substr($_aisdata, 8, 30));
231 231
 		if ($ro->id >= 1 && $ro->id <= 3) {
232
-			$ro->cog = bindec(substr($_aisdata,116,12))/10;
233
-			$ro->sog = bindec(substr($_aisdata,50,10))/10;
234
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
235
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
232
+			$ro->cog = bindec(substr($_aisdata, 116, 12))/10;
233
+			$ro->sog = bindec(substr($_aisdata, 50, 10))/10;
234
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
235
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
236 236
 			$ro->cls = 1; // class A
237 237
 		} else if ($ro->id == 4) {
238
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,79,28)));
239
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,107,27)));
238
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 79, 28)));
239
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 107, 27)));
240 240
 			$ro->cls = 1; // class A
241 241
 		} else if ($ro->id == 5) {
242
-			$ro->imo = bindec(substr($_aisdata,40,30));
243
-			$ro->callsign = $this->binchar($_aisdata,70,42);
244
-			$ro->name = $this->binchar($_aisdata,112,120);
245
-			$ro->typeid = bindec(substr($_aisdata,232,8));
242
+			$ro->imo = bindec(substr($_aisdata, 40, 30));
243
+			$ro->callsign = $this->binchar($_aisdata, 70, 42);
244
+			$ro->name = $this->binchar($_aisdata, 112, 120);
245
+			$ro->typeid = bindec(substr($_aisdata, 232, 8));
246 246
 			$ro->type = $this->getShipType($ro->typeid);
247 247
 			//$ro->to_bow = bindec(substr($_aisdata,240,9));
248 248
 			//$ro->to_stern = bindec(substr($_aisdata,249,9));
249 249
 			//$ro->to_port = bindec(substr($_aisdata,258,6));
250 250
 			//$ro->to_starboard = bindec(substr($_aisdata,264,6));
251
-			$ro->eta_month = bindec(substr($_aisdata,274,4));
252
-			$ro->eta_day = bindec(substr($_aisdata,278,5));
253
-			$ro->eta_hour = bindec(substr($_aisdata,283,5));
254
-			$ro->eta_minute = bindec(substr($_aisdata,288,6));
251
+			$ro->eta_month = bindec(substr($_aisdata, 274, 4));
252
+			$ro->eta_day = bindec(substr($_aisdata, 278, 5));
253
+			$ro->eta_hour = bindec(substr($_aisdata, 283, 5));
254
+			$ro->eta_minute = bindec(substr($_aisdata, 288, 6));
255 255
 			//$ro->draught = bindec(substr($_aisdata,294,8));
256
-			$ro->destination = $this->binchar($_aisdata,302,120);
256
+			$ro->destination = $this->binchar($_aisdata, 302, 120);
257 257
 			$ro->cls = 1; // class A
258 258
 		} else if ($ro->id == 9) {
259 259
 			// Search and Rescue aircraft position report
260 260
 		} else if ($ro->id == 18) {
261
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
262
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
263
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
264
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
265
-			$ro->heading = bindec(substr($_aisdata,124,9));
261
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
262
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
263
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 57, 28)));
264
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 85, 27)));
265
+			$ro->heading = bindec(substr($_aisdata, 124, 9));
266 266
 			if ($ro->heading == 511) $ro->heading = '';
267 267
 			$ro->cls = 2; // class B
268 268
 		} else if ($ro->id == 19) {
269
-			$ro->cog = bindec(substr($_aisdata,112,12))/10;
270
-			$ro->sog = bindec(substr($_aisdata,46,10))/10;
271
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,61,28)));
272
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,89,27)));
273
-			$ro->name = $this->binchar($_aisdata,143,120);
269
+			$ro->cog = bindec(substr($_aisdata, 112, 12))/10;
270
+			$ro->sog = bindec(substr($_aisdata, 46, 10))/10;
271
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 61, 28)));
272
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 89, 27)));
273
+			$ro->name = $this->binchar($_aisdata, 143, 120);
274 274
 			$ro->cls = 2; // class B
275
-			$ro->heading = bindec(substr($_aisdata,124,9));
275
+			$ro->heading = bindec(substr($_aisdata, 124, 9));
276 276
 			if ($ro->heading == 511) $ro->heading = '';
277
-			$ro->typeid = bindec(substr($_aisdata,263,8));
277
+			$ro->typeid = bindec(substr($_aisdata, 263, 8));
278 278
 			$ro->type = $this->getShipType($ro->typeid);
279 279
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
280 280
 			//$ro->to_stern = bindec(substr($_aisdata,280,9));
281 281
 			//$ro->to_port = bindec(substr($_aisdata,289,6));
282 282
 			//$ro->to_starboard = bindec(substr($_aisdata,295,6));
283 283
 		} else if ($ro->id == 21) {
284
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,164,28)));
285
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,192,27)));
286
-			$ro->name = $this->binchar($_aisdata,43,120);
284
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 164, 28)));
285
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 192, 27)));
286
+			$ro->name = $this->binchar($_aisdata, 43, 120);
287 287
 			//$ro->to_bow = bindec(substr($_aisdata,219,9));
288 288
 			//$ro->to_stern = bindec(substr($_aisdata,228,9));
289 289
 			//$ro->to_port = bindec(substr($_aisdata,237,6));
290 290
 			//$ro->to_starboard = bindec(substr($_aisdata,243,6));
291 291
 			$ro->cls = 2; // class B
292 292
 		} else if ($ro->id == 24) {
293
-			$pn = bindec(substr($_aisdata,38,2));
293
+			$pn = bindec(substr($_aisdata, 38, 2));
294 294
 			if ($pn == 0) {
295
-				$ro->name = $this->binchar($_aisdata,40,120);
295
+				$ro->name = $this->binchar($_aisdata, 40, 120);
296 296
 			}
297
-			$ro->typeid = bindec(substr($_aisdata,40,8));
297
+			$ro->typeid = bindec(substr($_aisdata, 40, 8));
298 298
 			$ro->type = $this->getShipType($ro->typeid);
299
-			$ro->callsign = $this->binchar($_aisdata,90,42);
299
+			$ro->callsign = $this->binchar($_aisdata, 90, 42);
300 300
 			//$ro->to_bow = bindec(substr($_aisdata,132,9));
301 301
 			//$ro->to_stern = bindec(substr($_aisdata,141,9));
302 302
 			//$ro->to_port = bindec(substr($_aisdata,150,6));
303 303
 			//$ro->to_starboard = bindec(substr($_aisdata,156,6));
304 304
 			$ro->cls = 2; // class B
305 305
 		} else if ($ro->id == 27) {
306
-			$ro->cog = bindec(substr($_aisdata,85,9));
306
+			$ro->cog = bindec(substr($_aisdata, 85, 9));
307 307
 			if ($ro->cog == 511) $ro->cog = 0.0;
308
-			$ro->sog = bindec(substr($_aisdata,79,6));
308
+			$ro->sog = bindec(substr($_aisdata, 79, 6));
309 309
 			if ($ro->sog == 63) $ro->sog = 0.0;
310
-			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
311
-			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
310
+			$ro->lon = $this->make_lonf(bindec(substr($_aisdata, 44, 18))*10);
311
+			$ro->lat = $this->make_latf(bindec(substr($_aisdata, 62, 17))*10);
312 312
 			$ro->cls = 1; // class A
313 313
 		
314 314
 		}
315
-		$ro->statusid = bindec(substr($_aisdata,38,4));
315
+		$ro->statusid = bindec(substr($_aisdata, 38, 4));
316 316
 		$ro->status = $this->getStatus($ro->statusid);
317 317
 		return $ro;
318 318
 	}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	}
360 360
 
361 361
 	public function getShipTypeID($type) {
362
-		$typeid = array_search($type,$this->shiptype);
362
+		$typeid = array_search($type, $this->shiptype);
363 363
 		if ($typeid !== FALSE) return $typeid;
364 364
 		elseif ($type == 'Cargo' || $type == 'General Cargo' || $type == 'Bulk Carrier' || $type == 'Container Ship' || $type == 'Cargo A' || $type == 'Reefer' || $type == 'Vehicles Carrier' || $type == 'Ro-Ro Cargo') return 70;
365 365
 		elseif ($type == 'Passengers Ship' || $type == 'Passenger' || $type == 'Ro-Ro/Passenger Ship' || $type == 'Motor Passenger') return 60;
@@ -381,14 +381,14 @@  discard block
 block discarded – undo
381 381
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
382 382
 		global $port; // tcpip port...
383 383
 		static $debug_counter = 0;
384
-		$aisdata168='';//six bit array of ascii characters
384
+		$aisdata168 = ''; //six bit array of ascii characters
385 385
 		$ais_nmea_array = str_split($_itu); // convert to an array
386 386
 		foreach ($ais_nmea_array as $value) {
387 387
 			$dec = $this->ascii_2_dec($value);
388 388
 			$bit8 = $this->asciidec_2_8bit($dec);
389 389
 			$bit6 = $this->dec_2_6bit($bit8);
390 390
 			//echo $value ."-" .$bit6 ."";
391
-			$aisdata168 .=$bit6;
391
+			$aisdata168 .= $bit6;
392 392
 		}
393 393
 		//echo $aisdata168 . "<br/>";
394 394
 		//return $this->decode_ais($aisdata168, $aux);
@@ -411,24 +411,24 @@  discard block
 block discarded – undo
411 411
 		// calculate checksum after ! till *
412 412
 		// assume 1st ! is valid
413 413
 		// find * ensure that it is at correct position
414
-		$end = strrpos ( $rawdata , '*' );
414
+		$end = strrpos($rawdata, '*');
415 415
 		if ($end === FALSE) return -1; // check for NULLS!!!
416
-		$cs = substr( $rawdata, $end + 1 );
417
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
418
-		$dcs = (int)hexdec( $cs );
419
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
420
-		if ( $chksum == $dcs ) { // NMEA checksum pass
416
+		$cs = substr($rawdata, $end + 1);
417
+		if (strlen($cs) != 2) return -1; // correct cs length
418
+		$dcs = (int) hexdec($cs);
419
+		for ($alias = 1; $alias < $end; $alias++) $chksum ^= ord($rawdata[$alias]); // perform XOR for NMEA checksum
420
+		if ($chksum == $dcs) { // NMEA checksum pass
421 421
 			$pcs = explode(',', $rawdata);
422 422
 			// !AI??? identifier
423 423
 			if (!isset($pcs[1])) {
424 424
 				echo "ERROR,INVALID_DATA ".time()." $rawdata\n";
425 425
 				return -1;
426 426
 			}
427
-			$num_seq = (int)$pcs[1]; // number of sequences
428
-			$seq = (int)$pcs[2]; // get sequence
427
+			$num_seq = (int) $pcs[1]; // number of sequences
428
+			$seq = (int) $pcs[2]; // get sequence
429 429
 			// get msg sequence id
430 430
 			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
431
-			else $msg_sid = (int)$pcs[3]; // multipart message
431
+			else $msg_sid = (int) $pcs[3]; // multipart message
432 432
 			$ais_ch = $pcs[4]; // get AIS channel
433 433
 			// message sequence checking
434 434
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 					}
462 462
 				}
463 463
 				$itu = $itu.$pcs[5]; // get itu message
464
-				$filler += (int)$pcs[6][0]; // get filler
464
+				$filler += (int) $pcs[6][0]; // get filler
465 465
 				if ($num_seq == 1 // valid single message
466 466
 				    || $num_seq == $pseq // valid multi-part message
467 467
 				) {
@@ -483,13 +483,13 @@  discard block
 block discarded – undo
483 483
 		$cbuf = $cbuf.$ibuf;
484 484
 		$last_pos = 0;
485 485
 		$result = new stdClass();
486
-		while ( ($start = strpos($cbuf,"VDM",$last_pos)) !== FALSE) {
486
+		while (($start = strpos($cbuf, "VDM", $last_pos)) !== FALSE) {
487 487
 		//while ( ($start = strpos($cbuf,"!AI",$last_pos)) !== FALSE) {
488 488
 			//DEBUG echo $cbuf;
489
-			if ( ($end = strpos($cbuf,"\r\n", $start)) !== FALSE) { //TBD need to trim?
489
+			if (($end = strpos($cbuf, "\r\n", $start)) !== FALSE) { //TBD need to trim?
490 490
 				$tst = substr($cbuf, $start - 3, ($end - $start + 3));
491 491
 				//DEBUG echo "[$start $end $tst]\n";
492
-				$result = $this->process_ais_raw( $tst, "" );
492
+				$result = $this->process_ais_raw($tst, "");
493 493
 				$last_pos = $end + 1;
494 494
 			} else break;
495 495
 		}
@@ -501,41 +501,41 @@  discard block
 block discarded – undo
501 501
 	// incoming data from serial or IP comms
502 502
 	public function process_ais_line($cbuf) {
503 503
 		$result = new stdClass();
504
-		$start = strpos($cbuf,"VDM");
504
+		$start = strpos($cbuf, "VDM");
505 505
 		$tst = substr($cbuf, $start - 3);
506
-		$result = $this->process_ais_raw( $tst, "" );
506
+		$result = $this->process_ais_raw($tst, "");
507 507
 		return $result;
508 508
 	}
509 509
 
510 510
 	/* AIS Encoding
511 511
 	*/
512
-	private function mk_ais_lat( $lat ) {
512
+	private function mk_ais_lat($lat) {
513 513
 		//$lat = 1.2569;
514
-		if ($lat<0.0) {
514
+		if ($lat < 0.0) {
515 515
 			$lat = -$lat;
516
-			$neg=true;
517
-		} else $neg=false;
516
+			$neg = true;
517
+		} else $neg = false;
518 518
 		$latd = 0x00000000;
519
-		$latd = intval ($lat * 600000.0);
520
-		if ($neg==true) {
519
+		$latd = intval($lat*600000.0);
520
+		if ($neg == true) {
521 521
 			$latd = ~$latd;
522
-			$latd+=1;
522
+			$latd += 1;
523 523
 			$latd &= 0x07FFFFFF;
524 524
 		}
525 525
 		return $latd;
526 526
 	}
527 527
 
528
-	private function mk_ais_lon( $lon ) {
528
+	private function mk_ais_lon($lon) {
529 529
 		//$lon = 103.851;
530
-		if ($lon<0.0) {
530
+		if ($lon < 0.0) {
531 531
 			$lon = -$lon;
532
-			$neg=true;
533
-		} else $neg=false;
532
+			$neg = true;
533
+		} else $neg = false;
534 534
 		$lond = 0x00000000;
535
-		$lond = intval ($lon * 600000.0);
536
-		if ($neg==true) {
535
+		$lond = intval($lon*600000.0);
536
+		if ($neg == true) {
537 537
 			$lond = ~$lond;
538
-			$lond+=1;
538
+			$lond += 1;
539 539
 			$lond &= 0x0FFFFFFF;
540 540
 		}
541 541
 		return $lond;
@@ -543,8 +543,8 @@  discard block
 block discarded – undo
543 543
 
544 544
 	private function char2bin($name, $max_len) {
545 545
 		$len = strlen($name);
546
-		if ($len > $max_len) $name = substr($name,0,$max_len);
547
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
546
+		if ($len > $max_len) $name = substr($name, 0, $max_len);
547
+		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len)*6);
548 548
 		else $pad = '';
549 549
 		$rv = '';
550 550
 		$ais_chars = array(
@@ -561,26 +561,26 @@  discard block
 block discarded – undo
561 561
 		if ($_a) foreach ($_a as $_1) {
562 562
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
563 563
 			else $dec = 0;
564
-			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
564
+			$bin = str_pad(decbin($dec), 6, '0', STR_PAD_LEFT);
565 565
 			$rv .= $bin;
566 566
 			//echo "$_1 $dec ($bin)<br/>";
567 567
 		}
568 568
 		return $rv.$pad;
569 569
 	}
570 570
 
571
-	private function mk_ais($_enc, $_part=1,$_total=1,$_seq='',$_ch='A') {
571
+	private function mk_ais($_enc, $_part = 1, $_total = 1, $_seq = '', $_ch = 'A') {
572 572
 		$len_bit = strlen($_enc);
573
-		$rem6 = $len_bit % 6;
573
+		$rem6 = $len_bit%6;
574 574
 		$pad6_len = 0;
575 575
 		if ($rem6) $pad6_len = 6 - $rem6;
576 576
 		//echo  $pad6_len.'<br>';
577 577
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
578
-		$len_enc = strlen($_enc) / 6;
578
+		$len_enc = strlen($_enc)/6;
579 579
 		//echo $_enc.' '.$len_enc.'<br/>';
580 580
 		$itu = '';
581
-		for ($i=0; $i<$len_enc; $i++) {
582
-			$offset = $i * 6;
583
-			$dec = bindec(substr($_enc,$offset,6));
581
+		for ($i = 0; $i < $len_enc; $i++) {
582
+			$offset = $i*6;
583
+			$dec = bindec(substr($_enc, $offset, 6));
584 584
 			if ($dec < 40) $dec += 48;
585 585
 			else $dec += 56;
586 586
 			//echo chr($dec)." $dec<br/>";
@@ -590,15 +590,15 @@  discard block
 block discarded – undo
590 590
 		$chksum = 0;
591 591
 		$itu = "AIVDM,$_part,$_total,$_seq,$_ch,".$itu.",0";
592 592
 		$len_itu = strlen($itu);
593
-		for ($i=0; $i<$len_itu; $i++) {
594
-			$chksum ^= ord( $itu[$i] );
593
+		for ($i = 0; $i < $len_itu; $i++) {
594
+			$chksum ^= ord($itu[$i]);
595 595
 		}
596
-		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
597
-		$lsb = $chksum & 0x0F;
598
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
596
+		$hex_arr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
597
+		$lsb = $chksum&0x0F;
598
+		if ($lsb >= 0 && $lsb <= 15) $lsbc = $hex_arr[$lsb];
599 599
 		else $lsbc = '0';
600
-		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
601
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
600
+		$msb = (($chksum&0xF0) >> 4)&0x0F;
601
+		if ($msb >= 0 && $msb <= 15) $msbc = $hex_arr[$msb];
602 602
 		else $msbc = '0';
603 603
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
604 604
 		return $itu;
@@ -624,14 +624,14 @@  discard block
 block discarded – undo
624 624
 
625 625
 	public function mmsitype($mmsi) {
626 626
 		if (strlen($mmsi) == 9) {
627
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
628
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
629
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
630
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
631
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
632
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
633
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
634
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
627
+			if (substr($mmsi, 0, 3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
628
+			elseif (substr($mmsi, 0, 3) == '972') return 'MOB (Man Overboard) device';
629
+			elseif (substr($mmsi, 0, 3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
630
+			elseif (substr($mmsi, 0, 3) == '111') return 'SAR (Search and Rescue) aircraft';
631
+			elseif (substr($mmsi, 0, 2) == '98') return 'Auxiliary craft associated with a parent ship';
632
+			elseif (substr($mmsi, 0, 2) == '99') return 'Aids to Navigation';
633
+			elseif (substr($mmsi, 0, 2) == '00') return 'Coastal stations';
634
+			elseif (substr($mmsi, 0, 1) == '0') return 'Group of ships';
635 635
 			else return 'Ship';
636 636
 		}
637 637
 
@@ -641,19 +641,19 @@  discard block
 block discarded – undo
641 641
 	public function parse_line($buffer) {
642 642
 		global $globalDebug;
643 643
 		$result = array();
644
-		$start = strpos($buffer,"VDM");
644
+		$start = strpos($buffer, "VDM");
645 645
 		$tst = substr($buffer, $start - 3);
646
-		$data = $this->process_ais_raw( $tst, "" );
646
+		$data = $this->process_ais_raw($tst, "");
647 647
 		if (!is_object($data)) {
648 648
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
649 649
 			return array();
650 650
 		}
651 651
 		if ($data->lon != 0) $result['longitude'] = $data->lon;
652 652
 		if ($data->lat != 0) $result['latitude'] = $data->lat;
653
-		$result['ident'] = trim(str_replace('@','',$data->name));
653
+		$result['ident'] = trim(str_replace('@', '', $data->name));
654 654
 		$result['timestamp'] = $data->ts;
655 655
 		$result['mmsi'] = $data->mmsi;
656
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
656
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'], 0, 3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
657 657
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
658 658
 		if ($data->sog != -1.0) $result['speed'] = $data->sog;
659 659
 		if ($data->heading !== '') $result['heading'] = $data->heading;
@@ -663,16 +663,16 @@  discard block
 block discarded – undo
663 663
 		if ($data->type !== '') $result['type'] = $data->type;
664 664
 		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
665 665
 		if ($data->imo !== '') $result['imo'] = $data->imo;
666
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
666
+		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@', '', $data->callsign));
667 667
 		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 !== '') {
668
-			$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');
668
+			$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');
669 669
 			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
670 670
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
671
-			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
671
+			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d", $data->eta_hour).':'.sprintf("%02d", $data->eta_minute).':00');
672 672
 			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
673 673
 		}
674 674
 		if ($data->destination != '') {
675
-			$dest = trim(str_replace('@','',$data->destination));
675
+			$dest = trim(str_replace('@', '', $data->destination));
676 676
 			if ($dest != '') $result['destination'] = $dest;
677 677
 		}
678 678
 		$result['all'] = (array) $data;
Please login to merge, or discard this patch.
require/class.TrackerImport.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	    if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49 49
     		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
50
+        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
51 51
             }
52 52
 	}
53 53
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60 60
     	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
61
+        	if ($flight['lastupdate'] < (time() - 3000)) {
62 62
             	    if (isset($this->all_tracked[$key]['id'])) {
63 63
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             		//$real_arrival = $this->arrival($key);
70 70
             		$Tracker = new Tracker($this->db);
71 71
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72
-				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
72
+				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	$send = false;
90 90
 	
91 91
 	// SBS format is CSV format
92
-	if(is_array($line) && isset($line['ident'])) {
92
+	if (is_array($line) && isset($line['ident'])) {
93 93
 	    //print_r($line);
94 94
   	    if (isset($line['ident'])) {
95 95
 
@@ -113,33 +113,33 @@  discard block
 block discarded – undo
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115 115
 		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
116
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0));
117
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => ''));
118
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
119 119
 		    if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
121
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
122
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
123 123
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
126
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
127 127
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
128
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
129 129
 		    } else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133 133
 		    }
134
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
134
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
137
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
137
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
138 138
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
139 139
 			return '';
140 140
 		} elseif (!isset($line['datetime'])) {
141 141
 			date_default_timezone_set('UTC');
142
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
142
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
143 143
 		} else {
144 144
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
145 145
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
150
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
151 151
 		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153 153
             		$Tracker = new Tracker($this->db);
154 154
             		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
155
+            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
158
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
159 159
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
160
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
165
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
167
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
168 168
 		    if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
171
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173 173
 		    }
174 174
 		}
175 175
 
176 176
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
177
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
178 178
 	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
179
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
181
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'], 0.08)) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
187 187
 				$timeelapsed = microtime(true);
188 188
 				$Tracker = new Tracker($this->db);
189
-				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
189
+				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
190 190
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
191 191
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195 195
 			    }
@@ -197,75 +197,75 @@  discard block
 block discarded – undo
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
200
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 201
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 202
 				    $dataFound = true;
203 203
 				    $this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
205
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208 208
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
210
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 211
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 212
 				    $dataFound = true;
213 213
 				    $this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
215
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218 218
 		    } else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
222
-				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
223
-				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
222
+				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
223
+				echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226 226
 		    }
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229 229
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
230
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
239
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment']));
240 240
 		    //$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
243
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
244 244
 		    //$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 248
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
249
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => $line['altitude']));
251
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253 253
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
263
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
264 264
 		    //$dataFound = true;
265 265
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
267
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
268
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269 269
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -273,54 +273,54 @@  discard block
 block discarded – undo
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274 274
 		    $this->all_tracked[$id]['lastupdate'] = time();
275 275
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
276
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 277
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282 282
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
283
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 285
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
286
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
287 287
 				} else $recent_ident = '';
288
-				$TrackerLive->db=null;
288
+				$TrackerLive->db = null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292 292
 			    } else {
293 293
 				$recent_ident = '';
294
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
294
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
295 295
 			    }
296 296
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
297
+			    if ($recent_ident == "")
298 298
 			    {
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301 301
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
302
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303 303
 				    $timeelapsed = microtime(true);
304 304
 				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
305
+				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
306 306
 				    $Tracker->db = null;
307 307
 				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
308
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
309 309
 				    
310 310
 				    
311 311
 				    // Add source stat in DB
312 312
 				    $Stats = new Stats($this->db);
313 313
 				    if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
315
+				        foreach ($this->stats as $date => $data) {
316
+					    foreach ($data as $source => $sourced) {
317 317
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
318
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_tracker', $date);
319
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_tracker', $date);
320 320
 				    		if (isset($sourced['msg'])) {
321 321
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 322
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
323
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg_tracker', $date);
324 324
 			    			        unset($this->stats[$date][$source]['msg']);
325 325
 			    			    }
326 326
 			    			}
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 344
 				    $TrackerLive = new TrackerLive($this->db);
345 345
 				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
346
+				    $TrackerLive->db = null;
347 347
 				    if ($globalDebug) echo " Done\n";
348 348
 				    $this->last_delete = time();
349 349
 				}
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
354 354
 					$Tracker = new Tracker($this->db);
355
-					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
355
+					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
 		    $ignoreImport = false;
367 367
 
368 368
 		    if (!$ignoreImport) {
369
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
369
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
372 372
 				$TrackerLive = new TrackerLive($this->db);
373
-				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
373
+				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
374 374
 				$TrackerLive->db = null;
375 375
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
376
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
377 377
 
378 378
 				// Put statistics in $this->stats variable
379 379
 				
@@ -390,19 +390,19 @@  discard block
 block discarded – undo
390 390
 							$latitude = $globalCenterLatitude;
391 391
 							$longitude = $globalCenterLongitude;
392 392
 						}
393
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
393
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
394 394
 					} else {
395 395
 						$latitude = $this->source_location[$source]['latitude'];
396 396
 						$longitude = $this->source_location[$source]['longitude'];
397 397
 					}
398
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
398
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
399 399
 					//$stats_heading = $stats_heading%22.5;
400 400
 					$stats_heading = round($stats_heading/22.5);
401
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
401
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
402 402
 					$current_date = date('Y-m-d');
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405
-						for ($i=0;$i<=15;$i++) {
405
+						for ($i = 0; $i <= 15; $i++) {
406 406
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 419
 						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
420
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
421 421
 						} else $mini = 0;
422
-						for ($i=$mini;$i<=$distance;$i+=10) {
422
+						for ($i = $mini; $i <= $distance; $i += 10) {
423 423
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 				$this->all_tracked[$id]['lastupdate'] = time();
432 432
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433 433
 				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
434
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
435 435
 			//$this->del();
436 436
 			
437 437
 			
Please login to merge, or discard this patch.
require/class.TrackerArchive.php 1 patch
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -14,33 +14,33 @@  discard block
 block discarded – undo
14 14
 	* @param Array $filter the filter
15 15
 	* @return Array the SQL part
16 16
 	*/
17
-	public function getFilter($filter = array(),$where = false,$and = false) {
17
+	public function getFilter($filter = array(), $where = false, $and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
20 20
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 22
 				$filters = $globalStatsFilters[$globalFilterName];
23 23
 			} else {
24
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
24
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
25 25
 			}
26 26
 		}
27 27
 		if (isset($filter[0]['source'])) {
28
-			$filters = array_merge($filters,$filter);
28
+			$filters = array_merge($filters, $filter);
29 29
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
30
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
31 31
 		$filter_query_join = '';
32 32
 		$filter_query_where = '';
33
-		foreach($filters as $flt) {
33
+		foreach ($filters as $flt) {
34 34
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
35 35
 				if (isset($flt['source'])) {
36
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
36
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
37 37
 				} else {
38
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
38
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
39 39
 				}
40 40
 			}
41 41
 		}
42 42
 		if (isset($filter['source']) && !empty($filter['source'])) {
43
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
43
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
44 44
 		}
45 45
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
46 46
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -68,38 +68,38 @@  discard block
 block discarded – undo
68 68
 					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'";
69 69
 				}
70 70
 			}
71
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid";
71
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid";
72 72
 		}
73 73
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
74
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
74
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
75 75
 		}
76 76
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
77 77
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
78 78
 		if ($filter_query_where != '') {
79
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
79
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
80 80
 		}
81 81
 		$filter_query = $filter_query_join.$filter_query_where;
82 82
 		return $filter_query;
83 83
 	}
84 84
 
85 85
 	// tracker_archive
86
-	public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') {
86
+	public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') {
87 87
 		require_once(dirname(__FILE__).'/class.Tracker.php');
88 88
 		if ($over_country == '') {
89 89
 			$Tracker = new Tracker($this->db);
90
-			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude);
90
+			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude, $longitude);
91 91
 			if (!empty($data_country)) $country = $data_country['iso2'];
92 92
 			else $country = '';
93 93
 		} else $country = $over_country;
94 94
 		// Route is not added in tracker_archive
95
-		$query  = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
95
+		$query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
96 96
 		    VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
97
-		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':comment' => $comment,':type' => $type);
97
+		$query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':comment' => $comment, ':type' => $type);
98 98
 		try {
99 99
 			$sth = $this->db->prepare($query);
100 100
 			$sth->execute($query_values);
101 101
 			$sth->closeCursor();
102
-		} catch(PDOException $e) {
102
+		} catch (PDOException $e) {
103 103
 			return "error : ".$e->getMessage();
104 104
 		}
105 105
 		return "success";
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 
120 120
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
121 121
                 //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
122
-                $query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
122
+                $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
123 123
 
124
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
124
+                $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident));
125 125
 
126 126
                 return $spotter_array;
127 127
         }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
141 141
                 //$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
142 142
                 //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
143
-                $query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
143
+                $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
144 144
 
145 145
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
146 146
                   /*
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                 }
154 154
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
155 155
                 */
156
-                $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
156
+                $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id));
157 157
 
158 158
                 return $spotter_array;
159 159
         }
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
         * @return Array the spotter information
165 165
         *
166 166
         */
167
-        public function getAllArchiveTrackerDataById($id,$date = '')
167
+        public function getAllArchiveTrackerDataById($id, $date = '')
168 168
 	{
169 169
                 date_default_timezone_set('UTC');
170 170
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
171
-                if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
-                else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
171
+                if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
+                else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c', $date)."' ORDER BY date";
173 173
 
174 174
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
175 175
 
176 176
                 try {
177 177
                         $sth = $this->db->prepare($query);
178 178
                         $sth->execute(array(':id' => $id));
179
-                } catch(PDOException $e) {
179
+                } catch (PDOException $e) {
180 180
                         echo $e->getMessage();
181 181
                         die;
182 182
                 }
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
         {
196 196
                 date_default_timezone_set('UTC');
197 197
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
198
-                $query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
198
+                $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
199 199
 
200 200
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
201 201
 
202 202
                 try {
203 203
                         $sth = $this->db->prepare($query);
204 204
                         $sth->execute(array(':id' => $id));
205
-                } catch(PDOException $e) {
205
+                } catch (PDOException $e) {
206 206
                         echo $e->getMessage();
207 207
                         die;
208 208
                 }
@@ -224,12 +224,12 @@  discard block
 block discarded – undo
224 224
                 date_default_timezone_set('UTC');
225 225
 
226 226
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
227
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
227
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
228 228
 
229 229
                 try {
230 230
                         $sth = $this->db->prepare($query);
231 231
                         $sth->execute(array(':ident' => $ident));
232
-                } catch(PDOException $e) {
232
+                } catch (PDOException $e) {
233 233
                         echo $e->getMessage();
234 234
                         die;
235 235
                 }
@@ -250,12 +250,12 @@  discard block
 block discarded – undo
250 250
                 date_default_timezone_set('UTC');
251 251
 
252 252
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
253
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
253
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
254 254
 
255 255
                 try {
256 256
                         $sth = $this->db->prepare($query);
257 257
                         $sth->execute(array(':id' => $id));
258
-                } catch(PDOException $e) {
258
+                } catch (PDOException $e) {
259 259
                         echo $e->getMessage();
260 260
                         die;
261 261
                 }
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
                 date_default_timezone_set('UTC');
277 277
 
278 278
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
279
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
279
+                $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
280 280
 
281 281
                 try {
282 282
                         $sth = $this->db->prepare($query);
283 283
                         $sth->execute(array(':id' => $id));
284
-                } catch(PDOException $e) {
284
+                } catch (PDOException $e) {
285 285
                         echo $e->getMessage();
286 286
                         die;
287 287
                 }
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
                 date_default_timezone_set('UTC');
304 304
 
305 305
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
306
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
306
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
307 307
 //                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident";
308 308
 
309 309
                 try {
310 310
                         $sth = $this->db->prepare($query);
311 311
                         $sth->execute(array(':ident' => $ident));
312
-                } catch(PDOException $e) {
312
+                } catch (PDOException $e) {
313 313
                         echo $e->getMessage();
314 314
                         die;
315 315
                 }
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
         * @return Array the spotter information
327 327
         *
328 328
         */
329
-        public function getTrackerArchiveData($ident,$famtrackid,$date)
329
+        public function getTrackerArchiveData($ident, $famtrackid, $date)
330 330
         {
331 331
     		$Tracker = new Tracker($this->db);
332 332
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
333
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
333
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
334 334
 
335
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
335
+                $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%'));
336 336
 
337 337
                 return $spotter_array;
338 338
         }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 		try {
349 349
 			$sth = $this->db->prepare($query);
350 350
 			$sth->execute();
351
-		} catch(PDOException $e) {
351
+		} catch (PDOException $e) {
352 352
 			echo $e->getMessage();
353 353
 			die;
354 354
 		}
@@ -360,24 +360,24 @@  discard block
 block discarded – undo
360 360
         * @return Array the spotter information
361 361
         *
362 362
         */
363
-        public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
363
+        public function getMinLiveTrackerData($begindate, $enddate, $filter = array())
364 364
         {
365 365
                 global $globalDBdriver, $globalLiveInterval;
366 366
                 date_default_timezone_set('UTC');
367 367
 
368 368
                 $filter_query = '';
369 369
                 if (isset($filter['source']) && !empty($filter['source'])) {
370
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
370
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
371 371
                 }
372 372
                 // Use spotter_output also ?
373 373
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
374
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
375 375
                 }
376 376
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377 377
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
378 378
                 }
379 379
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
380
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
381 381
                 }
382 382
 
383 383
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
 						GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid 
397 397
 				    AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
398 398
 */
399
-			$query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
399
+			$query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
400 400
 				    FROM tracker_archive 
401 401
 				    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
402 402
 				    WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
403 403
                         	    '.$filter_query.' ORDER BY famtrackid';
404 404
                 } else {
405 405
                         //$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
406
-                        $query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
406
+                        $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
407 407
                         	    FROM tracker_archive 
408 408
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
409 409
                         	    WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".'
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                 try {
414 414
                         $sth = $this->db->prepare($query);
415 415
                         $sth->execute();
416
-                } catch(PDOException $e) {
416
+                } catch (PDOException $e) {
417 417
                         echo $e->getMessage();
418 418
                         die;
419 419
                 }
@@ -428,24 +428,24 @@  discard block
 block discarded – undo
428 428
         * @return Array the spotter information
429 429
         *
430 430
         */
431
-        public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
431
+        public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array())
432 432
         {
433 433
                 global $globalDBdriver, $globalLiveInterval;
434 434
                 date_default_timezone_set('UTC');
435 435
 
436 436
                 $filter_query = '';
437 437
                 if (isset($filter['source']) && !empty($filter['source'])) {
438
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
438
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
439 439
                 }
440 440
                 // Should use spotter_output also ?
441 441
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
442
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
443 443
                 }
444 444
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445 445
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
446 446
                 }
447 447
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
448
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
449 449
                 }
450 450
 
451 451
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
                     		    FROM tracker_archive 
456 456
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
457 457
 			*/
458
-			$query  = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
458
+			$query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
459 459
 				    FROM tracker_archive_output 
460 460
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao 
461 461
 				    WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
471 471
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
472 472
                         */
473
-                        $query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
473
+                        $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
474 474
                         	    FROM tracker_archive_output 
475 475
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
476 476
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
                 try {
483 483
                         $sth = $this->db->prepare($query);
484 484
                         $sth->execute();
485
-                } catch(PDOException $e) {
485
+                } catch (PDOException $e) {
486 486
                         echo $e->getMessage();
487 487
                         die;
488 488
                 }
@@ -497,23 +497,23 @@  discard block
 block discarded – undo
497 497
         * @return Array the spotter information
498 498
         *
499 499
         */
500
-        public function getLiveTrackerCount($begindate,$enddate,$filter = array())
500
+        public function getLiveTrackerCount($begindate, $enddate, $filter = array())
501 501
         {
502 502
                 global $globalDBdriver, $globalLiveInterval;
503 503
                 date_default_timezone_set('UTC');
504 504
 
505 505
                 $filter_query = '';
506 506
                 if (isset($filter['source']) && !empty($filter['source'])) {
507
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
507
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
508 508
                 }
509 509
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
510
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
511 511
                 }
512 512
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513 513
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
514 514
                 }
515 515
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
516
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
517 517
                 }
518 518
 
519 519
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
                 try {
529 529
                         $sth = $this->db->prepare($query);
530 530
                         $sth->execute();
531
-                } catch(PDOException $e) {
531
+                } catch (PDOException $e) {
532 532
                         echo $e->getMessage();
533 533
                         die;
534 534
                 }
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
     * @return Array the spotter information
549 549
     *
550 550
     */
551
-    public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
551
+    public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
552 552
     {
553 553
 	global $globalTimezone, $globalDBdriver;
554 554
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	        
571 571
 		$q_array = explode(" ", $q);
572 572
 		
573
-		foreach ($q_array as $q_item){
573
+		foreach ($q_array as $q_item) {
574 574
 		    $additional_query .= " AND (";
575 575
 		    $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
576 576
 		    $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	
603 603
 	if ($registration != "")
604 604
 	{
605
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
605
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
606 606
 	    if (!is_string($registration))
607 607
 	    {
608 608
 		return false;
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 	
614 614
 	if ($aircraft_icao != "")
615 615
 	{
616
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
616
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
617 617
 	    if (!is_string($aircraft_icao))
618 618
 	    {
619 619
 		return false;
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 	
625 625
 	if ($aircraft_manufacturer != "")
626 626
 	{
627
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
627
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
628 628
 	    if (!is_string($aircraft_manufacturer))
629 629
 	    {
630 630
 		return false;
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 	
646 646
 	if ($airline_icao != "")
647 647
 	{
648
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
648
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
649 649
 	    if (!is_string($airline_icao))
650 650
 	    {
651 651
 		return false;
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 	
657 657
 	if ($airline_country != "")
658 658
 	{
659
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
659
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
660 660
 	    if (!is_string($airline_country))
661 661
 	    {
662 662
 		return false;
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	
668 668
 	if ($airline_type != "")
669 669
 	{
670
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
670
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
671 671
 	    if (!is_string($airline_type))
672 672
 	    {
673 673
 		return false;
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 	
690 690
 	if ($airport != "")
691 691
 	{
692
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
692
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
693 693
 	    if (!is_string($airport))
694 694
 	    {
695 695
 		return false;
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 	
701 701
 	if ($airport_country != "")
702 702
 	{
703
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
703
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
704 704
 	    if (!is_string($airport_country))
705 705
 	    {
706 706
 		return false;
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
     
712 712
 	if ($callsign != "")
713 713
 	{
714
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
714
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
715 715
 	    if (!is_string($callsign))
716 716
 	    {
717 717
 		return false;
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 		$translate = $Translation->ident2icao($callsign);
720 720
 		if ($translate != $callsign) {
721 721
 			$additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
722
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
722
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
723 723
 		} else {
724 724
 			$additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
725 725
 		}
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 
729 729
 	if ($owner != "")
730 730
 	{
731
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
731
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
732 732
 	    if (!is_string($owner))
733 733
 	    {
734 734
 		return false;
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 
740 740
 	if ($pilot_name != "")
741 741
 	{
742
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
742
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
743 743
 	    if (!is_string($pilot_name))
744 744
 	    {
745 745
 		return false;
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 	
751 751
 	if ($pilot_id != "")
752 752
 	{
753
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
753
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
754 754
 	    if (!is_string($pilot_id))
755 755
 	    {
756 756
 		return false;
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	
762 762
 	if ($departure_airport_route != "")
763 763
 	{
764
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
764
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
765 765
 	    if (!is_string($departure_airport_route))
766 766
 	    {
767 767
 		return false;
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 	
773 773
 	if ($arrival_airport_route != "")
774 774
 	{
775
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
775
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
776 776
 	    if (!is_string($arrival_airport_route))
777 777
 	    {
778 778
 		return false;
@@ -785,8 +785,8 @@  discard block
 block discarded – undo
785 785
 	{
786 786
 	    $altitude_array = explode(",", $altitude);
787 787
 	    
788
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
789
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
790 790
 	    
791 791
 
792 792
 	    if ($altitude_array[1] != "")
@@ -804,8 +804,8 @@  discard block
 block discarded – undo
804 804
 	{
805 805
 	    $date_array = explode(",", $date_posted);
806 806
 	    
807
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
807
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
808
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
809 809
 	    
810 810
 	    if ($globalTimezone != '') {
811 811
 		date_default_timezone_set($globalTimezone);
@@ -837,8 +837,8 @@  discard block
 block discarded – undo
837 837
 	{
838 838
 	    $limit_array = explode(",", $limit);
839 839
 	    
840
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
840
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
841
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
842 842
 	    
843 843
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844 844
 	    {
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	
850 850
 
851 851
 	if ($origLat != "" && $origLon != "" && $dist != "") {
852
-		$dist = number_format($dist*0.621371,2,'.','');
853
-		$query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
852
+		$dist = number_format($dist*0.621371, 2, '.', '');
853
+		$query = "SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
854 854
                           FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
855 855
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
856 856
 	} else {
@@ -867,12 +867,12 @@  discard block
 block discarded – undo
867 867
 			$additional_query .= " AND (tracker_archive_output.waypoints <> '')";
868 868
 		}
869 869
 
870
-		$query  = "SELECT tracker_archive_output.* FROM tracker_archive_output 
870
+		$query = "SELECT tracker_archive_output.* FROM tracker_archive_output 
871 871
 		    WHERE tracker_archive_output.ident <> '' 
872 872
 		    ".$additional_query."
873 873
 		    ".$filter_query.$orderby_query;
874 874
 	}
875
-	$spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
875
+	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
876 876
 
877 877
 	return $spotter_array;
878 878
     }
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
                 try {
890 890
                         $sth = $this->db->prepare($query);
891 891
                         $sth->execute();
892
-                } catch(PDOException $e) {
892
+                } catch (PDOException $e) {
893 893
                         return "error";
894 894
                 }
895 895
 	}
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
 	{
927 927
 	    $limit_array = explode(",", $limit);
928 928
 	    
929
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
929
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
930
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
931 931
 	    
932 932
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933 933
 	    {
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 	$query_values = array();
969 969
 	$limit_query = '';
970 970
 	$additional_query = '';
971
-	$filter_query = $this->getFilter($filter,true,true);
971
+	$filter_query = $this->getFilter($filter, true, true);
972 972
 	
973 973
 	if ($owner != "")
974 974
 	{
@@ -985,8 +985,8 @@  discard block
 block discarded – undo
985 985
 	{
986 986
 	    $limit_array = explode(",", $limit);
987 987
 	    
988
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
989
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
990 990
 	    
991 991
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992 992
 	    {
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 	$query_values = array();
1027 1027
 	$limit_query = '';
1028 1028
 	$additional_query = '';
1029
-	$filter_query = $this->getFilter($filter,true,true);
1029
+	$filter_query = $this->getFilter($filter, true, true);
1030 1030
 	
1031 1031
 	if ($pilot != "")
1032 1032
 	{
@@ -1038,8 +1038,8 @@  discard block
 block discarded – undo
1038 1038
 	{
1039 1039
 	    $limit_array = explode(",", $limit);
1040 1040
 	    
1041
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1042
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1043 1043
 	    
1044 1044
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045 1045
 	    {
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
     * @return Array the airline country list
1070 1070
     *
1071 1071
     */
1072
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1072
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1073 1073
     {
1074 1074
 	global $globalDBdriver;
1075 1075
 	/*
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 	$flight_array = array();
1099 1099
 	$temp_array = array();
1100 1100
         
1101
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1101
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1102 1102
 	{
1103 1103
 	    $temp_array['flight_count'] = $row['nb'];
1104 1104
 	    $temp_array['flight_country'] = $row['name'];
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
     * @return Array the airline country list
1116 1116
     *
1117 1117
     */
1118
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1118
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1119 1119
     {
1120 1120
 	global $globalDBdriver;
1121 1121
 	/*
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 	$flight_array = array();
1145 1145
 	$temp_array = array();
1146 1146
         
1147
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1147
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1148 1148
 	{
1149 1149
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1150 1150
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1162,14 +1162,14 @@  discard block
 block discarded – undo
1162 1162
     * @return Array the spotter information
1163 1163
     *
1164 1164
     */
1165
-    public function getDateArchiveTrackerDataById($id,$date)
1165
+    public function getDateArchiveTrackerDataById($id, $date)
1166 1166
     {
1167 1167
 	$Tracker = new Tracker($this->db);
1168 1168
 	date_default_timezone_set('UTC');
1169 1169
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1170
-	$query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1171
-	$date = date('c',$date);
1172
-	$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1170
+	$query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1171
+	$date = date('c', $date);
1172
+	$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1173 1173
 	return $spotter_array;
1174 1174
     }
1175 1175
 
@@ -1179,14 +1179,14 @@  discard block
 block discarded – undo
1179 1179
     * @return Array the spotter information
1180 1180
     *
1181 1181
     */
1182
-    public function getDateArchiveTrackerDataByIdent($ident,$date)
1182
+    public function getDateArchiveTrackerDataByIdent($ident, $date)
1183 1183
     {
1184 1184
 	$Tracker = new Tracker($this->db);
1185 1185
 	date_default_timezone_set('UTC');
1186 1186
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1187
-	$query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1188
-	$date = date('c',$date);
1189
-	$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1187
+	$query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1188
+	$date = date('c', $date);
1189
+	$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1190 1190
 	return $spotter_array;
1191 1191
     }
1192 1192
 
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
     * @return Array the spotter information
1197 1197
     *
1198 1198
     */
1199
-    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1199
+    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1200 1200
     {
1201 1201
 	global $global_query;
1202 1202
 	$Tracker = new Tracker($this->db);
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 	$query_values = array();
1205 1205
 	$limit_query = '';
1206 1206
 	$additional_query = '';
1207
-	$filter_query = $this->getFilter($filters,true,true);
1207
+	$filter_query = $this->getFilter($filters, true, true);
1208 1208
 	
1209 1209
 	if ($airport != "")
1210 1210
 	{
@@ -1221,8 +1221,8 @@  discard block
 block discarded – undo
1221 1221
 	{
1222 1222
 	    $limit_array = explode(",", $limit);
1223 1223
 	    
1224
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1224
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1225
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1226 1226
 	    
1227 1227
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228 1228
 	    {
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 	* @param Array $filter the filter
18 18
 	* @return Array the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
38 38
 				if (isset($flt['source'])) {
39
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
39
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
40 40
 				} else {
41
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
41
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
42 42
 				}
43 43
 			}
44 44
 		}
45 45
 		if (isset($filter['source']) && !empty($filter['source'])) {
46
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
46
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
47 47
 		}
48 48
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
49 49
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
73 73
 				}
74 74
 			}
75
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
75
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
76 76
 		}
77 77
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
79 79
 		}
80 80
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81 81
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
82 82
 		if ($filter_query_where != '') {
83
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
84 84
 		}
85 85
 		$filter_query = $filter_query_join.$filter_query_where;
86 86
 		return $filter_query;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 		if ($limit != '')
104 104
 		{
105 105
 			$limit_array = explode(',', $limit);
106
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
107
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
106
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
107
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
108 108
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
109 109
 			{
110 110
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		} else {
128 128
 			$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query;
129 129
 		}
130
-		$spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true);
130
+		$spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true);
131 131
 
132 132
 		return $spotter_array;
133 133
 	}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		global $globalDBdriver, $globalLiveInterval;
144 144
 		date_default_timezone_set('UTC');
145 145
 
146
-		$filter_query = $this->getFilter($filter,true,true);
146
+		$filter_query = $this->getFilter($filter, true, true);
147 147
 
148 148
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
149 149
 		if ($globalDBdriver == 'mysql') {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		try {
162 162
 			$sth = $this->db->prepare($query);
163 163
 			$sth->execute();
164
-		} catch(PDOException $e) {
164
+		} catch (PDOException $e) {
165 165
 			echo $e->getMessage();
166 166
 			die;
167 167
 		}
@@ -176,25 +176,25 @@  discard block
 block discarded – undo
176 176
 	* @return Array the spotter information
177 177
 	*
178 178
 	*/
179
-	public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false)
179
+	public function getMinLastLiveTrackerData($coord, $filter = array(), $limit = false)
180 180
 	{
181 181
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit;
182 182
 		date_default_timezone_set('UTC');
183 183
 		$usecoord = false;
184 184
 		if (is_array($coord) && !empty($coord)) {
185
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
186
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
187
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
188
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
185
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
186
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
187
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
188
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
189 189
 			$usecoord = true;
190 190
 		}
191
-		$filter_query = $this->getFilter($filter,true,true);
191
+		$filter_query = $this->getFilter($filter, true, true);
192 192
 
193 193
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194 194
 		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300';
195 195
 		if ($globalDBdriver == 'mysql') {
196 196
 			if (isset($globalArchive) && $globalArchive) {
197
-				$query  = "SELECT * FROM (
197
+				$query = "SELECT * FROM (
198 198
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
199 199
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
200 200
 				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 			}
217 217
 		} else {
218 218
 			if (isset($globalArchive) && $globalArchive) {
219
-				$query  = "SELECT * FROM (
219
+				$query = "SELECT * FROM (
220 220
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
221 221
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
222 222
 				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		try {
241 241
 			$sth = $this->db->prepare($query);
242 242
 			$sth->execute();
243
-		} catch(PDOException $e) {
243
+		} catch (PDOException $e) {
244 244
 			echo $e->getMessage();
245 245
 			die;
246 246
 		}
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	public function getLiveTrackerCount($filter = array())
258 258
 	{
259 259
 		global $globalDBdriver, $globalLiveInterval;
260
-		$filter_query = $this->getFilter($filter,true,true);
260
+		$filter_query = $this->getFilter($filter, true, true);
261 261
 
262 262
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
263 263
 		if ($globalDBdriver == 'mysql') {
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		try {
269 269
 			$sth = $this->db->prepare($query);
270 270
 			$sth->execute();
271
-		} catch(PDOException $e) {
271
+		} catch (PDOException $e) {
272 272
 			echo $e->getMessage();
273 273
 			die;
274 274
 		}
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
 		$filter_query = $this->getFilter($filter);
292 292
 
293 293
 		if (is_array($coord)) {
294
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
295
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
296
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
297
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
294
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
295
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
296
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
297
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
298 298
 		} else return array();
299 299
 		if ($globalDBdriver == 'mysql') {
300 300
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
317 317
 		$Tracker = new Tracker($this->db);
318 318
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
319
-		$filter_query = $this->getFilter($filter,true,true);
319
+		$filter_query = $this->getFilter($filter, true, true);
320 320
 
321 321
 		if (is_array($coord)) {
322
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
323
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
325
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
322
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
323
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
324
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
325
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
326 326
 		} else return array();
327 327
 		/*
328 328
 		if ($globalDBdriver == 'mysql') {
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
 		*/
337 337
 		if ($globalDBdriver == 'mysql') {
338 338
 			if (isset($globalArchive) && $globalArchive === TRUE) {
339
-				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
339
+				$query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
340 340
 				    FROM tracker_live 
341 341
 				    '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= tracker_live.date 
342 342
 				    AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
343 343
 				    AND tracker_live.latitude <> 0 AND tracker_live.longitude <> 0';
344 344
 			} else {
345
-				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
345
+				$query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
346 346
 				    FROM tracker_live 
347 347
 				    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate 
348 348
 					FROM tracker_live l 
@@ -354,14 +354,14 @@  discard block
 block discarded – undo
354 354
 			}
355 355
 		} else {
356 356
 			if (isset($globalArchive) && $globalArchive === TRUE) {
357
-				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
357
+				$query = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
358 358
 				    FROM tracker_live 
359 359
 				    ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date 
360 360
 				    AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
361 361
 				    AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
362 362
 				    AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'";
363 363
 			} else {
364
-				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
364
+				$query = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
365 365
 				    FROM tracker_live 
366 366
 				    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate 
367 367
 					FROM tracker_live l 
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
                 if ($interval == '1m')
419 419
                 {
420 420
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
421
-                } else if ($interval == '15m'){
421
+                } else if ($interval == '15m') {
422 422
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
423 423
                 } 
424 424
             }
@@ -426,14 +426,14 @@  discard block
 block discarded – undo
426 426
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
427 427
         }
428 428
 
429
-                $query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
429
+                $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
430 430
                    WHERE tracker_live.latitude <> '' 
431 431
                                    AND tracker_live.longitude <> '' 
432 432
                    ".$additional_query."
433 433
                    HAVING distance < :radius  
434 434
                                    ORDER BY distance";
435 435
 
436
-                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
436
+                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
437 437
 
438 438
                 return $spotter_array;
439 439
         }
@@ -451,9 +451,9 @@  discard block
 block discarded – undo
451 451
 		date_default_timezone_set('UTC');
452 452
 
453 453
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
454
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
454
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
455 455
 
456
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
456
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true);
457 457
 
458 458
 		return $spotter_array;
459 459
 	}
@@ -464,16 +464,16 @@  discard block
 block discarded – undo
464 464
 	* @return Array the spotter information
465 465
 	*
466 466
 	*/
467
-	public function getDateLiveTrackerDataByIdent($ident,$date)
467
+	public function getDateLiveTrackerDataByIdent($ident, $date)
468 468
 	{
469 469
 		$Tracker = new Tracker($this->db);
470 470
 		date_default_timezone_set('UTC');
471 471
 
472 472
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
473
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
473
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
474 474
 
475
-                $date = date('c',$date);
476
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
475
+                $date = date('c', $date);
476
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
477 477
 
478 478
 		return $spotter_array;
479 479
 	}
@@ -490,9 +490,9 @@  discard block
 block discarded – undo
490 490
 		date_default_timezone_set('UTC');
491 491
 
492 492
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
493
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
493
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
494 494
 
495
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
495
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true);
496 496
 
497 497
 		return $spotter_array;
498 498
 	}
@@ -503,15 +503,15 @@  discard block
 block discarded – undo
503 503
 	* @return Array the spotter information
504 504
 	*
505 505
 	*/
506
-	public function getDateLiveTrackerDataById($id,$date)
506
+	public function getDateLiveTrackerDataById($id, $date)
507 507
 	{
508 508
 		$Tracker = new Tracker($this->db);
509 509
 		date_default_timezone_set('UTC');
510 510
 
511 511
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
512
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
513
-                $date = date('c',$date);
514
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
512
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
513
+                $date = date('c', $date);
514
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
515 515
 
516 516
 		return $spotter_array;
517 517
 	}
@@ -528,13 +528,13 @@  discard block
 block discarded – undo
528 528
 		date_default_timezone_set('UTC');
529 529
 
530 530
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
531
-                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
531
+                $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
532 532
 
533 533
     		try {
534 534
 			
535 535
 			$sth = $this->db->prepare($query);
536 536
 			$sth->execute(array(':ident' => $ident));
537
-		} catch(PDOException $e) {
537
+		} catch (PDOException $e) {
538 538
 			echo $e->getMessage();
539 539
 			die;
540 540
 		}
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 	* @return Array the spotter information
550 550
 	*
551 551
 	*/
552
-	public function getAllLiveTrackerDataById($id,$liveinterval = false)
552
+	public function getAllLiveTrackerDataById($id, $liveinterval = false)
553 553
 	{
554 554
 		global $globalDBdriver, $globalLiveInterval;
555 555
 		date_default_timezone_set('UTC');
@@ -558,19 +558,19 @@  discard block
 block discarded – undo
558 558
 		if ($globalDBdriver == 'mysql') {
559 559
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
560 560
 			if ($liveinterval === true) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
561
-			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'";
561
+			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c', $liveinterval)."'";
562 562
 			$query .= ' ORDER BY date';
563 563
 		} else {
564 564
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
565 565
 			if ($liveinterval === true) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
566
-			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'";
566
+			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c', $liveinterval)."'";
567 567
 			$query .= ' ORDER BY date';
568 568
 		}
569 569
 
570 570
 		try {
571 571
 			$sth = $this->db->prepare($query);
572 572
 			$sth->execute(array(':id' => $id));
573
-		} catch(PDOException $e) {
573
+		} catch (PDOException $e) {
574 574
 			echo $e->getMessage();
575 575
 			die;
576 576
 		}
@@ -588,12 +588,12 @@  discard block
 block discarded – undo
588 588
 	{
589 589
 		date_default_timezone_set('UTC');
590 590
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
591
-		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
591
+		$query = self::$global_query.' WHERE tracker_live.ident = :ident';
592 592
     		try {
593 593
 			
594 594
 			$sth = $this->db->prepare($query);
595 595
 			$sth->execute(array(':ident' => $ident));
596
-		} catch(PDOException $e) {
596
+		} catch (PDOException $e) {
597 597
 			echo $e->getMessage();
598 598
 			die;
599 599
 		}
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 			
624 624
 			$sth = $this->db->prepare($query);
625 625
 			$sth->execute();
626
-		} catch(PDOException $e) {
626
+		} catch (PDOException $e) {
627 627
 			return "error";
628 628
 		}
629 629
 
@@ -646,14 +646,14 @@  discard block
 block discarded – undo
646 646
 				
647 647
 				$sth = $this->db->prepare($query);
648 648
 				$sth->execute();
649
-			} catch(PDOException $e) {
649
+			} catch (PDOException $e) {
650 650
 				return "error";
651 651
 			}
652 652
 			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
653 653
                         $i = 0;
654
-                        $j =0;
654
+                        $j = 0;
655 655
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
656
-			foreach($all as $row)
656
+			foreach ($all as $row)
657 657
 			{
658 658
 				$i++;
659 659
 				$j++;
@@ -661,9 +661,9 @@  discard block
 block discarded – undo
661 661
 					if ($globalDebug) echo ".";
662 662
 				    	try {
663 663
 						
664
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
664
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
665 665
 						$sth->execute();
666
-					} catch(PDOException $e) {
666
+					} catch (PDOException $e) {
667 667
 						return "error";
668 668
 					}
669 669
                                 	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
@@ -674,9 +674,9 @@  discard block
 block discarded – undo
674 674
 			if ($i > 0) {
675 675
     				try {
676 676
 					
677
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
677
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
678 678
 					$sth->execute();
679
-				} catch(PDOException $e) {
679
+				} catch (PDOException $e) {
680 680
 					return "error";
681 681
 				}
682 682
 			}
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 				
690 690
 				$sth = $this->db->prepare($query);
691 691
 				$sth->execute();
692
-			} catch(PDOException $e) {
692
+			} catch (PDOException $e) {
693 693
 				return "error";
694 694
 			}
695 695
 /*			$query_delete = "DELETE FROM tracker_live WHERE famtrackid IN (";
@@ -737,13 +737,13 @@  discard block
 block discarded – undo
737 737
 	public function deleteLiveTrackerDataByIdent($ident)
738 738
 	{
739 739
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
740
-		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
740
+		$query = 'DELETE FROM tracker_live WHERE ident = :ident';
741 741
         
742 742
     		try {
743 743
 			
744 744
 			$sth = $this->db->prepare($query);
745 745
 			$sth->execute(array(':ident' => $ident));
746
-		} catch(PDOException $e) {
746
+		} catch (PDOException $e) {
747 747
 			return "error";
748 748
 		}
749 749
 
@@ -759,13 +759,13 @@  discard block
 block discarded – undo
759 759
 	public function deleteLiveTrackerDataById($id)
760 760
 	{
761 761
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
762
-		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
762
+		$query = 'DELETE FROM tracker_live WHERE famtrackid = :id';
763 763
         
764 764
     		try {
765 765
 			
766 766
 			$sth = $this->db->prepare($query);
767 767
 			$sth->execute(array(':id' => $id));
768
-		} catch(PDOException $e) {
768
+		} catch (PDOException $e) {
769 769
 			return "error";
770 770
 		}
771 771
 
@@ -783,13 +783,13 @@  discard block
 block discarded – undo
783 783
 	{
784 784
 		global $globalDBdriver, $globalTimezone;
785 785
 		if ($globalDBdriver == 'mysql') {
786
-			$query  = 'SELECT tracker_live.ident FROM tracker_live 
786
+			$query = 'SELECT tracker_live.ident FROM tracker_live 
787 787
 				WHERE tracker_live.ident = :ident 
788 788
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
789 789
 				AND tracker_live.date < UTC_TIMESTAMP()';
790 790
 			$query_data = array(':ident' => $ident);
791 791
 		} else {
792
-			$query  = "SELECT tracker_live.ident FROM tracker_live 
792
+			$query = "SELECT tracker_live.ident FROM tracker_live 
793 793
 				WHERE tracker_live.ident = :ident 
794 794
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
795 795
 				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -798,8 +798,8 @@  discard block
 block discarded – undo
798 798
 		
799 799
 		$sth = $this->db->prepare($query);
800 800
 		$sth->execute($query_data);
801
-		$ident_result='';
802
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
801
+		$ident_result = '';
802
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
803 803
 		{
804 804
 			$ident_result = $row['ident'];
805 805
 		}
@@ -816,13 +816,13 @@  discard block
 block discarded – undo
816 816
 	{
817 817
 		global $globalDBdriver, $globalTimezone;
818 818
 		if ($globalDBdriver == 'mysql') {
819
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
819
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
820 820
 				WHERE tracker_live.ident = :ident 
821 821
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
822 822
 //				AND tracker_live.date < UTC_TIMESTAMP()";
823 823
 			$query_data = array(':ident' => $ident);
824 824
 		} else {
825
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
825
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
826 826
 				WHERE tracker_live.ident = :ident 
827 827
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
828 828
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -831,8 +831,8 @@  discard block
 block discarded – undo
831 831
 		
832 832
 		$sth = $this->db->prepare($query);
833 833
 		$sth->execute($query_data);
834
-		$ident_result='';
835
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
834
+		$ident_result = '';
835
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
836 836
 		{
837 837
 			$ident_result = $row['famtrackid'];
838 838
 		}
@@ -849,13 +849,13 @@  discard block
 block discarded – undo
849 849
 	{
850 850
 		global $globalDBdriver, $globalTimezone;
851 851
 		if ($globalDBdriver == 'mysql') {
852
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
852
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
853 853
 				WHERE tracker_live.famtrackid = :id 
854 854
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
855 855
 //				AND tracker_live.date < UTC_TIMESTAMP()";
856 856
 			$query_data = array(':id' => $id);
857 857
 		} else {
858
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
858
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
859 859
 				WHERE tracker_live.famtrackid = :id 
860 860
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
861 861
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -864,8 +864,8 @@  discard block
 block discarded – undo
864 864
 		
865 865
 		$sth = $this->db->prepare($query);
866 866
 		$sth->execute($query_data);
867
-		$ident_result='';
868
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
867
+		$ident_result = '';
868
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
869 869
 		{
870 870
 			$ident_result = $row['famtrackid'];
871 871
 		}
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 	* @return String success or false
884 884
 	*
885 885
 	*/
886
-	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
886
+	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
887 887
 	{
888 888
 		global $globalURL, $globalArchive, $globalDebug;
889 889
 		$Common = new Common();
@@ -942,21 +942,21 @@  discard block
 block discarded – undo
942 942
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
943 943
 
944 944
         
945
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
946
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
947
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
948
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
949
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
950
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
951
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
952
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
953
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
954
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
955
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
956
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
957
-
958
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
959
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
945
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
946
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
947
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
948
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
949
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
950
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
951
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
952
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
953
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
954
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
955
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
956
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
957
+
958
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
959
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
960 960
             	
961 961
 		$query = '';
962 962
 		if ($globalArchive) {
@@ -966,12 +966,12 @@  discard block
 block discarded – undo
966 966
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
967 967
 		VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
968 968
 
969
-		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type);
969
+		$query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type);
970 970
 		try {
971 971
 			$sth = $this->db->prepare($query);
972 972
 			$sth->execute($query_values);
973 973
 			$sth->closeCursor();
974
-		} catch(PDOException $e) {
974
+		} catch (PDOException $e) {
975 975
 			return "error : ".$e->getMessage();
976 976
 		}
977 977
                 /*
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
982 982
 		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
983 983
 		    $TrackerArchive = new TrackerArchive($this->db);
984
-		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
984
+		    $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type, $noarchive, $format_source, $source_name, $over_country);
985 985
 		    if ($globalDebug) echo $result.')';
986 986
 		}
987 987
 
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 
992 992
 	public function getOrderBy()
993 993
 	{
994
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
994
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
995 995
 		return $orderby;
996 996
 	}
997 997
 
Please login to merge, or discard this patch.
header.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -14,35 +14,35 @@  discard block
 block discarded – undo
14 14
 if (isset($globalMapOffline) && $globalMapOffline) $MapType = 'offline';
15 15
 
16 16
 if (isset($_GET['3d'])) {
17
-	setcookie('MapFormat','3d');
17
+	setcookie('MapFormat', '3d');
18 18
 } else if (isset($_GET['2d'])) {
19
-	setcookie('MapFormat','2d');
19
+	setcookie('MapFormat', '2d');
20 20
 }
21 21
 
22 22
 if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) {
23
-	$tsk = filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL);
23
+	$tsk = filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL);
24 24
 }
25 25
 
26 26
 if (isset($_POST['archive'])) {
27
-	setcookie('archive','true');
28
-	setcookie('archive_begin',strtotime($_POST['start_date']));
29
-	setcookie('archive_end',strtotime($_POST['end_date']));
30
-	setcookie('archive_speed',$_POST['archivespeed']);
27
+	setcookie('archive', 'true');
28
+	setcookie('archive_begin', strtotime($_POST['start_date']));
29
+	setcookie('archive_end', strtotime($_POST['end_date']));
30
+	setcookie('archive_speed', $_POST['archivespeed']);
31 31
 }
32 32
 if (isset($_POST['noarchive'])) {
33
-	setcookie('archive','false',-1);
34
-	setcookie('archive_begin','',-1);
35
-	setcookie('archive_end','',-1);
36
-	setcookie('archive_speed','',-1);
33
+	setcookie('archive', 'false', -1);
34
+	setcookie('archive_begin', '', -1);
35
+	setcookie('archive_end', '', -1);
36
+	setcookie('archive_speed', '', -1);
37 37
 }
38 38
 // When button "Remove all filters" is clicked
39 39
 if (isset($_POST['removefilters'])) {
40
-	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
41
-	    return strpos($key,'filter_') === 0;
40
+	$allfilters = array_filter(array_keys($_COOKIE), function($key) {
41
+	    return strpos($key, 'filter_') === 0;
42 42
 	});
43 43
 	foreach ($allfilters as $filt) {
44 44
 		unset($_COOKIE[$filt]);
45
-		setcookie($filt,null,-1);
45
+		setcookie($filt, null, -1);
46 46
 	}
47 47
 }
48 48
 ?>
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
265 265
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
266 266
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
267
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
267
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
268 268
 <?php
269 269
 		if (!isset($type) || $type == 'aircraft') {
270 270
 ?>
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
338 338
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
339 339
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
340
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
340
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
341 341
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
342 342
 <?php
343 343
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -742,8 +742,8 @@  discard block
 block discarded – undo
742 742
 ?>
743 743
       <div class="search">
744 744
 	<form action="<?php print $globalURL; ?>/search" method="get">
745
-		<!--<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != ""){ print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>-->
746
-		<input type="text" name="callsign" value="<?php if (isset($GET['callsign'])) { if ($_GET['callsign'] != ""){ print $_GET['callsign']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
745
+		<!--<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != "") { print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>-->
746
+		<input type="text" name="callsign" value="<?php if (isset($GET['callsign'])) { if ($_GET['callsign'] != "") { print $_GET['callsign']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
747 747
 	</form>
748 748
 	</div>
749 749
   	<div class="social">
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	print '</div>';
762 762
 }
763 763
 
764
-if (strtolower($current_page) =='ident-detailed' || strtolower($current_page) == 'flightid-overview') {
764
+if (strtolower($current_page) == 'ident-detailed' || strtolower($current_page) == 'flightid-overview') {
765 765
 ?>
766 766
     <div class="top-header clear" role="main">
767 767
 <?php
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
     </div>
775 775
 <?php
776 776
 }
777
-if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
777
+if ((strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) || (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false))
778 778
 {
779 779
     ?>
780 780
     <div class="top-header clear" role="main">
@@ -787,15 +787,15 @@  discard block
 block discarded – undo
787 787
         var zoom = 13;
788 788
 //create the map
789 789
 <?php
790
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
790
+    if (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($airport_array[0]['latitude'])) {
791 791
 ?>
792 792
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
793 793
 <?php
794
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
794
+    } elseif (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) {
795 795
 ?>
796 796
   map = L.map('map', { zoomControl:true });
797 797
 <?php
798
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
798
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
799 799
 ?>
800 800
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
801 801
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
804 804
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
805 805
 <?php
806
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
806
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
807 807
 ?>
808 808
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
809 809
 <?php
Please login to merge, or discard this patch.